Skip to content

Commit b35085d

Browse files
committed
SIM: Add detector version parsing
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 08d9479 commit b35085d

5 files changed

Lines changed: 304 additions & 45 deletions

File tree

Common/SimConfig/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ o2_add_library(SimConfig
1313
SOURCES src/SimConfig.cxx
1414
src/SimParams.cxx
1515
src/SimUserDecay.cxx
16-
src/DigiParams.cxx src/G4Params.cxx
16+
src/DigiParams.cxx
17+
src/G4Params.cxx
18+
src/DetectorVersions.cxx
1719
src/MatMapParams.cxx
1820
src/InteractionDiamondParam.cxx
1921
src/GlobalProcessCutSimParam.cxx
@@ -27,8 +29,9 @@ o2_target_root_dictionary(SimConfig
2729
include/SimConfig/SimParams.h
2830
include/SimConfig/SimUserDecay.h
2931
include/SimConfig/InteractionDiamondParam.h
30-
include/SimConfig/DigiParams.h
32+
include/SimConfig/DigiParams.h
3133
include/SimConfig/G4Params.h
34+
include/SimConfig/DetectorVersions.h
3235
include/SimConfig/GlobalProcessCutSimParam.h
3336
include/SimConfig/MatMapParams.h)
3437

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
12+
#ifndef O2_DETECTORVERSIONS_H_
13+
#define O2_DETECTORVERSIONS_H_
14+
15+
#include <string>
16+
#include <unordered_map>
17+
#include <vector>
18+
19+
#include "Framework/Logger.h"
20+
21+
namespace o2::conf
22+
{
23+
using DetectorElements_t = std::vector<std::string>;
24+
using DetectorMap_t = std::unordered_map<std::string, DetectorElements_t>;
25+
26+
// Container defining different general evolutions of the ALICE experiment. Each
27+
// evolution is given a name and a list defining the names of the detectors and
28+
// passive elements present.
29+
extern const DetectorMap_t DetectorVersions;
30+
31+
void printDetMap(const DetectorMap_t& map);
32+
} // namespace o2::conf
33+
34+
#endif // O2_DETECTORVERSIONS_H_

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,43 @@ enum class TimeStampMode {
4848

4949
// configuration struct (which can be passed around)
5050
struct SimConfigData {
51-
std::vector<std::string> mActiveModules; // list of active modules
52-
std::vector<std::string> mReadoutDetectors; // list of readout detectors
53-
std::string mMCEngine; // chosen VMC engine
54-
std::string mGenerator; // chosen VMC generator
55-
std::string mTrigger; // chosen VMC generator trigger
56-
unsigned int mNEvents; // number of events to be simulated
57-
std::string mExtKinFileName; // file name of external kinematics file (needed for ext kinematics generator)
58-
std::string mEmbedIntoFileName; // filename containing the reference events to be used for the embedding
59-
unsigned int mStartEvent; // index of first event to be taken
60-
float mBMax; // maximum for impact parameter sampling
61-
bool mIsMT; // chosen MT mode (Geant4 only)
62-
std::string mOutputPrefix; // prefix to be used for output files
63-
std::string mLogSeverity; // severity for FairLogger
64-
std::string mLogVerbosity; // loglevel for FairLogger
65-
std::string mKeyValueTokens; // a string holding arbitrary sequence of key-value tokens
66-
// Foo.parameter1=x,Bar.parameter2=y,Baz.paramter3=hello
67-
// (can be used to **loosely** change any configuration parameter from command-line)
68-
std::string mConfigFile; // path to a JSON or INI config file (file extension is required to determine type).
69-
// values within the config file will override values set in code by the param classes
70-
// but will themselves be overridden by any values given in mKeyValueTokens.
71-
int mPrimaryChunkSize; // defining max granularity for input primaries of a sim job
72-
int mInternalChunkSize; //
73-
ULong_t mStartSeed; // base for random number seeds
74-
int mSimWorkers = 1; // number of parallel sim workers (when it applies)
75-
bool mFilterNoHitEvents = false; // whether to filter out events not leaving any response
76-
std::string mCCDBUrl; // the URL where to find CCDB
77-
uint64_t mTimestamp; // timestamp in ms to anchor transport simulation to
51+
std::vector<std::string> mActiveModules; // list of active modules
52+
std::vector<std::string> mReadoutDetectors; // list of readout detectors
53+
std::string mMCEngine; // chosen VMC engine
54+
std::string mGenerator; // chosen VMC generator
55+
std::string mTrigger; // chosen VMC generator trigger
56+
unsigned int mNEvents; // number of events to be simulated
57+
std::string mExtKinFileName; // file name of external kinematics file (needed for ext kinematics generator)
58+
std::string mEmbedIntoFileName; // filename containing the reference events to be used for the embedding
59+
unsigned int mStartEvent; // index of first event to be taken
60+
float mBMax; // maximum for impact parameter sampling
61+
bool mIsMT; // chosen MT mode (Geant4 only)
62+
std::string mOutputPrefix; // prefix to be used for output files
63+
std::string mLogSeverity; // severity for FairLogger
64+
std::string mLogVerbosity; // loglevel for FairLogger
65+
std::string mKeyValueTokens; // a string holding arbitrary sequence of key-value tokens
66+
// Foo.parameter1=x,Bar.parameter2=y,Baz.paramter3=hello
67+
// (can be used to **loosely** change any configuration parameter from command-line)
68+
std::string mConfigFile; // path to a JSON or INI config file (file extension is required to determine type).
69+
// values within the config file will override values set in code by the param classes
70+
// but will themselves be overridden by any values given in mKeyValueTokens.
71+
unsigned int mPrimaryChunkSize; // defining max granularity for input primaries of a sim job
72+
int mInternalChunkSize; //
73+
ULong_t mStartSeed; // base for random number seeds
74+
int mSimWorkers = 1; // number of parallel sim workers (when it applies)
75+
bool mFilterNoHitEvents = false; // whether to filter out events not leaving any response
76+
std::string mCCDBUrl; // the URL where to find CCDB
77+
uint64_t mTimestamp; // timestamp in ms to anchor transport simulation to
7878
TimeStampMode mTimestampMode = TimeStampMode::kNow; // telling of timestamp was given as option or defaulted to now
79-
int mRunNumber = -1; // ALICE run number (if set != -1); the timestamp should be compatible
80-
int mField; // L3 field setting in kGauss: +-2,+-5 and 0
81-
SimFieldMode mFieldMode = SimFieldMode::kDefault; // uniform magnetic field
82-
bool mAsService = false; // if simulation should be run as service/deamon (does not exit after run)
83-
bool mNoGeant = false; // if Geant transport should be turned off (when one is only interested in the generated events)
84-
bool mIsUpgrade = false; // true if the simulation is for Run 5
85-
std::string mFromCollisionContext = ""; // string denoting a collision context file; If given, this file will be used to determine number of events
86-
bool mForwardKine = false; // true if tracks and event headers are to be published on a FairMQ channel (for reading by other consumers)
87-
bool mWriteToDisc = true; // whether we write simulation products (kine, hits) to disc
79+
int mRunNumber = -1; // ALICE run number (if set != -1); the timestamp should be compatible
80+
int mField; // L3 field setting in kGauss: +-2,+-5 and 0
81+
SimFieldMode mFieldMode = SimFieldMode::kDefault; // uniform magnetic field
82+
bool mAsService = false; // if simulation should be run as service/deamon (does not exit after run)
83+
bool mNoGeant = false; // if Geant transport should be turned off (when one is only interested in the generated events)
84+
bool mIsUpgrade = false; // true if the simulation is for Run 5
85+
std::string mFromCollisionContext = ""; // string denoting a collision context file; If given, this file will be used to determine number of events
86+
bool mForwardKine = false; // true if tracks and event headers are to be published on a FairMQ channel (for reading by other consumers)
87+
bool mWriteToDisc = true; // whether we write simulation products (kine, hits) to disc
8888
VertexMode mVertexMode = VertexMode::kDiamondParam; // by default we should use die InteractionDiamond parameter
8989

9090
ClassDefNV(SimConfigData, 4);
@@ -105,6 +105,9 @@ class SimConfig
105105
resetFromArguments(1, argv);
106106
};
107107

108+
// Function used to check that of 'for_what' is specified, then 'required_option' is specified too.
109+
void checkOptionalDependency(const boost::program_options::variables_map& vm, const char* for_what, const char* required_option) const;
110+
108111
public:
109112
static SimConfig& Instance()
110113
{
@@ -140,6 +143,7 @@ class SimConfig
140143
// static helper functions to determine list of active / readout modules
141144
// can also be used from outside
142145
static void determineActiveModules(std::vector<std::string> const& input, std::vector<std::string> const& skipped, std::vector<std::string>& active, bool isUpgrade = false);
146+
static bool determineActiveModulesVersion(const std::string& version, const std::string& fileName, std::vector<std::string> const& input, std::vector<std::string> const& skipped, std::vector<std::string>& active);
143147
static void determineReadoutDetectors(std::vector<std::string> const& active, std::vector<std::string> const& enabledRO, std::vector<std::string> const& skippedRO, std::vector<std::string>& finalRO);
144148

145149
// helper to parse field option
@@ -206,9 +210,9 @@ struct SimReconfigData {
206210
std::string configFile; // path to a JSON or INI config file (file extension is required to determine type).
207211
// values within the config file will override values set in code by the param classes
208212
// but will themselves be overridden by any values given in mKeyValueTokens.
209-
unsigned int primaryChunkSize; // defining max granularity for input primaries of a sim job
210-
ULong_t startSeed; // base for random number seeds
211-
bool stop; // to shut down the service
213+
unsigned int primaryChunkSize; // defining max granularity for input primaries of a sim job
214+
ULong_t startSeed; // base for random number seeds
215+
bool stop; // to shut down the service
212216
std::string mFromCollisionContext = ""; // string denoting a collision context file; If given, this file will be used to determine number of events
213217

214218
ClassDefNV(SimReconfigData, 1);
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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+
12+
#include "SimConfig/DetectorVersions.h"
13+
14+
namespace o2::conf
15+
{
16+
17+
const DetectorMap_t DetectorVersions{
18+
#ifdef ENABLE_UPGRADES
19+
{"ALICE3", {
20+
// clang-format off
21+
// Active
22+
"TRK",
23+
"FT3",
24+
"FCT",
25+
"RCH",
26+
"MI3",
27+
"ECL",
28+
// Passive
29+
"HALL",
30+
"MAG",
31+
"A3IP",
32+
"A3ABSO",
33+
"A3MAG",
34+
// clang-format on
35+
}},
36+
// ALICE 2.1
37+
{"ALICE2.1", {
38+
// clang-format off
39+
// Active
40+
"IT3",
41+
"TPC",
42+
"TRD",
43+
"TOF",
44+
"PHS",
45+
"EMC",
46+
"HMP",
47+
"MFT",
48+
"MCH",
49+
"MID",
50+
"ZDC",
51+
"FT0",
52+
"FV0",
53+
"FDD",
54+
"CTP",
55+
"FOC",
56+
// Passive
57+
"HALL",
58+
"MAG",
59+
"DIPO",
60+
"COMP",
61+
"PIPE",
62+
"ABSO",
63+
"SHIL"
64+
// clang-format on
65+
// Note for IT3 the pipe is automatically replaced with another version
66+
}},
67+
#endif
68+
// ALICE 2
69+
{"ALICE2", {
70+
// clang-format off
71+
// Active
72+
"ITS",
73+
"TPC",
74+
"TRD",
75+
"TOF",
76+
"PHS",
77+
"EMC",
78+
"HMP",
79+
"MFT",
80+
"MCH",
81+
"MID",
82+
"ZDC",
83+
"FT0",
84+
"FV0",
85+
"FDD",
86+
"CTP",
87+
// Passive
88+
"HALL",
89+
"MAG",
90+
"DIPO",
91+
"COMP",
92+
"PIPE",
93+
"ABSO",
94+
"SHIL",
95+
// clang-format on
96+
}},
97+
};
98+
99+
void printDetMap(const DetectorMap_t& map)
100+
{
101+
LOGP(error, "List of available versions including their detectors:");
102+
for (int i{0}; const auto& [version, elements] : map) {
103+
LOGP(error, " - {: >2d}. {}:", i++, version);
104+
for (int j{0}; const auto& element : elements) {
105+
LOGP(error, "\t\t* {: >2d}.\t{}", j++, element);
106+
}
107+
}
108+
}
109+
110+
} // namespace o2::conf

0 commit comments

Comments
 (0)