7 #include <TLorentzVector.h> 26 #include "HepMC/GenEvent.h" 27 #include "HepMC/HeavyIon.h" 28 #include "HepMC/IO_HEPEVT.h" 29 #include "HepMC/PythiaWrapper6_4.h" 30 #include "HepMC/SimpleVector.h" 43 int Hydjet2Hadronizer::convertStatusForComponents(
int sta,
int typ,
int pySta) {
48 st = convertStatus(pySta);
51 throw cms::Exception(
"ConvertStatus") <<
"Wrong status code!" << endl;
53 if (separateHydjetComponents_) {
54 if (st == 1 && typ == 0)
56 if (st == 1 && typ == 1)
58 if (st == 2 && typ == 0)
60 if (st == 2 && typ == 1)
66 int Hydjet2Hadronizer::convertStatus(
int st) {
84 rotate_(
pset.getParameter<
bool>(
"rotateEventPlane")),
97 fParams.allowEmptyEvent =
false;
169 strcpy(
fParams.partDat, (
f1.fullPath()).c_str());
172 strcpy(
fParams.tabDecay, (
f2.fullPath()).c_str());
182 LogDebug(
"EventSignalVertex") <<
"Setting event signal vertex " 221 LogInfo(
"Hydjet2Hadronizer|GenSeed") <<
"Seed for random number generation: " 233 LogInfo(
"Hydjet2Hadronizer|RAScaling") <<
"Nuclear radius(RA) = " << ra;
250 HepMC::GenVertex *genvtx =
nullptr;
253 e.getByToken(
src_, cf);
255 if (
mix.size() < 1) {
256 throw cms::Exception(
"MatchVtx") <<
"Mixing has " <<
mix.size() <<
" sub-events, should have been at least 1" 261 throw cms::Exception(
"MatchVtx") <<
"Input background does not have smeared vertex!" << endl;
266 genvtx = inev->signal_process_vertex();
269 throw cms::Exception(
"MatchVtx") <<
"Input background does not have signal process vertex!" << endl;
271 double aX, aY, aZ, aT;
273 aX = genvtx->position().x();
274 aY = genvtx->position().y();
275 aZ = genvtx->position().z();
276 aT = genvtx->position().t();
281 LogInfo(
"MatchVtx") <<
" setting vertex " 282 <<
" aX " << aX <<
" aY " << aY <<
" aZ " << aZ <<
" aT " << aT << endl;
285 const HepMC::HeavyIon *
hi = inev->heavy_ion();
289 phi0_ =
hi->event_plane_angle();
293 LogWarning(
"EventEmbedding") <<
"Background event does not have heavy ion record!";
307 LogError(
"Hydjet2EmptyEvent") <<
"##### HYDJET2: No Particles generated, Number of tries =" << ntry;
310 std::ostringstream sstr;
311 sstr <<
"Hydjet2HadronizerProducer: No particles generated after " << ntry <<
" tries.\n";
317 if (
hj2->IsEmpty()) {
340 std::unique_ptr<HepMC::GenEvent>
evt = std::make_unique<HepMC::GenEvent>();
341 std::unique_ptr<edm::HepMCProduct> HepMCEvt = std::make_unique<edm::HepMCProduct>();
346 evt->set_signal_process_id(
pypars.msti[0]);
353 HepMCEvt = std::make_unique<edm::HepMCProduct>(
evt.get());
355 evt = std::make_unique<HepMC::GenEvent>(*HepMCEvt->GetEvent());
358 HepMC::HEPEVT_Wrapper::check_hepevt_consistency();
359 LogDebug(
"HEPEVT_info") <<
"Ev numb: " << HepMC::HEPEVT_Wrapper::event_number()
360 <<
" Entries number: " << HepMC::HEPEVT_Wrapper::number_entries() <<
" Max. entries " 361 << HepMC::HEPEVT_Wrapper::max_number_entries() << std::endl;
369 std::vector<int>
pdg = _pdg;
370 for (
size_t i = 0;
i <
pdg.size();
i++) {
372 std::ostringstream pyCard;
373 pyCard <<
"MDCY(" << pyCode <<
",1)=0";
389 const double pi = 3.14159265358979;
398 LogDebug(
"Hydjet2") <<
" Number of hard events " <<
hj2->GetNjet();
407 vector<HepMC::GenParticle *> particle(
hj2->GetNtot());
408 HepMC::GenVertex *sub_vertices =
nullptr;
410 while (ihy < hj2->GetNtot()) {
411 if ((
hj2->GetiJet().at(ihy)) != isub_l) {
412 sub_vertices =
new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0),
hj2->GetiJet().at(ihy));
413 evt->add_vertex(sub_vertices);
414 if (!
evt->signal_process_vertex())
415 evt->set_signal_process_vertex(sub_vertices);
416 isub_l =
hj2->GetiJet().at(ihy);
420 (
hj2->GetFinal()).at(ihy), (
hj2->GetType()).at(ihy), (
hj2->GetPythiaStatus().at(ihy)))) == 1)
422 LogDebug(
"Hydjet2_array") << ihy <<
" MULTin ev.:" <<
hj2->GetNtot() <<
" SubEv.#" <<
hj2->GetiJet().at(ihy)
423 <<
" Part #" << ihy + 1 <<
", PDG: " <<
hj2->GetPdg().at(ihy) <<
" (st. " 425 <<
") mother=" <<
hj2->GetMotherIndex().at(ihy) + 1 <<
", childs (" 426 <<
hj2->GetFirstDaughterIndex().at(ihy) + 1 <<
"-" 427 <<
hj2->GetLastDaughterIndex().at(ihy) + 1 <<
"), vtx (" <<
hj2->GetX().at(ihy) <<
"," 428 <<
hj2->GetY().at(ihy) <<
"," <<
hj2->GetZ().at(ihy) <<
") " << std::endl;
430 if ((
hj2->GetMotherIndex().at(ihy)) <= 0) {
433 LogError(
"Hydjet2_array") <<
"##### HYDJET2: Vertex not initialized!";
435 sub_vertices->add_particle_out(particle.at(ihy));
436 LogDebug(
"Hydjet2_array") <<
" ---> " << ihy + 1 << std::endl;
439 int mid =
hj2->GetMotherIndex().at(ihy);
441 while (((mid + 1) < ihy) && (
std::abs(
hj2->GetPdg().at(mid)) < 100) &&
442 ((
hj2->GetFirstDaughterIndex().at(mid + 1)) <= ihy)) {
444 LogDebug(
"Hydjet2_array") <<
"======== MID changed to " << mid
445 <<
" ======== PDG(mid) = " <<
hj2->GetPdg().at(mid) << std::endl;
449 mid =
hj2->GetMotherIndex().at(ihy);
450 LogDebug(
"Hydjet2_array") <<
"======== MID changed BACK to " << mid
451 <<
" ======== PDG(mid) = " <<
hj2->GetPdg().at(mid) << std::endl;
455 HepMC::GenVertex *prod_vertex = mother->end_vertex();
459 prod_vertex->add_particle_in(mother);
460 LogDebug(
"Hydjet2_array") <<
" <--- " << mid + 1 << std::endl;
461 evt->add_vertex(prod_vertex);
463 prod_vertex->add_particle_out(particle.at(ihy));
464 LogDebug(
"Hydjet2_array") <<
" ---" << mid + 1 <<
"---> " << ihy + 1 << std::endl;
469 LogDebug(
"Hydjet2_array") <<
" MULTin ev.:" <<
hj2->GetNtot() <<
", last index: " << ihy - 1
470 <<
", stable particles: " << stab << std::endl;
477 double px0 = (
hj2->GetPx()).at(
index);
478 double py0 = (
hj2->GetPy()).at(
index);
484 HepMC::FourVector(
px,
493 p->suggest_barcode(barcode);
500 double x0 = (
hj2->GetX()).at(
i);
501 double y0 = (
hj2->GetY()).at(
i);
504 const double fm_to_mm = 1
e-12;
507 double z = fm_to_mm * (
hj2->GetZ()).at(
i);
508 double t = fm_to_mm * (
hj2->GetT()).at(
i);
510 HepMC::GenVertex *
vertex =
new HepMC::GenVertex(HepMC::FourVector(
x, y, z,
t),
id);
518 int nproj =
static_cast<int>((
hj2->GetNpart()) / 2);
519 int ntarg =
static_cast<int>((
hj2->GetNpart()) - nproj);
521 HepMC::HeavyIon *
hi =
new HepMC::HeavyIon(
nsub_,
536 evt->set_heavy_ion(*
hi);
T getParameter(std::string const &) const
bool declareStableParticles(const std::vector< int > &)
bool separateHydjetComponents_
unsigned int maxEventsToPrint_
InitialParamsHydjet_t fParams
bool isVtxGenApplied() const
void add_heavy_ion_rec(HepMC::GenEvent *evt)
unsigned int pythiaPylistVerbosity_
Sin< T >::type sin(const T &t)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
T const * product() const
bool call_pygive(const std::string &line)
HepMC::FourVector * fVertex_
std::vector< double > signalVtx_
Log< level::Error, false > LogError
edm::EDGetTokenT< CrossingFrame< edm::HepMCProduct > > src_
const char * classname() const
T getUntrackedParameter(std::string const &, T const &) const
static const std::string kPythia6
HepMC::GenVertex * build_hyjet2_vertex(int i, int id)
double nuclear_radius() const
Pythia6Service * pythia6Service_
edm::Event & getEDMEvent() const
CLHEP::HepRandomEngine * hjRandomEngine
Interface to the HYDJET++ (Hydjet2) generator (since core v. 2.4.3), produces HepMC events...
bool get_particles(HepMC::GenEvent *evt)
int convertStatusForComponents(int, int, int)
bool initializeForInternalPartons()
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
std::unique_ptr< HepMC::GenEvent > & event()
const HepMC::GenEvent * GetEvent() const
Log< level::Info, false > LogInfo
~Hydjet2Hadronizer() override
HepMC::GenParticle * build_hyjet2(int index, int barcode)
void setRandomEngine(CLHEP::HepRandomEngine *v)
Log< level::Warning, false > LogWarning
bool generatePartonsAndHadronize()