Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BesSim Class Reference

#include <BesSim.hh>

List of all members.

Public Member Functions

StatusCode beginRun ()
StatusCode beginRun ()
 BesSim (const std::string &name, ISvcLocator *pSvcLocator)
 BesSim (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode bookEmcRootFile ()
StatusCode bookEmcRootFile ()
StatusCode bookMdcRootFile ()
StatusCode bookMdcRootFile ()
StatusCode bookMucRootFile ()
StatusCode bookMucRootFile ()
StatusCode bookTofRootFile ()
StatusCode bookTofRootFile ()
StatusCode execute ()
StatusCode execute ()
StatusCode finalize ()
StatusCode finalize ()
StatusCode initialize ()
StatusCode initialize ()

Private Attributes

std::string m_asciiFile
std::string m_asciiFlag
int m_emc
int m_field
int m_formatAR
G4Svcm_G4Svc
G4Svcm_G4Svc
int m_hitOut
int m_logLevel
int m_mdc
int m_muc
int m_nEvent
int m_nRun
int m_physicsList
int m_pipeSCM
std::string m_rootFile
bool m_rootFlag
bool m_TDSFlag
int m_tof
int m_tuning
std::vector< std::string > m_tuningFile
std::vector< std::string > m_tuningFile
double newcut
IBesRndmGenSvcp_BesRndmGenSvc
IBesRndmGenSvcp_BesRndmGenSvc


Constructor & Destructor Documentation

BesSim::BesSim const std::string &  name,
ISvcLocator *  pSvcLocator
 

00043                                                               :
00044   Algorithm(name, pSvcLocator)
00045 {
00046   declareProperty("Mdc",m_mdc=2);
00047   declareProperty("Tof",m_tof=2);
00048   declareProperty("Emc",m_emc=2);
00049   declareProperty("Muc",m_muc=2);
00050   declareProperty("PipeSCM",m_pipeSCM=2);
00051   declareProperty("Field",m_field=1);
00052   declareProperty("PhysicsList",m_physicsList=0);
00053   declareProperty("FormatAR", m_formatAR =0);
00054   declareProperty("Tuning",m_tuning=0);
00055   declareProperty("TuningFile",m_tuningFile);
00056   declareProperty("HitOut",m_hitOut=0);
00057   declareProperty("TDSFlag",m_TDSFlag=false);
00058   declareProperty("AsciiFlag",m_asciiFlag="00000000");
00059   declareProperty("AsciiFile",m_asciiFile="boost.dat");
00060   declareProperty("RootFlag",m_rootFlag=false);
00061   declareProperty("RootFile",m_rootFile="Hit.root");
00062   declareProperty("CutValue", newcut = 0.7);//unite is mm
00063   declareProperty("LogLevel",m_logLevel=5000);
00064 }

BesSim::BesSim const std::string &  name,
ISvcLocator *  pSvcLocator
 


Member Function Documentation

StatusCode BesSim::beginRun  ) 
 

StatusCode BesSim::beginRun  ) 
 

00192 {
00193   static int flag = -1;
00194   if(flag<0)
00195   {
00196     MsgStream log(msgSvc(), name());
00197     log << MSG::DEBUG << "\t start initializing G4 "<<endreq;
00198     //new visMgr,  StartUISession(),  runMgr->Initialize()
00199     m_G4Svc->G4Init();
00200 
00201     //to do: runMgr->RunInitialization()
00202     m_G4Svc->RunInitialize();
00203    
00204     //G4VPhysicalVolume* g4wv =
00205     //  G4TransportationManager::GetTransportationManager()->
00206     //  GetNavigatorForTracking()->GetWorldVolume();
00207     //G4GDMLWriter g4writerBes("/afs/ihep.ac.cn/bes3/offline/sw/packages/BesGDML/2.8.0/GDMLSchema/gdml.xsd", "Bes.gdml",2);
00208     //G4GDMLWriter g4writerMdc("/afs/ihep.ac.cn/bes3/offline/sw/packages/BesGDML/2.8.0/GDMLSchema/gdml.xsd", "Mdc.gdml",2);
00209     //G4GDMLWriter g4writerTof("/afs/ihep.ac.cn/bes3/offline/sw/packages/BesGDML/2.8.0/GDMLSchema/gdml.xsd", "Tof.gdml",2);
00210     //G4GDMLWriter g4writerEmc("/afs/ihep.ac.cn/bes3/offline/sw/packages/BesGDML/2.8.0/GDMLSchema/gdml.xsd", "Emc.gdml",2);
00211     //G4GDMLWriter g4writerMuc("/afs/ihep.ac.cn/bes3/offline/sw/packages/BesGDML/2.8.0/GDMLSchema/gdml.xsd", "Muc.gdml",2);
00212     //try
00213     //{
00214       //g4writerBes.DumpGeometryInfo(g4wv);
00215       //g4writerTof.DumpGeometryInfo(g4wv->GetLogicalVolume()->GetDaughter(0));
00216 
00217     //}
00218     //catch(std::logic_error &lerr)
00219     //{
00220     //  std::cout << "Caught an exception: "
00221     //    << lerr.what () << std::endl;
00222     //}
00223 
00224     //For random seed added by caogf. Note the position of the code, otherwise it is not available.
00225     CLHEP::HepRandomEngine* engine = p_BesRndmGenSvc->GetEngine("SIM");
00226     HepRandom::setTheEngine(engine);
00227     HepRandom::showEngineStatus();
00228   }
00229   return StatusCode::SUCCESS;
00230 }

