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