26#include "MyRunClass.h"
29int main(
int argc,
char **argv) {
32 std::cout <<
"Usage: " << argv[0] <<
" <input_hepmc3_file> <output_root_file>" <<std:: endl;
38 TFile* fFile =
new TFile(argv[2],
"RECREATE");
40 int events_parsed = 0;
42 bool is_gen_run_info_written =
false;
44 while( !text_input.failed() ) {
48 text_input.read_event(evt);
50 if( text_input.failed() )
break;
52 if( events_parsed == 0 ) {
53 std::cout <<
"First event: " << std::endl;
57 if(!is_gen_run_info_written) {
65 fFile->WriteObject(my_run,
"MyRunClass");
67 is_gen_run_info_written =
true;
75 std::ostringstream os;
77 std::string stevt =
"Event_" + os.str();
78 const char* chevt = stevt.c_str();
80 std::cout <<
"writing " << stevt << std::endl;
82 fFile->WriteObject(myclass, chevt);
86 if( events_parsed%100 == 0 ) {
87 std::cout <<
"Event: " << events_parsed << std::endl;
93 std::cout <<
"Events parsed and written: " << events_parsed << std::endl;
Definition of class GenEvent.
Definition of class GenRunInfo.
Definition of static class Print.
Definition of class ReaderAscii.
Stores event-related information.
Stores run-related information.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
GenEvent I/O parsing for structured text files.
Sample class for root I/O test.
void SetEvent(GenEvent *)
Set HepMC event.
Sample class for root I/O test.
void SetRunInfo(GenRunInfo *)
Set HepMC event.