19 #include "MyRunClass.h"
27 using namespace HepMC3;
31 int main(
int argc,
char **argv) {
34 std::cout <<
"Usage: " << argv[0] <<
" <input_root_file> <output_hepmc3_file>" << std::endl;
43 int events_parsed = 0;
47 std::shared_ptr<GenRunInfo> run_info;
49 if( my_run ) run_info.reset(my_run->
GetRunInfo());
52 fo.GetListOfKeys()->Print();
54 TIter next(fo.GetListOfKeys());
57 while ((key=(TKey*)next()))
59 const char *cl = key->GetClassName();
61 if( strncmp(cl,
"MyClass",7) != 0 )
continue;
63 fo.GetObject(key->GetName(), myevent);
65 std::cout <<
"Event: " << key->GetName() << std::endl;
67 if( events_parsed == 0 ) {
68 std::cout <<
"First event: " << std::endl;
73 std::cout <<
"Setting run info" << std::endl;
78 text_output.write_event(*(myevent->
GetEvent()));
81 if( events_parsed%100 == 0 ) {
82 std::cout <<
"Event: " << events_parsed << std::endl;
91 std::cout <<
"Events parsed and written: " << events_parsed << std::endl;
Definition of class GenRunInfo.
Sample class for root I/O test.
Definition of class WriterAscii.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
Sample class for root I/O test.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
Definition of static class Print.
int main(int argc, char **argv)
GenRunInfo * GetRunInfo()
Get HepMC event.
Definition of class GenEvent.
GenEvent I/O serialization for structured text files.
GenEvent * GetEvent()
Get HepMC event.