CMS 3D CMS Logo

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