16#include "FTFP_BERT_ATL.hh"
17#include "FTFP_BERT.hh"
18#include "FTFP_BERT_HP.hh"
19#include "FTFP_BERT_TRV.hh"
20#include "FTFQGSP_BERT.hh"
23#include "QGSP_BERT.hh"
24#include "QGSP_BERT_HP.hh"
25#include "QGSP_BIC_AllHP.hh"
27#include "QGSP_BIC_HP.hh"
28#include "QGSP_FTFP_BERT.hh"
31#include "G4RunManager.hh"
33#include "GaudiKernel/MsgStream.h"
34#include "GaudiKernel/AlgFactory.h"
35#include "GaudiKernel/SmartIF.h"
36#include "GaudiKernel/Property.h"
39#include "GaudiKernel/NTuple.h"
42#include "G4Writer/G4GDMLWriter.h"
44#include "CLHEP/Random/Random.h"
58 Algorithm(name, pSvcLocator)
60 declareProperty(
"Mdc",m_mdc=2);
61 declareProperty(
"Tof",
m_tof=2);
62 declareProperty(
"Emc",m_emc=2);
63 declareProperty(
"Muc",m_muc=2);
64 declareProperty(
"PipeSCM",m_pipeSCM=2);
65 declareProperty(
"Field",m_field=1);
66 declareProperty(
"PhysicsList",m_physicsList=0);
67 declareProperty(
"FormatAR", m_formatAR =0);
68 declareProperty(
"Tuning",m_tuning=0);
69 declareProperty(
"TuningFile",m_tuningFile);
70 declareProperty(
"HitOut",m_hitOut=0);
71 declareProperty(
"TDSFlag",m_TDSFlag=
false);
72 declareProperty(
"AsciiFlag",m_asciiFlag=
"00000000");
73 declareProperty(
"AsciiFile",m_asciiFile=
"boost.dat");
74 declareProperty(
"RootFlag",m_rootFlag=
false);
75 declareProperty(
"RootFile",m_rootFile=
"Hit.root");
76 declareProperty(
"CutValue", newcut = 0.7);
77 declareProperty(
"LogLevel",m_logLevel=5000);
78 declareProperty(
"BesGenAction",m_besGenAction=
false);
86 MsgStream log(
msgSvc(), name());
87 log << MSG::INFO <<
"initialize()" << endreq;
92 static const bool CREATEIFNOTTHERE(
true);
93 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
94 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
96 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
102 status = service(
"G4Svc",tmpSvc);
103 if (status.isSuccess()) {
104 log << MSG::INFO <<
"got the G4Svc" << endreq;
105 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
107 log << MSG::ERROR <<
"could not get the G4Svc" << endreq;
108 return StatusCode::FAILURE;
112 StatusCode sc_det = service(
"DetVerSvc",
detVerSvc);
113 if( sc_det.isFailure() ) {
114 log << MSG::ERROR <<
"can't retrieve DetVerSvc instance" << endreq;
119 log << MSG::INFO <<
"** ~~~ZZZ~~~ ** : retrieved DetectorStage = " << phase << endreq;
122 if( phase>2 ) { m_tof = 4; }
137 log << MSG::INFO <<
"Four sub-detector construction flags: " <<m_mdc<<
" "<<m_tof<<
" "<<m_emc<<
" "<<m_muc<<endreq;
143 log << MSG::INFO <<
"Instantiating BESIII Detector" << endreq;
152 switch(m_physicsList)
235 return StatusCode::SUCCESS;
242 static int flag = -1;
245 MsgStream log(
msgSvc(), name());
246 log << MSG::DEBUG <<
"\t start initializing G4 "<<endreq;
272 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"SIM");
273 HepRandom::setTheEngine(engine);
274 HepRandom::showEngineStatus();
276 return StatusCode::SUCCESS;
281 MsgStream log(
msgSvc(), name());
283 NTuple::Tuple* tupleMdc;
284 if(nt) tupleMdc = nt;
286 tupleMdc =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
289 return StatusCode::SUCCESS;
296 MsgStream log(
msgSvc(), name());
297 NTuplePtr nt1(
ntupleSvc(),
"FILE802/n1");
298 NTuple::Tuple* tupleTof1;
299 if(nt1) tupleTof1 = nt1;
301 tupleTof1 =
ntupleSvc()->book(
"FILE802/n1",CLID_ColumnWiseTuple,
"BesSim");
304 NTuplePtr nt2(
ntupleSvc(),
"FILE802/n2");
305 NTuple::Tuple* tupleTof2;
306 if(nt2) tupleTof2 = nt2;
308 tupleTof2 =
ntupleSvc()->book(
"FILE802/n2",CLID_ColumnWiseTuple,
"BesSim");
311 NTuplePtr nt3(
ntupleSvc(),
"FILE802/n3");
312 NTuple::Tuple* tupleTof3;
313 if(nt3) tupleTof3 = nt3;
315 tupleTof3 =
ntupleSvc()->book(
"FILE802/n3",CLID_ColumnWiseTuple,
"BesSim");
327 return StatusCode::SUCCESS;
334 NTuplePtr nt1(
ntupleSvc(),
"FILE803/n1");
335 NTuple::Tuple* tupleEmc1;
336 if(nt1) tupleEmc1 = nt1;
338 tupleEmc1 =
ntupleSvc()->book(
"FILE803/n1",CLID_ColumnWiseTuple,
"BesSim");
342 NTuplePtr nt2(
ntupleSvc(),
"FILE803/n2");
343 NTuple::Tuple* tupleEmc2;
344 if(nt2) tupleEmc2 = nt2;
346 tupleEmc2 =
ntupleSvc()->book(
"FILE803/n2",CLID_ColumnWiseTuple,
"BesSim");
351 return StatusCode::SUCCESS;
358 MsgStream log(
msgSvc(), name());
360 NTuple::Tuple* tupleMuc;
361 if(nt) tupleMuc = nt;
363 tupleMuc =
ntupleSvc()->book(
"FILE804/n1",CLID_ColumnWiseTuple,
"BesSim");
366 return StatusCode::SUCCESS;
373 MsgStream log(
msgSvc(), name());
376 if(m_nEvent%m_logLevel == 0)
377 std::cout<<
" BesSim Begin of Event: "<<m_nEvent<<std::endl;
382 return StatusCode::SUCCESS;
389 MsgStream log(
msgSvc(), name());
390 log << MSG::INFO <<
"finalize()" << endreq;
391 log << MSG::DEBUG <<
"\t terminating the current G4 run"<<endreq;
394 std::cout<<
"BesSim::finalize(), total events in this run: "<<m_nEvent<<std::endl;
396 if(m_G4Svc->
runMgr() != 0)
400 if(m_G4Svc->visMgr() != 0)
401 delete m_G4Svc->visMgr();
405 return StatusCode::SUCCESS;
NTuple::Array< double > m_tof
void SetAsciiFile(std::string file)
void SetAsciiFlag(std::string flag)
void SetBesGenActionFlag(G4bool flag)
void SetTDSFlag(G4bool flag)
void SetTuningFile(std::vector< std::string > file)
void SetRootFile(std::string file)
void SetRootFlag(G4bool flag)
void SetPipeSCM(G4int value)
void SetLogLevel(G4int level)
StatusCode bookEmcRootFile()
StatusCode bookMdcRootFile()
StatusCode bookMucRootFile()
StatusCode bookTofRootFile()
void SetTupleTof3(NTuple::Tuple *tuple)
void SetTupleMdc(NTuple::Tuple *tuple)
void SetTupleMuc(NTuple::Tuple *tuple)
void SetTupleEmc1(NTuple::Tuple *tuple)
void SetTupleEmc2(NTuple::Tuple *tuple)
void SetTupleTof2(NTuple::Tuple *tuple)
void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetTupleTof1(NTuple::Tuple *tuple)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.