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(
"Tof",m_tof=2);
55 declareProperty(
"Emc",m_emc=2);
56 declareProperty(
"Muc",m_muc=2);
57 declareProperty(
"PipeSCM",m_pipeSCM=2);
58 declareProperty(
"Field",m_field=1);
59 declareProperty(
"PhysicsList",m_physicsList=0);
60 declareProperty(
"FormatAR", m_formatAR =0);
61 declareProperty(
"Tuning",m_tuning=0);
62 declareProperty(
"TuningFile",m_tuningFile);
63 declareProperty(
"HitOut",m_hitOut=0);
64 declareProperty(
"TDSFlag",m_TDSFlag=
false);
65 declareProperty(
"AsciiFlag",m_asciiFlag=
"00000000");
66 declareProperty(
"AsciiFile",m_asciiFile=
"boost.dat");
67 declareProperty(
"RootFlag",m_rootFlag=
false);
68 declareProperty(
"RootFile",m_rootFile=
"Hit.root");
69 declareProperty(
"CutValue", newcut = 0.7);
70 declareProperty(
"LogLevel",m_logLevel=5000);
78 MsgStream log(
msgSvc(), name());
79 log << MSG::INFO <<
"initialize()" << endreq;
84 static const bool CREATEIFNOTTHERE(
true);
85 StatusCode RndmStatus = service(
"BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
86 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
88 log << MSG::ERROR <<
" Could not initialize Random Number Service" << endreq;
94 status = service(
"G4Svc",tmpSvc);
95 if (status.isSuccess()) {
96 log << MSG::INFO <<
"got the G4Svc" << endreq;
97 m_G4Svc=
dynamic_cast<G4Svc *
>(tmpSvc);
99 log << MSG::ERROR <<
"could not get the G4Svc" << endreq;
100 return StatusCode::FAILURE;
119 log << MSG::INFO <<
"Four sub-detector construction flags: " <<m_mdc<<
" "<<m_cgem<<
" "<<m_tof<<
" "<<m_emc<<
" "<<m_muc<<endreq;
129 log << MSG::INFO <<
"Instantiating BESIII Detector" << endreq;
138 switch(m_physicsList)
178 vector<string>::iterator pd;
179 for (pd = m_tuningFile.begin(); pd != m_tuningFile.end(); pd++){
180 std::cout <<
"tuning File: " << *pd << std::endl;
200 return StatusCode::SUCCESS;
207 static int flag = -1;
210 MsgStream log(
msgSvc(), name());
211 log << MSG::DEBUG <<
"\t start initializing G4 "<<endreq;
238 CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->
GetEngine(
"SIM");
239 HepRandom::setTheEngine(engine);
240 HepRandom::showEngineStatus();
242 return StatusCode::SUCCESS;
247 MsgStream log(
msgSvc(), name());
249 NTuple::Tuple* tupleMdc;
250 if(nt) tupleMdc = nt;
252 tupleMdc =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
255 return StatusCode::SUCCESS;
260 MsgStream log(
msgSvc(), name());
262 NTuple::Tuple* tupleCgem;
263 if(nt) tupleCgem = nt;
265 tupleCgem =
ntupleSvc()->book(
"FILE801/n1",CLID_ColumnWiseTuple,
"BesSim");
268 return StatusCode::SUCCESS;
275 MsgStream log(
msgSvc(), name());
276 NTuplePtr nt1(
ntupleSvc(),
"FILE802/n1");
277 NTuple::Tuple* tupleTof1;
278 if(nt1) tupleTof1 = nt1;
280 tupleTof1 =
ntupleSvc()->book(
"FILE802/n1",CLID_ColumnWiseTuple,
"BesSim");
283 NTuplePtr nt2(
ntupleSvc(),
"FILE802/n2");
284 NTuple::Tuple* tupleTof2;
285 if(nt2) tupleTof2 = nt2;
287 tupleTof2 =
ntupleSvc()->book(
"FILE802/n2",CLID_ColumnWiseTuple,
"BesSim");
290 NTuplePtr nt3(
ntupleSvc(),
"FILE802/n3");
291 NTuple::Tuple* tupleTof3;
292 if(nt3) tupleTof3 = nt3;
294 tupleTof3 =
ntupleSvc()->book(
"FILE802/n3",CLID_ColumnWiseTuple,
"BesSim");
308 return StatusCode::SUCCESS;
315 NTuplePtr nt1(
ntupleSvc(),
"FILE803/n1");
316 NTuple::Tuple* tupleEmc1;
317 if(nt1) tupleEmc1 = nt1;
319 tupleEmc1 =
ntupleSvc()->book(
"FILE803/n1",CLID_ColumnWiseTuple,
"BesSim");
323 NTuplePtr nt2(
ntupleSvc(),
"FILE803/n2");
324 NTuple::Tuple* tupleEmc2;
325 if(nt2) tupleEmc2 = nt2;
327 tupleEmc2 =
ntupleSvc()->book(
"FILE803/n2",CLID_ColumnWiseTuple,
"BesSim");
332 return StatusCode::SUCCESS;
339 MsgStream log(
msgSvc(), name());
341 NTuple::Tuple* tupleMuc;
342 if(nt) tupleMuc = nt;
344 tupleMuc =
ntupleSvc()->book(
"FILE804/n1",CLID_ColumnWiseTuple,
"BesSim");
347 return StatusCode::SUCCESS;
354 MsgStream log(
msgSvc(), name());
357 if(m_nEvent%m_logLevel == 0)
358 std::cout<<
" BesSim Begin of Event: "<<m_nEvent<<std::endl;
363 return StatusCode::SUCCESS;
370 MsgStream log(
msgSvc(), name());
371 log << MSG::INFO <<
"finalize()" << endreq;
372 log << MSG::DEBUG <<
"\t terminating the current G4 run"<<endreq;
375 std::cout<<
"BesSim::finalize(), total events in this run: "<<m_nEvent<<std::endl;
377 if(m_G4Svc->
runMgr() != 0)
381 if(m_G4Svc->visMgr() != 0)
382 delete m_G4Svc->visMgr();
386 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.