/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #include "GtHepMCDumper.h" 00002 00003 #include "Event/GenHeader.h" 00004 00005 #include "HepMC/GenEvent.h" 00006 #include "HepMC/GenVertex.h" 00007 #include "HepMC/GenParticle.h" 00008 using namespace HepMC; 00009 00010 GtHepMCDumper::GtHepMCDumper(const std::string& name, ISvcLocator* pSvcLocator) 00011 : GaudiAlgorithm(name,pSvcLocator) 00012 { 00013 declareProperty("Location",m_tesLoc = DayaBay::GenHeaderLocation::Default, 00014 "Location in TES of HepMCEvents"); 00015 declareProperty("StandardDumper",m_standardDumper=false, 00016 "Use standard HepMC dumper (def=false)"); 00017 } 00018 GtHepMCDumper::~GtHepMCDumper() 00019 { 00020 } 00021 StatusCode GtHepMCDumper::initialize() 00022 { 00023 return this->GaudiAlgorithm::initialize(); 00024 } 00025 00026 #include "CLHEP/Units/SystemOfUnits.h" 00027 00028 StatusCode GtHepMCDumper::execute() 00029 { 00030 DayaBay::GenHeader* header = 0; 00031 try { 00032 header = get<DayaBay::GenHeader>(m_tesLoc); 00033 } 00034 catch (const GaudiException& eg) { 00035 fatal() << "Failed to get GenHeader from TES at " << m_tesLoc << endreq; 00036 return StatusCode::FAILURE; 00037 } 00038 00039 const TimeStamp& reftime = header->timeStamp(); 00040 00041 info () << "Generator: " << header->generatorName() 00042 << " @ reference time: " << reftime 00043 << " made:" << endreq; 00044 if (m_standardDumper) { 00045 header->event()->print(); 00046 return StatusCode::SUCCESS; 00047 } 00048 00049 GenEvent* event = header->event(); 00050 if (!event) { 00051 info() << "\nEvent #(unknown), the GenEvent must be pruned" 00052 << endreq; 00053 return StatusCode::SUCCESS; 00054 } 00055 info() << "\nEvent #" << event->event_number() 00056 << " signal_process_id=" << event->signal_process_id() << ", " 00057 << event->vertices_size() << " vertices\n"; 00058 GenEvent::vertex_iterator vit, vdone = event->vertices_end(); 00059 for (vit=event->vertices_begin(); vit != vdone; ++vit) { 00060 GenVertex* vtx = *vit; 00061 info() << "\t#" << vtx->id() << " bc="<< vtx->barcode() << " @ x=(" 00062 << vtx->position().x()/CLHEP::cm << "," 00063 << vtx->position().y()/CLHEP::cm << "," 00064 << vtx->position().z()/CLHEP::cm << "," 00065 << vtx->position().t()/CLHEP::second << ") [cm,cm,cm,second] (abstime=" 00066 << vtx->position().t()/CLHEP::second + (double)reftime << ")\n" 00067 << "\t " << vtx->particles_in_size() << " IN particles:\n"; 00068 GenVertex::particles_in_const_iterator piit, pidone = vtx->particles_in_const_end(); 00069 for (piit=vtx->particles_in_const_begin(); piit != pidone; ++piit) { 00070 const GenParticle* part = *piit; 00071 info() << "\t\tPDGID=" << part->pdg_id() << " P=(" 00072 << part->momentum().x() << "," 00073 << part->momentum().y() << "," 00074 << part->momentum().z() << "," 00075 << part->momentum().t() << ")\n"; 00076 } 00077 info() << "\t " << vtx->particles_out_size() << " OUT particles:\n"; 00078 GenVertex::particles_out_const_iterator poit, podone = vtx->particles_out_const_end(); 00079 for (poit=vtx->particles_out_const_begin(); poit != podone; ++poit) { 00080 const GenParticle* part = *poit; 00081 info() << "\t\tPDGID=" << part->pdg_id() << " P=(" 00082 << part->momentum().x() << "," 00083 << part->momentum().y() << "," 00084 << part->momentum().z() << "," 00085 << part->momentum().t() << ")\n"; 00086 } 00087 00088 } // loop over vertices 00089 info() << endreq; 00090 00091 return StatusCode::SUCCESS; 00092 } 00093 StatusCode GtHepMCDumper::finalize() 00094 { 00095 return this->GaudiAlgorithm::finalize(); 00096 }