BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
AtRndmGen_test.cxx
Go to the documentation of this file.
1/** @file AtRndmGen_test.cxx
2 * @brief unit test for AtRndSvc
3 *
4 * based on ATLAS software
5 *
6 **/
7
8#include "AthenaKernel/IAtRndmGenSvc.h"
9#include "CLHEP/Random/RandomEngine.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "StoreGate/tools/hash_functions.h"
12#include "TestTools/initGaudi.h"
13#include <cassert>
14#include <iostream>
15
16using std::cerr;
17using std::cout;
18using std::endl;
19using namespace Athena_test;
20
21int main() {
22 ISvcLocator* pSvcLoc( 0 );
23 if ( !initGaudi( "AtRndmGen_test.txt", pSvcLoc ) )
24 {
25 cerr << "This test can not be run" << endl;
26 return 0;
27 }
28 assert( pSvcLoc );
29
30 IAtRndmGenSvc* pAtRndmGen( 0 );
31 assert( ( pSvcLoc->service( "AtRndmGenSvc", pAtRndmGen, true ) ).isSuccess() );
32 assert( pAtRndmGen );
33 // this depends on AtRndmGen_test.txt
34 HepRandomEngine* pEng( pAtRndmGen->GetEngine( "PITHIA_INIT" ) );
35 assert( pEng );
36 const long* seeds( pEng->getSeeds() );
37 assert( 1 == seeds[1] - seeds[0] );
38
39 pEng = pAtRndmGen->setOnDefinedSeeds( 1, "PITHIA" );
40 assert( pEng );
41 seeds = pEng->getSeeds();
42 // this depends on the details of setOnDefinedSeeds
43 assert( 9000 == seeds[0] - seeds[1] );
44 assert( SG::simpleStringHash( "PITHIA" ) == seeds[0] - 10000 );
45
46 cout << "*** AtRndSvc_test OK ***" << endl;
47 return 0;
48}
int main()