-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathGeneratorTParticle.h
More file actions
119 lines (110 loc) · 3.74 KB
/
GeneratorTParticle.h
File metadata and controls
119 lines (110 loc) · 3.74 KB
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
// Copyright 2023-2099 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// @author: Christian Holm Christensen <cholm@nbi.dk>
#ifndef ALICEO2_GENERATORTPARTICLE_H_
#define ALICEO2_GENERATORTPARTICLE_H_
#include <FairGenerator.h>
#include <Generators/Generator.h>
#include <Generators/GeneratorFileOrCmd.h>
#include <Generators/GeneratorTParticleParam.h>
// Forward decls
class TChain;
class TParticle;
class TClonesArray;
namespace o2
{
namespace conf
{
class SimConfig;
}
namespace eventgen
{
/// A class that reads in particles of class @c TParticle from a
/// branch in a @c TChain.
///
/// Optionally, a program that generates such a @c TTree can be
/// spawn, and the @c TParticles written to a file from which this
/// object reads them in. This is done with
///
/// --configKeyValues "TParticle.progCmd=<eg program and options>"
///
/// which will execute the specified EG program with the given
/// options. The EG program _must_ support the command line options
///
/// -n NUMBER Number of events to generate
/// -o FILENAME Name of file to write to
///
/// The tree name and particle branch names can be configured.
///
/// --configKeyValues "TParticle.treeName=T,TParticle.branchName=P"
///
/// File(s) to read are also configurable
///
/// --configKeyValues "TParticle.fileNames=foo.root,bar.root"
///
class GeneratorTParticle : public Generator, public GeneratorFileOrCmd
{
public:
/** CTOR */
GeneratorTParticle();
/** CTOR */
GeneratorTParticle(const std::string& name)
: Generator(name.c_str(), "ALICEo2 TParticle Generator")
{
}
/** DTOR */
virtual ~GeneratorTParticle();
/** Initialize this generator. This will set up the chain.
* Optionally, if a command line was specified by @c
* TParticle.progCmd then that command line is executed in the
* background and events are read from the output file of that
* program */
Bool_t Init() override;
/**
* Configure the generator from parameters and the general
* simulation configuration. This is implemented as a member
* function so as to better facilitate changes. */
void setup(const GeneratorFileOrCmdParam& param0,
const GeneratorTParticleParam& param,
const conf::SimConfig& config);
/** Read in the next entry from the chain. Returns false in case of
* errors or no more entries to read. */
Bool_t generateEvent() override;
/** Import the read-in particles into the steer particle stack */
Bool_t importParticles() override;
/** Set the name of the tree in the files. The tree _must_ reside
* in the top-level directory of the files. */
void setTreeName(const std::string& val) { mTreeName = val; }
/** Set the branch name of the branch that holds a @c TClonesArray
* of @c TParticle objects */
void setBranchName(const std::string& val) { mBranchName = val; }
protected:
/** Name of the tree to read */
std::string mTreeName = "T";
/** Name of branch containing a TClonesArray of TParticle */
std::string mBranchName = "Particles";
/** Current entry */
unsigned int mEntry = 0;
/** Chain of files */
TChain* mChain = 0;
/** Array to read particles into */
TClonesArray* mTParticles;
ClassDefOverride(GeneratorTParticle, 1);
};
} // namespace eventgen
} // namespace o2
#endif
// Local Variables:
// mode: C++
// End:
//
// EOF
//