StatusCode BesSim::bookEmcRootFile  ) 
 

StatusCode BesSim::bookEmcRootFile  ) 
 

00277 {
00278   NTuplePtr nt1(ntupleSvc(), "FILE803/n1");
00279   NTuple::Tuple* tupleEmc1;
00280   if(nt1) tupleEmc1 = nt1;
00281   else {
00282     tupleEmc1 = ntupleSvc()->book("FILE803/n1",CLID_ColumnWiseTuple,"BesSim");       
00283     m_G4Svc->SetTupleEmc1(tupleEmc1);
00284   }
00285   
00286   NTuplePtr nt2(ntupleSvc(), "FILE803/n2");
00287   NTuple::Tuple* tupleEmc2;
00288   if(nt2) tupleEmc2 = nt2;
00289   else {
00290     tupleEmc2 = ntupleSvc()->book("FILE803/n2",CLID_ColumnWiseTuple,"BesSim");       
00291     m_G4Svc->SetTupleEmc2(tupleEmc2);
00292   }
00293   
00294   return StatusCode::SUCCESS;
00295 }

StatusCode BesSim::bookMdcRootFile  ) 
 

StatusCode BesSim::bookMdcRootFile  ) 
 

00233 {
00234   MsgStream log(msgSvc(), name());
00235   NTuplePtr nt(ntupleSvc(), "FILE801/n1");
00236   NTuple::Tuple* tupleMdc;
00237   if(nt) tupleMdc = nt;
00238   else {
00239     tupleMdc = ntupleSvc()->book("FILE801/n1",CLID_ColumnWiseTuple,"BesSim");
00240     m_G4Svc->SetTupleMdc(tupleMdc);
00241   }
00242   return StatusCode::SUCCESS;
00243 }

StatusCode BesSim::bookMucRootFile  ) 
 

StatusCode BesSim::bookMucRootFile  ) 
 

00300 {
00301   MsgStream log(msgSvc(), name());
00302   NTuplePtr nt(ntupleSvc(), "FILE804/n1");
00303   NTuple::Tuple* tupleMuc;
00304   if(nt) tupleMuc = nt;
00305   else {
00306     tupleMuc = ntupleSvc()->book("FILE804/n1",CLID_ColumnWiseTuple,"BesSim");
00307     m_G4Svc->SetTupleMuc(tupleMuc);
00308   }
00309   return StatusCode::SUCCESS;
00310 }

StatusCode BesSim::bookTofRootFile  ) 
 

StatusCode BesSim::bookTofRootFile  ) 
 

