CMS 3D CMS Logo

ReggeGribovPartonMCHadronizer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <string>
4 
9 
10 #include "CLHEP/Random/RandomEngine.h"
11 
12 #include <HepMC/GenCrossSection.h>
13 #include <HepMC/GenEvent.h>
14 #include <HepMC/GenVertex.h>
15 #include <HepMC/GenParticle.h>
16 #include <HepMC/HeavyIon.h>
17 #include <HepMC/PdfInfo.h>
18 #include <HepMC/Units.h>
19 
25 
28 
30 
32 
33 using namespace edm;
34 using namespace std;
35 using namespace gen;
36 
39 
41 
42 static CLHEP::HepRandomEngine* reggeGribovRandomEngine;
43 
44 extern "C" {
45 float gen::rangen_() {
46  float a = float(reggeGribovRandomEngine->flat());
47  return a;
48 }
49 
50 double gen::drangen_(int* idummy) {
51  double a = reggeGribovRandomEngine->flat();
52  return a;
53 }
54 }
55 
56 ReggeGribovPartonMCHadronizer::ReggeGribovPartonMCHadronizer(const ParameterSet& pset)
58  pset_(pset),
59  m_BeamMomentum(pset.getParameter<double>("beammomentum")),
60  m_TargetMomentum(pset.getParameter<double>("targetmomentum")),
61  m_BeamID(pset.getParameter<int>("beamid")),
62  m_TargetID(pset.getParameter<int>("targetid")),
63  m_HEModel(pset.getParameter<int>("model")),
64  m_bMin(pset.getParameter<double>("bmin")),
65  m_bMax(pset.getParameter<double>("bmax")),
66  m_ParamFileName(pset.getUntrackedParameter<string>("paramFileName")),
67  m_SkipNuclFrag(pset.getParameter<bool>("skipNuclFrag")),
68  m_NEvent(0),
69  m_NParticles(0),
70  m_ImpactParameter(0.),
71  m_IsInitialized(false) {
72  int nevet = 1; //needed for CS
73  int noTables = 0; //don't calculate tables
74  int LHEoutput = 0; //no lhe
75  int dummySeed = 123;
76  char dummyName[] = "dummy";
77  crmc_set_f_(nevet,
78  dummySeed,
81  m_BeamID,
82  m_TargetID,
83  m_HEModel,
84  noTables,
85  LHEoutput,
86  dummyName,
87  m_ParamFileName.fullPath().c_str());
88 
89  //additionally initialise tables
91 
92  //change impact paramter
93  nucl2_.bminim = float(m_bMin);
94  nucl2_.bmaxim = float(m_bMax);
95 }
96 
97 //_____________________________________________________________________
99  // destructor
100 }
101 
102 //_____________________________________________________________________
104 
105 //_____________________________________________________________________
107  int iout = 0, ievent = 0;
108  crmc_f_(iout,
109  ievent,
110  m_NParticles,
112  m_PartID[0],
113  m_PartPx[0],
114  m_PartPy[0],
115  m_PartPz[0],
116  m_PartEnergy[0],
117  m_PartMass[0],
118  m_PartStatus[0]);
119  LogDebug("ReggeGribovPartonMCInterface") << "event generated" << endl;
120 
121  const bool isHeavyIon = (m_TargetID + m_BeamID > 2);
122 
123  if (isHeavyIon)
125 
127 
128  HepMC::GenEvent* evt = conv.read_next_event();
129 
130  evt->set_event_number(m_NEvent++);
131  int sig_id = -1;
132  switch (int(c2evt_.typevt)) // if negative typevt mini plasma was created by event (except -4)
133  {
134  case 0:
135  break; //unknown for qgsjetII
136  case 1:
137  sig_id = 101;
138  break;
139  case -1:
140  sig_id = 101;
141  break;
142  case 2:
143  sig_id = 105;
144  break;
145  case -2:
146  sig_id = 105;
147  break;
148  case 3:
149  sig_id = 102;
150  break;
151  case -3:
152  sig_id = 102;
153  break;
154  case 4:
155  sig_id = 103;
156  break;
157  case -4:
158  sig_id = 104;
159  break;
160  default:
161  LogDebug("ReggeGribovPartonMCInterface") << "Signal ID not recognised for setting HEPEVT" << endl;
162  }
163  evt->set_signal_process_id(sig_id); //an integer ID uniquely specifying the signal process (i.e. MSUB in Pythia)
164 
165 #ifdef HEPMC_HAS_CROSS_SECTION
166  // set cross section information for this event
167  HepMC::GenCrossSection theCrossSection;
168  theCrossSection.set_cross_section(double(hadr5_.sigineaa) * 1e9); //required in pB
169  evt->set_cross_section(theCrossSection);
170 #endif
171 
172  if (isHeavyIon) //other than pp
173  {
174  HepMC::HeavyIon ion(cevt_.kohevt, // Number of hard scatterings
175  cevt_.npjevt, // Number of projectile participants
176  cevt_.ntgevt, // Number of target participants
177  cevt_.kolevt, // Number of NN (nucleon-nucleon) collisions
178  cevt_.npnevt + cevt_.ntnevt, // Number of spectator neutrons
179  cevt_.nppevt + cevt_.ntpevt, // Number of spectator protons
180  -1, // Number of N-Nwounded collisions
181  -1, // Number of Nwounded-N collisons
182  -1, // Number of Nwounded-Nwounded collisions
183  cevt_.bimevt, // Impact Parameter(fm) of collision
184  cevt_.phievt, // Azimuthal angle of event plane
185  c2evt_.fglevt, // eccentricity of participating nucleons
186  hadr5_.sigine * 1e9); // nucleon-nucleon inelastic (in pB)
187  evt->set_heavy_ion(ion);
188  }
189 
190  event().reset(evt);
191  //evt->print();
192  //EPOS::EPOS_Wrapper::print_hepcom();
193 
194  return true;
195 }
196 
197 //_____________________________________________________________________
199 
201 
203 
205 
207 
208 const char* ReggeGribovPartonMCHadronizer::classname() const { return "gen::ReggeGribovPartonMCHadronizer"; }
209 
210 bool ReggeGribovPartonMCHadronizer::declareStableParticles(const std::vector<int>&) { return true; }
211 
213  if (!m_IsInitialized) {
214  //use set parameters to init models
215  crmc_init_f_();
216  m_IsInitialized = true;
217  }
218  return true;
219 }
220 
222  //epos
223  string path_fnii(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.initl").fullPath());
224  string path_fnie(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.iniev").fullPath());
225  string path_fnrj(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.inirj").fullPath());
226  string path_fncs(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.inics").fullPath());
227 
228  if (path_fnii.length() >= 500)
229  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
230  else
231  nfname_.nfnii = path_fnii.length();
232  if (path_fnie.length() >= 500)
233  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
234  else
235  nfname_.nfnie = path_fnie.length();
236  if (path_fnrj.length() >= 500)
237  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
238  else
239  nfname_.nfnrj = path_fnrj.length();
240  if (path_fncs.length() >= 500)
241  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
242  else
243  nfname_.nfncs = path_fncs.length();
244 
245  strcpy(fname_.fnii, path_fnii.c_str());
246  strcpy(fname_.fnie, path_fnie.c_str());
247  strcpy(fname_.fnrj, path_fnrj.c_str());
248  strcpy(fname_.fncs, path_fncs.c_str());
249 
250  //qgsjet
251  string path_fndat(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/qgsjet.dat").fullPath());
252  string path_fnncs(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/qgsjet.ncs").fullPath());
253 
254  if (path_fndat.length() >= 500)
255  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
256  else
257  qgsnfname_.nfndat = path_fndat.length();
258  if (path_fnncs.length() >= 500)
259  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
260  else
261  qgsnfname_.nfnncs = path_fnncs.length();
262 
263  strcpy(qgsfname_.fndat, path_fndat.c_str());
264  strcpy(qgsfname_.fnncs, path_fnncs.c_str());
265 
266  qgsfname_.ifdat = 1; //option to overwrite the normal path
267  qgsfname_.ifncs = 2;
268 
269  //qgsjetII
270  string path_fniidat(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/qgsdat-II-04.lzma").fullPath());
271  string path_fniincs(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/sectnu-II-04").fullPath());
272 
273  if (path_fniidat.length() >= 500)
274  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
275  else
276  qgsiinfname_.nfniidat = path_fniidat.length();
277  if (path_fniincs.length() >= 500)
278  LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
279  else
280  qgsiinfname_.nfniincs = path_fniincs.length();
281 
282  strcpy(qgsiifname_.fniidat, path_fniidat.c_str());
283  strcpy(qgsiifname_.fniincs, path_fniincs.c_str());
284 
285  qgsiifname_.ifiidat = 1; //option to overwrite the normal path
286  qgsiifname_.ifiincs = 2;
287 
288  return true;
289 }
void set_skip_nuclear_fragments(bool b=true)
!!MODIFICATION
Definition: IO_EPOS.h:74
struct @737 fname_
Log< level::Error, false > LogError
void crmc_f_(int &, int &, int &, double &, int &, double &, double &, double &, double &, double &, int &)
double v[5][pyjets_maxn]
bool declareStableParticles(const std::vector< int > &)
struct @739 qgsfname_
struct @736 nucl2_
double drangen_(int *)
void crmc_init_f_()
struct @740 qgsnfname_
std::unique_ptr< HepMC::GenEvent > & event()
struct @742 qgsiinfname_
struct @735 c2evt_
void set_trust_beam_particles(bool b=true)
Definition: IO_EPOS.h:71
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
struct @733 hadr5_
static CLHEP::HepRandomEngine * reggeGribovRandomEngine
EPOS::IO_EPOS conv
struct @738 nfname_
HLT enums.
struct @741 qgsiifname_
double a
Definition: hdecay.h:121
const std::string & fullPath() const
Definition: FileInPath.cc:144
void crmc_set_f_(int &, int &, double &, double &, int &, int &, int &, int &, int &, const char *, const char *)
struct @734 cevt_
#define LogDebug(id)