28 #include "MyRunClass.h"
31 int main(
int argc,
char **argv) {
34 cout <<
"Usage: " << argv[0] <<
" <input_hepmc3_file> <output_root_file>" << endl;
40 TFile* fFile =
new TFile(argv[2],
"RECREATE");
42 int events_parsed = 0;
44 bool is_gen_run_info_written =
false;
46 while( !text_input.failed() ) {
50 text_input.read_event(evt);
52 if( text_input.failed() )
break;
54 if( events_parsed == 0 ) {
55 cout <<
"First event: " << endl;
59 if(!is_gen_run_info_written) {
65 my_run->SetRunInfo(&run_info);
67 fFile->WriteObject(my_run,
"MyRunClass");
69 is_gen_run_info_written =
true;
77 std::ostringstream os;
79 std::string stevt =
"Event_" + os.str();
80 const char* chevt = stevt.c_str();
82 cout <<
"writing " << stevt << endl;
84 fFile->WriteObject(myclass, chevt);
88 if( events_parsed%100 == 0 ) {
89 cout <<
"Event: " << events_parsed << endl;
95 std::cout <<
"Events parsed and written: " << events_parsed << std::endl;