00001
00002 #include "DsPushKine.h"
00003 #include "G4DataHelpers/IHepMCtoG4.h"
00004
00005 #include "Event/GenHeader.h"
00006
00007 #include "GiGa/IGiGaSvc.h"
00008
00009 #include "G4PrimaryVertex.hh"
00010
00011 DsPushKine::DsPushKine(const std::string& name, ISvcLocator* pSvcLocator)
00012 : GaudiAlgorithm(name,pSvcLocator)
00013 , m_giga(0)
00014 , m_converter(0)
00015 {
00016 declareProperty("Location",m_location=DayaBay::GenHeaderLocation::Default,
00017 "Location in the TES to get HepMCEvents");
00018 declareProperty("Converter",m_converterName="HepMCtoG4",
00019 "Name of tool to convert HepMCEvents to G4PrimaryVertex");
00020 }
00021
00022 DsPushKine::~DsPushKine()
00023 {
00024 }
00025
00026 StatusCode DsPushKine::initialize()
00027 {
00028 this->GaudiAlgorithm::initialize();
00029
00030 m_giga = svc<IGiGaSvc>("GiGa",true);
00031 try {
00032 m_converter = tool<IHepMCtoG4>(m_converterName);
00033 }
00034 catch (const GaudiException& gex) {
00035 fatal() << "Failed to get converter tool \""
00036 << m_converterName << "\"" << endreq;
00037 return StatusCode::FAILURE;
00038 }
00039
00040 return StatusCode::SUCCESS;
00041 }
00042
00043 StatusCode DsPushKine::execute()
00044 {
00045 DayaBay::GenHeader* gen_header = get<DayaBay::GenHeader>(m_location);
00046
00047 HepMC::GenEvent* genevt = gen_header->event();
00048 std::vector<G4PrimaryVertex*> g4verts;
00049 m_converter->convert(*genevt,g4verts);
00050
00051 debug() << "Got " << g4verts.size() << " primary vertices" << endreq;
00052
00053 for (size_t ind=0; ind < g4verts.size(); ++ind) {
00054
00055 *m_giga << g4verts[ind];
00056
00057 }
00058
00059 debug() << "Pushed " << gen_header->generatorName()
00060 << " to giga" << endreq;
00061
00062 return StatusCode::SUCCESS;
00063 }
00064
00065 StatusCode DsPushKine::finalize()
00066 {
00067
00068 return this->GaudiAlgorithm::finalize();
00069 }