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 "TString.h"
21#include "TSystem.h"
22
23#include <iostream>
24
25namespace o2
26{
27namespace eventgen
28{
29
30/*****************************************************************/
31/*****************************************************************/
32
34{
35
37 mPythia.readString("ProcessLevel:all off");
38
41 LOG(info) << "Init \'DecayerPythia8\' with following parameters";
42 LOG(info) << param;
43 for (int i = 0; i < 8; ++i) {
44 if (param.config[i].empty()) {
45 continue;
46 }
47 TString config = param.config[i];
48 gSystem->ExpandPathName(config);
49 LOG(info) << "Reading configuration from file: " << config;
50 if (!mPythia.readFile(config.Data(), true)) {
51 LOG(fatal) << "Failed to init \'DecayerPythia8\': problems with configuration file "
52 << config;
53 return;
54 }
55 }
56
58 mVerbose = param.verbose;
59
61 if (param.showChanged) {
62 mPythia.readString(std::string("Init:showChangedParticleData on"));
63 } else {
64 mPythia.readString(std::string("Init:showChangedParticleData off"));
65 }
66
68 if (!mPythia.init()) {
69 LOG(fatal) << "Failed to init \'DecayerPythia8\': init returned with error";
70 return;
71 }
72}
73
74/*****************************************************************/
75
76void DecayerPythia8::Decay(Int_t pdg, TLorentzVector* lv)
77{
78 auto mayDecay = mPythia.particleData.mayDecay(pdg); // save mayDecay status
79 mPythia.particleData.mayDecay(pdg, true); // force decay
80
81 mPythia.event.clear();
82 mPythia.event.append(pdg, 11, 0, 0, lv->Px(), lv->Py(), lv->Pz(), lv->E(), lv->M());
83 mPythia.moreDecays();
84 if (mVerbose) {
85 mPythia.event.list();
86 }
87
88 mPythia.particleData.mayDecay(pdg, mayDecay); // restore mayDecay status
89}
90
91/*****************************************************************/
92
93Int_t DecayerPythia8::ImportParticles(TClonesArray* particles)
94{
95 TClonesArray& ca = *particles;
96 ca.Clear();
97
98 auto nParticles = mPythia.event.size();
99 for (Int_t iparticle = 0; iparticle < nParticles; iparticle++) {
100 // Do not import the decayed particle - start loop from 1
101 auto particle = mPythia.event[iparticle];
102 auto pdg = particle.id();
103 auto st = particle.isFinal();
104 auto px = particle.px();
105 auto py = particle.py();
106 auto pz = particle.pz();
107 auto et = particle.e();
108 auto vx = particle.xProd() * 0.1;
109 auto vy = particle.yProd() * 0.1;
110 auto vz = particle.zProd() * 0.1;
111 auto vt = particle.tProd() * 3.3356410e-12;
112 auto m1 = particle.mother1();
113 auto m2 = particle.mother2();
114 auto d1 = particle.daughter1();
115 auto d2 = particle.daughter2();
116
117 new (ca[iparticle]) TParticle(pdg, st, m1, m2, d1, d2, px, py, pz, et, vx, vy, vz, vt);
118 }
119
120 return ca.GetEntries();
121}
122
123/*****************************************************************/
124/*****************************************************************/
125
126} /* namespace eventgen */
127} /* namespace o2 */
128
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"