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