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

Go to the documentation of this file.
00001 #include "G4Svc/BesHepMCInterface.h"
00002 #include "HepMC/GenEvent.h"
00003 
00004 #include "GaudiKernel/ISvcLocator.h"
00005 #include "GaudiKernel/Bootstrap.h"
00006 #include "GaudiKernel/MsgStream.h"
00007 #include "GaudiKernel/IMessageSvc.h"
00008 
00009 #include "GeneratorObject/McGenEvent.h"
00010 #include "GaudiKernel/SmartDataPtr.h"
00011 
00012 BesHepMCInterface::BesHepMCInterface()
00013 {
00014   p_evtSvc = 0;
00015 }
00016 BesHepMCInterface::~BesHepMCInterface()
00017 {
00018         //std::cout<< "\b the BesHepMCInterface is being destroyed "<<std::endl;
00019 }
00020 
00021 HepMC::GenEvent* BesHepMCInterface::GenerateHepMCEvent()
00022 {
00023   
00024   if (p_evtSvc == 0) {     
00025     //std::cout<<" standard interface to EvtDataSvc for retrieving HepMC events"<<std::endl;
00026     ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap
00027     StatusCode sc=svcLocator->service("EventDataSvc", p_evtSvc);
00028     if (sc.isFailure()) 
00029     {
00030             //std::cout<<"BesHepMCInterface could not access EventDataSvc!!"<<std::endl;
00031     }
00032   }
00033         int n = 0;
00034   //std::cout <<" BesHepMCInterface::GenerateAnEvent "<<std::endl;
00035 
00036         SmartDataPtr<McGenEventCol> mcCollptr( p_evtSvc, "/Event/Gen");
00037 
00038         if ( mcCollptr != 0 ) {
00039           //std::cout <<" could retrieve the collection "<<std::endl;
00040 
00041           n = mcCollptr->size();
00042           
00043           //std::cout <<" nr of events "<<n<<std::endl;
00044 
00045           McGenEventCol::const_iterator it = mcCollptr->begin();
00046 
00047           McGenEvent* mcEvent = (McGenEvent* ) (*it);   
00048           // getting only the first event here.         
00049           // std::cout <<"iterator"<<std::endl;
00050                 
00051           HepMC::GenEvent *p_evt;
00052                 
00053           //std::cout <<"hepmc event"<<std::endl;
00054           p_evt = mcEvent->getGenEvt();
00055           //std::cout << "eventNumber = " << p_evt-> event_number()  << std::endl;
00056 
00057           //std::cout << " BesHepMCInterface:: --> " <<std::endl;
00058           //std::cout << " particles_size = " << p_evt->particles_size() 
00059                 //    << " vertices_size = " << p_evt->vertices_size()
00060                 //    << std::endl;
00061 
00062           //std::cout <<"got it"<<std::endl;
00063           
00064           return p_evt;
00065         }
00066 
00067     else {
00068           std::cout << "no McGenEventCollection found."  << std::endl;
00069         }     
00070           return 0;
00071 }
00072 

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