Project
Loading...
Searching...
No Matches
GeneratorTGenerator.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
16#include <fairlogger/Logger.h>
17#include "FairPrimaryGenerator.h"
18#include "TGenerator.h"
19#include "TClonesArray.h"
20#include "TParticle.h"
21#include "TMCProcess.h" // for VMC Particle Production Process
22
23namespace o2
24{
25namespace eventgen
26{
27
28/*****************************************************************/
29/*****************************************************************/
30
31GeneratorTGenerator::GeneratorTGenerator() : Generator("ALICEo2", "ALICEo2 TGenerator Generator"),
32 mTGenerator(nullptr),
33 mCloneParticles(nullptr)
34{
37 mInterface = reinterpret_cast<void*>(mTGenerator);
38 mInterfaceName = "tgenerator";
39 mCloneParticles = new TClonesArray("TParticle");
40 mCloneParticles->SetOwner(kTRUE);
41}
42
43/*****************************************************************/
44
45GeneratorTGenerator::GeneratorTGenerator(const Char_t* name, const Char_t* title) : Generator(name, title),
46 mTGenerator(nullptr),
47 mCloneParticles(nullptr)
48{
51 mInterface = reinterpret_cast<void*>(mTGenerator);
52 mInterfaceName = "tgenerator";
53 mCloneParticles = new TClonesArray("TParticle");
54 mCloneParticles->SetOwner(kTRUE);
55}
56
57/*****************************************************************/
58
65
66/*****************************************************************/
67
68Bool_t
70{
73 mTGenerator->GenerateEvent();
74
76 return kTRUE;
77}
78
79/*****************************************************************/
80
81Bool_t
83{
86 mTGenerator->ImportParticles(mCloneParticles, "All");
87 auto nparticles = mCloneParticles->GetEntries();
88 for (Int_t iparticle = 0; iparticle < nparticles; iparticle++) {
89 auto particle = (TParticle*)mCloneParticles->At(iparticle);
90 // Some particle comes in from somewhere.
91 // To support the user and in case the status code is found to be not encoded, do it here,
92 // assuming that the current code is the HepMC status (like it used to be before).
93 auto statusCode = particle->GetStatusCode();
94 if (!mcgenstatus::isEncoded(statusCode)) {
95 particle->SetStatusCode(mcgenstatus::MCGenStatusEncoding(statusCode, 0).fullEncoding);
96 }
97 mParticles.push_back(*particle);
98 // Set the transport bit according to the HepMC status code as it always used to be
99 mParticles.back().SetBit(ParticleStatus::kToBeDone, mcgenstatus::getHepMCStatusCode(particle->GetStatusCode()) == 1);
100
101 if (GeneratorExternalParam::Instance().markAllAsPrimary) {
102 // The production process will be set to kPPrimary which is the expected default for generator-level particles in O2
103 // not doing this might confuse transport and selection of particles to keep in AOD
104 mParticles.back().SetUniqueID(kPPrimary);
105 }
106 }
107
109 return kTRUE;
110}
111
112/*****************************************************************/
113
114Bool_t
116{
121
122 if (!mTGenerator) {
123 LOG(fatal) << "No TGenerator inteface assigned" << std::endl;
124 return kFALSE;
125 }
126
128 return kTRUE;
129}
130
131/*****************************************************************/
132/*****************************************************************/
133
134} /* namespace eventgen */
135} /* namespace o2 */
@ kToBeDone
std::string mInterfaceName
Definition Generator.h:120
std::vector< TParticle > mParticles
Definition Generator.h:140
Bool_t Init() override
Definition Generator.cxx:57
GLuint const GLchar * name
Definition glcorearb.h:781
int getHepMCStatusCode(MCGenStatusEncoding enc)
bool isEncoded(MCGenStatusEncoding statusCode)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"