BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesHepMCInterface.cpp
Go to the documentation of this file.
1#include "BesHepMCInterface.h"
2#include "HepMC/GenEvent.h"
3
4#include "GaudiKernel/Bootstrap.h"
5#include "GaudiKernel/IMessageSvc.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/MsgStream.h"
8
9#include "GaudiKernel/SmartDataPtr.h"
10#include "GeneratorObject/McGenEvent.h"
11
14 // std::cout<< "\b the BesHepMCInterface is being destroyed "<<std::endl;
15}
16
18
19 if ( p_evtSvc == 0 )
20 {
21 // std::cout<<" standard interface to EvtDataSvc for retrieving HepMC events"<<std::endl;
22 ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap
23 StatusCode sc = svcLocator->service( "EventDataSvc", p_evtSvc );
24 if ( sc.isFailure() )
25 {
26 // std::cout<<"BesHepMCInterface could not access EventDataSvc!!"<<std::endl;
27 }
28 }
29 int n = 0;
30 // std::cout <<" BesHepMCInterface::GenerateAnEvent "<<std::endl;
31
32 SmartDataPtr<McGenEventCol> mcCollptr( p_evtSvc, "/Event/Gen" );
33
34 if ( mcCollptr != 0 )
35 {
36 // std::cout <<" could retrieve the collection "<<std::endl;
37
38 n = mcCollptr->size();
39
40 // std::cout <<" nr of events "<<n<<std::endl;
41
42 McGenEventCol::const_iterator it = mcCollptr->begin();
43
44 McGenEvent* mcEvent = (McGenEvent*)( *it );
45 // getting only the first event here.
46 // std::cout <<"iterator"<<std::endl;
47
48 HepMC::GenEvent* p_evt;
49
50 // std::cout <<"hepmc event"<<std::endl;
51 p_evt = mcEvent->getGenEvt();
52 // std::cout << "eventNumber = " << p_evt-> event_number() << std::endl;
53
54 // std::cout << " BesHepMCInterface:: --> " <<std::endl;
55 // std::cout << " particles_size = " << p_evt->particles_size()
56 // << " vertices_size = " << p_evt->vertices_size()
57 // << std::endl;
58
59 // std::cout <<"got it"<<std::endl;
60
61 return p_evt;
62 }
63
64 else { std::cout << "no McGenEventCollection found." << std::endl; }
65 return 0;
66}
const Int_t n
HepMC::GenEvent * GenerateHepMCEvent()
GenEvent * getGenEvt() const