16 std::map<int,std::pair<Writer*,GenEvent*> > gWriters;
19 int delete_writer_(
const int & position)
21 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
22 gWriters[position].first->close();
23 gWriters.erase(gWriters.find(position));
27 int convert_event_(
const int & position)
29 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
32 printf(
"Error in %s: HEPEVT block does not exist\n",__FUNCTION__);
35 gWriters[position].second=
new GenEvent(Units::GEV,Units::MM);
40 std::shared_ptr<GenRunInfo> run=std::make_shared<GenRunInfo>();
41 std::vector<std::string> names;
42 names.push_back(
"Default");
43 run->set_weight_names(names);
44 gWriters[position].second->set_run_info(run);
47 int write_event_(
const int & position)
49 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
50 gWriters[position].first->write_event(*(gWriters[position].second));
53 int clear_event_(
const int & position)
55 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
56 gWriters[position].second->clear();
59 int set_cross_section_(
const int & position,
const double& x,
const double& xe,
const int& n1,
const int& n2)
61 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
62 GenCrossSectionPtr cs=std::make_shared< GenCrossSection>();
63 cs->set_cross_section(x,xe,n1,n2);
64 gWriters[position].second->set_cross_section(cs);
67 int set_hepevt_address_(
int* a)
71 printf(
"Info in %s: setting /hepevt/ block adress\n",__FUNCTION__);
77 printf(
"Info in %s: /hepevt/ block adress is already set\n",__FUNCTION__);
81 int set_attribute_int_(
const int & position,
const int & attval,
const char* attname,
size_t len)
83 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
84 gWriters[position].second->add_attribute(attname,std::make_shared<IntAttribute>(attval));
87 int set_attribute_double_(
const int & position,
const double & attval,
const char* attname,
size_t len)
89 if (gWriters.find(position)==gWriters.end()) { printf(
"Warning in %s: Writer at position %i does not exist\n",__FUNCTION__,position);
return 1;}
90 gWriters[position].second->add_attribute(attname,std::make_shared<DoubleAttribute>(attval));
94 int new_writer_(
const int & position,
const int & mode,
const char* ffilename,
size_t len)
96 std::string filename=std::string(ffilename,len);
97 int r_position=position;
100 if (gWriters.size()==0) r_position=1;
101 if (gWriters.size()!=0) r_position=gWriters.rend()->first+1;
103 if (gWriters.find(r_position)!=gWriters.end()) { printf(
"Error in %s: Writer at position %i already exists\n",__FUNCTION__,r_position); exit(1);}
107 gWriters[r_position]=std::pair<Writer*,GenEvent*>(
new WriterAscii(filename.c_str()),
new GenEvent(Units::GEV,Units::MM));
110 gWriters[r_position]=std::pair<Writer*,GenEvent*>(
new WriterAsciiHepMC2(filename.c_str()),
new GenEvent(Units::GEV,Units::MM));
113 gWriters[r_position]=std::pair<Writer*,GenEvent*>(
new WriterHEPEVT(filename.c_str()),
new GenEvent(Units::GEV,Units::MM));
117 gWriters[r_position]=std::pair<Writer*,GenEvent*>(
new WriterRoot(filename.c_str()),
new GenEvent(Units::GEV,Units::MM));
120 gWriters[r_position]=std::pair<Writer*,GenEvent*>(
new WriterRootTree(filename.c_str()),
new GenEvent(Units::GEV,Units::MM));
124 printf(
"Error in %s:Output format %d is unknown or not supported.\n",__FUNCTION__,mode);
GenEvent I/O serialization for structured text files.
Definition of class GenRunInfo.
Definition of class WriterHEPEVT.
Definition of class WriterRootTree.
Definition of class WriterAscii.
static void set_hepevt_address(char *c)
Set Fortran block address.
GenEvent I/O serialization for HEPEVT files.
Stores event-related information.
Definition of interface Writer.
GenEvent I/O serialization for root files.
GenEvent I/O serialization for root files based on root TTree.
static bool HEPEVT_to_GenEvent(GenEvent *evt)
Convert HEPEVT to GenEvent.
Definition of class WriterAsciiHepMC2.
Definition of class WriterRoot.
Definition of static class Print.
int jmohep[NMXHEP][2]
Pointer to position of 1st and 2nd (or last!) mother.
Definition of class GenEvent.
Definition of class Attribute, class IntAttribute and class StringAttribute.
GenEvent I/O serialization for structured text files.
Definition of class HEPEVT_Wrapper.
static int number_entries()
Get number of entries.