/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/G4Svc/G4Svc-00-01-52/src/G4SvcRunManager.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------
00002 //
00003 // ClassName:   G4SvcRunManager
00004 //  
00005 // Description: replacement G4RunManager with extra features
00006 //
00007 // $Id: G4SvcRunManager.cpp,v 1.13 2011/02/15 01:05:25 dengzy Exp $
00008 // Simulation/G4Sim/G4Svc tag $Name: G4Svc-00-01-52 $
00009 
00010 #include "G4Svc/G4SvcRunManager.h"
00011 #include "G4Svc/BesHepMCInterface.h"
00012 #include "G4ios.hh"
00013 #include "G4Event.hh"
00014 #include "G4VHit.hh"
00015 #include "G4HCofThisEvent.hh"
00016 #include "G4VHitsCollection.hh"
00017 #include "G4THitsCollection.hh"
00018 #include "G4VUserDetectorConstruction.hh"
00019 #include "G4VUserPhysicsList.hh"
00020 #include "G4SDManager.hh"
00021 #include "G4PrimaryParticle.hh"
00022 
00023 #include "G4TrajectoryContainer.hh"
00024 #include "G4Trajectory.hh"
00025 
00026 #include "GaudiKernel/System.h"
00027 #include "GaudiKernel/IMessageSvc.h"
00028 
00029 //#include "FadsKinematics/GeneratorCenter.hh"
00030 #include "G4VUserPrimaryGeneratorAction.hh"
00031 
00032 #include <iostream>
00033 #include <string>
00034 #include <vector>
00035 
00036 //*************************************************************************//
00037 
00038 G4SvcRunManager::G4SvcRunManager(): 
00039   G4RunManager(),
00040   m_logLevel(6) {
00041 }
00042 
00043 //*************************************************************************//
00044 
00045 G4SvcRunManager::~G4SvcRunManager() {
00046 }
00047 
00048 G4Event* G4SvcRunManager::GenerateEvent(G4int i_event)
00049 {
00050   G4Event* anEvent = new G4Event(i_event);
00051   
00052   if(!userPrimaryGeneratorAction)
00053   {
00054     if(m_logLevel<=4)
00055             std::cout<<"calling the hepmc interface"<<std::endl;
00056     BesHepMCInterface* hepmcInterface = new BesHepMCInterface;
00057     hepmcInterface->SetLogLevel(m_logLevel);
00058     HepMC::GenEvent* hepmcEvent = hepmcInterface->GenerateHepMCEvent();
00059     if(m_logLevel<=4)
00060       std::cout<<"got the hepmcEvent"<<std::endl;
00061     hepmcInterface->HepMC2G4(hepmcEvent, anEvent);
00062     delete hepmcInterface;
00063     if(m_logLevel<=4)
00064       PrintPrimary(anEvent);
00065 
00066   }
00067   else{
00068     if(storeRandomNumberStatus) {
00069       G4String fileN = randomNumberStatusDir + "currentEvent.rndm"; 
00070       CLHEP::HepRandom::saveEngineStatus(fileN);
00071     }  
00072     userPrimaryGeneratorAction->GeneratePrimaries(anEvent);
00073   }
00074   return anEvent;
00075 }
00076 
00077 void G4SvcRunManager::PrintPrimary(G4Event* anEvent)
00078 {
00079   G4cout<<G4endl<<"primary particles of this event: "<<G4endl;
00080   G4int n_vertex = anEvent->GetNumberOfPrimaryVertex();
00081   for( G4int i=0; i<n_vertex; i++ )
00082   {
00083     G4cout<<"vertex:"<<i<<G4endl;
00084     G4PrimaryVertex* primaryVertex = anEvent->GetPrimaryVertex(i);
00085     G4PrimaryParticle* primaryParticle = primaryVertex->GetPrimary();
00086     G4cout<<"PDGCode:";
00087     while( primaryParticle != 0 )
00088     {
00089       G4int PDGcode = primaryParticle->GetPDGcode();
00090       G4cout<<PDGcode<<" ";
00091       primaryParticle = primaryParticle->GetNext();
00092     }
00093     G4cout<<G4endl;
00094   }
00095   G4cout<<G4endl;
00096 }
00097 void G4SvcRunManager::SimulateEvent(int i)
00098 {
00099         //G4StateManager* stateManager = G4StateManager::GetStateManager();
00100   //stateManager->SetNewState(G4State_EventProc);
00101   currentEvent = GenerateEvent(i);
00102   eventManager->ProcessOneEvent(currentEvent);
00103   AnalyzeEvent(currentEvent);
00104   //stateManager->SetNewState(G4State_GeomClosed);
00105   StackPreviousEvent(currentEvent);
00106   currentEvent = 0;
00107   if(m_logLevel<=4)
00108           std::cout<<"SimulateEvent : done simulating one event "<<std::endl<<std::endl;
00109 }
00110 
00111 
00112 

Generated on Tue Nov 29 23:14:34 2016 for BOSS_7.0.2 by  doxygen 1.4.7