CMS 3D CMS Logo

Hydjet2Hadronizer.cc
Go to the documentation of this file.
1 /*
2 
3 ##########################
4 # Hydjet2 #
5 # version: 2.2.0 patch1 #
6 ##########################
7 
8  Interface to the HYDJET++ generator, produces HepMC events
9 
10  Author: Andrey Belyaev (Andrey.Belyaev@cern.ch)
11 
12  Hydjet2Hadronizer is the modified InitialStateHydjet
13 
14  HYDJET++
15  version 2.2:
16  InitialStateHydjet is the modified InitialStateBjorken
17  The high-pt part related with PYTHIA-PYQUEN is included
18  InitialStateBjorken (FASTMC) was used.
19 
20 
21  InitialStateBjorken
22  version 2.0:
23  Ludmila Malinina malinina@lav01.sinp.msu.ru, SINP MSU/Moscow and JINR/Dubna
24  Ionut Arsene i.c.arsene@fys.uio.no, Oslo University
25  June 2007
26 
27  version 1.0:
28  Nikolai Amelin, Ludmila Malinina, Timur Pocheptsov (C) JINR/Dubna
29  amelin@sunhe.jinr.ru, malinina@sunhe.jinr.ru, pocheptsov@sunhe.jinr.ru
30  November. 2, 2005
31 */
32 
33 //expanding localy equilibated fireball with volume hadron radiation
34 //thermal part: Blast wave model, Bjorken-like parametrization
35 //high-pt: PYTHIA + jet quenching model PYQUEN
36 
37 #include <TLorentzVector.h>
38 #include <TVector3.h>
39 #include <TMath.h>
40 
51 
52 #include <iostream>
53 #include <fstream>
54 #include <cmath>
55 #include "boost/lexical_cast.hpp"
56 
63 
66 
67 #include "HepMC/PythiaWrapper6_4.h"
68 #include "HepMC/GenEvent.h"
69 #include "HepMC/HeavyIon.h"
70 #include "HepMC/SimpleVector.h"
71 
76 
78 
79 extern "C" void hyevnt_();
80 extern "C" void myini_();
81 
82 extern HYIPARCommon HYIPAR;
83 extern HYFPARCommon HYFPAR;
84 extern HYJPARCommon HYJPAR;
85 extern HYPARTCommon HYPART;
86 
87 using namespace edm;
88 using namespace std;
89 using namespace gen;
90 
92 
93 // definition of the static member fLastIndex
95 bool ev=0;
96 namespace {
97  int convertStatusForComponents(int sta, int typ){
98 
99  if(sta== 1 && typ==0) return 6;
100  if(sta== 1 && typ==1) return 7;
101  if(sta== 2 && typ==0) return 16;
102  if(sta== 2 && typ==1) return 17;
103 
104  else return sta;
105  }
106 
107  int convertStatus(int st){
108 
109  if(st<= 0) return 0;
110  if(st<=10) return 1;
111  if(st<=20) return 2;
112  if(st<=30) return 3;
113 
114  else return st;
115  }
116 }
117 
118 const std::vector<std::string> Hydjet2Hadronizer::theSharedResources = { edm::SharedResourceNames::kPythia6, gen::FortranInstance::kFortranInstance };
119 
120 //____________________________________________________________________________________________
121 Hydjet2Hadronizer::Hydjet2Hadronizer(const edm::ParameterSet& pset):
122  BaseHadronizer(pset),
123  fSqrtS(pset.getParameter<double>("fSqrtS")), // C.m.s. energy per nucleon pair
124  fAw(pset.getParameter<double>("fAw")), // Atomic weigth of nuclei, fAw
125  fIfb(pset.getParameter<int>("fIfb")), // Flag of type of centrality generation, fBfix (=0 is fixed by fBfix, >0 distributed [fBfmin, fBmax])
126  fBmin(pset.getParameter<double>("fBmin")), // Minimum impact parameter in units of nuclear radius, fBmin
127  fBmax(pset.getParameter<double>("fBmax")), // Maximum impact parameter in units of nuclear radius, fBmax
128  fBfix(pset.getParameter<double>("fBfix")), // Fixed impact parameter in units of nuclear radius, fBfix
129  fT(pset.getParameter<double>("fT")), // Temperature at chemical freeze-out, fT [GeV]
130  fMuB(pset.getParameter<double>("fMuB")), // Chemical baryon potential per unit charge, fMuB [GeV]
131  fMuS(pset.getParameter<double>("fMuS")), // Chemical strangeness potential per unit charge, fMuS [GeV]
132  fMuC(pset.getParameter<double>("fMuC")), // Chemical charm potential per unit charge, fMuC [GeV] (used if charm production is turned on)
133  fMuI3(pset.getParameter<double>("fMuI3")), // Chemical isospin potential per unit charge, fMuI3 [GeV]
134  fThFO(pset.getParameter<double>("fThFO")), // Temperature at thermal freeze-out, fThFO [GeV]
135  fMu_th_pip(pset.getParameter<double>("fMu_th_pip")),// Chemical potential of pi+ at thermal freeze-out, fMu_th_pip [GeV]
136  fTau(pset.getParameter<double>("fTau")), // Proper time proper at thermal freeze-out for central collisions, fTau [fm/c]
137  fSigmaTau(pset.getParameter<double>("fSigmaTau")), // Duration of emission at thermal freeze-out for central collisions, fSigmaTau [fm/c]
138  fR(pset.getParameter<double>("fR")), // Maximal transverse radius at thermal freeze-out for central collisions, fR [fm]
139  fYlmax(pset.getParameter<double>("fYlmax")), // Maximal longitudinal flow rapidity at thermal freeze-out, fYlmax
140  fUmax(pset.getParameter<double>("fUmax")), // Maximal transverse flow rapidity at thermal freeze-out for central collisions, fUmax
141  fDelta(pset.getParameter<double>("fDelta")), // Momentum azimuthal anizotropy parameter at thermal freeze-out, fDelta
142  fEpsilon(pset.getParameter<double>("fEpsilon")), // Spatial azimuthal anisotropy parameter at thermal freeze-out, fEpsilon
143  fIfDeltaEpsilon(pset.getParameter<double>("fIfDeltaEpsilon")), // Flag to specify fDelta and fEpsilon values, fIfDeltaEpsilon (=0 user's ones, >=1 calculated)
144  fDecay(pset.getParameter<int>("fDecay")), // Flag to switch on/off hadron decays, fDecay (=0 decays off, >=1 decays on)
145  fWeakDecay(pset.getParameter<double>("fWeakDecay")),// Low decay width threshold fWeakDecay[GeV]: width<fWeakDecay decay off, width>=fDecayWidth decay on; can be used to switch off weak decays
146  fEtaType(pset.getParameter<double>("fEtaType")), // Flag to choose longitudinal flow rapidity distribution, fEtaType (=0 uniform, >0 Gaussian with the dispersion Ylmax)
147  fTMuType(pset.getParameter<double>("fTMuType")), // Flag to use calculated T_ch, mu_B and mu_S as a function of fSqrtS, fTMuType (=0 user's ones, >0 calculated)
148  fCorrS(pset.getParameter<double>("fCorrS")), // Strangeness supression factor gamma_s with fCorrS value (0<fCorrS <=1, if fCorrS <= 0 then it is calculated)
149  fCharmProd(pset.getParameter<int>("fCharmProd")), // Flag to include thermal charm production, fCharmProd (=0 no charm production, >=1 charm production)
150  fCorrC(pset.getParameter<double>("fCorrC")), // Charmness enhancement factor gamma_c with fCorrC value (fCorrC >0, if fCorrC<0 then it is calculated)
151  fNhsel(pset.getParameter<int>("fNhsel")), //Flag to include jet (J)/jet quenching (JQ) and hydro (H) state production, fNhsel (0 H on & J off, 1 H/J on & JQ off, 2 H/J/HQ on, 3 J on & H/JQ off, 4 H off & J/JQ on)
152  fPyhist(pset.getParameter<int>("fPyhist")), // Flag to suppress the output of particle history from PYTHIA, fPyhist (=1 only final state particles; =0 full particle history from PYTHIA)
153  fIshad(pset.getParameter<int>("fIshad")), // Flag to switch on/off nuclear shadowing, fIshad (0 shadowing off, 1 shadowing on)
154  fPtmin(pset.getParameter<double>("fPtmin")), // Minimal pt of parton-parton scattering in PYTHIA event, fPtmin [GeV/c]
155  fT0(pset.getParameter<double>("fT0")), // Initial QGP temperature for central Pb+Pb collisions in mid-rapidity, fT0 [GeV]
156  fTau0(pset.getParameter<double>("fTau0")), // Proper QGP formation time in fm/c, fTau0 (0.01<fTau0<10)
157  fNf(pset.getParameter<int>("fNf")), // Number of active quark flavours in QGP, fNf (0, 1, 2 or 3)
158  fIenglu(pset.getParameter<int>("fIenglu")), // Flag to fix type of partonic energy loss, fIenglu (0 radiative and collisional loss, 1 radiative loss only, 2 collisional loss only)
159  fIanglu(pset.getParameter<int>("fIanglu")), // Flag to fix type of angular distribution of in-medium emitted gluons, fIanglu (0 small-angular, 1 wide-angular, 2 collinear).
160 
161  embedding_(pset.getParameter<bool>("embeddingMode")),
162  rotate_(pset.getParameter<bool>("rotateEventPlane")),
163  evt(0),
164  nsub_(0),
165  nhard_(0),
166  nsoft_(0),
167  phi0_(0.),
168  sinphi0_(0.),
169  cosphi0_(1.),
170  pythia6Service_(new Pythia6Service(pset))
171 
172 {
173  // constructor
174  // PYLIST Verbosity Level
175  // Valid PYLIST arguments are: 1, 2, 3, 5, 7, 11, 12, 13
176  pythiaPylistVerbosity_ = pset.getUntrackedParameter<int>("pythiaPylistVerbosity",0);
177  LogDebug("PYLISTverbosity") << "Pythia PYLIST verbosity level = " << pythiaPylistVerbosity_;
178  //Max number of events printed on verbosity level
179  maxEventsToPrint_ = pset.getUntrackedParameter<int>("maxEventsToPrint",0);
180  LogDebug("Events2Print") << "Number of events to be printed = " << maxEventsToPrint_;
181  if(embedding_) src_ = pset.getParameter<edm::InputTag>("backgroundLabel");
182 }
183 
184 //__________________________________________________________________________________________
186  // destructor
187  call_pystat(1);
188  delete pythia6Service_;
189 }
190 
191 
192 //_____________________________________________________________________
193 void Hydjet2Hadronizer::doSetRandomEngine(CLHEP::HepRandomEngine* v)
194 {
196  hjRandomEngine = v;
197 }
198 
199 //______________________________________________________________________________________________________
201 
204 
205  SERVICE.iseed_fromC=hjRandomEngine->CLHEP::HepRandomEngine::getSeed();
206  LogInfo("Hydjet2Hadronizer|GenSeed") << "Seed for random number generation: "<<hjRandomEngine->CLHEP::HepRandomEngine::getSeed();
207 
208  fNPartTypes = 0; //counter of hadron species
209 
210  return kTRUE;
211 }
212 
213 //______________________________________________________________________________________________________
215 
217 
218  // the input impact parameter (bxx_) is in [fm]; transform in [fm/RA] for hydjet usage
219  const float ra = nuclear_radius();
220  LogInfo("Hydjet2Hadronizer|RAScaling")<<"Nuclear radius(RA) = "<<ra;
221  fBmin /= ra;
222  fBmax /= ra;
223  fBfix /= ra;
224 
225  //check and redefine input parameters
226  if(fTMuType>0 && fSqrtS > 2.24) {
227 
228  if(fSqrtS < 2.24){
229  LogError("Hydjet2Hadronizer|sqrtS") << "SqrtS<2.24 not allowed with fTMuType>0";
230  return 0;
231  }
232 
233  //sqrt(s) = 2.24 ==> T_kin = 0.8 GeV
234  //see J. Cleymans, H. Oeschler, K. Redlich,S. Wheaton, Phys Rev. C73 034905 (2006)
235  fMuB = 1.308/(1. + fSqrtS*0.273);
236  fT = 0.166 - 0.139*fMuB*fMuB - 0.053*fMuB*fMuB*fMuB*fMuB;
237  fMuI3 = 0.;
238  fMuS = 0.;
239 
240  //create strange potential object and set strangeness density 0
242  psp->SetBaryonPotential(fMuB);
243  psp->SetTemperature(fT);
244 
245  //compute strangeness potential
246  if(fMuB > 0.01) fMuS = psp->CalculateStrangePotential();
247  LogInfo("Hydjet2Hadronizer|Strange") << "fMuS = " << fMuS;
248 
249  //if user choose fYlmax larger then allowed by kinematics at the specified beam energy sqrt(s)
250  if(fYlmax > TMath::Log(fSqrtS/0.94)){
251  LogError("Hydjet2Hadronizer|Ylmax") << "fYlmax more then TMath::Log(fSqrtS vs 0.94)!!! ";
252  return 0;
253  }
254 
255  if(fCorrS <= 0.) {
256  //see F. Becattini, J. Mannien, M. Gazdzicki, Phys Rev. C73 044905 (2006)
257  fCorrS = 1. - 0.386* TMath::Exp(-1.23*fT/fMuB);
258  LogInfo("Hydjet2Hadronizer|Strange") << "The phenomenological f-la F. Becattini et al. PRC73 044905 (2006) for CorrS was used."<<endl
259  <<"Strangeness suppression parameter = "<<fCorrS;
260  }
261  LogInfo("Hydjet2Hadronizer|Strange") << "The phenomenological f-la J. Cleymans et al. PRC73 034905 (2006) for Tch mu_B was used." << endl
262  <<"The simulation will be done with the calculated parameters:" << endl
263  <<"Baryon chemical potential = "<<fMuB<< " [GeV]" << endl
264  <<"Strangeness chemical potential = "<<fMuS<< " [GeV]" << endl
265  <<"Isospin chemical potential = "<<fMuI3<< " [GeV]" << endl
266  <<"Strangeness suppression parameter = "<<fCorrS << endl
267  <<"Eta_max = "<<fYlmax;
268  }
269 
270  LogInfo("Hydjet2Hadronizer|Param") << "Used eta_max = "<<fYlmax<< endl
271  <<"maximal allowed eta_max TMath::Log(fSqrtS/0.94)= "<<TMath::Log(fSqrtS/0.94);
272 
273  //initialisation of high-pt part
274  HYJPAR.nhsel = fNhsel;
275  HYJPAR.ptmin = fPtmin;
276  HYJPAR.ishad = fIshad;
277  HYJPAR.iPyhist = fPyhist;
278  HYIPAR.bminh = fBmin;
279  HYIPAR.bmaxh = fBmax;
280  HYIPAR.AW = fAw;
281 
282  HYPYIN.ifb = fIfb;
283  HYPYIN.bfix = fBfix;
284  HYPYIN.ene = fSqrtS;
285 
286  PYQPAR.T0 = fT0;
287  PYQPAR.tau0 = fTau0;
288  PYQPAR.nf = fNf;
289  PYQPAR.ienglu = fIenglu;
290  PYQPAR.ianglu = fIanglu;
291  myini_();
292 
293  // calculation of multiplicities of different particle species
294  // according to the grand canonical approach
295  GrandCanonical gc(15, fT, fMuB, fMuS, fMuI3, fMuC);
296  GrandCanonical gc_ch(15, fT, fMuB, fMuS, fMuI3, fMuC);
297  GrandCanonical gc_pi_th(15, fThFO, 0., 0., fMu_th_pip, fMuC);
298  GrandCanonical gc_th_0(15, fThFO, 0., 0., 0., 0.);
299 
300  // std::ofstream outMult("densities.txt");
301  // outMult<<"encoding particle density chemical potential "<<std::endl;
302 
303  double Nocth=0; //open charm
304  double NJPsith=0; //JPsi
305 
306  //effective volume for central
307  double dYl= 2 * fYlmax; //uniform distr. [-Ylmax; Ylmax]
308  if (fEtaType >0) dYl = TMath::Sqrt(2 * TMath::Pi()) * fYlmax ; //Gaussian distr.
309  fVolEff = 2 * TMath::Pi() * fTau * dYl * (fR * fR)/TMath::Power((fUmax),2) *
310  ((fUmax)*TMath::SinH((fUmax))-TMath::CosH((fUmax))+ 1);
311  LogInfo("Hydjet2Hadronizer|Param") << "central Effective volume = " << fVolEff << " [fm^3]";
312 
313  double particleDensity_pi_ch=0;
314  double particleDensity_pi_th=0;
315  // double particleDensity_th_0=0;
316 
317  if(fThFO != fT && fThFO > 0){
318  GrandCanonical gc_ch(15, fT, fMuB, fMuS, fMuI3, fMuC);
319  GrandCanonical gc_pi_th(15, fThFO, 0., 0., fMu_th_pip, fMuC);
320  GrandCanonical gc_th_0(15, fThFO, 0., 0., 0., 0.);
321  particleDensity_pi_ch = gc_ch.ParticleNumberDensity(fDatabase->GetPDGParticle(211));
322  particleDensity_pi_th = gc_pi_th.ParticleNumberDensity(fDatabase->GetPDGParticle(211));
323  }
324 
325  for(int particleIndex = 0; particleIndex < fDatabase->GetNParticles(); particleIndex++) {
326  ParticlePDG *currParticle = fDatabase->GetPDGParticleByIndex(particleIndex);
327  int encoding = currParticle->GetPDG();
328 
329  //strangeness supression
330  double gammaS = 1;
331  int S = int(currParticle->GetStrangeness());
332  if(encoding == 333)S = 2;
333  if(fCorrS < 1. && S != 0)gammaS = TMath::Power(fCorrS,-TMath::Abs(S));
334 
335 
336  //average densities
337  double particleDensity = gc.ParticleNumberDensity(currParticle)/gammaS;
338 
339  //compute chemical potential for single f.o. mu==mu_ch
340  double mu = fMuB * int(currParticle->GetBaryonNumber()) +
341  fMuS * int(currParticle->GetStrangeness()) +
342  fMuI3 * int(currParticle->GetElectricCharge()) +
343  fMuC * int(currParticle->GetCharmness());
344 
345  //thermal f.o.
346  if(fThFO != fT && fThFO > 0){
347  double particleDensity_ch = gc_ch.ParticleNumberDensity(currParticle);
348  double particleDensity_th_0 = gc_th_0.ParticleNumberDensity(currParticle);
349  double numb_dens_bolt = particleDensity_pi_th*particleDensity_ch/particleDensity_pi_ch;
350  mu = fThFO*TMath::Log(numb_dens_bolt/particleDensity_th_0);
351  if(abs(encoding)==211 || encoding==111)mu= fMu_th_pip;
352  particleDensity = numb_dens_bolt;
353  }
354 
355  // set particle densities to zero for some particle codes
356  // pythia quark codes
357  if(abs(encoding)<=9) {
358  particleDensity=0;
359  }
360  // leptons
361  if(abs(encoding)>10 && abs(encoding)<19) {
362  particleDensity=0;
363  }
364  // exchange bosons
365  if(abs(encoding)>20 && abs(encoding)<30) {
366  particleDensity=0;
367  }
368  // pythia special codes (e.g. strings, clusters ...)
369  if(abs(encoding)>80 && abs(encoding)<100) {
370  particleDensity=0;
371  }
372  // pythia di-quark codes
373  // Note: in PYTHIA all diquark codes have the tens digits equal to zero
374  if(abs(encoding)>1000 && abs(encoding)<6000) {
375  int tens = ((abs(encoding)-(abs(encoding)%10))/10)%10;
376  if(tens==0) { // its a diquark;
377  particleDensity=0;
378  }
379  }
380  // K0S and K0L
381  if(abs(encoding)==130 || abs(encoding)==310) {
382  particleDensity=0;
383  }
384  // charmed particles
385 
386  if(encoding==443)NJPsith=particleDensity*fVolEff/dYl;
387 
388  // We generate thermo-statistically only J/psi(443), D_+(411), D_-(-411), D_0(421),
389  //Dbar_0(-421), D1_+(413), D1_-(-413), D1_0(423), D1bar_0(-423)
390  //Dcs(431) Lambdac(4122)
391  if(currParticle->GetCharmQNumber()!=0 || currParticle->GetCharmAQNumber()!=0) {
392  //ml if(abs(encoding)!=443 &&
393  //ml abs(encoding)!=411 && abs(encoding)!=421 &&
394  //ml abs(encoding)!=413 && abs(encoding)!=423 && abs(encoding)!=4122 && abs(encoding)!=431) {
395  //ml particleDensity=0; }
396 
397  if(abs(encoding)==441 ||
398  abs(encoding)==10441 || abs(encoding)==10443 ||
399  abs(encoding)==20443 || abs(encoding)==445 || abs(encoding)==4232 || abs(encoding)==4322 ||
400  abs(encoding)==4132 || abs(encoding)==4312 || abs(encoding)==4324 || abs(encoding)==4314 ||
401  abs(encoding)==4332 || abs(encoding)==4334
402  ) {
403  particleDensity=0; }
404  else
405  {
406  if(abs(encoding)!=443){ //only open charm
407  Nocth=Nocth+particleDensity*fVolEff/dYl;
408  LogInfo("Hydjet2Hadronizer|Charam") << encoding<<" Nochth "<<Nocth;
409  // particleDensity=particleDensity*fCorrC;
410  // if(abs(encoding)==443)particleDensity=particleDensity*fCorrC;
411  }
412  }
413 
414  }
415 
416 
417  // bottom mesons
418  if((abs(encoding)>500 && abs(encoding)<600) ||
419  (abs(encoding)>10500 && abs(encoding)<10600) ||
420  (abs(encoding)>20500 && abs(encoding)<20600) ||
421  (abs(encoding)>100500 && abs(encoding)<100600)) {
422  particleDensity=0;
423  }
424  // bottom baryons
425  if(abs(encoding)>5000 && abs(encoding)<6000) {
426  particleDensity=0;
427  }
429 
430 
431  if(particleDensity > 0.) {
432  fPartEnc[fNPartTypes] = encoding;
433  fPartMult[2 * fNPartTypes] = particleDensity;
434  fPartMu[2 * fNPartTypes] = mu;
435  ++fNPartTypes;
436  if(fNPartTypes > 1000)
437  LogError("Hydjet2Hadronizer") << "fNPartTypes is too large" << fNPartTypes;
438 
439  //outMult<<encoding<<" "<<particleDensity*fVolEff/dYl <<" "<<mu<<std::endl;
440 
441  }
442  }
443 
444  //put open charm number and cc number in Params
445  fNocth = Nocth;
446  fNccth = NJPsith;
447 
448 
449  return kTRUE;
450 }
451 
452 
453 //__________________________________________________________________________________________
455 
456 
458 
459  // Initialize the static "last index variable"
461 
462  //----- high-pt part------------------------------
463  TLorentzVector partJMom, partJPos, zeroVec;
464 
465  // generate single event
466  if(embedding_){
467  fIfb = 0;
468  const edm::Event& e = getEDMEvent();
470  e.getByLabel(src_,input);
471  const HepMC::GenEvent * inev = input->GetEvent();
472  const HepMC::HeavyIon* hi = inev->heavy_ion();
473  if(hi){
474  fBfix = hi->impact_parameter();
475  phi0_ = hi->event_plane_angle();
476  sinphi0_ = sin(phi0_);
477  cosphi0_ = cos(phi0_);
478  }else{
479  LogWarning("EventEmbedding")<<"Background event does not have heavy ion record!";
480  }
481  }else if(rotate_) rotateEvtPlane();
482 
483  nsoft_ = 0;
484  nhard_ = 0;
485  /*
486  edm::LogInfo("HYDJET2mode") << "##### HYDJET2 fNhsel = " << fNhsel;
487  edm::LogInfo("HYDJET2fpart") << "##### HYDJET2 fpart = " << hyflow.fpart;??
488  edm::LogInfo("HYDJET2tf") << "##### HYDJET2 hadron freez-out temp, Tf = " << hyflow.Tf;??
489  edm::LogInfo("HYDJET2tf") << "##### HYDJET2 hadron freez-out temp, Tf = " << hyflow.Tf;??
490  edm::LogInfo("HYDJET2inTemp") << "##### HYDJET2: QGP init temperature, fT0 ="<<fT0;
491  edm::LogInfo("HYDJET2inTau") << "##### HYDJET2: QGP formation time, fTau0 ="<<fTau0;
492  */
493  // generate a HYDJET event
494  int ntry = 0;
495  while(nsoft_ == 0 && nhard_ == 0){
496  if(ntry > 100){
497  LogError("Hydjet2EmptyEvent") << "##### HYDJET2: No Particles generated, Number of tries ="<<ntry;
498  // Throw an exception. Use the EventCorruption exception since it maps onto SkipEvent
499  // which is what we want to do here.
500  std::ostringstream sstr;
501  sstr << "Hydjet2HadronizerProducer: No particles generated after " << ntry << " tries.\n";
502  edm::Exception except(edm::errors::EventCorruption, sstr.str());
503  throw except;
504  } else {
505 
506 
507  //generate non-equilibrated part event
508  hyevnt_();
509 
511  if(fNhsel != 0){
512  //get number of particles in jets
513  int numbJetPart = HYPART.njp;
514 
515  for(int i = 0; i <numbJetPart; ++i) {
516  int pythiaStatus = int(HYPART.ppart[i][0]); // PYTHIA status code
517  int pdg = int(HYPART.ppart[i][1]); // PYTHIA species code
518  double px = HYPART.ppart[i][2]; // px
519  double py = HYPART.ppart[i][3]; // py
520  double pz = HYPART.ppart[i][4]; // pz
521  double e = HYPART.ppart[i][5]; // E
522  double vx = HYPART.ppart[i][6]; // x
523  double vy = HYPART.ppart[i][7]; // y
524  double vz = HYPART.ppart[i][8]; // z
525  double vt = HYPART.ppart[i][9]; // t
526  // particle line number in pythia are 1 based while we use a 0 based numbering
527  int mother_index = int(HYPART.ppart[i][10])-1; //line number of parent particle
528  int daughter_index1 = int(HYPART.ppart[i][11])-1; //line number of first daughter
529  int daughter_index2 = int(HYPART.ppart[i][12])-1; //line number of last daughter
530 
531  // For status codes 3, 13, 14 the first and last daughter indexes have a different meaning
532  // used for color flow in PYTHIA. So these indexes will be reset to zero.
533  if(TMath::Abs(daughter_index1)>numbJetPart || TMath::Abs(daughter_index2)>numbJetPart ||
534  TMath::Abs(daughter_index1)>TMath::Abs(daughter_index2)) {
535  daughter_index1 = -1;
536  daughter_index2 = -1;
537  }
538 
539  ParticlePDG *partDef = fDatabase->GetPDGParticle(pdg);
540 
541  int type=1; //from jet
542  if(partDef) {
543  int motherPdg = int(HYPART.ppart[mother_index][1]);
544  if(motherPdg==0) motherPdg = -1;
545  partJMom.SetXYZT(px, py, pz, e);
546  partJPos.SetXYZT(vx, vy, vz, vt);
547  Particle particle(partDef, partJPos, partJMom, 0, 0, type, motherPdg, zeroVec, zeroVec);
548  int index = particle.SetIndex();
549  if(index!=i) {
550  // LogWarning("Hydjet2Hadronizer") << " Allocated Hydjet2 index is not synchronized with the PYTHIA index !" << endl
551  // << " Collision history information is destroyed! It happens when a PYTHIA code is not" << endl
552  // << " implemented in Hydjet2 particle list particles.data! Check it out!";
553  }
554  particle.SetPythiaStatusCode(pythiaStatus);
555  particle.SetMother(mother_index);
556  particle.SetFirstDaughterIndex(daughter_index1);
557  particle.SetLastDaughterIndex(daughter_index2);
558  if(pythiaStatus!=1) particle.SetDecayed();
559  allocator.AddParticle(particle, source);
560  }
561  else {
562  LogWarning("Hydjet2Hadronizer") << " PYTHIA particle of specie " << pdg << " is not in Hydjet2 particle list" << endl
563  <<" Please define it in particles.data, otherwise the history information will be de-synchronized and lost!";
564  }
565  }
566  } //nhsel !=0 not only hydro!
567 
568 
569  //----------HYDRO part--------------------------------------
570 
571  // get impact parameter
572  double impactParameter = HYFPAR.bgen;
573 
574  // Sergey psiforv3
575  psiforv3 = 0.; //AS-ML Nov2012 epsilon3 //
576  double e3 = (0.2/5.5)*TMath::Power(impactParameter,1./3.);
577  psiforv3 = TMath::TwoPi() * (-0.5 + CLHEP::RandFlat::shoot(hjRandomEngine)) / 3.;
578  SERVICEEV.psiv3 = -psiforv3;
579 
580  if(fNhsel < 3){
581  const double weightMax = 2*TMath::CosH(fUmax);
582  const int nBins = 100;
583  double probList[nBins];
584  RandArrayFunction arrayFunctDistE(nBins);
585  RandArrayFunction arrayFunctDistR(nBins);
586  TLorentzVector partPos, partMom, n1, p0;
587  TVector3 vec3;
588  const TLorentzVector zeroVec;
589  //set maximal hadron energy
590  const double eMax = 5.;
591  //-------------------------------------
592  // get impact parameter
593 
594  double Delta =fDelta;
595  double Epsilon =fEpsilon;
596 
597  if(fIfDeltaEpsilon>0){
598  double Epsilon0 = 0.5*impactParameter; //e0=b/2Ra
599  double coeff = (HYIPAR.RA/fR)/12.;//phenomenological coefficient
600  Epsilon = Epsilon0 * coeff;
601  double C=5.6;
602  double A = C*Epsilon*(1-Epsilon*Epsilon);
603  if(TMath::Abs(Epsilon)<0.0001 || TMath::Abs(A)<0.0001 )Delta=0.0;
604  if(TMath::Abs(Epsilon)>0.0001 && TMath::Abs(A)>0.0001)Delta = 0.5*(TMath::Sqrt(1+4*A*(Epsilon+A))-1)/A;
605 
606  }
607 
608  //effective volume for central
609  double dYl= 2 * fYlmax; //uniform distr. [-Ylmax; Ylmax]
610  if (fEtaType >0) dYl = TMath::Sqrt(2 * TMath::Pi()) * fYlmax ; //Gaussian distr.
611 
612  double VolEffcent = 2 * TMath::Pi() * fTau * dYl * (fR * fR)/TMath::Power((fUmax),2) * ((fUmax)*TMath::SinH((fUmax))-TMath::CosH((fUmax))+ 1);
613 
614  //effective volume for non-central Simpson2
615  double VolEffnoncent = fTau * dYl * SimpsonIntegrator2(0., 2.*TMath::Pi(), Epsilon, Delta);
616 
617  fVolEff = VolEffcent * HYFPAR.npart/HYFPAR.npart0;
618 
619  double coeff_RB = TMath::Sqrt(VolEffcent * HYFPAR.npart/HYFPAR.npart0/VolEffnoncent);
620  double coeff_R1 = HYFPAR.npart/HYFPAR.npart0;
621  coeff_R1 = TMath::Power(coeff_R1, 0.333333);
622 
623  double Veff=fVolEff;
624  //------------------------------------
625  //cycle on particles types
626 
627  double Nbcol = HYFPAR.nbcol;
628  double NccNN = SERVICE.charm;
629  double Ncc = Nbcol * NccNN/dYl;
630  double Nocth = fNocth;
631  double NJPsith = fNccth;
632 
633  double gammaC=1.0;
634  if(fCorrC<=0){
635  gammaC=CharmEnhancementFactor(Ncc, Nocth, NJPsith, 0.001);
636  }else{
637  gammaC=fCorrC;
638  }
639 
640  LogInfo("Hydjet2Hadronizer|Param") <<" gammaC = " <<gammaC;
641 
642  for(int i = 0; i < fNPartTypes; ++i) {
643  double Mparam = fPartMult[2 * i] * Veff;
644  const int encoding = fPartEnc[i];
645 
646  //ml if(abs(encoding)==443)Mparam = Mparam * gammaC * gammaC;
647  //ml if(abs(encoding)==411 || abs(encoding)==421 ||abs(encoding)==413 || abs(encoding)==423
648  //ml || abs(encoding)==4122 || abs(encoding)==431)
649 
650  ParticlePDG *partDef0 = fDatabase->GetPDGParticle(encoding);
651 
652  if(partDef0->GetCharmQNumber()!=0 || partDef0->GetCharmAQNumber()!=0)Mparam = Mparam * gammaC;
653  if(abs(encoding)==443)Mparam = Mparam * gammaC;
654 
655  LogInfo("Hydjet2Hadronizer|Param") <<encoding<<" "<<Mparam/dYl;
656 
657  int multiplicity = CLHEP::RandPoisson::shoot(hjRandomEngine, Mparam);
658 
659  LogInfo("Hydjet2Hadronizer|Param") <<"specie: " << encoding << "; average mult: = " << Mparam << "; multiplicity = " << multiplicity;
660 
661  if (multiplicity > 0) {
662  ParticlePDG *partDef = fDatabase->GetPDGParticle(encoding);
663  if(!partDef) {
664  LogError("Hydjet2Hadronizer") << "No particle with encoding "<< encoding;
665  continue;
666  }
667 
668 
669  if(fCharmProd<=0 && (partDef->GetCharmQNumber()!=0 || partDef->GetCharmAQNumber()!=0)){
670  LogInfo("Hydjet2Hadronizer|Param") <<"statistical charmed particle not allowed ! "<<encoding;
671  continue;
672  }
673  if(partDef->GetCharmQNumber()!=0 || partDef->GetCharmAQNumber()!=0)
674  LogInfo("Hydjet2Hadronizer|Param") <<" charm pdg generated "<< encoding;
675 
676 
677  //compute chemical potential for single f.o. mu==mu_ch
678  //compute chemical potential for thermal f.o.
679  double mu = fPartMu[2 * i];
680 
681  //choose Bose-Einstein or Fermi-Dirac statistics
682  const double d = !(int(2*partDef->GetSpin()) & 1) ? -1 : 1;
683  const double mass = partDef->GetMass();
684 
685  //prepare histogram to sample hadron energy:
686  double h = (eMax - mass) / nBins;
687  double x = mass + 0.5 * h;
688  int i;
689  for(i = 0; i < nBins; ++i) {
690  if(x>=mu && fThFO>0)probList[i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (fThFO)) + d);
691  if(x>=mu && fThFO<=0)probList[i] = x * TMath::Sqrt(x * x - mass * mass) / (TMath::Exp((x - mu) / (fT)) + d);
692  if(x<mu)probList[i] = 0.;
693  x += h;
694  }
695  arrayFunctDistE.PrepareTable(probList);
696 
697  //prepare histogram to sample hadron transverse radius:
698  h = (fR) / nBins;
699  x = 0.5 * h;
700  double param = (fUmax) / (fR);
701  for (i = 0; i < nBins; ++i) {
702  probList[i] = x * TMath::CosH(param*x);
703  x += h;
704  }
705  arrayFunctDistR.PrepareTable(probList);
706 
707  //loop over hadrons, assign hadron coordinates and momenta
708  double weight = 0., yy = 0., px0 = 0., py0 = 0., pz0 = 0.;
709  double e = 0., x0 = 0., y0 = 0., z0 = 0., t0 = 0., etaF = 0.;
710  double r, RB, phiF;
711 
712  RB = fR * coeff_RB * coeff_R1 * TMath::Sqrt((1+e3)/(1-e3));
713 
714  for(int j = 0; j < multiplicity; ++j) {
715  do {
716  fEtaType <=0 ? etaF = fYlmax * (2. * CLHEP::RandFlat::shoot(hjRandomEngine) - 1.) : etaF = (fYlmax) * (CLHEP::RandGauss::shoot(hjRandomEngine));
717  n1.SetXYZT(0.,0.,TMath::SinH(etaF),TMath::CosH(etaF));
718 
719  if(TMath::Abs(etaF)>5.)continue;
720 
721  //old
722  //double RBold = fR * TMath::Sqrt(1-fEpsilon);
723 
724  //RB = fR * coeff_RB * coeff_R1;
725 
726  //double impactParameter =HYFPAR.bgen;
727  //double e0 = 0.5*impactParameter;
728  //double RBold1 = fR * TMath::Sqrt(1-e0);
729 
730  double rho = TMath::Sqrt(CLHEP::RandFlat::shoot(hjRandomEngine));
731  double phi = TMath::TwoPi() * CLHEP::RandFlat::shoot(hjRandomEngine);
732  double Rx = TMath::Sqrt(1-Epsilon)*RB;
733  double Ry = TMath::Sqrt(1+Epsilon)*RB;
734 
735  x0 = Rx * rho * TMath::Cos(phi);
736  y0 = Ry * rho * TMath::Sin(phi);
737  r = TMath::Sqrt(x0*x0+y0*y0);
738  phiF = TMath::Abs(TMath::ATan(y0/x0));
739 
740  if(x0<0&&y0>0)phiF = TMath::Pi()-phiF;
741  if(x0<0&&y0<0)phiF = TMath::Pi()+phiF;
742  if(x0>0&&y0<0)phiF = 2.*TMath::Pi()-phiF;
743 
744  //new Nov2012 AS-ML
745  if(r>RB*(1+e3*TMath::Cos(3*(phiF+psiforv3)))/(1+e3))continue;
746 
747  //proper time with emission duration
748  double tau = coeff_R1 * fTau + sqrt(2.) * fSigmaTau * coeff_R1 * (CLHEP::RandGauss::shoot(hjRandomEngine));
749  z0 = tau * TMath::SinH(etaF);
750  t0 = tau * TMath::CosH(etaF);
751  double rhou = fUmax * r / RB;
752  double rhou3 = 0.063*TMath::Sqrt((0.5*impactParameter)/0.67);
753  double rhou4 = 0.023*((0.5*impactParameter)/0.67);
754  double rrcoeff = 1./TMath::Sqrt(1. + Delta*TMath::Cos(2*phiF));
755 
756  //AS-ML Nov.2012
757  rhou3=0.;
758  //rhou4=0.;
759 
760  rhou = rhou * (1 + rrcoeff*rhou3*TMath::Cos(3*(phiF+psiforv3)) + rrcoeff*rhou4*TMath::Cos(4*phiF) );
761 
762  //ML new suggestion of AS mar2012
763  double delta1 = 0.;
764  Delta = Delta * (1.0 + delta1 * TMath::Cos(phiF) - delta1 * TMath::Cos(3*phiF));
765 
766  double uxf = TMath::SinH(rhou)*TMath::Sqrt(1+Delta)*TMath::Cos(phiF);
767  double uyf = TMath::SinH(rhou)*TMath::Sqrt(1-Delta)*TMath::Sin(phiF);
768  double utf = TMath::CosH(etaF) * TMath::CosH(rhou) *
769  TMath::Sqrt(1+Delta*TMath::Cos(2*phiF)*TMath::TanH(rhou)*TMath::TanH(rhou));
770  double uzf = TMath::SinH(etaF) * TMath::CosH(rhou) *
771  TMath::Sqrt(1+Delta*TMath::Cos(2*phiF)*TMath::TanH(rhou)*TMath::TanH(rhou));
772 
773  vec3.SetXYZ(uxf / utf, uyf / utf, uzf / utf);
774  n1.Boost(-vec3);
775 
776  yy = weightMax * CLHEP::RandFlat::shoot(hjRandomEngine);
777 
778  double php0 = TMath::TwoPi() * CLHEP::RandFlat::shoot(hjRandomEngine);
779  double ctp0 = 2. * CLHEP::RandFlat::shoot(hjRandomEngine) - 1.;
780  double stp0 = TMath::Sqrt(1. - ctp0 * ctp0);
781  e = mass + (eMax - mass) * arrayFunctDistE();
782  double pp0 = TMath::Sqrt(e * e - mass * mass);
783  px0 = pp0 * stp0 * TMath::Sin(php0);
784  py0 = pp0 * stp0 * TMath::Cos(php0);
785  pz0 = pp0 * ctp0;
786  p0.SetXYZT(px0, py0, pz0, e);
787 
788  //weight for rdr
789  weight = (n1 * p0) /e; // weight for rdr gammar: weight = (n1 * p0) / n1[3] / e;
790 
791  } while(yy >= weight);
792 
793  if(abs(z0)>1000 || abs(x0)>1000) LogInfo("Hydjet2Hadronizer|Param") <<" etaF = "<<etaF<<std::endl;
794 
795  partMom.SetXYZT(px0, py0, pz0, e);
796  partPos.SetXYZT(x0, y0, z0, t0);
797  partMom.Boost(vec3);
798 
799  int type =0; //hydro
800  Particle particle(partDef, partPos, partMom, 0., 0, type, -1, zeroVec, zeroVec);
801  particle.SetIndex();
802  allocator.AddParticle(particle, source);
803  } //nhsel==4 , no hydro part
804  }
805  }
806  }
807 
809 
810  Npart = (int)HYFPAR.npart;
811  Bgen = HYFPAR.bgen;
812  Njet = (int)HYJPAR.njet;
813  Nbcol = (int)HYFPAR.nbcol;
814 
815  //if(source.empty()) {
816  // LogError("Hydjet2Hadronizer") << "Source is not initialized!! Trying again...";
817  //return ;
818  //}
819  //Run the decays
821 
822  LPIT_t it;
823  LPIT_t e;
824 
825  //Fill the decayed arrays
826  Ntot = 0; Nhyd=0; Npyt=0;
827  for(it = source.begin(), e = source.end(); it != e; ++it) {
828  TVector3 pos(it->Pos().Vect());
829  TVector3 mom(it->Mom().Vect());
830  float m1 = it->TableMass();
831  pdg[Ntot] = it->Encoding();
832  Mpdg[Ntot] = it->GetLastMotherPdg();
833  Px[Ntot] = mom[0];
834  Py[Ntot] = mom[1];
835  Pz[Ntot] = mom[2];
836  E[Ntot] = TMath::Sqrt(mom.Mag2() + m1*m1);
837  X[Ntot] = pos[0];
838  Y[Ntot] = pos[1];
839  Z[Ntot] = pos[2];
840  T[Ntot] = it->T();
841  type[Ntot] = it->GetType();
842  pythiaStatus[Ntot] = convertStatus(it->GetPythiaStatusCode());
843  Index[Ntot] = it->GetIndex();
844  MotherIndex[Ntot] = it->GetMother();
845  NDaughters[Ntot] = it->GetNDaughters();
847  //index of first daughter
848  FirstDaughterIndex[Ntot] = it->GetFirstDaughterIndex();
849  //index of last daughter
850  LastDaughterIndex[Ntot] = it->GetLastDaughterIndex();
851  if(type[Ntot]==1) { // jets
852  if(pythiaStatus[Ntot]==1 && NDaughters[Ntot]==0){ // code for final state particle in pythia
853  final[Ntot]=1;
854  }else{
855  final[Ntot]=pythiaStatus[Ntot];
856  }
857  }
858  if(type[Ntot]==0) { // hydro
859  if(NDaughters[Ntot]==0)
860  final[Ntot]=1;
861  else
862  final[Ntot]=2;
863  }
864 
865  if(type[Ntot]==0)Nhyd++;
866  if(type[Ntot]==1)Npyt++;
867 
868  Ntot++;
869  if(Ntot > kMax)
870  LogError("Hydjet2Hadronizer") << "Ntot is too large" << Ntot;
871  }
872 
873  nsoft_ = Nhyd;
874  nsub_ = Njet;
875  nhard_ = Npyt;
876 
877  //100 trys
878 
879  ++ntry;
880  }
881  }
882 
883  if(ev==0) {
884  Sigin=HYJPAR.sigin;
885  Sigjet=HYJPAR.sigjet;
886  }
887  ev=1;
888 
889  if(fNhsel < 3) nsub_++;
890 
891  // event information
892  HepMC::GenEvent *evt = new HepMC::GenEvent();
893  if(nhard_>0 || nsoft_>0) get_particles(evt);
894 
895  evt->set_signal_process_id(pypars.msti[0]); // type of the process
896  evt->set_event_scale(pypars.pari[16]); // Q^2
897  add_heavy_ion_rec(evt);
898 
899 
900  event().reset(evt);
901 
903 
904  return kTRUE;
905 }
906 
907 
908 //________________________________________________________________
909 bool Hydjet2Hadronizer::declareStableParticles(const std::vector<int>& _pdg )
910 {
911  std::vector<int> pdg = _pdg;
912  for ( size_t i=0; i < pdg.size(); i++ ) {
913  int pyCode = pycomp_( pdg[i] );
914  std::ostringstream pyCard ;
915  pyCard << "MDCY(" << pyCode << ",1)=0";
916  std::cout << pyCard.str() << std::endl;
917  call_pygive( pyCard.str() );
918  }
919  return true;
920 }
921 //________________________________________________________________
923 {
924  return false;
925 }
927 {
928  return true;
929 }
931 {
932  return true;
933 }
935 {
936 }
938 {
939 }
940 const char* Hydjet2Hadronizer::classname() const
941 {
942  return "gen::Hydjet2Hadronizer";
943 }
944 
945 //----------------------------------------------------------------------------------------------
946 
947 //______________________________________________________________________________________________
948 //f2=f(phi,r)
949 double Hydjet2Hadronizer::f2(double x, double y, double Delta) {
950  LogDebug("f2") <<"in f2: "<<"delta"<<Delta;
951  double RsB = fR; //test: podstavit' *coefff_RB
952  double rhou = fUmax * y / RsB;
953  double ff = y*TMath::CosH(rhou)*
954  TMath::Sqrt(1+Delta*TMath::Cos(2*x)*TMath::TanH(rhou)*TMath::TanH(rhou));
955  //n_mu u^mu f-la 20
956  return ff;
957 }
958 
959 //____________________________________________________________________________________________
960 double Hydjet2Hadronizer::SimpsonIntegrator(double a, double b, double phi, double Delta) {
961  LogDebug("SimpsonIntegrator") <<"in SimpsonIntegrator"<<"delta - "<<Delta;
962  int nsubIntervals=100;
963  double h = (b - a)/nsubIntervals;
964  double s = f2(phi,a + 0.5*h,Delta);
965  double t = 0.5*(f2(phi,a,Delta) + f2(phi,b,Delta));
966  double x = a;
967  double y = a + 0.5*h;
968  for(int i = 1; i < nsubIntervals; i++) {
969  x += h;
970  y += h;
971  s += f2(phi,y,Delta);
972  t += f2(phi,x,Delta);
973  }
974  t += 2.0*s;
975  return t*h/3.0;
976 }
977 
978 //______________________________________________________________________________________________
979 double Hydjet2Hadronizer::SimpsonIntegrator2(double a, double b, double Epsilon, double Delta) {
980 
981  LogInfo("SimpsonIntegrator2") <<"in SimpsonIntegrator2: epsilon - "<<Epsilon<<" delta - "<<Delta;
982  int nsubIntervals=10000;
983  double h = (b - a)/nsubIntervals; //-1-pi, phi
984  double s=0;
985  // double h2 = (fR)/nsubIntervals; //0-R maximal RB ?
986 
987  double x = 0; //phi
988  for(int j = 1; j < nsubIntervals; j++) {
989  x += h; // phi
990  double e = Epsilon;
991  double RsB = fR; //test: podstavit' *coefff_RB
992  double RB = RsB *(TMath::Sqrt(1-e*e)/TMath::Sqrt(1+e*TMath::Cos(2*x))); //f-la7 RB
993  double sr = SimpsonIntegrator(0,RB,x,Delta);
994  s += sr;
995  }
996  return s*h;
997 
998 }
999 
1000 //___________________________________________________________________________________________________
1001 double Hydjet2Hadronizer::MidpointIntegrator2(double a, double b, double Delta, double Epsilon) {
1002 
1003  int nsubIntervals=2000;
1004  int nsubIntervals2=1;
1005  double h = (b - a)/nsubIntervals; //0-pi , phi
1006  double h2 = (fR)/nsubIntervals; //0-R maximal RB ?
1007 
1008  double x = a + 0.5*h;
1009  double y = 0;
1010 
1011  double t = f2(x,y,Delta);
1012 
1013  double e = Epsilon;
1014 
1015  for(int j = 1; j < nsubIntervals; j++) {
1016  x += h; // integr phi
1017 
1018  double RsB = fR; //test: podstavit' *coefff_RB
1019  double RB = RsB *(TMath::Sqrt(1-e*e)/TMath::Sqrt(1+e*TMath::Cos(2*x))); //f-la7 RB
1020 
1021  nsubIntervals2 = int(RB / h2)+1;
1022  // integr R
1023  y=0;
1024  for(int i = 1; i < nsubIntervals2; i++)
1025  t += f2(x,(y += h2),Delta);
1026  }
1027  return t*h*h2;
1028 }
1029 
1030 //__________________________________________________________________________________________________________
1031 double Hydjet2Hadronizer::CharmEnhancementFactor(double Ncc, double Ndth, double NJPsith, double Epsilon) {
1032 
1033  double gammaC=100.;
1034  double x1 = gammaC*Ndth;
1035  double var1 = Ncc-0.5*gammaC*Ndth*TMath::BesselI1(x1)/TMath::BesselI0(x1)-gammaC*gammaC*NJPsith;
1036  LogInfo("Charam") << "gammaC 20"<<" var "<<var1<<endl;
1037  gammaC=1.;
1038  double x0 = gammaC*Ndth;
1039  double var0 = Ncc-0.5*gammaC*Ndth*TMath::BesselI1(x0)/TMath::BesselI0(x0)-gammaC*gammaC*NJPsith;
1040  LogInfo("Charam") << "gammaC 1"<<" var "<<var0;
1041 
1042  for(int i=1; i<1000; i++){
1043  if(var1 * var0<0){
1044  gammaC=gammaC+0.01*i;
1045  double x = gammaC*Ndth;
1046  var0 = Ncc-0.5*gammaC*Ndth*TMath::BesselI1(x)/TMath::BesselI0(x)-gammaC*gammaC*NJPsith;
1047  }
1048  else
1049  {
1050  LogInfo("Charam") << "gammaC "<<gammaC<<" var0 "<<var0;
1051  return gammaC;
1052  }
1053 
1054  }
1055  LogInfo("Charam") << "gammaC not found ? "<<gammaC<<" var0 "<<var0;
1056  return -100;
1057 }
1058 //----------------------------------------------------------------------------------------------
1059 
1060 
1061 
1062 //_____________________________________________________________________
1063 
1064 
1065 
1066 
1067 //________________________________________________________________
1069 {
1070  const double pi = 3.14159265358979;
1071  phi0_ = 2.*pi*gen::pyr_(0) - pi;
1072  sinphi0_ = sin(phi0_);
1073  cosphi0_ = cos(phi0_);
1074 }
1075 
1076 //_____________________________________________________________________
1077 bool Hydjet2Hadronizer::get_particles(HepMC::GenEvent *evt )
1078 {
1079  // Hard particles. The first nhard_ lines from hyjets array.
1080  // Pythia/Pyquen sub-events (sub-collisions) for a given event
1081  // Return T/F if success/failure
1082  // Create particles from lujet entries, assign them into vertices and
1083  // put the vertices in the GenEvent, for each SubEvent
1084  // The SubEvent information is kept by storing indeces of main vertices
1085  // of subevents as a vector in GenHIEvent.
1086  LogDebug("SubEvent")<< "Number of sub events "<<nsub_;
1087  LogDebug("Hydjet2")<<"Number of hard events "<<Njet;
1088  LogDebug("Hydjet2")<<"Number of hard particles "<<nhard_;
1089  LogDebug("Hydjet2")<<"Number of soft particles "<<nsoft_;
1090 
1091  vector<HepMC::GenVertex*> sub_vertices(nsub_);
1092 
1093  int ihy = 0;
1094  for(int isub=0;isub<nsub_;isub++){
1095  LogDebug("SubEvent") <<"Sub Event ID : "<<isub;
1096 
1097  int sub_up = (isub+1)*150000; // Upper limit in mother index, determining the range of Sub-Event
1098  vector<HepMC::GenParticle*> particles;
1099  vector<int> mother_ids;
1100  vector<HepMC::GenVertex*> prods;
1101 
1102  sub_vertices[isub] = new HepMC::GenVertex(HepMC::FourVector(0,0,0,0),isub);
1103  evt->add_vertex(sub_vertices[isub]);
1104 
1105  if(!evt->signal_process_vertex()) evt->set_signal_process_vertex(sub_vertices[isub]);
1106 
1107  while(ihy<nhard_+nsoft_ && (MotherIndex[ihy] < sub_up || ihy > nhard_ )){
1108  particles.push_back(build_hyjet2(ihy,ihy+1));
1109  prods.push_back(build_hyjet2_vertex(ihy,isub));
1110  mother_ids.push_back(MotherIndex[ihy]);
1111  LogDebug("DecayChain")<<"Mother index : "<<MotherIndex[ihy];
1112  ihy++;
1113  }
1114  //Produce Vertices and add them to the GenEvent. Remember that GenParticles are adopted by
1115  //GenVertex and GenVertex is adopted by GenEvent.
1116  LogDebug("Hydjet2")<<"Number of particles in vector "<<particles.size();
1117 
1118  for (unsigned int i = 0; i<particles.size(); i++) {
1119 
1120  HepMC::GenParticle* part = particles[i];
1121  //The Fortran code is modified to preserve mother id info, by seperating the beginning
1122  //mother indices of successive subevents by 5000
1123  int mid = mother_ids[i]-isub*150000-1;
1124  LogDebug("DecayChain")<<"Particle "<<i;
1125  LogDebug("DecayChain")<<"Mother's ID "<<mid;
1126  LogDebug("DecayChain")<<"Particle's PDG ID "<<part->pdg_id();
1127 
1128  if(mid <= 0){
1129 
1130  sub_vertices[isub]->add_particle_out(part);
1131  continue;
1132  }
1133 
1134  if(mid > 0){
1135  HepMC::GenParticle* mother = particles[mid];
1136  LogDebug("DecayChain")<<"Mother's PDG ID "<<mother->pdg_id();
1137  HepMC::GenVertex* prod_vertex = mother->end_vertex();
1138  if(!prod_vertex){
1139  prod_vertex = prods[i];
1140  prod_vertex->add_particle_in(mother);
1141  evt->add_vertex(prod_vertex);
1142  prods[i]=0; // mark to protect deletion
1143  }
1144 
1145  prod_vertex->add_particle_out(part);
1146 
1147  }
1148  }
1149 
1150  // cleanup vertices not assigned to evt
1151  for (unsigned int i = 0; i<prods.size(); i++) {
1152  if(prods[i]) delete prods[i];
1153  }
1154  }
1155 
1156  return kTRUE;
1157 }
1158 
1159 
1160 //___________________________________________________________________
1162 {
1163  // Build particle object corresponding to index in hyjets (soft+hard)
1164 
1165  double px0 = Px[index];
1166  double py0 = Py[index];
1167 
1168  double px = px0*cosphi0_-py0*sinphi0_;
1169  double py = py0*cosphi0_+px0*sinphi0_;
1170 // cout<< "status: "<<convertStatus(final[index], type[index])<<endl;
1172  HepMC::FourVector(
1173  px, // px
1174  py, // py
1175  Pz[index], // pz
1176  E[index]), // E
1177  pdg[index], // id
1178  convertStatusForComponents(final[index], type[index])// status
1179 
1180  );
1181 
1182  p->suggest_barcode(barcode);
1183  return p;
1184 }
1185 
1186 //___________________________________________________________________
1187 HepMC::GenVertex* Hydjet2Hadronizer::build_hyjet2_vertex(int i,int id)
1188 {
1189  // build verteces for the hyjets stored events
1190 
1191  double x0=X[i];
1192  double y0=Y[i];
1193  double x = x0*cosphi0_-y0*sinphi0_;
1194  double y = y0*cosphi0_+x0*sinphi0_;
1195  double z=Z[i];
1196  double t=T[i];
1197 
1198  HepMC::GenVertex* vertex = new HepMC::GenVertex(HepMC::FourVector(x,y,z,t),id);
1199  return vertex;
1200 }
1201 
1202 //_____________________________________________________________________
1204 {
1205  // heavy ion record in the final CMSSW Event
1206  double npart = Npart;
1207  int nproj = static_cast<int>(npart / 2);
1208  int ntarg = static_cast<int>(npart - nproj);
1209 
1210  HepMC::HeavyIon* hi = new HepMC::HeavyIon(
1211  nsub_, // Ncoll_hard/N of SubEvents
1212  nproj, // Npart_proj
1213  ntarg, // Npart_targ
1214  Nbcol, // Ncoll
1215  0, // spectator_neutrons
1216  0, // spectator_protons
1217  0, // N_Nwounded_collisions
1218  0, // Nwounded_N_collisions
1219  0, // Nwounded_Nwounded_collisions
1220  Bgen * nuclear_radius(), // impact_parameter in [fm]
1221  phi0_, // event_plane_angle
1222  0, // eccentricity
1223  Sigin // sigma_inel_NN
1224  );
1225 
1226  evt->set_heavy_ion(*hi);
1227  delete hi;
1228 }
1229 
1230 
1231 
1232 
#define LogDebug(id)
const double TwoPi
const double Pi
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void SetBaryonPotential(double value)
bool declareStableParticles(const std::vector< int > &)
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:222
#define HYPYIN
Definition: HYJET_COMMONS.h:86
int GetNParticles(bool all=kFALSE)
Definition: DatabasePDG.cc:574
double ParticleNumberDensity(ParticlePDG *particle)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
ParticleAllocator allocator
#define HYJPAR
Definition: HYJET_COMMONS.h:70
#define PYQPAR
TString RunInputHYDJETstr
int GetPDG()
Definition: ParticlePDG.h:67
void add_heavy_ion_rec(HepMC::GenEvent *evt)
#define HYPART
unsigned int pythiaPylistVerbosity_
double SimpsonIntegrator2(double, double, double, double)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double BesselI0(double x)
bool call_pygive(const std::string &line)
double CalculateStrangePotential()
Definition: weight.py:1
double npart
Definition: HydjetWrapper.h:49
bool ev
double MidpointIntegrator2(double, double, double, double)
double SimpsonIntegrator(double, double, double, double)
#define SERVICEEV
Definition: HYJET_COMMONS.h:53
double f2(double, double, double)
double v[5][pyjets_maxn]
std::auto_ptr< HepMC::GenEvent > & event()
double GetCharmAQNumber()
Definition: ParticlePDG.h:79
static std::string const input
Definition: EdmProvDump.cc:44
double nuclear_radius() const
#define HYFPAR
const Double_t pi
static const std::string kPythia6
virtual double GetWeakDecayLimit() override
HepMC::GenVertex * build_hyjet2_vertex(int i, int id)
double GetSpin()
Definition: ParticlePDG.h:71
void PrepareTable(const double *aProbFunc)
Pythia6Service * pythia6Service_
double p[5][pyjets_maxn]
ParticlePDG * GetPDGParticleByIndex(int index)
Definition: DatabasePDG.cc:202
std::vector< vec2 > vec3
Definition: HCALResponse.h:17
double GetCharmness()
Definition: ParticlePDG.h:83
void FreeList(List_t &list)
Definition: Particle.cc:122
bool get_particles(HepMC::GenEvent *evt)
void hyevnt_()
double GetElectricCharge()
Definition: ParticlePDG.h:84
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T Abs(T a)
Definition: MathUtil.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double CharmEnhancementFactor(double, double, double, double)
const int mu
Definition: Constants.h:22
virtual bool RunDecays() override
double GetBaryonNumber()
Definition: ParticlePDG.h:80
virtual void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:464
CLHEP::HepRandomEngine * hjRandomEngine
double GetStrangeness()
Definition: ParticlePDG.h:82
#define HYIPAR
Definition: HYJET_COMMONS.h:27
virtual void Evolve(List_t &secondaries, ParticleAllocator &allocator, double weakDecayLimit)
Definition: InitialState.cc:13
static int fLastIndex
Definition: Particle.h:38
static void InitIndexing()
Definition: Particle.h:103
#define SERVICE
Definition: HYJET_COMMONS.h:39
const char * classname() const
static const std::string kFortranInstance
int pycomp_(int &)
#define pypars
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
void myini_()
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
HepMC::GenParticle * build_hyjet2(int index, int barcode)
void setRandomEngine(CLHEP::HepRandomEngine *v)
HLT enums.
double GetCharmQNumber()
Definition: ParticlePDG.h:78
DatabasePDG * fDatabase
Definition: InitialState.h:16
void SetTemperature(double value)
double GetMass()
Definition: ParticlePDG.h:68
double BesselI1(double x)
double a
Definition: hdecay.h:121
double ppart[150000][20]
#define kMax
void AddParticle(const Particle &particle, List_t &list)
Definition: Particle.cc:109
def convertStatus(status)
Definition: crabWrap.py:174
std::list< Particle >::iterator LPIT_t
Definition: Particle.h:142
double pyr_(int *idummy)
long double T
edm::Event & getEDMEvent() const