00248 {
00249   MsgStream log(msgSvc(), name());
00250   NTuplePtr nt1(ntupleSvc(), "FILE802/n1");
00251   NTuple::Tuple* tupleTof1;
00252   if(nt1) tupleTof1 = nt1;
00253   else {
00254     tupleTof1 = ntupleSvc()->book("FILE802/n1",CLID_ColumnWiseTuple,"BesSim");       
00255     m_G4Svc->SetTupleTof1(tupleTof1);
00256   }
00257   NTuplePtr nt2(ntupleSvc(), "FILE802/n2");
00258   NTuple::Tuple* tupleTof2;
00259   if(nt2) tupleTof2 = nt2;
00260   else {
00261     tupleTof2 = ntupleSvc()->book("FILE802/n2",CLID_ColumnWiseTuple,"BesSim");       
00262     m_G4Svc->SetTupleTof2(tupleTof2);
00263   }
00264   NTuplePtr nt3(ntupleSvc(), "FILE802/n3");
00265   NTuple::Tuple* tupleTof3;
00266   if(nt3) tupleTof3 = nt3;
00267   else {
00268     tupleTof3 = ntupleSvc()->book("FILE802/n3",CLID_ColumnWiseTuple,"BesSim");       
00269     m_G4Svc->SetTupleTof3(tupleTof3);
00270   }
00271   return StatusCode::SUCCESS;
00272 }

StatusCode BesSim::execute  ) 
 

StatusCode BesSim::execute  ) 
 

00314                            {
00315 
00316   MsgStream log(msgSvc(), name());
00317   
00318   //log << MSG::INFO << "event ID:"<<m_nEvent<<endreq;
00319   if(m_nEvent%m_logLevel == 0)
00320     std::cout<<" BesSim Begin of Event: "<<m_nEvent<<std::endl;
00321   
00322   m_G4Svc->SimulateEvents(m_nEvent);
00323   m_nEvent++;
00324 
00325   return StatusCode::SUCCESS;
00326 }

StatusCode BesSim::finalize  ) 
 

StatusCode BesSim::finalize  ) 
 

00330                             {
00331 
00332   MsgStream log(msgSvc(), name());
00333   log << MSG::INFO << "finalize()" << endreq;
00334   log << MSG::DEBUG  << "\t terminating the current G4 run"<<endreq;
00335   m_G4Svc->RunTerminate();
00336   
00337   std::cout<<"BesSim::finalize(), total events in this run: "<<m_nEvent<<std::endl;
00338   return StatusCode::SUCCESS;
00339 }

StatusCode BesSim::initialize  ) 
 

StatusCode BesSim::initialize  ) 
 

