28 base_class(
type, name, parent ),
35 declareProperty(
"Output",
37 "Name of the back-end we'll use to write out the HepMC::GenEvent."
38 "\nEx: ascii:hepmc.genevent.txt" );
42 declareProperty(
"McEvents",
44 "Input location of the McEventCollection to write out" );
66 if ( !evtStore().retrieve().isSuccess() ) {
68 return StatusCode::FAILURE;
76 return StatusCode::SUCCESS;
82 return StatusCode::SUCCESS;
89 if ( evtStore()->retrieve( mcEvts,
m_mcEventsName ).isFailure() ||
nullptr == mcEvts ) {
91 return StatusCode::FAILURE;
94 if ( mcEvts->
empty() ) {
96 return StatusCode::FAILURE;
99 const HepMC::GenEvent * evt = mcEvts->
front();
101 ATH_MSG_ERROR(
"Retrieved NULL pointer to HepMC::GenEvent !!");
102 return StatusCode::FAILURE;
119 return StatusCode::SUCCESS;
125 std::string protocol =
"ascii";
126 std::string fileName =
"hepmc.genevent.txt";
137 std::string::size_type protocolPos = url.find(
s_protocolSep);
139 if ( std::string::npos != protocolPos ) {
140 protocol = url.substr( 0, protocolPos );
141 fileName = url.substr( protocolPos+1, std::string::npos );
148 std::transform( protocol.begin(), protocol.end(), protocol.begin(), [](
unsigned char c){ return std::tolower(c); } );
150 if (
"ascii" == protocol ) {
151 m_ioBackend =
new HepMC3::WriterAsciiHepMC2( fileName.c_str());
154 ATH_MSG_WARNING(
"UNKNOWN protocol [" << protocol <<
"] !!" <<
endmsg <<
"Will use [ascii] instead...");
156 m_ioBackend =
new HepMC3::WriterAsciiHepMC2( fileName.c_str());
159 if (
"ascii" == protocol ) {
160 m_ioBackend =
new HepMC::IO_GenEvent( fileName.c_str(), std::ios::out | std::ios::trunc );
163 ATH_MSG_WARNING(
"UNKNOWN protocol [" << protocol <<
"] !!" <<
endmsg <<
"Will use [ascii] instead...");
165 m_ioBackend =
new HepMC::IO_GenEvent( fileName.c_str(), std::ios::out | std::ios::trunc );
168 ATH_MSG_DEBUG(
"Using protocol [" << protocol <<
"] and write to ["<< fileName <<
"]");
#define ATH_MSG_WARNING(x)
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...