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
00019 }
00020
00021 HepMC::GenEvent* BesHepMCInterface::GenerateHepMCEvent()
00022 {
00023
00024 if (p_evtSvc == 0) {
00025
00026 ISvcLocator* svcLocator = Gaudi::svcLocator();
00027 StatusCode sc=svcLocator->service("EventDataSvc", p_evtSvc);
00028 if (sc.isFailure())
00029 {
00030
00031 }
00032 }
00033 int n = 0;
00034
00035
00036 SmartDataPtr<McGenEventCol> mcCollptr( p_evtSvc, "/Event/Gen");
00037
00038 if ( mcCollptr != 0 ) {
00039
00040
00041 n = mcCollptr->size();
00042
00043
00044
00045 McGenEventCol::const_iterator it = mcCollptr->begin();
00046
00047 McGenEvent* mcEvent = (McGenEvent* ) (*it);
00048
00049
00050
00051 HepMC::GenEvent *p_evt;
00052
00053
00054 p_evt = mcEvent->getGenEvt();
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 return p_evt;
00065 }
00066
00067 else {
00068 std::cout << "no McGenEventCollection found." << std::endl;
00069 }
00070 return 0;
00071 }
00072