17#include "QGSP_BERT.hh"
19#include "QGSP_BERT_HP.hh"
23#include "G4RunManager.hh"
25#include "GaudiKernel/MsgStream.h"
26#include "GaudiKernel/AlgFactory.h"
27#include "GaudiKernel/SmartIF.h"
28#include "GaudiKernel/Property.h"
31#include "GaudiKernel/NTuple.h"
34#include "G4Writer/G4GDMLWriter.h"
36#include "CLHEP/Random/Random.h"
48 Algorithm(name, pSvcLocator)
50 declareProperty(
"Mdc",m_mdc=2);
51 declareProperty(
"Tof",m_tof=2);
52 declareProperty(
"Emc",m_emc=2);
53 declareProperty(
"Muc",m_muc=2);
54 declareProperty(
"PipeSCM",m_pipeSCM=2);
55 declareProperty(
"Field",m_field=1);
56 declareProperty(
"PhysicsList",m_physicsList=0);
57 declareProperty(
"FormatAR", m_formatAR =0);
58 declareProperty(
"Tuning",m_tuning=0);
59 declareProperty(
"TuningFile",m_tuningFile);
60 declareProperty(
"HitOut",m_hitOut=0);
61 declareProperty(
"TDSFlag",m_TDSFlag=
false);
62 declareProperty(
"AsciiFlag",m_asciiFlag=
"00000000");
63 declareProperty(
"AsciiFile",m_asciiFile=
"boost.dat");
64 declareProperty(
"RootFlag",m_rootFlag=
false);
65 declareProperty(
"RootFile",m_rootFile=
"Hit.root");
66 declareProperty(
"CutValue", newcut = 0.7);
67 declareProperty(
"LogLevel",m_logLevel=5000);
75 MsgStream log(
msgSvc(), name());
76 log << MSG::INFO <<
"initialize()" << endreq;
81 static const bool CREATEIFNOTTHERE(
true);
82 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
83 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
85 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
91 status = service(
"G4Svc",tmpSvc);
92 if (status.isSuccess()) {
93 log << MSG::INFO <<
"got the G4Svc" << endreq;
94 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
96 log << MSG::ERROR <<
"could not get the G4Svc" << endreq;
97 return StatusCode::FAILURE;
113 log << MSG::INFO <<
"Four sub-detector construction flags: " <<m_mdc<<
" "<<m_tof<<
" "<<m_emc<<
" "<<m_muc<<endreq;
119 log << MSG::INFO <<
"Instantiating BESIII Detector" << endreq;
128 switch(m_physicsList)
168 vector<string>::iterator pd;
169 for (pd = m_tuningFile.begin(); pd != m_tuningFile.end(); pd++){
170 std::cout <<
"tuning File: " << *pd << std::endl;
190 return StatusCode::SUCCESS;
197 static int flag = -1;
200 MsgStream log(
msgSvc(), name());
201 log << MSG::DEBUG <<
"\t start initializing G4 "<<endreq;
227 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"SIM");
228 HepRandom::setTheEngine(engine);
229 HepRandom::showEngineStatus();
231 return StatusCode::SUCCESS;
236 MsgStream log(
msgSvc(), name());
238 NTuple::Tuple* tupleMdc;
239 if(nt) tupleMdc = nt;
241 tupleMdc =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
244 return StatusCode::SUCCESS;
251 MsgStream log(
msgSvc(), name());
252 NTuplePtr nt1(
ntupleSvc(),
"FILE802/n1");
253 NTuple::Tuple* tupleTof1;
254 if(nt1) tupleTof1 = nt1;
256 tupleTof1 =
ntupleSvc()->book(
"FILE802/n1",CLID_ColumnWiseTuple,
"BesSim");
259 NTuplePtr nt2(
ntupleSvc(),
"FILE802/n2");
260 NTuple::Tuple* tupleTof2;
261 if(nt2) tupleTof2 = nt2;
263 tupleTof2 =
ntupleSvc()->book(
"FILE802/n2",CLID_ColumnWiseTuple,
"BesSim");
266 NTuplePtr nt3(
ntupleSvc(),
"FILE802/n3");
267 NTuple::Tuple* tupleTof3;
268 if(nt3) tupleTof3 = nt3;
270 tupleTof3 =
ntupleSvc()->book(
"FILE802/n3",CLID_ColumnWiseTuple,
"BesSim");
284 return StatusCode::SUCCESS;
291 NTuplePtr nt1(
ntupleSvc(),
"FILE803/n1");
292 NTuple::Tuple* tupleEmc1;
293 if(nt1) tupleEmc1 = nt1;
295 tupleEmc1 =
ntupleSvc()->book(
"FILE803/n1",CLID_ColumnWiseTuple,
"BesSim");
299 NTuplePtr nt2(
ntupleSvc(),
"FILE803/n2");
300 NTuple::Tuple* tupleEmc2;
301 if(nt2) tupleEmc2 = nt2;
303 tupleEmc2 =
ntupleSvc()->book(
"FILE803/n2",CLID_ColumnWiseTuple,
"BesSim");
308 return StatusCode::SUCCESS;
315 MsgStream log(
msgSvc(), name());
317 NTuple::Tuple* tupleMuc;
318 if(nt) tupleMuc = nt;
320 tupleMuc =
ntupleSvc()->book(
"FILE804/n1",CLID_ColumnWiseTuple,
"BesSim");
323 return StatusCode::SUCCESS;
330 MsgStream log(
msgSvc(), name());
333 if(m_nEvent%m_logLevel == 0)
334 std::cout<<
" BesSim Begin of Event: "<<m_nEvent<<std::endl;
339 return StatusCode::SUCCESS;
346 MsgStream log(
msgSvc(), name());
347 log << MSG::INFO <<
"finalize()" << endreq;
348 log << MSG::DEBUG <<
"\t terminating the current G4 run"<<endreq;
351 std::cout<<
"BesSim::finalize(), total events in this run: "<<m_nEvent<<std::endl;
353 if(m_G4Svc->
runMgr() != 0)
357 if(m_G4Svc->visMgr() != 0)
358 delete m_G4Svc->visMgr();
362 return StatusCode::SUCCESS;
void SetPipeSCM(G4int value)
void SetTuningFile(std::vector< std::string > file)
void SetRootFile(std::string file)
void SetTDSFlag(G4bool flag)
void SetRootFlag(G4bool flag)
void SetAsciiFlag(std::string flag)
void SetAsciiFile(std::string file)
void SetLogLevel(G4int level)
StatusCode bookEmcRootFile()
StatusCode bookMdcRootFile()
StatusCode bookMucRootFile()
BesSim(const std::string &name, ISvcLocator *pSvcLocator)
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)
void SetUserAction(G4UserRunAction *)
virtual CLHEP::HepRandomEngine * GetEngine(const std::string &StreamName)=0
Interface to the CLHEP engine.