00068                              {
00069 
00070   MsgStream log(msgSvc(), name());
00071   log << MSG::INFO << "initialize()" << endreq;
00072   m_nEvent = 0;
00073   m_nRun = 1;
00074 
00075   //caogf for random seed
00076   static const bool CREATEIFNOTTHERE(true);
00077   StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, CREATEIFNOTTHERE);
00078   if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc)
00079   {
00080      log << MSG::ERROR << " Could not initialize Random Number Service" << endreq;
00081       return RndmStatus;
00082   }
00083 
00084   StatusCode status;
00085   IG4Svc *tmpSvc;
00086   status = service("G4Svc",tmpSvc);
00087   if (status.isSuccess()) {
00088     log << MSG::INFO << "got the G4Svc" << endreq;
00089     m_G4Svc=dynamic_cast<G4Svc *>(tmpSvc);
00090   } else { 
00091     log << MSG::ERROR << "could not get the G4Svc" << endreq;
00092     return StatusCode::FAILURE;
00093   }
00094 
00095   //book Ntuple
00096   if(m_G4Svc->MdcRootFlag())
00097     bookMdcRootFile();
00098   
00099   if(m_G4Svc->TofRootFlag())
00100     bookTofRootFile();
00101   
00102   if(m_G4Svc->EmcRootFlag())
00103     bookEmcRootFile();
00104 
00105   if(m_G4Svc->MucRootFlag())
00106     bookMucRootFile();
00107 
00108   log << MSG::INFO << "Four sub-detector construction flags: " <<m_mdc<<" "<<m_tof<<" "<<m_emc<<" "<<m_muc<<endreq;
00109   
00110   ReadBoostRoot* readBoost =new ReadBoostRoot(m_mdc, m_tof,m_emc, m_muc, m_field,m_formatAR,m_tuning,m_hitOut);
00111   BesMdcGeoParameter * mdcGeoService;
00112   mdcGeoService = new BesMdcGeoParameter;
00113   
00114   log << MSG::INFO << "Instantiating BESIII Detector" << endreq;
00115  
00116   BesSensitiveManager* sensitiveManager = new BesSensitiveManager;
00117   sensitiveManager->SetLogLevel(m_G4Svc->LogLevel());
00118 
00119   BesDetectorConstruction* detectorConstruction = new BesDetectorConstruction();
00120   detectorConstruction->SetPipeSCM(m_pipeSCM);  
00121   m_G4Svc->SetUserInitialization(detectorConstruction);
00122 
00123   switch(m_physicsList)
00124   {
00125     case 1:
00126       m_G4Svc->SetUserInitialization(new BesPhysicsList);
00127       break;
00128     case 2:
00129       m_G4Svc->SetUserInitialization(new QGSP);
00130       break;
00131     case 3:
00132       m_G4Svc->SetUserInitialization(new QGSP_BIC);
00133       break;
00134     case 4:
00135       m_G4Svc->SetUserInitialization(new QGSP_BERT);
00136       break;
00137     case 5:
00138       m_G4Svc->SetUserInitialization(new QGSP_BERT_HP);
00139       break;
00140     case 6:
00141       m_G4Svc->SetUserInitialization(new BgsPhysicsList);
00142       break;
00143     case 7:
00144       m_G4Svc->SetUserInitialization(new CHIPS);
00145       break;
00146     case 8:
00147       m_G4Svc->SetUserInitialization(new QBBC);
00148       break;
00149     case 9:
00150       m_G4Svc->SetUserInitialization(new QGSP_BERT_CHIPS);
00151       break; 
00152     default:
00153       m_G4Svc->SetUserInitialization(new QGSP_BERT);
00154       break;
00155   }
00156       
00157   m_G4Svc->SetUserAction(new BesPrimaryGeneratorAction);
00158   
00159   BesRunAction* runAction = new BesRunAction;
00160   runAction->SetTDSFlag(m_TDSFlag);
00161   runAction->SetAsciiFlag(m_asciiFlag);
00162   runAction->SetAsciiFile(m_asciiFile);
00163   runAction->SetRootFlag(m_rootFlag);
00164   runAction->SetRootFile(m_rootFile);
00165   vector<string>::iterator pd;
00166   for (pd = m_tuningFile.begin(); pd != m_tuningFile.end(); pd++){
00167     std::cout << "tuning File: " << *pd << std::endl;
00168   }
00169   runAction->SetTuningFile(m_tuningFile);
00170   m_G4Svc->SetUserAction(runAction);
00171   
00172   BesEventAction* evtAction = new BesEventAction(runAction);
00173   m_G4Svc->SetUserAction(evtAction);
00174   
00175   m_G4Svc->SetUserAction(new BesSteppingAction);
00176   
00177   m_G4Svc->SetUserAction(new BesTrackingAction(runAction) );
00178   
00179 //#ifdef G4VIS_USE
00180 //visualization manager
00181 //  G4VisManager* visManager = new BesVisManager;
00182 //  visManager->Initialize();
00183 //#endif
00184 
00185   
00186     return StatusCode::SUCCESS;
00187 }


Member Data Documentation

std::string BesSim::m_asciiFile [private]
 

std::string BesSim::m_asciiFlag [private]
 

int BesSim::m_emc [private]
 

int BesSim::m_field [private]
 

int BesSim::m_formatAR [private]
 

G4Svc* BesSim::m_G4Svc [private]
 

G4Svc* BesSim::m_G4Svc [private]
 

int BesSim::m_hitOut [private]
 

int BesSim::m_logLevel [private]
 

int BesSim::m_mdc [private]
 

int BesSim::m_muc [private]
 

int BesSim::m_nEvent [private]
 

int BesSim::m_nRun [private]
 

int BesSim::m_physicsList [private]
 

int BesSim::m_pipeSCM [private]
 

std::string BesSim::m_rootFile [private]
 

bool BesSim::m_rootFlag [private]
 

bool BesSim::m_TDSFlag [private]
 

int BesSim::m_tof [private]
 

int BesSim::m_tuning [private]
 

std::vector<std::string> BesSim::m_tuningFile [private]
 

std::vector<std::string> BesSim::m_tuningFile [private]
 

double BesSim::newcut [private]
 

IBesRndmGenSvc* BesSim::p_BesRndmGenSvc [private]
 

IBesRndmGenSvc* BesSim::p_BesRndmGenSvc [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 15:53:15 2011 for BOSS6.5.5 by  doxygen 1.3.9.1