#include <BesGenModule.h>
Inheritance diagram for BesGenModule:
Public Member Functions | |
BesGenModule (const std::string &name, ISvcLocator *pSvcLocator) | |
virtual | ~BesGenModule () |
virtual StatusCode | genInitialize () |
virtual StatusCode | callGenerator () |
virtual StatusCode | genFinalize () |
virtual StatusCode | fillEvt (GenEvent *evt) |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
virtual StatusCode | genuserInitialize () |
Public Attributes | |
IBesRndmGenSvc * | p_BesRndmGenSvc |
Static Public Attributes | |
static std::string | besMcGen_stream = "PHOTOS_INIT" |
Protected Member Functions | |
void | StripPartonsInit (void) |
void | StripPartons (GenEvent *evt) |
Protected Attributes | |
int | m_fortout |
std::vector< long int > | m_seeds |
const char * | cardname |
std::string | runname |
int | Nr |
int | mvec [10] |
int | nvec [10] |
std::vector< int > | m_par |
int | m_events |
int | n |
int | n1 |
int | m_GenIndex |
int | m_SuperIndex |
int | m_SubIndex |
bool | m_fixedMode |
double | m_meanInteractions |
int | m_randomSeed |
std::vector< int > | m_AllPartons |
std::vector< int > | m_StripVector |
bool | m_StripPartonSwitch |
CLHEP::HepRandomEngine * | m_pRandomEngine |
CLHEP::RandPoisson * | m_pPoissonGenerator |
HepPDT::ParticleDataTable * | m_particleTable |
Definition at line 21 of file BesGenModule.h.
BesGenModule::BesGenModule | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 73 of file BesGenModule.cxx.
References besMcGen_stream, Nr, and runname.
00074 : GenModule(name,pSvcLocator) 00075 { 00076 //-------------------------------------------------------------------------- 00077 besMcGen_stream = "PHOTOS_INIT"; 00078 // declareProperty("BesMcGenCommand", m_BesMcGenCommandVector); 00079 00080 declareProperty("Runcards", runname = "run.cards"); 00081 declareProperty("Ratio", Nr = 1); 00082 00083 }
BesGenModule::~BesGenModule | ( | ) | [virtual] |
StatusCode BesGenModule::callGenerator | ( | ) | [virtual] |
Reimplemented from GenModule.
Definition at line 143 of file BesGenModule.cxx.
References Bes_Common::INFO, m_events, mainexe_(), mvec, Nr, and DecayMode::putData().
00143 { 00144 //--------------------------------------------------------------------------- 00145 MsgStream log(messageService(), name()); 00146 log << MSG::INFO << " BesGenModule generating. \n" << endreq; 00147 00148 StatusCode status = StatusCode::SUCCESS; 00149 int iq; 00150 00151 // n=1; 00152 00153 00154 mainexe_(&Nr,mvec); 00155 00156 /* 00157 for (int iq = 1; iq < 11; iq++) { 00158 nvec[iq-1]=mvec[iq]; 00159 } 00160 */ 00161 00162 McEvent* aMcEvent = new McEvent; 00163 StatusCode sc = eventSvc()->registerObject("/Event/MC",aMcEvent); 00164 00165 00166 SmartDataPtr<DecayMode> anMcCol(eventSvc(), "/Event/MC/DecayMode"); 00167 if (anMcCol!=0) { 00168 // log << MSG::INFO << "Add McEvent to existing collection" << endreq; 00169 } 00170 else { 00171 // log << MSG::INFO << "No decay mode now" << endreq; 00172 DecayMode *decayMode = new DecayMode; 00173 decayMode->putData(mvec, 10); 00174 StatusCode sc = eventSvc()->registerObject("/Event/MC/DecayMode",decayMode); 00175 } 00176 00177 00178 SmartDataPtr<DecayMode> aMcCol(eventSvc(), "/Event/MC/DecayMode"); 00179 if (aMcCol!=0) { 00180 // log << MSG::INFO << "Haha signal exist!!!!" << endreq; 00181 } 00182 00183 00184 00185 00186 // HEPEVT_Wrapper::print_hepevt(); 00187 00188 ++m_events; 00189 00190 00191 00192 log << MSG::INFO << " BESGenModule generating done. \n" << endreq; 00193 return status; 00194 00195 }
StatusCode GenModule::execute | ( | ) | [inherited] |
Definition at line 125 of file GenModule.cxx.
References Bes_Common::DEBUG, calibUtil::ERROR, GenModule::fillEvt(), genRecEmupikp::i, Bes_Common::INFO, GenModule::m_fixedMode, GenModule::m_meanInteractions, GenModule::m_pPoissonGenerator, GenModule::m_StripPartonSwitch, and GenModule::StripPartons().
00125 { 00126 //--------------------------------------------------------------------------- 00127 00128 int numToGenerate; 00129 StatusCode status; 00130 00131 MsgStream log(messageService(), name()); 00132 00133 log << MSG::DEBUG << "GenModule::execute()" << endreq; 00134 00135 // Decide how many interactions to generate 00136 if(m_fixedMode) { 00137 numToGenerate = (int) m_meanInteractions; 00138 } 00139 else { 00140 numToGenerate = m_pPoissonGenerator->fire(); 00141 } 00142 00143 // Generate as many interactions as requested 00144 for(int i=0; i<numToGenerate; i++) { 00145 00146 // Call the code that generates an event 00147 status = this->callGenerator(); 00148 00149 // Create the MC event and send the GeneratorEvent stored in it to fillEvt 00150 GenEvent* evt = new GenEvent(1,1); 00151 status = this->fillEvt(evt); 00152 00153 // Strip out the requested partons here. 00154 if (m_StripPartonSwitch) StripPartons(evt); 00155 00156 // Check if the McCollection already exists 00157 SmartDataPtr<McGenEventCol> anMcCol(eventSvc(), "/Event/Gen"); 00158 if (anMcCol!=0) { 00159 // Add event to existing collection 00160 MsgStream log(messageService(), name()); 00161 log << MSG::INFO << "Add McGenEvent to existing collection" << endreq; 00162 McGenEvent* mcEvent = new McGenEvent(evt); 00163 anMcCol->push_back(mcEvent); 00164 } 00165 else { 00166 // Create Collection and add to the transient store 00167 McGenEventCol *mcColl = new McGenEventCol; 00168 McGenEvent* mcEvent = new McGenEvent(evt); 00169 mcColl->push_back(mcEvent); 00170 00171 StatusCode sc = eventSvc()->registerObject("/Event/Gen",mcColl); 00172 00173 if (sc != StatusCode::SUCCESS) { 00174 MsgStream log(messageService(), name()); 00175 log << MSG::ERROR << "Could not register McGenEvent" << endreq; 00176 delete mcColl; 00177 delete evt; 00178 delete mcEvent; 00179 return StatusCode::FAILURE; 00180 } 00181 else { 00182 // std::cout << " McGenEventCol made and stored" << std::endl; 00183 } 00184 00185 } 00186 } 00187 00188 // now call the incident service and set the signal. 00189 IIncidentSvc *incSvc; 00190 service("IncidentSvc",incSvc); 00191 incSvc->fireIncident( Incident( name(), "McGenEvent Generated") ); 00192 00193 return status; 00194 }
StatusCode BesGenModule::fillEvt | ( | GenEvent * | evt | ) | [virtual] |
Reimplemented from GenModule.
Definition at line 206 of file BesGenModule.cxx.
References Bes_Common::INFO, and m_events.
00206 { 00207 //--------------------------------------------------------------------------- 00208 MsgStream log(messageService(), name()); 00209 log << MSG:: INFO << " BESGenModule Filling... \n" << endreq; 00210 00211 evt->set_event_number(m_events); 00212 HepMC::IO_HEPEVT hepio; 00213 hepio.fill_next_event(evt); 00214 // cmTomm(evt); 00215 // GeVToMeV(evt); 00216 00217 00218 return StatusCode::SUCCESS; 00219 }
StatusCode GenModule::finalize | ( | ) | [inherited] |
Definition at line 197 of file GenModule.cxx.
References GenModule::genFinalize().
00197 { 00198 //--------------------------------------------------------------------------- 00199 00200 StatusCode status = this->genFinalize(); 00201 00202 return status; 00203 }
StatusCode BesGenModule::genFinalize | ( | ) | [virtual] |
Reimplemented from GenModule.
Definition at line 198 of file BesGenModule.cxx.
References Bes_Common::INFO, mainfin_(), and n.
00198 { 00199 //--------------------------------------------------------------------------- 00200 MsgStream log(messageService(), name()); 00201 mainfin_(&n); 00202 log << MSG:: INFO << " BESGenModule Ending... \n" << endreq; 00203 return StatusCode::SUCCESS; 00204 }
StatusCode BesGenModule::genInitialize | ( | ) | [virtual] |
Reimplemented from GenModule.
Definition at line 104 of file BesGenModule.cxx.
References besMcGen_stream, cardname, calibUtil::ERROR, Bes_Common::INFO, m_events, mainini_(), n, p_BesRndmGenSvc, runi_seed_(), runname, and IBesRndmGenSvc::setGenseed().
00104 { 00105 //--------------------------------------------------------------------------- 00106 00107 MsgStream log(messageService(), name()); 00108 log << MSG::INFO << " BES PHOTOS INITIALISING. \n" << endreq; 00109 // log << MSG::INFO << " BES PHOTOS 2. \n" << endreq; 00110 00111 //caogf add for random seed of genbes 00112 StatusCode RndmStatus = service("BesRndmGenSvc", p_BesRndmGenSvc, true); 00113 if (!RndmStatus.isSuccess() || 0 == p_BesRndmGenSvc) 00114 { 00115 log << MSG::ERROR << " Could not initialize Random Number Service" << endreq; 00116 return RndmStatus; 00117 } 00118 00119 BesGenModule::besMcGen_stream = "PHOTOS_INIT"; 00120 00121 BesGenModule::besMcGen_stream = "PHOTOS111"; 00122 00123 m_events = 0; 00124 n=0; 00125 cardname = runname.c_str(); 00126 00127 00128 mainini_(&n,cardname); 00129 00130 int theseed; 00131 runi_seed_(&theseed); 00132 p_BesRndmGenSvc->setGenseed(theseed+1); 00133 00134 HepMC::HEPEVT_Wrapper::set_sizeof_int(4); 00135 HepMC::HEPEVT_Wrapper::set_sizeof_real(4); 00136 HepMC::HEPEVT_Wrapper::set_max_number_entries(2000); 00137 00138 00139 return StatusCode::SUCCESS; 00140 }
StatusCode GenModule::genuserInitialize | ( | ) | [virtual, inherited] |
Definition at line 212 of file GenModule.cxx.
Referenced by GenModule::initialize().
00212 { 00213 //--------------------------------------------------------------------------- 00214 return StatusCode::SUCCESS; 00215 }
StatusCode GenModule::initialize | ( | ) | [inherited] |
Definition at line 63 of file GenModule.cxx.
References calibUtil::ERROR, GenModule::genInitialize(), GenModule::genuserInitialize(), Bes_Common::INFO, GenModule::m_fixedMode, GenModule::m_meanInteractions, GenModule::m_particleTable, GenModule::m_pPoissonGenerator, GenModule::m_pRandomEngine, GenModule::m_randomSeed, GenModule::m_StripPartonSwitch, GenModule::m_StripVector, and GenModule::StripPartonsInit().
00063 { 00064 //--------------------------------------------------------------------------- 00065 00066 // Inform the user what the mode and conditions are: 00067 MsgStream log(messageService(), name()); 00068 00069 // Initialize StripPartons variables 00070 if (m_StripVector[0] > 0) { 00071 StripPartonsInit(); 00072 } else { 00073 m_StripPartonSwitch = false; 00074 m_StripVector.clear(); 00075 } 00076 00077 00078 // Get the Particle Properties Service 00079 IPartPropSvc* p_PartPropSvc; 00080 //static const bool CREATEIFNOTTHERE(true); 00081 //StatusCode PartPropStatus = service("PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE); 00082 StatusCode PartPropStatus = service("PartPropSvc", p_PartPropSvc); 00083 if (!PartPropStatus.isSuccess() || 0 == p_PartPropSvc) { 00084 log << MSG::ERROR << " Could not initialize Particle Properties Service" << endreq; 00085 return PartPropStatus; 00086 } 00087 00088 m_particleTable = p_PartPropSvc->PDT(); 00089 00090 m_pRandomEngine = new CLHEP::Ranlux64Engine(m_randomSeed); 00091 00092 if(m_fixedMode) { 00093 if(m_meanInteractions == 1.0) { 00094 log << MSG::INFO << "Standard Initialization: Single Interaction Mode " 00095 << endreq; 00096 } 00097 else { 00098 log << MSG::INFO << "Fixed Number of Interactions per Event is: " 00099 << m_meanInteractions << endreq; 00100 } 00101 } 00102 else { 00103 m_pPoissonGenerator = new CLHEP::RandPoisson(*m_pRandomEngine, 00104 m_meanInteractions); 00105 00106 log << MSG::INFO << 00107 "Poisson Distribution of Interactions per Event with Mean: " 00108 << m_meanInteractions << endreq; 00109 } 00110 // Initialize the generator itself 00111 StatusCode status = this->genInitialize(); 00112 if (status.isFailure()) { 00113 log << MSG::ERROR << "Could not initialize Generator properly" << endreq; 00114 return status; 00115 } 00116 StatusCode status1 = this->genuserInitialize(); 00117 if (status1.isFailure()) { 00118 log << MSG::ERROR << "Could not initialize user part properly" << endreq; 00119 return status1; 00120 } 00121 return status; 00122 }
void GenModule::StripPartons | ( | GenEvent * | evt | ) | [protected, inherited] |
Definition at line 274 of file GenModule.cxx.
References GenModule::m_StripVector.
Referenced by GenModule::execute().
00275 { 00276 // for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); 00277 // p != evt->particles_end(); ++p ) 00278 // { 00279 // // std::cout << " PDG, BAR " << (*p)->pdg_id() << " " << (*p)->barcode() << std::endl; 00280 // if ( std::find(m_StripVector.begin(), 00281 // m_StripVector.end(), 00282 // (*p)->pdg_id()) != m_StripVector.end() ) 00283 // { 00284 // // std::cout << " REMOVING " << (*p)->pdg_id() << " " << (*p)->barcode() << std::endl; 00285 // HepMC::GenVertex* pvtx = (*p)->production_vertex(); 00286 // HepMC::GenVertex* evtx = (*p)->end_vertex(); 00287 // if (pvtx) pvtx->remove_particle(*p); 00288 // if (evtx) evtx->remove_particle(*p); 00289 // delete *p; 00290 // } 00291 00292 // } 00293 00294 // Loop on all vertices of the event and remove the particle from the vertex 00295 for ( HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); 00296 vtx != evt->vertices_end(); ++vtx ) { 00297 // Loop on all children particles and remove the ones that should be stripped out 00298 for ( HepMC::GenVertex::particle_iterator p = (*vtx)-> particles_begin(HepMC::children); 00299 p != (*vtx)->particles_end(HepMC::children); 00300 ++p ){ 00301 if ( std::find(m_StripVector.begin(), 00302 m_StripVector.end(), 00303 (*p)->pdg_id()) != m_StripVector.end() ) { 00304 if ( (*p)->end_vertex() ) (*p)->end_vertex()->remove_particle(*p); 00305 if ( (*p)->production_vertex() ) (*p)->production_vertex()->remove_particle(*p); 00306 delete *p; 00307 } 00308 } 00309 // Loop on all parents particles and remove the ones that should be stripped out 00310 for ( HepMC::GenVertex::particle_iterator p = (*vtx)-> particles_begin(HepMC::parents); 00311 p != (*vtx)->particles_end(HepMC::parents); 00312 ++p ) { 00313 if ( std::find(m_StripVector.begin(), 00314 m_StripVector.end(), 00315 (*p)->pdg_id()) != m_StripVector.end() ) { 00316 if ( (*p)->end_vertex() ) (*p)->end_vertex()->remove_particle(*p); 00317 if ( (*p)->production_vertex() ) (*p)->production_vertex()->remove_particle(*p); 00318 delete *p; 00319 } 00320 } 00321 } 00322 }
void GenModule::StripPartonsInit | ( | void | ) | [protected, inherited] |
Definition at line 236 of file GenModule.cxx.
References genRecEmupikp::i, Bes_Common::INFO, GenModule::m_AllPartons, GenModule::m_StripPartonSwitch, and GenModule::m_StripVector.
Referenced by GenModule::initialize().
00237 { 00238 MsgStream log(messageService(), name()); 00239 00240 for (int i = 1; i < 9; ++i) { m_AllPartons.push_back(i); m_AllPartons.push_back(-i); } // Quarks 00241 m_AllPartons.push_back(21); // gluon 00242 00243 m_StripPartonSwitch = true; 00244 m_StripVector.erase(m_StripVector.begin(), m_StripVector.begin()+1); 00245 // When the user specifies only the StripPartonSwitch or gives a Particle Code 00246 // which is NOT a parton then strip ALL partons 00247 if (m_StripVector.size() == 0) { 00248 log << MSG::INFO << " !!!! NO SPECIFIC PARTON FOR STRIPOUT WAS REQUESTED => STRIPOUT ALL " 00249 << endreq; 00250 m_StripVector = m_AllPartons; 00251 } else { 00252 bool value_ok = true; 00253 std::vector<int>::const_iterator i = m_StripVector.begin(); 00254 do { 00255 if ( std::find(m_AllPartons.begin(), 00256 m_AllPartons.end(), 00257 *i) == m_AllPartons.end() ) value_ok = false; 00258 ++i; 00259 } while (i != m_StripVector.end() && value_ok); 00260 if (!value_ok) { 00261 log << MSG::INFO << " !!!! ILEGAL PDG-ID FOR STRIPOUT WAS REQUESTED => STRIPOUT ALL " 00262 << endreq; 00263 m_StripVector = m_AllPartons; 00264 } 00265 } 00266 log << MSG::INFO << " THE FOLLOWING PARTON(S) WILL BE STRIPED OUT "; 00267 for (std::vector<int>::const_iterator ip = m_StripVector.begin(); ip != m_StripVector.end(); ++ip) 00268 log << *ip << " "; 00269 log << endreq; 00270 00271 }
std::string BesGenModule::besMcGen_stream = "PHOTOS_INIT" [static] |
const char* BesGenModule::cardname [protected] |
std::vector<int> GenModule::m_AllPartons [protected, inherited] |
int BesGenModule::m_events [protected] |
Definition at line 53 of file BesGenModule.h.
Referenced by callGenerator(), fillEvt(), and genInitialize().
bool GenModule::m_fixedMode [protected, inherited] |
Definition at line 57 of file GenModule.h.
Referenced by GenModule::execute(), GenModule::GenModule(), and GenModule::initialize().
int BesGenModule::m_fortout [protected] |
Definition at line 39 of file BesGenModule.h.
int BesGenModule::m_GenIndex [protected] |
Definition at line 57 of file BesGenModule.h.
double GenModule::m_meanInteractions [protected, inherited] |
Definition at line 58 of file GenModule.h.
Referenced by GenModule::execute(), GenModule::GenModule(), and GenModule::initialize().
std::vector<int> BesGenModule::m_par [protected] |
Definition at line 50 of file BesGenModule.h.
HepPDT::ParticleDataTable* GenModule::m_particleTable [protected, inherited] |
Definition at line 73 of file GenModule.h.
Referenced by SingleParticleGun::genInitialize(), and GenModule::initialize().
CLHEP::RandPoisson* GenModule::m_pPoissonGenerator [protected, inherited] |
Definition at line 68 of file GenModule.h.
Referenced by GenModule::execute(), GenModule::initialize(), and GenModule::~GenModule().
CLHEP::HepRandomEngine* GenModule::m_pRandomEngine [protected, inherited] |
Definition at line 67 of file GenModule.h.
Referenced by GenModule::initialize(), and GenModule::~GenModule().
int GenModule::m_randomSeed [protected, inherited] |
Definition at line 59 of file GenModule.h.
Referenced by GenModule::GenModule(), and GenModule::initialize().
std::vector<long int> BesGenModule::m_seeds [protected] |
Definition at line 42 of file BesGenModule.h.
bool GenModule::m_StripPartonSwitch [protected, inherited] |
Definition at line 62 of file GenModule.h.
Referenced by GenModule::execute(), GenModule::initialize(), and GenModule::StripPartonsInit().
std::vector<int> GenModule::m_StripVector [protected, inherited] |
Definition at line 61 of file GenModule.h.
Referenced by GenModule::GenModule(), GenModule::initialize(), GenModule::StripPartons(), and GenModule::StripPartonsInit().
int BesGenModule::m_SubIndex [protected] |
Definition at line 61 of file BesGenModule.h.
int BesGenModule::m_SuperIndex [protected] |
Definition at line 59 of file BesGenModule.h.
int BesGenModule::mvec[10] [protected] |
int BesGenModule::n [protected] |
int BesGenModule::n1 [protected] |
Definition at line 55 of file BesGenModule.h.
int BesGenModule::Nr [protected] |
int BesGenModule::nvec[10] [protected] |
Definition at line 48 of file BesGenModule.h.
std::string BesGenModule::runname [protected] |