19 #include "MyRunClass.h" 32 int main(
int argc,
char **argv) {
35 cout <<
"Usage: " << argv[0] <<
" <input_root_file> <output_hepmc3_file>" << endl;
44 int events_parsed = 0;
48 shared_ptr<GenRunInfo> run_info;
50 if( my_run ) run_info.reset(my_run->
GetRunInfo());
53 fo.GetListOfKeys()->Print();
55 TIter next(fo.GetListOfKeys());
58 while ((key=(TKey*)next()))
60 const char *cl = key->GetClassName();
62 if( strncmp(cl,
"MyClass",7) != 0 )
continue;
64 fo.GetObject(key->GetName(), myevent);
66 cout <<
"Event: " << key->GetName() << endl;
68 if( events_parsed == 0 ) {
69 cout <<
"First event: " << endl;
74 cout <<
"Setting run info" << endl;
79 text_output.write_event(*(myevent->
GetEvent()));
82 if( events_parsed%1000 == 0 ) {
83 cout <<
"Event: " << events_parsed << endl;
92 std::cout <<
"Events parsed and written: " << events_parsed << std::endl;
void set_run_info(shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
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.
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.