Project
Loading...
Searching...
No Matches
DecayerPythia8.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
13
16#include <fairlogger/Logger.h>
17#include "TLorentzVector.h"
18#include "TClonesArray.h"
19#include "TParticle.h"
20#include "TSystem.h"
21
22#include <iostream>
23
24namespace o2
25{
26namespace eventgen
27{
28
29/*****************************************************************/
30/*****************************************************************/
31
33{
34
36 mPythia.readString("ProcessLevel:all off");
37
40 LOG(info) << "Init \'DecayerPythia8\' with following parameters";
41 LOG(info) << param;
42 for (int i = 0; i < 8; ++i) {
43 if (param.config[i].empty()) {
44 continue;
45 }
46 std::string config = gSystem->ExpandPathName(param.config[i].c_str());
47 LOG(info) << "Reading configuration from file: " << config;
48 if (!mPythia.readFile(config, true)) {
49 LOG(fatal) << "Failed to init \'DecayerPythia8\': problems with configuration file "
50 << config;
51 return;
52 }
53 }
54
56 mVerbose = param.verbose;
57
59 if (param.showChanged) {
60 mPythia.readString(std::string("Init:showChangedParticleData on"));
61 } else {
62 mPythia.readString(std::string("Init:showChangedParticleData off"));
63 }
64
66 if (!mPythia.init()) {
67 LOG(fatal) << "Failed to init \'DecayerPythia8\': init returned with error";
68 return;
69 }
70}
71
72/*****************************************************************/
73
74void DecayerPythia8::Decay(Int_t pdg, TLorentzVector* lv)
75{
76 auto mayDecay = mPythia.particleData.mayDecay(pdg); // save mayDecay status
77 mPythia.particleData.mayDecay(pdg, true); // force decay
78
79 mPythia.event.clear();
80 mPythia.event.append(pdg, 11, 0, 0, lv->Px(), lv->Py(), lv->Pz(), lv->E(), lv->M());
81 mPythia.moreDecays();
82 if (mVerbose) {
83 mPythia.event.list();
84 }
85
86 mPythia.particleData.mayDecay(pdg, mayDecay); // restore mayDecay status
87}
88
89/*****************************************************************/
90
91Int_t DecayerPythia8::ImportParticles(TClonesArray* particles)
92{
93 TClonesArray& ca = *particles;
94 ca.Clear();
95
96 auto nParticles = mPythia.event.size();
97 for (Int_t iparticle = 0; iparticle < nParticles; iparticle++) {
98 // Do not import the decayed particle - start loop from 1
99 auto particle = mPythia.event[iparticle];
100 auto pdg = particle.id();
101 auto st = particle.isFinal();
102 auto px = particle.px();
103 auto py = particle.py();
104 auto pz = particle.pz();
105 auto et = particle.e();
106 auto vx = particle.xProd() * 0.1;
107 auto vy = particle.yProd() * 0.1;
108 auto vz = particle.zProd() * 0.1;
109 auto vt = particle.tProd() * 3.3356410e-12;
110 auto m1 = particle.mother1();
111 auto m2 = particle.mother2();
112 auto d1 = particle.daughter1();
113 auto d2 = particle.daughter2();
114
115 new (ca[iparticle]) TParticle(pdg, st, m1, m2, d1, d2, px, py, pz, et, vx, vy, vz, vt);
116 }
117
118 return ca.GetEntries();
119}
120
121/*****************************************************************/
122/*****************************************************************/
123
124} /* namespace eventgen */
125} /* namespace o2 */
126
ClassImp(o2::eventgen::DecayerPythia8)
int32_t i
benchmark::State & st
Int_t ImportParticles(TClonesArray *particles) override
void Decay(Int_t pdg, TLorentzVector *lv) override
GLenum GLfloat param
Definition glcorearb.h:271
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"