CMS 3D CMS Logo

AMPTHadronizer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 
4 #include "boost/lexical_cast.hpp"
5 
10 
13 
17 
18 #include "HepMC/GenEvent.h"
19 #include "HepMC/HeavyIon.h"
20 #include "HepMC/SimpleVector.h"
21 #include "CLHEP/Random/RandomEngine.h"
22 
23 static const double pi = 3.14159265358979;
24 
25 using namespace edm;
26 using namespace std;
27 using namespace gen;
28 
29 static CLHEP::HepRandomEngine* amptRandomEngine;
30 
31 extern "C" {
32 float gen::ranart_(int*) {
33  float rannum = amptRandomEngine->flat();
34  return rannum;
35 }
36 }
37 
38 extern "C" {
39 float gen::ran1_(int*) { return amptRandomEngine->flat(); }
40 }
41 
42 AMPTHadronizer::AMPTHadronizer(const ParameterSet& pset)
44  evt(nullptr),
45  pset_(pset),
46  bmax_(pset.getParameter<double>("bMax")),
47  bmin_(pset.getParameter<double>("bMin")),
48  efrm_(pset.getParameter<double>("comEnergy")),
49  frame_(pset.getParameter<string>("frame")),
50  proj_(pset.getParameter<string>("proj")),
51  targ_(pset.getParameter<string>("targ")),
52  iap_(pset.getParameter<int>("iap")),
53  izp_(pset.getParameter<int>("izp")),
54  iat_(pset.getParameter<int>("iat")),
55  izt_(pset.getParameter<int>("izt")),
56  amptmode_(pset.getParameter<int>("amptmode")),
57  ntmax_(pset.getParameter<int>("ntmax")),
58  dt_(pset.getParameter<double>("dt")),
59  stringFragA_(pset.getParameter<double>("stringFragA")),
60  stringFragB_(pset.getParameter<double>("stringFragB")),
61  popcornmode_(pset.getParameter<bool>("popcornmode")),
62  popcornpar_(pset.getParameter<double>("popcornpar")),
63  shadowingmode_(pset.getParameter<bool>("shadowingmode")),
64  quenchingmode_(pset.getParameter<bool>("quenchingmode")),
65  quenchingpar_(pset.getParameter<double>("quenchingpar")),
66  pthard_(pset.getParameter<double>("pthard")),
67  mu_(pset.getParameter<double>("mu")),
68  izpc_(pset.getParameter<int>("izpc")),
69  alpha_(pset.getParameter<double>("alpha")),
70  dpcoal_(pset.getParameter<double>("dpcoal")),
71  drcoal_(pset.getParameter<double>("drcoal")),
72  ks0decay_(pset.getParameter<bool>("ks0decay")),
73  phidecay_(pset.getParameter<bool>("phidecay")),
74  deuteronmode_(pset.getParameter<int>("deuteronmode")),
75  deuteronfactor_(pset.getParameter<int>("deuteronfactor")),
76  deuteronxsec_(pset.getParameter<int>("deuteronxsec")),
77  minijetpt_(pset.getParameter<double>("minijetpt")),
78  maxmiss_(pset.getParameter<int>("maxmiss")),
79  doInitialAndFinalRadiation_(pset.getParameter<int>("doInitialAndFinalRadiation")),
80  ktkick_(pset.getParameter<int>("ktkick")),
81  diquarkembedding_(pset.getParameter<int>("diquarkembedding")),
82  diquarkpx_(pset.getParameter<double>("diquarkpx")),
83  diquarkpy_(pset.getParameter<double>("diquarkpy")),
84  diquarkx_(pset.getParameter<double>("diquarkx")),
85  diquarky_(pset.getParameter<double>("diquarky")),
86  phi0_(0.),
87  sinphi0_(0.),
88  cosphi0_(1.),
89  rotate_(pset.getParameter<bool>("rotateEventPlane")) {}
90 
91 //_____________________________________________________________________
93 
94 //_____________________________________________________________________
95 void AMPTHadronizer::doSetRandomEngine(CLHEP::HepRandomEngine* v) { amptRandomEngine = v; }
96 
97 //_____________________________________________________________________
99  // heavy ion record in the final CMSSW Event
100  HepMC::HeavyIon* hi = new HepMC::HeavyIon(hmain1.jatt, // Ncoll_hard/N of SubEvents
101  hmain1.np, // Npart_proj
102  hmain1.nt, // Npart_targ
103  hmain1.n0 + hmain1.n01 + hmain1.n10 + hmain1.n11, // Ncoll
104  0, // spectator_neutrons
105  0, // spectator_protons
106  hmain1.n01, // N_Nwounded_collisions
107  hmain1.n10, // Nwounded_N_collisions
108  hmain1.n11, // Nwounded_Nwounded_collisions
109  hparnt.hint1[18], // impact_parameter in [fm]
110  phi0_, // event_plane_angle
111  0, // eccentricity
112  hparnt.hint1[11] // sigma_inel_NN
113  );
114  evt->set_heavy_ion(*hi);
115  delete hi;
116 }
117 
118 //___________________________________________________________________
120  // Build particle object corresponding to index in ampt
121 
122  float px0 = hbt.plast[index][0];
123  float py0 = hbt.plast[index][1];
124  float pz0 = hbt.plast[index][2];
125  float m = hbt.plast[index][3];
126 
127  float px = px0 * cosphi0_ - py0 * sinphi0_;
128  float py = py0 * cosphi0_ + px0 * sinphi0_;
129  float pz = pz0;
130  float e = sqrt(px * px + py * py + pz * pz + m * m);
131  int status = 1;
132 
133  HepMC::GenParticle* p = new HepMC::GenParticle(HepMC::FourVector(px, py, pz, e),
134  INVFLV(hbt.lblast[index]), // id
135  status // status
136  );
137 
138  p->suggest_barcode(barcode);
139  return p;
140 }
141 
142 //___________________________________________________________________
143 HepMC::GenVertex* AMPTHadronizer::build_ampt_vertex(int i, int id) {
144  // build verteces for the ampt stored events
145  HepMC::GenVertex* vertex = new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0), id);
146  return vertex;
147 }
148 //_____________________________________________________________________
150  // generate single event
151  if (rotate_)
152  rotateEvtPlane();
153 
154  // generate a AMPT event
155  AMPT(frame_.data(), bmin_, bmax_, strlen(frame_.data()));
156 
157  // event information
160 
162 
163  event().reset(evt);
164 
165  return true;
166 }
167 
168 //_____________________________________________________________________
170  HepMC::GenVertex* vertice;
171 
172  vector<HepMC::GenParticle*> particles;
173  vector<int> mother_ids;
174  vector<HepMC::GenVertex*> prods;
175 
176  vertice = new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0), 0);
177  evt->add_vertex(vertice);
178  if (!evt->signal_process_vertex())
179  evt->set_signal_process_vertex(vertice);
180 
181  const unsigned int knumpart = hbt.nlast;
182  for (unsigned int ipart = 0; ipart < knumpart; ipart++) {
183  int mid = 0;
184  particles.push_back(build_ampt(ipart, ipart + 1));
185  prods.push_back(build_ampt_vertex(ipart, 0));
186  mother_ids.push_back(mid);
187  LogDebug("DecayChain") << "Mother index : " << mid;
188  }
189 
190  LogDebug("AMPT") << "Number of particles in vector " << particles.size();
191 
192  for (unsigned int ipart = 0; ipart < particles.size(); ipart++) {
194 
195  int mid = mother_ids[ipart];
196  LogDebug("DecayChain") << "Particle " << ipart;
197  LogDebug("DecayChain") << "Mother's ID " << mid;
198  LogDebug("DecayChain") << "Particle's PDG ID " << part->pdg_id();
199 
200  if (mid <= 0) {
201  vertice->add_particle_out(part);
202  continue;
203  }
204 
205  if (mid > 0) {
206  HepMC::GenParticle* mother = particles[mid];
207  LogDebug("DecayChain") << "Mother's PDG ID " << mother->pdg_id();
208 
209  HepMC::GenVertex* prod_vertex = mother->end_vertex();
210  if (!prod_vertex) {
211  prod_vertex = prods[ipart];
212  prod_vertex->add_particle_in(mother);
213  evt->add_vertex(prod_vertex);
214  prods[ipart] = nullptr; // mark to protect deletion
215  }
216  prod_vertex->add_particle_out(part);
217  }
218  }
219 
220  // cleanup vertices not assigned to evt
221  for (unsigned int i = 0; i < prods.size(); i++) {
222  if (prods[i])
223  delete prods[i];
224  }
225 
226  return true;
227 }
228 
229 //_____________________________________________________________________
231  double efrm, std::string frame, std::string proj, std::string targ, int iap, int izp, int iat, int izt) {
232  // initialize hydjet
233  AMPTSET(efrm,
234  frame.data(),
235  proj.data(),
236  targ.data(),
237  iap,
238  izp,
239  iat,
240  izt,
241  strlen(frame.data()),
242  strlen(proj.data()),
243  strlen(targ.data()));
244  return true;
245 }
246 //______________________________________________________________________
248  anim.isoft = amptmode_;
249  input2.ntmax = ntmax_;
250  input1.dt = dt_;
251  ludat1.parj[40] = stringFragA_;
252  ludat1.parj[41] = stringFragB_;
253  popcorn.ipop = popcornmode_;
254  ludat1.parj[4] = popcornpar_;
255  hparnt.ihpr2[5] = shadowingmode_;
256  hparnt.ihpr2[3] = quenchingmode_;
257  hparnt.hipr1[13] = quenchingpar_;
258  hparnt.hipr1[7] = pthard_;
259  para2.xmu = mu_;
260  anim.izpc = izpc_;
261  para2.alpha = alpha_;
262  coal.dpcoal = dpcoal_;
263  coal.drcoal = drcoal_;
264  resdcy.iksdcy = ks0decay_;
265  phidcy.iphidcy = phidecay_;
266  para8.idpert = deuteronmode_;
267  para8.npertd = deuteronfactor_;
268  para8.idxsec = deuteronxsec_;
269  phidcy.pttrig = minijetpt_;
270  phidcy.maxmiss = maxmiss_;
272  hparnt.ihpr2[4] = ktkick_;
273  embed.iembed = diquarkembedding_;
274  embed.pxqembd = diquarkpx_;
275  embed.pyqembd = diquarkpy_;
276  embed.xembd = diquarkx_;
277  embed.yembd = diquarky_;
278 
279  return true;
280 }
281 
282 //_____________________________________________________________________
284  // ampt running options
285  ampt_init(pset_);
286 
287  // initialize ampt
288  LogInfo("AMPTinAction") << "##### Calling AMPTSET(" << efrm_ << "," << frame_ << "," << proj_ << "," << targ_ << ","
289  << iap_ << "," << izp_ << "," << iat_ << "," << izt_ << ") ####";
290 
292 
293  return true;
294 }
295 
296 bool AMPTHadronizer::declareStableParticles(const std::vector<int>& pdg) { return true; }
297 
298 //________________________________________________________________
300  int zero = 0;
301  double test = (double)gen::ranart_(&zero);
302  phi0_ = 2. * pi * test - pi;
303  sinphi0_ = sin(phi0_);
304  cosphi0_ = cos(phi0_);
305 }
306 
307 //________________________________________________________________
308 bool AMPTHadronizer::hadronize() { return false; }
309 
310 bool AMPTHadronizer::decay() { return true; }
311 
312 bool AMPTHadronizer::residualDecay() { return true; }
313 
315 
316 void AMPTHadronizer::statistics() { return; }
317 
318 const char* AMPTHadronizer::classname() const { return "gen::AMPTHadronizer"; }
INVFLV
#define INVFLV
Definition: AMPTWrapper.h:34
embed
#define embed
Definition: AMPTWrapper.h:188
gen::AMPTHadronizer::add_heavy_ion_rec
void add_heavy_ion_rec(HepMC::GenEvent *evt)
Definition: AMPTHadronizer.cc:98
gen::AMPTHadronizer::quenchingpar_
double quenchingpar_
Definition: AMPTHadronizer.h:87
gen::AMPTHadronizer::finalizeEvent
void finalizeEvent()
Definition: AMPTHadronizer.cc:314
phidcy
#define phidcy
Definition: AMPTWrapper.h:177
amptDefault_cfi.iap
iap
Definition: amptDefault_cfi.py:15
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
gen::AMPTHadronizer::diquarky_
double diquarky_
Definition: AMPTHadronizer.h:107
MessageLogger.h
gen::AMPTHadronizer::declareStableParticles
bool declareStableParticles(const std::vector< int > &)
Definition: AMPTHadronizer.cc:296
gen::AMPTHadronizer::proj_
std::string proj_
Definition: AMPTHadronizer.h:72
gen::AMPTHadronizer::phi0_
double phi0_
Definition: AMPTHadronizer.h:113
gen::AMPTHadronizer::amptmode_
int amptmode_
Definition: AMPTHadronizer.h:78
gen::AMPTHadronizer::deuteronxsec_
int deuteronxsec_
Definition: AMPTHadronizer.h:98
mps_update.status
status
Definition: mps_update.py:69
gen::AMPTHadronizer::frame_
std::string frame_
Definition: AMPTHadronizer.h:71
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
gen::AMPTHadronizer::doSetRandomEngine
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
Definition: AMPTHadronizer.cc:95
gen::AMPTHadronizer::izpc_
int izpc_
Definition: AMPTHadronizer.h:90
pi
static const double pi
Definition: AMPTHadronizer.cc:23
gen::AMPTHadronizer::classname
const char * classname() const
Definition: AMPTHadronizer.cc:318
resdcy
#define resdcy
Definition: AMPTWrapper.h:167
gen::AMPTHadronizer::iap_
int iap_
Definition: AMPTHadronizer.h:74
amptDefault_cfi.izt
izt
Definition: amptDefault_cfi.py:18
gen::AMPTHadronizer::~AMPTHadronizer
~AMPTHadronizer() override
Definition: AMPTHadronizer.cc:92
AMPTSET
#define AMPTSET
Definition: AMPTWrapper.h:24
gen::AMPTHadronizer::pthard_
double pthard_
Definition: AMPTHadronizer.h:88
gen::AMPTHadronizer::izp_
int izp_
Definition: AMPTHadronizer.h:75
gen::AMPTHadronizer::shadowingmode_
bool shadowingmode_
Definition: AMPTHadronizer.h:85
SiPixelPI::zero
Definition: SiPixelPayloadInspectorHelper.h:39
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
gen::AMPTHadronizer::deuteronfactor_
int deuteronfactor_
Definition: AMPTHadronizer.h:97
gen::AMPTHadronizer::alpha_
double alpha_
Definition: AMPTHadronizer.h:91
gen::BaseHadronizer
Definition: BaseHadronizer.h:46
GenRunInfoProduct.h
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
gen::AMPTHadronizer::diquarkpx_
double diquarkpx_
Definition: AMPTHadronizer.h:104
gen::AMPTHadronizer::cosphi0_
double cosphi0_
Definition: AMPTHadronizer.h:115
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
popcorn
#define popcorn
Definition: AMPTWrapper.h:193
ludat1
#define ludat1
Definition: AMPTWrapper.h:80
gen::AMPTHadronizer::rotate_
bool rotate_
Definition: AMPTHadronizer.h:116
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
gen::AMPTHadronizer::dt_
double dt_
Definition: AMPTHadronizer.h:80
AMPTWrapper.h
AMPTHadronizer.h
gen::AMPTHadronizer::bmin_
double bmin_
Definition: AMPTHadronizer.h:68
test
Definition: SmallWORMDict.h:13
part
part
Definition: HCALResponse.h:20
gen::AMPTHadronizer::popcornmode_
bool popcornmode_
Definition: AMPTHadronizer.h:83
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
gen::AMPTHadronizer::build_ampt_vertex
HepMC::GenVertex * build_ampt_vertex(int i, int id)
Definition: AMPTHadronizer.cc:143
gen::p
double p[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
gen::AMPTHadronizer::ntmax_
int ntmax_
Definition: AMPTHadronizer.h:79
gen::AMPTHadronizer::diquarkx_
double diquarkx_
Definition: AMPTHadronizer.h:106
Run.h
gen::AMPTHadronizer::rotateEvtPlane
void rotateEvtPlane()
Definition: AMPTHadronizer.cc:299
gen::AMPTHadronizer::diquarkembedding_
int diquarkembedding_
Definition: AMPTHadronizer.h:103
gen::AMPTHadronizer::bmax_
double bmax_
Definition: AMPTHadronizer.h:66
gen::AMPTHadronizer::targ_
std::string targ_
Definition: AMPTHadronizer.h:73
gen
Definition: PythiaDecays.h:13
gen::AMPTHadronizer::ampt_init
bool ampt_init(const edm::ParameterSet &pset)
Definition: AMPTHadronizer.cc:247
gen::AMPTHadronizer::build_ampt
HepMC::GenParticle * build_ampt(int index, int barcode)
Definition: AMPTHadronizer.cc:119
gen::AMPTHadronizer::residualDecay
bool residualDecay()
Definition: AMPTHadronizer.cc:312
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
gen::AMPTHadronizer::pset_
edm::ParameterSet pset_
Definition: AMPTHadronizer.h:65
edm::ParameterSet
Definition: ParameterSet.h:47
gen::AMPTHadronizer::quenchingmode_
bool quenchingmode_
Definition: AMPTHadronizer.h:86
GenEventInfoProduct.h
Event.h
gen::AMPTHadronizer::drcoal_
double drcoal_
Definition: AMPTHadronizer.h:93
para2
#define para2
Definition: AMPTWrapper.h:110
gen::AMPTHadronizer::diquarkpy_
double diquarkpy_
Definition: AMPTHadronizer.h:105
gen::AMPTHadronizer::evt
HepMC::GenEvent * evt
Definition: AMPTHadronizer.h:64
gen::AMPTHadronizer::ktkick_
int ktkick_
Definition: AMPTHadronizer.h:102
gen::v
double v[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
createfilelist.int
int
Definition: createfilelist.py:10
gen::AMPTHadronizer::statistics
void statistics()
Definition: AMPTHadronizer.cc:316
gen::AMPTHadronizer::initializeForInternalPartons
bool initializeForInternalPartons()
Definition: AMPTHadronizer.cc:283
gen::AMPTHadronizer::decay
bool decay()
Definition: AMPTHadronizer.cc:310
amptDefault_cfi.iat
iat
Definition: amptDefault_cfi.py:17
gen::AMPTHadronizer::popcornpar_
double popcornpar_
Definition: AMPTHadronizer.h:84
amptRandomEngine
static CLHEP::HepRandomEngine * amptRandomEngine
Definition: AMPTHadronizer.cc:29
coal
#define coal
Definition: AMPTWrapper.h:99
gen::AMPTHadronizer::get_particles
bool get_particles(HepMC::GenEvent *evt)
Definition: AMPTHadronizer.cc:169
hmain1
#define hmain1
Definition: AMPTWrapper.h:50
input2
#define input2
Definition: AMPTWrapper.h:159
gen::AMPTHadronizer::stringFragB_
double stringFragB_
Definition: AMPTHadronizer.h:82
gen::AMPTHadronizer::efrm_
double efrm_
Definition: AMPTHadronizer.h:70
gen::AMPTHadronizer::iat_
int iat_
Definition: AMPTHadronizer.h:76
gen::ran1_
float ran1_(int *)
Definition: AMPTHadronizer.cc:39
gen::AMPTHadronizer::mu_
double mu_
Definition: AMPTHadronizer.h:89
hi
Definition: EPCuts.h:4
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
gen::AMPTHadronizer::izt_
int izt_
Definition: AMPTHadronizer.h:77
hbt
#define hbt
Definition: AMPTWrapper.h:60
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
std
Definition: JetResolutionObject.h:76
gen::BaseHadronizer::event
std::unique_ptr< HepMC::GenEvent > & event()
Definition: BaseHadronizer.h:86
gen::AMPTHadronizer::maxmiss_
int maxmiss_
Definition: AMPTHadronizer.h:100
gen::AMPTHadronizer::hadronize
bool hadronize()
Definition: AMPTHadronizer.cc:308
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
gen::AMPTHadronizer::stringFragA_
double stringFragA_
Definition: AMPTHadronizer.h:81
gen::AMPTHadronizer::generatePartonsAndHadronize
bool generatePartonsAndHadronize()
Definition: AMPTHadronizer.cc:149
pdg
Definition: pdg_functions.h:28
hparnt
#define hparnt
Definition: AMPTWrapper.h:70
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
gen::AMPTHadronizer::dpcoal_
double dpcoal_
Definition: AMPTHadronizer.h:92
amptDefault_cfi.izp
izp
Definition: amptDefault_cfi.py:16
gen::ranart_
float ranart_(int *)
Definition: AMPTHadronizer.cc:32
ParameterSet.h
input1
#define input1
Definition: AMPTWrapper.h:139
HepMCProduct.h
amptDefault_cfi.targ
targ
Definition: amptDefault_cfi.py:14
para8
#define para8
Definition: AMPTWrapper.h:128
gen::AMPTHadronizer::ks0decay_
bool ks0decay_
Definition: AMPTHadronizer.h:94
gen::AMPTHadronizer::minijetpt_
double minijetpt_
Definition: AMPTHadronizer.h:99
AMPT
#define AMPT
Definition: AMPTWrapper.h:29
gen::AMPTHadronizer::doInitialAndFinalRadiation_
int doInitialAndFinalRadiation_
Definition: AMPTHadronizer.h:101
gen::AMPTHadronizer::sinphi0_
double sinphi0_
Definition: AMPTHadronizer.h:114
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
anim
#define anim
Definition: AMPTWrapper.h:90
gen::AMPTHadronizer::call_amptset
bool call_amptset(double efrm, std::string frame, std::string proj, std::string targ, int iap, int izp, int iat, int izt)
Definition: AMPTHadronizer.cc:230
gen::AMPTHadronizer::deuteronmode_
int deuteronmode_
Definition: AMPTHadronizer.h:96
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
gen::AMPTHadronizer::phidecay_
bool phidecay_
Definition: AMPTHadronizer.h:95