Skip to content

Commit b731f9a

Browse files
preghenellasawenzel
authored andcommitted
Provide a way to trigger on generated event
1 parent 3445118 commit b731f9a

18 files changed

Lines changed: 687 additions & 128 deletions

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ struct SimConfigData {
2424
std::vector<std::string> mActiveDetectors; // list of active detectors
2525
std::string mMCEngine; // chosen VMC engine
2626
std::string mGenerator; // chosen VMC generator
27+
std::string mTrigger; // chosen VMC generator trigger
2728
unsigned int mNEvents; // number of events to be simulated
2829
std::string mExtKinFileName; // file name of external kinematics file (needed for ext kinematics generator)
2930
std::string mHepMCFileName; // file name of HepMC file
3031
std::string mExtGenFileName; // file name containing the external generator configuration
3132
std::string mExtGenFuncName; // function call to retrieve the external generator configuration
33+
std::string mExtTrgFileName; // file name containing the external trigger configuration
34+
std::string mExtTrgFuncName; // function call to retrieve the external trigger configuration
3235
std::string mEmbedIntoFileName; // filename containing the reference events to be used for the embedding
3336
unsigned int mStartEvent; // index of first event to be taken
3437
float mBMax; // maximum for impact parameter sampling
@@ -94,12 +97,15 @@ class SimConfig
9497
std::vector<std::string> const& getActiveDetectors() const { return mConfigData.mActiveDetectors; }
9598
// get selected generator (to be used to select a genconfig)
9699
std::string getGenerator() const { return mConfigData.mGenerator; }
100+
std::string getTrigger() const { return mConfigData.mTrigger; }
97101
unsigned int getNEvents() const { return mConfigData.mNEvents; }
98102

99103
std::string getExtKinematicsFileName() const { return mConfigData.mExtKinFileName; }
100104
std::string getHepMCFileName() const { return mConfigData.mHepMCFileName; }
101105
std::string getExtGeneratorFileName() const { return mConfigData.mExtGenFileName; }
102106
std::string getExtGeneratorFuncName() const { return mConfigData.mExtGenFuncName; }
107+
std::string getExtTriggerFileName() const { return mConfigData.mExtTrgFileName; }
108+
std::string getExtTriggerFuncName() const { return mConfigData.mExtTrgFuncName; }
103109
std::string getEmbedIntoFileName() const { return mConfigData.mEmbedIntoFileName; }
104110
unsigned int getStartEvent() const { return mConfigData.mStartEvent; }
105111
float getBMax() const { return mConfigData.mBMax; }

Common/SimConfig/src/SimConfig.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void SimConfig::initOptions(boost::program_options::options_description& options
2525
options.add_options()(
2626
"mcEngine,e", bpo::value<std::string>()->default_value("TGeant3"), "VMC backend to be used.")(
2727
"generator,g", bpo::value<std::string>()->default_value("boxgen"), "Event generator to be used.")(
28+
"trigger,t", bpo::value<std::string>()->default_value(""), "Event generator trigger to be used.")(
2829
"modules,m", bpo::value<std::vector<std::string>>()->multitoken()->default_value(std::vector<std::string>({"all"}), "all modules"), "list of detectors")(
2930
"skipModules", bpo::value<std::vector<std::string>>()->multitoken()->default_value(std::vector<std::string>({""}), ""), "list of detectors to skip (precendence over -m")("nEvents,n", bpo::value<unsigned int>()->default_value(1), "number of events")(
3031
"startEvent", bpo::value<unsigned int>()->default_value(0), "index of first event to be used (when applicable)")(
@@ -36,6 +37,10 @@ void SimConfig::initOptions(boost::program_options::options_description& options
3637
"name of .C file with definition of external event generator")(
3738
"extGenFunc", bpo::value<std::string>()->default_value(""),
3839
"function call to load the definition of external event generator")(
40+
"extTrgFile", bpo::value<std::string>()->default_value("exttrg.C"),
41+
"name of .C file with definition of external event generator trigger")(
42+
"extTrgFunc", bpo::value<std::string>()->default_value(""),
43+
"function call to load the definition of external event generator trigger")(
3944
"embedIntoFile", bpo::value<std::string>()->default_value(""),
4045
"filename containing the reference events to be used for the embedding")(
4146
"bMax,b", bpo::value<float>()->default_value(0.), "maximum value for impact parameter sampling (when applicable)")(
@@ -86,11 +91,14 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
8691
}
8792

8893
mConfigData.mGenerator = vm["generator"].as<std::string>();
94+
mConfigData.mTrigger = vm["trigger"].as<std::string>();
8995
mConfigData.mNEvents = vm["nEvents"].as<unsigned int>();
9096
mConfigData.mExtKinFileName = vm["extKinFile"].as<std::string>();
9197
mConfigData.mHepMCFileName = vm["HepMCFile"].as<std::string>();
9298
mConfigData.mExtGenFileName = vm["extGenFile"].as<std::string>();
9399
mConfigData.mExtGenFuncName = vm["extGenFunc"].as<std::string>();
100+
mConfigData.mExtTrgFileName = vm["extTrgFile"].as<std::string>();
101+
mConfigData.mExtTrgFuncName = vm["extTrgFunc"].as<std::string>();
94102
mConfigData.mEmbedIntoFileName = vm["embedIntoFile"].as<std::string>();
95103
mConfigData.mStartEvent = vm["startEvent"].as<unsigned int>();
96104
mConfigData.mBMax = vm["bMax"].as<float>();

Generators/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ endif()
1818

1919
o2_add_library(Generators
2020
SOURCES src/Generator.cxx
21+
src/Trigger.cxx
22+
src/TriggerParticle.cxx
2123
src/GeneratorTGenerator.cxx
2224
src/GeneratorFromFile.cxx
2325
src/Pythia6Generator.cxx
2426
src/PDG.cxx
2527
src/PrimaryGenerator.cxx
2628
src/InteractionDiamondParam.cxx
29+
src/TriggerParticleParam.cxx
2730
src/BoxGunParam.cxx
2831
src/QEDGenParam.cxx
2932
src/GeneratorFactory.cxx
@@ -44,12 +47,15 @@ endif()
4447

4548
set(headers
4649
include/Generators/Generator.h
50+
include/Generators/Trigger.h
51+
include/Generators/TriggerParticle.h
4752
include/Generators/GeneratorTGenerator.h
4853
include/Generators/GeneratorFromFile.h
4954
include/Generators/Pythia6Generator.h
5055
include/Generators/PDG.h
5156
include/Generators/PrimaryGenerator.h
5257
include/Generators/InteractionDiamondParam.h
58+
include/Generators/TriggerParticleParam.h
5359
include/Generators/BoxGunParam.h
5460
include/Generators/QEDGenParam.h)
5561

@@ -85,7 +91,12 @@ o2_add_test_root_macro(share/external/tgenerator.C
8591
PUBLIC_LINK_LIBRARIES O2::Generators
8692
LABELS generators)
8793

94+
o2_add_test_root_macro(share/external/multiphi_trigger.C
95+
PUBLIC_LINK_LIBRARIES O2::Generators
96+
LABELS generators)
97+
8898

8999
install(FILES share/external/extgen.C share/external/pythia6.C
90100
share/external/tgenerator.C share/external/QEDLoader.C share/external/QEDepem.C
101+
share/external/multiphi_trigger.C
91102
DESTINATION share/Generators/external/)

Generators/include/Generators/Generator.h

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,41 @@
1717
#include <vector>
1818
#include <array>
1919

20+
class TClonesArray;
21+
2022
namespace o2
2123
{
2224
namespace eventgen
2325
{
26+
27+
class Trigger;
28+
29+
/*****************************************************************/
30+
/*****************************************************************/
31+
2432
// this class implements a generic FairGenerator extension
2533
// that provides a base class for the ALICEo2 simulation needs
2634
// such that different interfaces to the event generators
2735
// (i.e. TGenerator, HEPdata reader) can be implemented
2836
// according to a common protocol
37+
2938
class Generator : public FairGenerator
3039
{
3140

3241
public:
42+
enum ETriggerMode_t { kTriggerOFF,
43+
kTriggerOR,
44+
kTriggerAND };
45+
3346
/** default constructor **/
3447
Generator();
3548
/** constructor **/
3649
Generator(const Char_t* name, const Char_t* title = "ALICEo2 Generator");
3750
/** destructor **/
38-
~Generator() override = default;
51+
~Generator() override;
52+
53+
/** Initialize the generator if needed **/
54+
Bool_t Init() override;
3955

4056
/** Abstract method ReadEvent must be implemented by any derived class.
4157
It has to handle the generation of input tracks (reading from input
@@ -52,6 +68,8 @@ class Generator : public FairGenerator
5268
void setPositionUnit(double val) { mPositionUnit = val; };
5369
void setTimeUnit(double val) { mTimeUnit = val; };
5470
void setBoost(Double_t val) { mBoost = val; };
71+
void setTriggerMode(ETriggerMode_t val) { mTriggerMode = val; };
72+
void addTrigger(Trigger* trigger) { mTriggers.push_back(trigger); };
5573

5674
protected:
5775
/** copy constructor **/
@@ -61,15 +79,26 @@ class Generator : public FairGenerator
6179

6280
/** methods to override **/
6381
virtual Bool_t generateEvent() = 0;
64-
virtual Bool_t boostEvent(Double_t boost) = 0;
65-
virtual Bool_t addTracks(FairPrimaryGenerator* primGen) const = 0;
82+
virtual Bool_t importParticles() = 0;
83+
84+
/** internal methods **/
85+
Bool_t addTracks(FairPrimaryGenerator* primGen);
86+
Bool_t boostEvent();
87+
Bool_t triggerEvent();
88+
89+
/** trigger data members **/
90+
ETriggerMode_t mTriggerMode = kTriggerOFF;
91+
std::vector<Trigger*> mTriggers;
6692

6793
/** conversion data members **/
6894
double mMomentumUnit = 1.; // [GeV/c]
6995
double mEnergyUnit = 1.; // [GeV/c]
7096
double mPositionUnit = 0.1; // [cm]
7197
double mTimeUnit = 3.3356410e-12; // [s]
7298

99+
/** particle array **/
100+
TClonesArray* mParticles; //!
101+
73102
/** lorentz boost data members **/
74103
Double_t mBoost;
75104

Generators/include/Generators/GeneratorHepMC.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class GeneratorHepMC : public Generator
5757

5858
/** methods to override **/
5959
Bool_t generateEvent() override;
60-
Bool_t boostEvent(Double_t boost) override;
61-
Bool_t addTracks(FairPrimaryGenerator* primGen) const override;
60+
Bool_t importParticles() override;
6261

6362
/** methods **/
6463
const HepMC::FourVector getBoostedVector(const HepMC::FourVector& vector, Double_t boost);

Generators/include/Generators/GeneratorTGenerator.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "Generators/Generator.h"
1717

1818
class TGenerator;
19-
class TClonesArray;
2019

2120
namespace o2
2221
{
@@ -35,7 +34,7 @@ class GeneratorTGenerator : public Generator
3534
/** constructor with name and title **/
3635
GeneratorTGenerator(const Char_t* name, const Char_t* title = "ALICEo2 TGenerator Generator");
3736
/** destructor **/
38-
~GeneratorTGenerator() override;
37+
~GeneratorTGenerator() override = default;
3938

4039
/** setters **/
4140
void setTGenerator(TGenerator* val) { mTGenerator = val; };
@@ -51,12 +50,10 @@ class GeneratorTGenerator : public Generator
5150

5251
/** methods to override **/
5352
Bool_t generateEvent() override;
54-
Bool_t boostEvent(Double_t boost) override;
55-
Bool_t addTracks(FairPrimaryGenerator* primGen) const override;
53+
Bool_t importParticles() override;
5654

5755
/** TGenerator interface **/
5856
TGenerator* mTGenerator;
59-
TClonesArray* mParticles;
6057

6158
ClassDefOverride(GeneratorTGenerator, 1);
6259

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \author R+Preghenella - August 2017
12+
13+
#ifndef ALICEO2_EVENTGEN_TRIGGER_H_
14+
#define ALICEO2_EVENTGEN_TRIGGER_H_
15+
16+
#include "TNamed.h"
17+
18+
class TClonesArray;
19+
20+
namespace o2
21+
{
22+
namespace eventgen
23+
{
24+
25+
/*****************************************************************/
26+
/*****************************************************************/
27+
28+
class Trigger : public TNamed
29+
{
30+
31+
public:
32+
/** default constructor **/
33+
Trigger() = default;
34+
/** destructor **/
35+
~Trigger() override = default;
36+
37+
/** methods to override **/
38+
virtual Bool_t fired(TClonesArray* particles) = 0;
39+
40+
protected:
41+
/** copy constructor **/
42+
Trigger(const Trigger&);
43+
/** operator= **/
44+
Trigger& operator=(const Trigger&);
45+
46+
ClassDefOverride(Trigger, 1);
47+
48+
}; /** class Trigger **/
49+
50+
/*****************************************************************/
51+
/*****************************************************************/
52+
53+
} // namespace eventgen
54+
} // namespace o2
55+
56+
#endif /* ALICEO2_EVENTGEN_TRIGGER_H_ */
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \author R+Preghenella - September 2019
12+
13+
#ifndef ALICEO2_EVENTGEN_TRIGGERPARTICLE_H_
14+
#define ALICEO2_EVENTGEN_TRIGGERPARTICLE_H_
15+
16+
#include "Generators/Trigger.h"
17+
18+
namespace o2
19+
{
20+
namespace eventgen
21+
{
22+
23+
/*****************************************************************/
24+
/*****************************************************************/
25+
26+
class TriggerParticle : public Trigger
27+
{
28+
29+
public:
30+
/** default constructor **/
31+
TriggerParticle() = default;
32+
/** destructor **/
33+
~TriggerParticle() override = default;
34+
35+
/** methods to override **/
36+
Bool_t fired(TClonesArray* particles) override;
37+
38+
/** setters **/
39+
void setPDG(Int_t val) { mPDG = val; };
40+
void setPtRange(Double_t min, Double_t max)
41+
{
42+
mPtMin = min;
43+
mPtMax = max;
44+
};
45+
void setEtaRange(Double_t min, Double_t max)
46+
{
47+
mEtaMin = min;
48+
mEtaMax = max;
49+
};
50+
void setPhiRange(Double_t min, Double_t max)
51+
{
52+
mPhiMin = min;
53+
mPhiMax = max;
54+
};
55+
void setYRange(Double_t min, Double_t max)
56+
{
57+
mYMin = min;
58+
mYMax = max;
59+
};
60+
61+
protected:
62+
/** copy constructor **/
63+
TriggerParticle(const TriggerParticle&);
64+
/** operator= **/
65+
TriggerParticle& operator=(const TriggerParticle&);
66+
67+
/** trigger particle selection **/
68+
Int_t mPDG = 0;
69+
Double_t mPtMin = 0.;
70+
Double_t mPtMax = 1.e6;
71+
Double_t mEtaMin = -1.e6;
72+
Double_t mEtaMax = 1.e6;
73+
Double_t mPhiMin = -1.e6;
74+
Double_t mPhiMax = 1.e6;
75+
Double_t mYMin = -1.e6;
76+
Double_t mYMax = 1.e6;
77+
78+
ClassDefOverride(TriggerParticle, 1);
79+
80+
}; /** class TriggerParticle **/
81+
82+
/*****************************************************************/
83+
/*****************************************************************/
84+
85+
} // namespace eventgen
86+
} // namespace o2
87+
88+
#endif /* ALICEO2_EVENTGEN_TRIGGERPARTICLE_H_ */

0 commit comments

Comments
 (0)