27 #ifdef HEPMCCONVERT_EXTENSION_ROOTTREEOPAL 29 #warning "HEPMCCONVERT_EXTENSION_ROOTTREEOPAL requires compilation with of HepMC with ROOT, i.e. HEPMC3_ROOTIO.This extension will be disabled." 30 #undef HEPMCCONVERT_EXTENSION_ROOTTREEOPAL 32 #include "WriterRootTreeOPAL.h" 35 #ifdef HEPMCCONVERT_EXTENSION_HEPEVTZEUS 36 #include "WriterHEPEVTZEUS.h" 38 #ifdef HEPMCCONVERT_EXTENSION_DOT 45 enum formats {hepmc2, hepmc3, hpe ,root, treeroot ,treerootopal, hpezeus, lhef, dump, dot, none};
46 int main(
int argc,
char** argv)
48 gengetopt_args_info ai;
49 if (cmdline_parser (argc, argv, &ai) != 0) {
54 printf(
"Exactly two arguments are requred: the name of input and output files\n");
57 std::map<std::string,formats> format_map;
58 format_map.insert(std::pair<std::string,formats> (
"hepmc2", hepmc2 ));
59 format_map.insert(std::pair<std::string,formats> (
"hepmc3", hepmc3 ));
60 format_map.insert(std::pair<std::string,formats> (
"hpe", hpe ));
61 format_map.insert(std::pair<std::string,formats> (
"root", root ));
62 format_map.insert(std::pair<std::string,formats> (
"treeroot", treeroot ));
63 format_map.insert(std::pair<std::string,formats> (
"treerootopal", treerootopal ));
64 format_map.insert(std::pair<std::string,formats> (
"hpezeus", hpezeus ));
65 format_map.insert(std::pair<std::string,formats> (
"lhef", lhef ));
66 format_map.insert(std::pair<std::string,formats> (
"dump", dump ));
67 format_map.insert(std::pair<std::string,formats> (
"dot", dot ));
68 format_map.insert(std::pair<std::string,formats> (
"none", none ));
69 std::map<std::string, std::string> options;
70 for (
size_t i=0; i<ai.extensions_given; i++)
72 std::string optarg=std::string(ai.extensions_arg[i]);
73 size_t pos=optarg.find_first_of(
'=');
74 if (pos<optarg.length())
75 options[std::string(optarg,0,pos)]=std::string(optarg,pos+1,optarg.length());
77 long int events_parsed = 0;
78 long int events_limit = ai.events_limit_arg;
79 long int first_event_number = ai.first_event_number_arg;
80 long int last_event_number = ai.last_event_number_arg;
81 long int print_each_events_parsed = ai.print_every_events_parsed_arg;
83 bool ignore_writer=
false;
84 switch (format_map.at(std::string(ai.input_format_arg)))
103 printf(
"Input format %s is not supported\n",ai.input_format_arg);
111 printf(
"Input format %s is not supported\n",ai.input_format_arg);
115 printf(
"Input format %s is not known\n",ai.input_format_arg);
120 switch (format_map.at(std::string(ai.output_format_arg)))
136 printf(
"Output format %s is not supported\n",ai.output_format_arg);
144 printf(
"Output format %s is not supported\n",ai.output_format_arg);
149 #ifdef HEPMCCONVERT_EXTENSION_ROOTTREEOPAL 152 if (options.find(
"Run")!=options.end()) ((
WriterRootTreeOPAL*)(output_file))->set_run_number(std::atoi(options.at(
"Run").c_str()));
155 printf(
"Output format %s is not supported\n",ai.output_format_arg);
160 #ifdef HEPMCCONVERT_EXTENSION_HEPEVTZEUS 164 printf(
"Output format %s is not supported\n",ai.output_format_arg);
168 #ifdef HEPMCCONVERT_EXTENSION_DOT 170 if (options.find(
"Style")!=options.end()) ((
WriterDOT*)(output_file))->set_style(std::atoi(options.at(
"Style").c_str()));
173 printf(
"Output format %s is not supported\n",ai.output_format_arg);
185 printf(
"Output format %s is not known\n",ai.output_format_arg);
189 while( !input_file->failed() )
193 if( input_file->failed() ) {
194 printf(
"End of file reached. Exit.\n");
197 if (evt.event_number()<first_event_number)
continue;
198 if (evt.event_number()>last_event_number)
continue;
199 evt.set_run_info(input_file->
run_info());
206 if( events_parsed%print_each_events_parsed == 0 ) printf(
"Events parsed: %i\n",events_parsed);
207 if( events_parsed >= events_limit ) {
208 printf(
"Event limit reached:->events_parsed(%i) >= events_limit(%i)<-. Exit.\n",events_parsed , events_limit);
213 if (input_file) input_file->close();
214 if (output_file) output_file->close();
GenEvent I/O serialization for structured text files.
GenEvent I/O parsing and serialization for LHEF files.
Definition of class WriterHEPEVT.
Definition of class ReaderHEPEVT.
virtual void write_event(const GenEvent &evt)=0
Write event evt to output target.
GenEvent I/O parsing for structured text files.
shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
virtual bool read_event(GenEvent &evt)=0
Fill next event from input into evt.
Definition of class WriterRootTree.
Definition of class WriterAscii.
GenEvent I/O parsing and serialization for HEPEVT files.
Definition of class ReaderRootTree.
Definition of class ReaderRoot.
GenEvent I/O serialization for HEPEVT files.
Parser for HepMC2 I/O files.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
GenEvent I/O output to dot files that should be processed by graphviz or other software.
GenEvent I/O serialization for root files.
GenEvent I/O serialization for root files based on root TTree.
Definition of class ReaderAscii.
Definition of class WriterAsciiHepMC2.
Definition of class WriterRoot.
GenEvent I/O parsing and serialization for root files based on root TTree.
Definition of static class Print.
int main(int argc, char **argv)
Base class for all I/O writers.
Definition of class WriterDOT.
Definition of class GenEvent.
Base class for all I/O readers.
Definition of class ReaderLHEF.
GenEvent I/O serialization for structured text files.
GenEvent I/O parsing and serialization for root files.
static void content(std::ostream &os, const GenEvent &event)
Print content of all GenEvent containers.