Skip to content

Commit d5e681c

Browse files
preghenellasawenzel
authored andcommitted
External trigger configuration moved to configurable params
1 parent ba1b721 commit d5e681c

File tree

12 files changed

+72
-26
lines changed

12 files changed

+72
-26
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ struct SimConfigData {
2929
std::string mExtKinFileName; // file name of external kinematics file (needed for ext kinematics generator)
3030
std::string mExtGenFileName; // file name containing the external generator configuration
3131
std::string mExtGenFuncName; // function call to retrieve the external generator configuration
32-
std::string mExtTrgFileName; // file name containing the external trigger configuration
33-
std::string mExtTrgFuncName; // function call to retrieve the external trigger configuration
3432
std::string mEmbedIntoFileName; // filename containing the reference events to be used for the embedding
3533
unsigned int mStartEvent; // index of first event to be taken
3634
float mBMax; // maximum for impact parameter sampling
@@ -102,8 +100,6 @@ class SimConfig
102100
std::string getExtKinematicsFileName() const { return mConfigData.mExtKinFileName; }
103101
std::string getExtGeneratorFileName() const { return mConfigData.mExtGenFileName; }
104102
std::string getExtGeneratorFuncName() const { return mConfigData.mExtGenFuncName; }
105-
std::string getExtTriggerFileName() const { return mConfigData.mExtTrgFileName; }
106-
std::string getExtTriggerFuncName() const { return mConfigData.mExtTrgFuncName; }
107103
std::string getEmbedIntoFileName() const { return mConfigData.mEmbedIntoFileName; }
108104
unsigned int getStartEvent() const { return mConfigData.mStartEvent; }
109105
float getBMax() const { return mConfigData.mBMax; }

Common/SimConfig/src/SimConfig.cxx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ void SimConfig::initOptions(boost::program_options::options_description& options
3535
"name of .C file with definition of external event generator")(
3636
"extGenFunc", bpo::value<std::string>()->default_value(""),
3737
"function call to load the definition of external event generator")(
38-
"extTrgFile", bpo::value<std::string>()->default_value("exttrg.C"),
39-
"name of .C file with definition of external event generator trigger")(
40-
"extTrgFunc", bpo::value<std::string>()->default_value(""),
41-
"function call to load the definition of external event generator trigger")(
4238
"embedIntoFile", bpo::value<std::string>()->default_value(""),
4339
"filename containing the reference events to be used for the embedding")(
4440
"bMax,b", bpo::value<float>()->default_value(0.), "maximum value for impact parameter sampling (when applicable)")(
@@ -100,8 +96,6 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
10096
mConfigData.mExtKinFileName = vm["extKinFile"].as<std::string>();
10197
mConfigData.mExtGenFileName = vm["extGenFile"].as<std::string>();
10298
mConfigData.mExtGenFuncName = vm["extGenFunc"].as<std::string>();
103-
mConfigData.mExtTrgFileName = vm["extTrgFile"].as<std::string>();
104-
mConfigData.mExtTrgFuncName = vm["extTrgFunc"].as<std::string>();
10599
mConfigData.mEmbedIntoFileName = vm["embedIntoFile"].as<std::string>();
106100
mConfigData.mStartEvent = vm["startEvent"].as<unsigned int>();
107101
mConfigData.mBMax = vm["bMax"].as<float>();

Generators/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ o2_add_library(Generators
2929
src/PDG.cxx
3030
src/PrimaryGenerator.cxx
3131
src/InteractionDiamondParam.cxx
32+
src/TriggerExternalParam.cxx
3233
src/TriggerParticleParam.cxx
3334
src/BoxGunParam.cxx
3435
src/QEDGenParam.cxx
@@ -68,6 +69,7 @@ set(headers
6869
include/Generators/PDG.h
6970
include/Generators/PrimaryGenerator.h
7071
include/Generators/InteractionDiamondParam.h
72+
include/Generators/TriggerExternalParam.h
7173
include/Generators/TriggerParticleParam.h
7274
include/Generators/ConfigurationMacroHelper.h
7375
include/Generators/BoxGunParam.h
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 2020
12+
13+
#ifndef ALICEO2_EVENTGEN_TRIGGEREXTERNALPARAM_H_
14+
#define ALICEO2_EVENTGEN_TRIGGEREXTERNALPARAM_H_
15+
16+
#include "CommonUtils/ConfigurableParam.h"
17+
#include "CommonUtils/ConfigurableParamHelper.h"
18+
19+
namespace o2
20+
{
21+
namespace eventgen
22+
{
23+
24+
/**
25+
** a parameter class/struct to keep the settings of
26+
** the event-generator external trigger and
27+
** allow the user to modify them
28+
**/
29+
struct TriggerExternalParam : public o2::conf::ConfigurableParamHelper<TriggerExternalParam> {
30+
std::string fileName = "";
31+
std::string funcName = "";
32+
O2ParamDef(TriggerExternalParam, "TriggerExternal");
33+
};
34+
35+
} // end namespace eventgen
36+
} // end namespace o2
37+
38+
#endif // ALICEO2_EVENTGEN_TRIGGEREXTERNALPARAM_H_

Generators/share/external/trigger_mpi.C

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// MPI trigger
22
//
3-
// usage: o2sim --trigger external --extTrgFile trigger_mpi.C
4-
// options: --extTrgFunc "trigger_mpi()"
3+
// usage: o2sim --trigger external --configKeyValues 'TriggerExternal.fileName=trigger_mpi.C;TriggerExternal.funcName="trigger_mpi()"'
54
//
65

76
/// \author R+Preghenella - February 2020

Generators/share/external/trigger_multiplicity.C

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// multiplicity trigger
22
//
3-
// usage: o2sim --trigger external --extTrgFile trigger_multiplicity.C
4-
// options: --extTrgFunc "trigger_multiplicity(-0.8, 0.8, 100)"
3+
// usage: o2sim --trigger external --configKeyValues 'TriggerExternal.fileName=trigger_multiplicity.C;TriggerExternal.funcName="trigger_multiplicity(-0.8, 0.8, 100)"'
54
//
65

76
/// \author R+Preghenella - February 2020

Generators/src/GeneratorFactory.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#endif
3333
#include <Generators/BoxGunParam.h>
3434
#include <Generators/TriggerParticle.h>
35+
#include <Generators/TriggerExternalParam.h>
3536
#include <Generators/TriggerParticleParam.h>
3637
#include "Generators/ConfigurationMacroHelper.h"
3738

@@ -227,8 +228,11 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
227228
trigger = TriggerParticle(TriggerParticleParam::Instance());
228229
} else if (trgconfig.compare("external") == 0) {
229230
// external trigger via configuration macro
230-
auto external_trigger_filename = conf.getExtTriggerFileName();
231-
auto external_trigger_func = conf.getExtTriggerFuncName();
231+
auto& params = TriggerExternalParam::Instance();
232+
LOG(INFO) << "Setting up external trigger with following parameters";
233+
LOG(INFO) << params;
234+
auto external_trigger_filename = params.fileName;
235+
auto external_trigger_func = params.funcName;
232236
trigger = GetFromMacro<o2::eventgen::Trigger>(external_trigger_filename, external_trigger_func, "o2::eventgen::Trigger", "trigger");
233237
if (!trigger) {
234238
LOG(INFO) << "Trying to retrieve a \'o2::eventgen::DeepTrigger\' type" << std::endl;

Generators/src/GeneratorsLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#pragma link C++ enum o2::eventgen::EVertexDistribution;
5353
#pragma link C++ class o2::eventgen::InteractionDiamondParam + ;
5454
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::InteractionDiamondParam > +;
55+
#pragma link C++ class o2::eventgen::TriggerExternalParam + ;
56+
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::TriggerExternalParam> + ;
5557
#pragma link C++ class o2::eventgen::TriggerParticleParam + ;
5658
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::eventgen::TriggerParticleParam > +;
5759
#pragma link C++ class o2::eventgen::BoxGunParam + ;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 2020
12+
13+
#include "Generators/TriggerExternalParam.h"
14+
O2ParamImpl(o2::eventgen::TriggerExternalParam);

doc/DetectorSimulation.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ o2-sim -g pythia8 -t particle --configKeyValues "TriggerParticle.pdg=333;Trigger
187187
Custom triggers can also be constructed by the user to provide unlimited flexibility in the trigger needs.
188188
An external trigger function can be specified via command line arguments
189189
```
190-
o2-sim -g pythia8 -t external --extTrgFile path_to_trigger_macro.C --extTrgFunc "the_function(some, parameters)"
190+
o2-sim -g pythia8 -t external --configKeyValues 'TriggerExternal.fileName=path_to_trigger_macro.C;TriggerExternal.funcName="the_function(some, parameters)"'
191191
```
192192
The function must comply with a simple protocol and return a lambda function defined as follows
193193
```
@@ -205,7 +205,7 @@ To allow users to define triggers that go beyond the particle stack generated by
205205
This allows the user to go deep into the core of the event generator, whenever this is possible.
206206
For this reason, this is called a 'DeepTrigger'. A 'DeepTrigger' is attached to the simulation in the same way as a normal trigger
207207
```
208-
o2-sim -g pythia8 -t external --extTrgFile path_to_deep_trigger_macro.C --extTrgFunc "the_deep_function(some, parameters)"
208+
o2-sim -g pythia8 -t external --configKeyValues 'TriggerExternal.fileName=path_to_deep_trigger_macro.C;TriggerExternal.funcName="the_deep_function(some, parameters)"'
209209
```
210210
In this case the function must comply with a similar, but different protocol than before and return a lambda function defined as follows
211211
``` o2::eventgen::DeepTrigger the_deep_function()
@@ -227,8 +227,7 @@ Deep triggers is just a name to a new functionality that allows the user to defi
227227
Here is an example of a deep trigger implementation in Pythia8.
228228

229229
```
230-
// usage: o2sim --trigger external --extTrgFile trigger_mpi.C
231-
// options: --extTrgFunc "trigger_mpi()"
230+
// usage: o2sim --trigger external --configKeyValues 'TriggerExternal.fileName=trigger_mpi.C;TriggerExternal.funcName="trigger_mpi()"'
232231
233232
#include "Generators/Trigger.h"
234233
#include "Pythia8/Pythia.h"
@@ -294,8 +293,7 @@ Pythia8::UserHooks*
294293
A new Pythia6 interface is provided via GeneratorPythia6. This complies with the o2::eventgen::Generator protocol, and hence the user is allowed to use all the trigger functionalities. The class can also be used for DeepTriggers as this modified macro shows.
295294

296295
```
297-
// usage: o2sim --trigger external --extTrgFile trigger_mpi.C
298-
// options: --extTrgFunc "trigger_mpi()"
296+
// usage: o2sim --trigger external --configKeyValues "TriggerExternal.fileName=trigger_mpi.C;TriggerExternal.funcName="trigger_mpi()"'
299297
300298
#include "Generators/Trigger.h"
301299
#include "Pythia8/Pythia.h"

0 commit comments

Comments
 (0)