2#include "BesDetectorConstruction.hh"
3#include "ReadBoostRoot.hh"
4#include "BesMdcGeoParameter.hh"
5#include "CgemGeomSvc.h"
6#include "BesPhysicsList.hh"
7#include "BgsPhysicsList.hh"
8#include "BesSensitiveManager.hh"
9#include "BesPrimaryGeneratorAction.hh"
10#include "BesRunAction.hh"
11#include "BesEventAction.hh"
12#include "BesSteppingAction.hh"
13#include "BesTrackingAction.hh"
18#include "QGSP_BERT.hh"
19#include "QGSP_BERT_CHIPS.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"
31#include "G4Svc/IG4Svc.h"
32#include "G4Svc/G4Svc.h"
33#include "GaudiKernel/NTuple.h"
34#include "BesKernel/IBesRndmGenSvc.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(
"Tof",
m_tof=2);
56 declareProperty(
"Emc",m_emc=2);
57 declareProperty(
"Muc",m_muc=2);
58 declareProperty(
"PipeSCM",m_pipeSCM=2);
59 declareProperty(
"Field",m_field=1);
60 declareProperty(
"PhysicsList",m_physicsList=0);
61 declareProperty(
"FormatAR", m_formatAR =0);
62 declareProperty(
"Tuning",m_tuning=0);
63 declareProperty(
"TuningFile",m_tuningFile);
64 declareProperty(
"HitOut",m_hitOut=0);
65 declareProperty(
"TDSFlag",m_TDSFlag=
false);
66 declareProperty(
"AsciiFlag",m_asciiFlag=
"00000000");
67 declareProperty(
"AsciiFile",m_asciiFile=
"boost.dat");
68 declareProperty(
"RootFlag",m_rootFlag=
false);
69 declareProperty(
"RootFile",m_rootFile=
"Hit.root");
70 declareProperty(
"CutValue", newcut = 0.7);
71 declareProperty(
"LogLevel",m_logLevel=5000);
79 MsgStream log(
msgSvc(), name());
80 log << MSG::INFO <<
"initialize()" << endreq;
85 static const bool CREATEIFNOTTHERE(
true);
86 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
87 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
89 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
95 status = service(
"G4Svc",tmpSvc);
96 if (status.isSuccess()) {
97 log << MSG::INFO <<
"got the G4Svc" << endreq;
98 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
100 log << MSG::ERROR <<
"could not get the G4Svc" << endreq;
101 return StatusCode::FAILURE;
120 log << MSG::INFO <<
"Four sub-detector construction flags: " <<m_mdc<<
" "<<m_cgem<<
" "<<m_tof<<
" "<<m_emc<<
" "<<m_muc<<endreq;
130 log << MSG::INFO <<
"Instantiating BESIII Detector" << endreq;
139 switch(m_physicsList)
179 vector<string>::iterator pd;
180 for (pd = m_tuningFile.begin(); pd != m_tuningFile.end(); pd++){
181 std::cout <<
"tuning File: " << *pd << std::endl;
201 return StatusCode::SUCCESS;
208 static int flag = -1;
211 MsgStream log(
msgSvc(), name());
212 log << MSG::DEBUG <<
"\t start initializing G4 "<<endreq;
239 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"SIM");
240 HepRandom::setTheEngine(engine);
241 HepRandom::showEngineStatus();
243 return StatusCode::SUCCESS;
248 MsgStream log(
msgSvc(), name());
250 NTuple::Tuple* tupleMdc;
251 if(nt) tupleMdc = nt;
253 tupleMdc =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
256 return StatusCode::SUCCESS;
261 MsgStream log(
msgSvc(), name());
263 NTuple::Tuple* tupleCgem;
264 if(nt) tupleCgem = nt;
266 tupleCgem =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
269 return StatusCode::SUCCESS;
276 MsgStream log(
msgSvc(), name());
277 NTuplePtr nt1(
ntupleSvc(),
"FILE802/n1");
278 NTuple::Tuple* tupleTof1;
279 if(nt1) tupleTof1 = nt1;
281 tupleTof1 =
ntupleSvc()->book(
"FILE802/n1",CLID_ColumnWiseTuple,
"BesSim");
284 NTuplePtr nt2(
ntupleSvc(),
"FILE802/n2");
285 NTuple::Tuple* tupleTof2;
286 if(nt2) tupleTof2 = nt2;
288 tupleTof2 =
ntupleSvc()->book(
"FILE802/n2",CLID_ColumnWiseTuple,
"BesSim");
291 NTuplePtr nt3(
ntupleSvc(),
"FILE802/n3");
292 NTuple::Tuple* tupleTof3;
293 if(nt3) tupleTof3 = nt3;
295 tupleTof3 =
ntupleSvc()->book(
"FILE802/n3",CLID_ColumnWiseTuple,
"BesSim");
309 return StatusCode::SUCCESS;
316 NTuplePtr nt1(
ntupleSvc(),
"FILE803/n1");
317 NTuple::Tuple* tupleEmc1;
318 if(nt1) tupleEmc1 = nt1;
320 tupleEmc1 =
ntupleSvc()->book(
"FILE803/n1",CLID_ColumnWiseTuple,
"BesSim");
324 NTuplePtr nt2(
ntupleSvc(),
"FILE803/n2");
325 NTuple::Tuple* tupleEmc2;
326 if(nt2) tupleEmc2 = nt2;
328 tupleEmc2 =
ntupleSvc()->book(
"FILE803/n2",CLID_ColumnWiseTuple,
"BesSim");
333 return StatusCode::SUCCESS;
340 MsgStream log(
msgSvc(), name());
342 NTuple::Tuple* tupleMuc;
343 if(nt) tupleMuc = nt;
345 tupleMuc =
ntupleSvc()->book(
"FILE804/n1",CLID_ColumnWiseTuple,
"BesSim");
348 return StatusCode::SUCCESS;
355 MsgStream log(
msgSvc(), name());
358 if(m_nEvent%m_logLevel == 0)
359 std::cout<<
" BesSim Begin of Event: "<<m_nEvent<<std::endl;
364 return StatusCode::SUCCESS;
371 MsgStream log(
msgSvc(), name());
372 log << MSG::INFO <<
"finalize()" << endreq;
373 log << MSG::DEBUG <<
"\t terminating the current G4 run"<<endreq;
376 std::cout<<
"BesSim::finalize(), total events in this run: "<<m_nEvent<<std::endl;
378 if(m_G4Svc->
runMgr() != 0)
382 if(m_G4Svc->visMgr() != 0)
383 delete m_G4Svc->visMgr();
387 return StatusCode::SUCCESS;
NTuple::Array< double > m_tof
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.