18#include "QGSP_BERT.hh"
20#include "QGSP_BERT_HP.hh"
24#include "G4RunManager.hh"
26#include "GaudiKernel/MsgStream.h"
27#include "GaudiKernel/AlgFactory.h"
28#include "GaudiKernel/SmartIF.h"
29#include "GaudiKernel/Property.h"
30#include "GaudiKernel/ISvcLocator.h"
33#include "GaudiKernel/NTuple.h"
36#include "G4Writer/G4GDMLWriter.h"
38#include "CLHEP/Random/Random.h"
50 Algorithm(name, pSvcLocator)
52 declareProperty(
"Mdc",m_mdc=1);
53 declareProperty(
"Cgem",m_cgem=1);
54 declareProperty(
"CgemDigitizer",m_CgemDigitizer=2);
55 declareProperty(
"CgemMisAligned",m_cgem_misAligned=0);
56 declareProperty(
"Tof",m_tof=2);
57 declareProperty(
"Emc",m_emc=2);
58 declareProperty(
"Muc",m_muc=2);
59 declareProperty(
"PipeSCM",m_pipeSCM=2);
60 declareProperty(
"Field",m_field=1);
61 declareProperty(
"PhysicsList",m_physicsList=0);
62 declareProperty(
"FormatAR", m_formatAR =0);
63 declareProperty(
"Tuning",m_tuning=0);
64 declareProperty(
"TuningFile",m_tuningFile);
65 declareProperty(
"HitOut",m_hitOut=0);
66 declareProperty(
"TDSFlag",m_TDSFlag=
false);
67 declareProperty(
"AsciiFlag",m_asciiFlag=
"00000000");
68 declareProperty(
"AsciiFile",m_asciiFile=
"boost.dat");
69 declareProperty(
"RootFlag",m_rootFlag=
false);
70 declareProperty(
"RootFile",m_rootFile=
"Hit.root");
71 declareProperty(
"CutValue", newcut = 0.7);
72 declareProperty(
"LogLevel",m_logLevel=5000);
80 MsgStream log(
msgSvc(), name());
81 log << MSG::INFO <<
"initialize()" << endreq;
86 static const bool CREATEIFNOTTHERE(
true);
87 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
88 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
90 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
96 status = service(
"G4Svc",tmpSvc);
97 if (status.isSuccess()) {
98 log << MSG::INFO <<
"got the G4Svc" << endreq;
99 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
101 log << MSG::ERROR <<
"could not get the G4Svc" << endreq;
102 return StatusCode::FAILURE;
121 log << MSG::INFO <<
"Four sub-detector construction flags: " <<m_mdc<<
" "<<m_cgem<<
" "<<m_tof<<
" "<<m_emc<<
" "<<m_muc<<endreq;
131 log << MSG::INFO <<
"Instantiating BESIII Detector" << endreq;
140 switch(m_physicsList)
180 vector<string>::iterator pd;
181 for (pd = m_tuningFile.begin(); pd != m_tuningFile.end(); pd++){
182 std::cout <<
"tuning File: " << *pd << std::endl;
202 return StatusCode::SUCCESS;
209 static int flag = -1;
212 MsgStream log(
msgSvc(), name());
213 log << MSG::DEBUG <<
"\t start initializing G4 "<<endreq;
240 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"SIM");
241 HepRandom::setTheEngine(engine);
242 HepRandom::showEngineStatus();
244 return StatusCode::SUCCESS;
249 MsgStream log(
msgSvc(), name());
251 NTuple::Tuple* tupleMdc;
252 if(nt) tupleMdc = nt;
254 tupleMdc =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
257 return StatusCode::SUCCESS;
262 MsgStream log(
msgSvc(), name());
264 NTuple::Tuple* tupleCgem;
265 if(nt) tupleCgem = nt;
267 tupleCgem =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
270 return StatusCode::SUCCESS;
277 MsgStream log(
msgSvc(), name());
278 NTuplePtr nt1(
ntupleSvc(),
"FILE802/n1");
279 NTuple::Tuple* tupleTof1;
280 if(nt1) tupleTof1 = nt1;
282 tupleTof1 =
ntupleSvc()->book(
"FILE802/n1",CLID_ColumnWiseTuple,
"BesSim");
285 NTuplePtr nt2(
ntupleSvc(),
"FILE802/n2");
286 NTuple::Tuple* tupleTof2;
287 if(nt2) tupleTof2 = nt2;
289 tupleTof2 =
ntupleSvc()->book(
"FILE802/n2",CLID_ColumnWiseTuple,
"BesSim");
292 NTuplePtr nt3(
ntupleSvc(),
"FILE802/n3");
293 NTuple::Tuple* tupleTof3;
294 if(nt3) tupleTof3 = nt3;
296 tupleTof3 =
ntupleSvc()->book(
"FILE802/n3",CLID_ColumnWiseTuple,
"BesSim");
310 return StatusCode::SUCCESS;
317 NTuplePtr nt1(
ntupleSvc(),
"FILE803/n1");
318 NTuple::Tuple* tupleEmc1;
319 if(nt1) tupleEmc1 = nt1;
321 tupleEmc1 =
ntupleSvc()->book(
"FILE803/n1",CLID_ColumnWiseTuple,
"BesSim");
325 NTuplePtr nt2(
ntupleSvc(),
"FILE803/n2");
326 NTuple::Tuple* tupleEmc2;
327 if(nt2) tupleEmc2 = nt2;
329 tupleEmc2 =
ntupleSvc()->book(
"FILE803/n2",CLID_ColumnWiseTuple,
"BesSim");
334 return StatusCode::SUCCESS;
341 MsgStream log(
msgSvc(), name());
343 NTuple::Tuple* tupleMuc;
344 if(nt) tupleMuc = nt;
346 tupleMuc =
ntupleSvc()->book(
"FILE804/n1",CLID_ColumnWiseTuple,
"BesSim");
349 return StatusCode::SUCCESS;
356 MsgStream log(
msgSvc(), name());
359 if(m_nEvent%m_logLevel == 0)
360 std::cout<<
" BesSim Begin of Event: "<<m_nEvent<<std::endl;
365 return StatusCode::SUCCESS;
372 MsgStream log(
msgSvc(), name());
373 log << MSG::INFO <<
"finalize()" << endreq;
374 log << MSG::DEBUG <<
"\t terminating the current G4 run"<<endreq;
377 std::cout<<
"BesSim::finalize(), total events in this run: "<<m_nEvent<<std::endl;
379 if(m_G4Svc->
runMgr() != 0)
383 if(m_G4Svc->visMgr() != 0)
384 delete m_G4Svc->visMgr();
388 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 bookCgemRootFile()
StatusCode bookMucRootFile()
BesSim(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode bookTofRootFile()
void SetTupleTof3(NTuple::Tuple *tuple)
void SetTupleMdc(NTuple::Tuple *tuple)
void SetTupleCgem(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.