6 #ifndef Pythia6_Pythia6ToHepMC3_H
7 #define Pythia6_Pythia6ToHepMC3_H
8 #ifdef DUMMYPYTHIA6TOHEPMC3
11 int hepmc3_delete_writer_(
const int & position)
15 int hepmc3_convert_event_(
const int & position)
19 int hepmc3_write_event_(
const int & position)
23 int hepmc3_clear_event_(
const int & position)
27 int hepmc3_set_cross_section_(
const int & position,
const double& x,
const double& xe,
const int& n1,
const int& n2)
32 int hepmc3_set_pdf_info_(
const int & position,
const int& parton_id1,
const int& parton_id2,
const double& x1,
const double& x2,
33 const double& scale_in,
const double& xf1,
const double& xf2,
34 const int& pdf_id1,
const int& pdf_id2)
38 int hepmc3_set_hepevt_address_(
int* a)
42 int hepmc3_set_attribute_int_(
const int & position,
const int & attval,
const char* attname)
46 int hepmc3_set_attribute_double_(
const int & position,
const double & attval,
const char* attname)
50 int hepmc3_new_writer_(
const int & position,
const int & mode,
const char* ffilename)
54 int hepmc3_new_weight_(
const int & position,
const char* name)
58 int hepmc3_set_weight_by_index_(
const int & position,
const double& val,
const int & pos)
62 int hepmc3_set_weight_by_name_(
const int & position,
const double& val,
const char* name)
83 std::map<int, std::pair<std::shared_ptr<Writer>,
GenEvent*> > hepmc3_gWriters;
85 std::map<int, std::shared_ptr<GenRunInfo> > hepmc3_gGenRunInfos;
87 GenEvent* hepmc3_gWriters_get_event(
const int & position)
89 if (hepmc3_gWriters.count(position) == 0) {
90 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
93 return hepmc3_gWriters[position].second;
98 int hepmc3_delete_writer_(
const int & position)
100 if (hepmc3_gWriters.count(position) == 0) {
101 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
104 hepmc3_gWriters[position].first->close();
105 hepmc3_gWriters.erase(hepmc3_gWriters.find(position));
109 int hepmc3_convert_event_(
const int & position)
111 if (hepmc3_gWriters.count(position) == 0) {
112 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
117 printf(
"Error in %s: HEPEVT block does not exist\n", __FUNCTION__);
120 hepmc3_gWriters[position].second=
new GenEvent(Units::GEV, Units::MM);
124 if (hepmc3_gGenRunInfos.count(position) == 0) hepmc3_gGenRunInfos[position] = std::make_shared<GenRunInfo>();
125 hepmc3_gWriters[position].second->set_run_info(hepmc3_gGenRunInfos[position]);
126 hepmc3_gWriters[position].second->weights() = std::vector<double>(hepmc3_gGenRunInfos[position]->weight_names().size(), 1.0);
129 int hepmc3_write_event_(
const int & position)
131 if (hepmc3_gWriters.count(position) == 0) {
132 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
135 hepmc3_gWriters[position].first->write_event(*(hepmc3_gWriters[position].second));
138 int hepmc3_clear_event_(
const int & position)
140 if (hepmc3_gWriters.count(position) == 0) {
141 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
144 hepmc3_gWriters[position].second->clear();
147 int hepmc3_set_cross_section_(
const int & position,
const double& x,
const double& xe,
const int& n1,
const int& n2)
149 if (hepmc3_gWriters.count(position) == 0) {
150 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
153 GenCrossSectionPtr cs=std::make_shared< GenCrossSection>();
154 cs->set_cross_section(x, xe, n1, n2);
155 hepmc3_gWriters[position].second->set_cross_section(cs);
159 int hepmc3_set_pdf_info_(
const int & position,
const int& parton_id1,
const int& parton_id2,
const double& x1,
const double& x2,
160 const double& scale_in,
const double& xf1,
const double& xf2,
161 const int& pdf_id1,
const int& pdf_id2)
163 if (hepmc3_gWriters.count(position) == 0) {
164 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
167 GenPdfInfoPtr pdf=std::make_shared< GenPdfInfo>();
168 pdf->set(parton_id1, parton_id2, x1, x2, scale_in, xf1, xf2, pdf_id1, pdf_id2);
169 hepmc3_gWriters[position].second->set_pdf_info(pdf);
174 int hepmc3_set_hepevt_address_(
int* a)
178 printf(
"Info in %s: setting /hepevt/ block adress\n", __FUNCTION__);
184 printf(
"Info in %s: /hepevt/ block adress is already set\n", __FUNCTION__);
188 int hepmc3_set_attribute_int_(
const int & position,
const int & attval,
const char* attname)
190 if (hepmc3_gWriters.count(position) == 0) {
191 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
194 hepmc3_gWriters[position].second->add_attribute(attname, std::make_shared<IntAttribute>(attval));
197 int hepmc3_set_attribute_double_(
const int & position,
const double & attval,
const char* attname)
199 if (hepmc3_gWriters.count(position) == 0) {
200 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
203 hepmc3_gWriters[position].second->add_attribute(attname, std::make_shared<DoubleAttribute>(attval));
207 int hepmc3_new_writer_(
const int & position,
const int & mode,
const char* ffilename)
209 std::string libHepMC3rootIO=
"libHepMC3rootIO.so";
211 libHepMC3rootIO=
"libHepMC3rootIO.dydl";
214 libHepMC3rootIO=
"HepMC3rootIO.dll";
216 std::string filename=std::string(ffilename);
217 int r_position=position;
220 if (hepmc3_gWriters.size() == 0) r_position = 1;
221 if (hepmc3_gWriters.size() != 0) r_position = hepmc3_gWriters.rend()->first+1;
223 if (hepmc3_gWriters.count(r_position) != 0) {
224 printf(
"Error in %s: Writer at position %i already exists\n", __FUNCTION__, r_position);
227 if (hepmc3_gGenRunInfos.count(r_position) != 0) {
228 printf(
"Warning in %s: RunInfo at position %i already exists\n", __FUNCTION__, r_position);
232 hepmc3_gGenRunInfos[r_position]=std::make_shared<GenRunInfo>();
238 hepmc3_gWriters[r_position] = std::pair<std::shared_ptr<Writer>,
GenEvent*>(std::make_shared<WriterAscii>(filename.c_str(), hepmc3_gGenRunInfos[position]),
new GenEvent(hepmc3_gGenRunInfos[position], Units::GEV, Units::MM));
241 hepmc3_gWriters[r_position] = std::pair<std::shared_ptr<Writer>,
GenEvent*>(std::make_shared<WriterAsciiHepMC2>(filename.c_str(), hepmc3_gGenRunInfos[position]),
new GenEvent(hepmc3_gGenRunInfos[position], Units::GEV, Units::MM));
244 hepmc3_gWriters[r_position] = std::pair<std::shared_ptr<Writer>,
GenEvent*>(std::make_shared<WriterHEPEVT>(filename.c_str()),
new GenEvent(hepmc3_gGenRunInfos[position], Units::GEV, Units::MM));
247 hepmc3_gWriters[r_position] = std::pair<std::shared_ptr<Writer>,
GenEvent*>(std::make_shared<WriterPlugin>(filename.c_str(), libHepMC3rootIO, std::string(
"newWriterRootfile"), hepmc3_gGenRunInfos[position]),
new GenEvent(hepmc3_gGenRunInfos[position], Units::GEV, Units::MM));
250 hepmc3_gWriters[r_position] = std::pair<std::shared_ptr<Writer>,
GenEvent*>(std::make_shared<WriterPlugin>(filename.c_str(), libHepMC3rootIO, std::string(
"newWriterRootTreefile"), hepmc3_gGenRunInfos[position]),
new GenEvent(hepmc3_gGenRunInfos[position], Units::GEV, Units::MM));
253 printf(
"Error in %s:Output format %d is unknown or not supported.\n", __FUNCTION__, mode);
259 int hepmc3_new_weight_(
const int & position,
const char* name)
261 if (hepmc3_gGenRunInfos.count(position) == 0) {
262 printf(
"Warning in %s: RunInfo at position %i does not exist\n", __FUNCTION__, position);
265 if (hepmc3_gGenRunInfos[position]->weight_index(std::string(name)) >= 0)
return 0;
266 std::vector<std::string> weight_names = hepmc3_gGenRunInfos[position]->weight_names();
267 weight_names.push_back(std::string(name));
268 hepmc3_gWriters[position].second->weights().push_back(1.0);
269 hepmc3_gGenRunInfos[position]->set_weight_names(weight_names);
272 int hepmc3_set_weight_by_index_(
const int & position,
const double& val,
const int & index)
274 if (hepmc3_gWriters.count(position) == 0) {
275 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
278 if (hepmc3_gWriters[position].second->weights().size() < index) {
279 printf(
"Warning in %s: Event has no weight with index %i\n", __FUNCTION__, index);
282 hepmc3_gWriters[position].second->weights()[index] = val;
285 int hepmc3_set_weight_by_name_(
const int & position,
const double& val,
const char* name)
287 if (hepmc3_gWriters.count(position) == 0) {
288 printf(
"Warning in %s: Writer at position %i does not exist\n", __FUNCTION__, position);
291 hepmc3_new_weight_(position, name);
292 hepmc3_gWriters[position].second->weight(std::string(name)) = val;
Definition of class Attribute, class IntAttribute and class StringAttribute.
Definition of class GenEvent.
Definition of class GenRunInfo.
Definition of class HEPEVT_Wrapper.
Definition of static class Print.
Definition of class WriterAsciiHepMC2.
Definition of class WriterAscii.
Definition of class WriterHEPEVT.
Definition of class WriterPlugin.
Definition of interface Writer.
Stores event-related information.
static void set_hepevt_address(char *c)
Set Fortran block address.
static bool HEPEVT_to_GenEvent(GenEvent *evt)
Convert HEPEVT to GenEvent.
static int number_entries()
Get number of entries.
struct HEPEVT * hepevtptr
This is a pointer to HEPEVT common block.
int jmohep[NMXHEP][2]
Pointer to position of 1st and 2nd (or last!) mother.