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"
40 using namespace HepMC3;
41 enum formats {hepmc2, hepmc3, hpe ,root, treeroot ,treerootopal, hpezeus, lhef, dump};
42 int main(
int argc,
char** argv)
44 gengetopt_args_info ai;
45 if (cmdline_parser (argc, argv, &ai) != 0) {
50 printf(
"Exactly two arguments are requred: the name of input and output files\n");
53 std::map<std::string,formats> format_map;
54 format_map.insert(std::pair<std::string,formats> (
"hepmc2", hepmc2 ));
55 format_map.insert(std::pair<std::string,formats> (
"hepmc3", hepmc3 ));
56 format_map.insert(std::pair<std::string,formats> (
"hpe", hpe ));
57 format_map.insert(std::pair<std::string,formats> (
"root", root ));
58 format_map.insert(std::pair<std::string,formats> (
"treeroot", treeroot ));
59 format_map.insert(std::pair<std::string,formats> (
"treerootopal", treerootopal ));
60 format_map.insert(std::pair<std::string,formats> (
"hpezeus", hpezeus ));
61 format_map.insert(std::pair<std::string,formats> (
"lhef", lhef ));
62 format_map.insert(std::pair<std::string,formats> (
"dump", dump ));
63 std::map<std::string, std::string> options;
64 for (
size_t i=0; i<ai.extensions_given; i++)
66 std::string optarg=std::string(ai.extensions_arg[i]);
67 size_t pos=optarg.find_first_of(
'=');
68 if (pos<optarg.length())
69 options[std::string(optarg,0,pos)]=std::string(optarg,pos+1,optarg.length());
71 long int events_parsed = 0;
72 long int events_limit = ai.events_limit_arg;
73 long int first_event_number = ai.first_event_number_arg;
74 long int last_event_number = ai.last_event_number_arg;
75 long int print_each_events_parsed = ai.print_every_events_parsed_arg;
77 switch (format_map.at(std::string(ai.input_format_arg)))
96 printf(
"Input format %s is not supported\n",ai.input_format_arg);
104 printf(
"Input format %s is not supported\n",ai.input_format_arg);
108 printf(
"Input format %s is not known\n",ai.input_format_arg);
113 switch (format_map.at(std::string(ai.output_format_arg)))
129 printf(
"Output format %s is not supported\n",ai.output_format_arg);
137 printf(
"Output format %s is not supported\n",ai.output_format_arg);
142 #ifdef HEPMCCONVERT_EXTENSION_ROOTTREEOPAL
145 if (options.find(
"Run")!=options.end()) ((
WriterRootTreeOPAL*)(output_file))->set_run_number(std::atoi(options.at(
"Run").c_str()));
148 printf(
"Output format %s is not supported\n",ai.output_format_arg);
153 #ifdef HEPMCCONVERT_EXTENSION_HEPEVTZEUS
157 printf(
"Output format %s is not supported\n",ai.output_format_arg);
164 printf(
"Output format %s is not known\n",ai.output_format_arg);
168 while( !input_file->failed() )
172 if( input_file->failed() ) {
173 printf(
"End of file reached. Exit.\n");
176 if (evt.event_number()<first_event_number)
continue;
177 if (evt.event_number()>last_event_number)
continue;
178 evt.set_run_info(input_file->
run_info());
184 if( events_parsed%print_each_events_parsed == 0 ) printf(
"Events parsed: %i\n",events_parsed);
185 if( events_parsed >= events_limit ) {
186 printf(
"Event limit reached:->events_parsed(%i) >= events_limit(%i)<-. Exit.\n",events_parsed , events_limit);
191 if (input_file) input_file->close();
192 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.
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.
shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
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 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.