CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 #include "CLHEP/Random/RandFlat.h"
12 
13 #include <HepMC/GenCrossSection.h>
14 #include <HepMC/GenEvent.h>
15 #include <HepMC/GenVertex.h>
16 #include <HepMC/GenParticle.h>
17 #include <HepMC/HeavyIon.h>
18 #include <HepMC/PdfInfo.h>
19 #include <HepMC/Units.h>
20 
31 
34 
36 
38 using namespace edm;
39 using namespace std;
40 using namespace gen;
41 
44 
46 
47 extern "C"
48 {
49  float gen::rangen_()
50  {
51  float a = float(gFlatDistribution_->fire());
52  return a;
53  }
54 
55  double gen::drangen_(int *idummy)
56  {
57  double a = gFlatDistribution_->fire();
58  return a;
59  }
60 }
61 
62 ReggeGribovPartonMCHadronizer::ReggeGribovPartonMCHadronizer(const ParameterSet &pset) :
63  BaseHadronizer(pset),
64  pset_(pset),
65  m_BeamMomentum(pset.getParameter<double>("beammomentum")),
66  m_TargetMomentum(pset.getParameter<double>("targetmomentum")),
67  m_BeamID(pset.getParameter<int>("beamid")),
68  m_TargetID(pset.getParameter<int>("targetid")),
69  m_HEModel(pset.getParameter<int>("model")),
70  m_bMin(pset.getParameter<double>("bmin")),
71  m_bMax(pset.getParameter<double>("bmax")),
72  m_ParamFileName(pset.getUntrackedParameter<string>("paramFileName")),
73  m_SkipNuclFrag(pset.getParameter<bool>("skipNuclFrag")),
74  m_NEvent(0),
75  m_NParticles(0),
76  m_ImpactParameter(0.)
77 {
79  if ( ! rng.isAvailable())
80  {
81  throw cms::Exception("Configuration")
82  << "ReggeGribovPartonMCHadronizer requires the RandomNumberGeneratorService\n"
83  "which is not present in the configuration file. You must add the service\n"
84  "in the configuration file or remove the modules that require it.";
85  }
86 
87  gFlatDistribution_.reset(new CLHEP::RandFlat(rng->getEngine(), 0., 1.));
88 
89  int nevet = 1; //needed for CS
90  int noTables = 0; //don't calculate tables
91  int LHEoutput = 0; //no lhe
92  int dummySeed = 123;
93  char dummyName[] = "dummy";
95  m_TargetID,m_HEModel,noTables,LHEoutput,dummyName,
96  m_ParamFileName.fullPath().c_str());
97 
98  //additionally initialise tables
100 
101  //change impact paramter
102  nucl2_.bminim = float(m_bMin);
103  nucl2_.bmaxim = float(m_bMax);
104 
105  //use set parameters to init models
106  crmc_init_f_();
107 }
108 
109 
110 //_____________________________________________________________________
112 {
113  // destructor
114  gFlatDistribution_.reset();
115 }
116 
117 //_____________________________________________________________________
119 {
120  int iout=0,ievent=0;
122  m_PartID[0],m_PartPx[0],m_PartPy[0],m_PartPz[0],
124  LogDebug("ReggeGribovPartonMCInterface") << "event generated" << endl;
125 
126  const bool isHeavyIon = (m_TargetID + m_BeamID > 2);
127 
128  if(isHeavyIon)
129  conv.set_trust_beam_particles(false);
130 
131  conv.set_skip_nuclear_fragments(m_SkipNuclFrag);
132 
133  HepMC::GenEvent* evt = conv.read_next_event();
134 
135  evt->set_event_number(m_NEvent++);
136  int sig_id = -1;
137  switch (int(c2evt_.typevt)) // if negative typevt mini plasma was created by event (except -4)
138  {
139  case 0: break; //unknown for qgsjetII
140  case 1: sig_id = 101; break;
141  case -1: sig_id = 101; break;
142  case 2: sig_id = 105; break;
143  case -2: sig_id = 105; break;
144  case 3: sig_id = 102; break;
145  case -3: sig_id = 102; break;
146  case 4: sig_id = 103; break;
147  case -4: sig_id = 104; break;
148  default: LogDebug("ReggeGribovPartonMCInterface") << "Signal ID not recognised for setting HEPEVT" << endl;
149  }
150  evt->set_signal_process_id(sig_id); //an integer ID uniquely specifying the signal process (i.e. MSUB in Pythia)
151 
152 #ifdef HEPMC_HAS_CROSS_SECTION
153  // set cross section information for this event
154  HepMC::GenCrossSection theCrossSection;
155  theCrossSection.set_cross_section(double(hadr5_.sigineaa)*1e9); //required in pB
156  evt->set_cross_section(theCrossSection);
157 #endif
158 
159  if (isHeavyIon) //other than pp
160  {
161  HepMC::HeavyIon ion(cevt_.kohevt, // Number of hard scatterings
162  cevt_.npjevt, // Number of projectile participants
163  cevt_.ntgevt, // Number of target participants
164  cevt_.kolevt, // Number of NN (nucleon-nucleon) collisions
165  cevt_.npnevt + cevt_.ntnevt, // Number of spectator neutrons
166  cevt_.nppevt + cevt_.ntpevt, // Number of spectator protons
167  -1, // Number of N-Nwounded collisions
168  -1, // Number of Nwounded-N collisons
169  -1, // Number of Nwounded-Nwounded collisions
170  cevt_.bimevt, // Impact Parameter(fm) of collision
171  cevt_.phievt, // Azimuthal angle of event plane
172  c2evt_.fglevt, // eccentricity of participating nucleons
173  hadr5_.sigine*1e9); // nucleon-nucleon inelastic (in pB)
174  evt->set_heavy_ion(ion);
175  }
176 
177 
178  event().reset(evt);
179  //evt->print();
180  //EPOS::EPOS_Wrapper::print_hepcom();
181 
182  return true;
183 }
184 
185 //_____________________________________________________________________
187 {
188  return false;
189 }
190 
192 {
193  return true;
194 }
195 
197 {
198  return true;
199 }
200 
202  return;
203 }
204 
206  return;
207 }
208 
210 {
211  return "gen::ReggeGribovPartonMCHadronizer";
212 }
213 
215 {
216  return true;
217  }
218 
220 {
221  return true;
222  }
223 
225 {
226  //epos
227  string path_fnii(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.initl").fullPath());
228  string path_fnie(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.iniev").fullPath());
229  string path_fnrj(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.inirj").fullPath());
230  string path_fncs(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/epos.inics").fullPath());
231 
232  if (path_fnii.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
233  else nfname_.nfnii = path_fnii.length();
234  if (path_fnie.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
235  else nfname_.nfnie = path_fnie.length();
236  if (path_fnrj.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
237  else nfname_.nfnrj = path_fnrj.length();
238  if (path_fncs.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
239  else nfname_.nfncs = path_fncs.length();
240 
241  strcpy(fname_.fnii, path_fnii.c_str());
242  strcpy(fname_.fnie, path_fnie.c_str());
243  strcpy(fname_.fnrj, path_fnrj.c_str());
244  strcpy(fname_.fncs, path_fncs.c_str());
245 
246  //qgsjet
247  string path_fndat(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/qgsjet.dat").fullPath());
248  string path_fnncs(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/qgsjet.ncs").fullPath());
249 
250  if (path_fndat.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
251  else qgsnfname_.nfndat = path_fndat.length();
252  if (path_fnncs.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
253  else qgsnfname_.nfnncs = path_fnncs.length();
254 
255  strcpy(qgsfname_.fndat, path_fndat.c_str());
256  strcpy(qgsfname_.fnncs, path_fnncs.c_str());
257 
258  qgsfname_.ifdat=1; //option to overwrite the normal path
259  qgsfname_.ifncs=2;
260 
261  //qgsjetII
262  string path_fniidat(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/qgsdat-II-04.lzma").fullPath());
263  string path_fniincs(FileInPath("GeneratorInterface/ReggeGribovPartonMCInterface/data/sectnu-II-04").fullPath());
264 
265  if (path_fniidat.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
266  else qgsiinfname_.nfniidat = path_fniidat.length();
267  if (path_fniincs.length() >= 500) LogError("ReggeGribovPartonMCInterface") << "table path too long" << endl;
268  else qgsiinfname_.nfniincs = path_fniincs.length();
269 
270  strcpy(qgsiifname_.fniidat, path_fniidat.c_str());
271  strcpy(qgsiifname_.fniincs, path_fniincs.c_str());
272 
273  qgsiifname_.ifiidat=1; //option to overwrite the normal path
274  qgsiifname_.ifiincs=2;
275 
276  return true;
277 }
#define LogDebug(id)
static HepMC::IO_HEPEVT conv
struct @394 nfname_
struct @397 qgsiifname_
struct @395 qgsfname_
struct @390 cevt_
struct @398 qgsiinfname_
void crmc_f_(int &, int &, int &, double &, int &, double &, double &, double &, double &, double &, int &)
std::auto_ptr< HepMC::GenEvent > & event()
bool isAvailable() const
Definition: Service.h:47
boost::scoped_ptr< CLHEP::RandFlat > gFlatDistribution_
void crmc_init_f_()
struct @393 fname_
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
struct @389 hadr5_
struct @392 nucl2_
double drangen_(int *)
double a
Definition: hdecay.h:121
std::string fullPath() const
Definition: FileInPath.cc:171
void crmc_set_f_(int &, int &, double &, double &, int &, int &, int &, int &, int &, const char *, const char *)
struct @396 qgsnfname_
struct @391 c2evt_
bool declareStableParticles(const std::vector< int >)