Skip to content

Commit

Permalink
Separating executable for Run 3 and Run 5 (the different modules will…
Browse files Browse the repository at this point in the history
… not mix) (AliceO2Group#9665)

* Separating Run3 and Run5 sim executables.

Co-authored-by: Zoltan Varga <zoltan.varga@cern.ch>
Co-authored-by: Benedikt Volkel <benedikt.volkel@cern.ch>
3 people authored Sep 14, 2022
1 parent bf83ec0 commit aeb2f45
Showing 8 changed files with 89 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Common/SimConfig/include/SimConfig/SimConfig.h
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ struct SimConfigData {
SimFieldMode mFieldMode = kDefault; // uniform magnetic field
bool mAsService = false; // if simulation should be run as service/deamon (does not exit after run)
bool mNoGeant = false; // if Geant transport should be turned off (when one is only interested in the generated events)
bool mIsRun5 = false; // true if the simulation is for Run 5

ClassDefNV(SimConfigData, 4);
};
@@ -114,7 +115,7 @@ class SimConfig

// static helper functions to determine list of active / readout modules
// can also be used from outside
static void determineActiveModules(std::vector<std::string> const& input, std::vector<std::string> const& skipped, std::vector<std::string>& active);
static void determineActiveModules(std::vector<std::string> const& input, std::vector<std::string> const& skipped, std::vector<std::string>& active, bool isRun5 = false);
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);

// helper to parse field option
@@ -144,6 +145,7 @@ class SimConfig
uint64_t getTimestamp() const { return mConfigData.mTimestamp; }
int getRunNumber() const { return mConfigData.mRunNumber; }
bool isNoGeant() const { return mConfigData.mNoGeant; }
void setRun5(bool value = true) { mConfigData.mIsRun5 = value; }

private:
SimConfigData mConfigData; //!
54 changes: 41 additions & 13 deletions Common/SimConfig/src/SimConfig.cxx
Original file line number Diff line number Diff line change
@@ -59,32 +59,60 @@ void SimConfig::initOptions(boost::program_options::options_description& options
"noGeant", bpo::bool_switch(), "prohibits any Geant transport/physics (by using tight cuts)");
}

void SimConfig::determineActiveModules(std::vector<std::string> const& inputargs, std::vector<std::string> const& skippedModules, std::vector<std::string>& activeModules)
void SimConfig::determineActiveModules(std::vector<std::string> const& inputargs, std::vector<std::string> const& skippedModules, std::vector<std::string>& activeModules, bool mIsRun5)
{
using o2::detectors::DetID;

// input args is a vector of module strings as obtained from the -m,--modules options
// of SimConfig
activeModules = inputargs;
#ifdef ENABLE_UPGRADES
if (activeModules[0] != "all") {
if (mIsRun5) {
for (int i = 0; i < activeModules.size(); ++i) {
if (activeModules[i] != "IT3" && activeModules[i] != "TRK" && activeModules[i] != "FT3" && activeModules[i] != "FCT") {
LOG(fatal) << "List of active modules contains " << activeModules[i] << " which is NOT a Run 5 module!";
}
}
}
if (!mIsRun5) {
for (int i = 0; i < activeModules.size(); ++i) {
if (activeModules[i] == "IT3" || activeModules[i] == "TRK" || activeModules[i] == "FT3" || activeModules[i] == "FCT") {
LOG(fatal) << "List of active modules contains " << activeModules[i] << " which is NOT a Run 3 module!";
}
}
}
}
#endif
if (activeModules.size() == 1 && activeModules[0] == "all") {
activeModules.clear();
for (int d = DetID::First; d <= DetID::Last; ++d) {
#ifdef ENABLE_UPGRADES
if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT) {
activeModules.emplace_back(DetID::getName(d));
if (mIsRun5) {
for (int d = DetID::First; d <= DetID::Last; ++d) {
if (d == DetID::IT3 || d == DetID::TRK || d == DetID::FT3 || d == DetID::FCT) {
activeModules.emplace_back(DetID::getName(d));
}
}
} else {
#endif
// add passive components manually (make a PassiveDetID for them!)
activeModules.emplace_back("HALL");
activeModules.emplace_back("MAG");
activeModules.emplace_back("DIPO");
activeModules.emplace_back("COMP");
activeModules.emplace_back("PIPE");
activeModules.emplace_back("ABSO");
activeModules.emplace_back("SHIL");
for (int d = DetID::First; d <= DetID::Last; ++d) {
#ifdef ENABLE_UPGRADES
if (d != DetID::IT3 && d != DetID::TRK && d != DetID::FT3 && d != DetID::FCT) {
activeModules.emplace_back(DetID::getName(d));
}
}
#else
activeModules.emplace_back(DetID::getName(d));
#endif
}
// add passive components manually (make a PassiveDetID for them!)
activeModules.emplace_back("HALL");
activeModules.emplace_back("MAG");
activeModules.emplace_back("DIPO");
activeModules.emplace_back("COMP");
activeModules.emplace_back("PIPE");
activeModules.emplace_back("ABSO");
activeModules.emplace_back("SHIL");
}
// now we take out detectors listed as skipped
for (auto& s : skippedModules) {
@@ -150,7 +178,7 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
mConfigData.mMCEngine = vm["mcEngine"].as<std::string>();

// get final set of active Modules
determineActiveModules(vm["modules"].as<std::vector<std::string>>(), vm["skipModules"].as<std::vector<std::string>>(), mConfigData.mActiveModules);
determineActiveModules(vm["modules"].as<std::vector<std::string>>(), vm["skipModules"].as<std::vector<std::string>>(), mConfigData.mActiveModules, mConfigData.mIsRun5);
const auto& activeModules = mConfigData.mActiveModules;

// get final set of detectors which are readout
4 changes: 3 additions & 1 deletion DataFormats/Parameters/src/GRPTool.cxx
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ struct Options {
bool lhciffromccdb = false; // whether only to take GRPLHCIF from CCDB
std::string publishto = "";
std::string ccdbhost = "http://alice-ccdb.cern.ch";
bool isRun5 = false; // whether or not this is supposed to be a Run5 detector configuration
};

void print_globalHelp(int argc, char* argv[])
@@ -226,7 +227,7 @@ bool create_GRPs(Options const& opts)
grp.setTimeEnd(runStart + 3600000);
grp.setNHBFPerTF(opts.orbitsPerTF);
std::vector<std::string> modules{};
o2::conf::SimConfig::determineActiveModules(opts.readout, std::vector<std::string>(), modules);
o2::conf::SimConfig::determineActiveModules(opts.readout, std::vector<std::string>(), modules, opts.isRun5);
std::vector<std::string> readout{};
o2::conf::SimConfig::determineReadoutDetectors(modules, std::vector<std::string>(), opts.skipreadout, readout);
for (auto& detstr : readout) {
@@ -476,6 +477,7 @@ bool parseOptions(int argc, char* argv[], Options& optvalues)
desc.add_options()("lhcif-CCDB", "take GRPLHCIF directly from CCDB");
desc.add_options()("print", "print resulting GRPs");
desc.add_options()("publishto", bpo::value<std::string>(&optvalues.publishto)->default_value(""), "Base path under which GRP objects should be published on disc. This path can serve as lookup for CCDB queries of the GRP objects.");
desc.add_options()("isRun5", bpo::bool_switch(&optvalues.isRun5), "Whether or not to expect a Run5 detector configuration.");
if (!subparse(desc, vm, "createGRPs")) {
return false;
}
17 changes: 17 additions & 0 deletions run/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -71,6 +71,17 @@ o2_add_executable(primary-server-device-runner
SOURCES O2PrimaryServerDeviceRunner.cxx
PUBLIC_LINK_LIBRARIES internal::allsim
TARGETVARNAME simexe)
if(ENABLE_UPGRADES)
o2_add_executable(serial-run5
COMPONENT_NAME sim
SOURCES o2sim.cxx
PUBLIC_LINK_LIBRARIES internal::allsim)

o2_add_executable(sim-run5
SOURCES o2sim_parallel.cxx
PUBLIC_LINK_LIBRARIES internal::allsim O2::Version
TARGETVARNAME simdriverrun5)
endif()
if(NOT APPLE)
set_property(TARGET ${simexe} PROPERTY LINK_WHAT_YOU_USE ON)
endif()
@@ -98,7 +109,13 @@ message(STATUS "SIMENV = ${SIMENV}")

o2_name_target(sim NAME o2simExecutable IS_EXE)
o2_name_target(sim-serial NAME o2simSerialExecutable IS_EXE)
if(ENABLE_UPGRADES)
o2_name_target(sim-serial-run5 NAME o2simSerialRun5Executable IS_EXE)
o2_name_target(sim-run5 NAME o2simRun5Executable IS_EXE)

target_compile_definitions(${o2simSerialRun5Executable} PUBLIC SIM_RUN5)
target_compile_definitions(${o2simRun5Executable} PUBLIC SIM_RUN5)
endif()
if (BUILD_TESTING)
o2_add_test_command(NAME o2sim_G4
WORKING_DIRECTORY ${SIMTESTDIR}
5 changes: 4 additions & 1 deletion run/O2PrimaryServerDevice.h
Original file line number Diff line number Diff line change
@@ -195,8 +195,11 @@ class O2PrimaryServerDevice final : public fair::mq::Device
LOG(info) << "Init Server device ";

// init sim config
auto& conf = o2::conf::SimConfig::Instance();
auto& vm = GetConfig()->GetVarMap();
auto& conf = o2::conf::SimConfig::Instance();
if (vm.count("isRun5")) {
conf.setRun5();
}
conf.resetFromParsedMap(vm);
// output varmap
// for (auto& keyvalue : vm) {
1 change: 1 addition & 0 deletions run/O2PrimaryServerDeviceRunner.cxx
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ void addCustomOptions(bpo::options_description& options)
{
// append the same options here as used for SimConfig
o2::conf::SimConfig::initOptions(options);
options.add_options()("isRun5", "flag whether a Run5 detector setup is expected");
}

std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& config)
3 changes: 3 additions & 0 deletions run/o2sim.cxx
Original file line number Diff line number Diff line change
@@ -19,6 +19,9 @@ int main(int argc, char* argv[])
TStopwatch timer;
timer.Start();
auto& conf = o2::conf::SimConfig::Instance();
#ifdef SIM_RUN5
conf.setRun5();
#endif
if (!conf.resetFromArguments(argc, argv)) {
return 1;
}
19 changes: 17 additions & 2 deletions run/o2sim_parallel.cxx
Original file line number Diff line number Diff line change
@@ -364,6 +364,9 @@ int main(int argc, char* argv[])
auto externalpublishchannel = o2::simpubsub::createPUBChannel(o2::simpubsub::getPublishAddress("o2sim-notifications"));

auto& conf = o2::conf::SimConfig::Instance();
#ifdef SIM_RUN5
conf.setRun5();
#endif
if (!conf.resetFromArguments(argc, argv)) {
return 1;
}
@@ -372,7 +375,11 @@ int main(int argc, char* argv[])
if (conf.getNEvents() <= 0 && !conf.asService()) {
LOG(info) << "No events to be simulated; Switching to non-distributed mode";
const int Nargs = argc + 1;
#ifdef SIM_RUN5
std::string name("o2-sim-serial-run5");
#else
std::string name("o2-sim-serial");
#endif
const char* arguments[Nargs];
arguments[0] = name.c_str();
for (int i = 1; i < argc; ++i) {
@@ -428,7 +435,12 @@ int main(int argc, char* argv[])
const std::string config = localconfig;

// copy all arguments into a common vector
const int Nargs = argc + 9;
#ifdef SIM_RUN5
const int addNArgs = 10;
#else
const int addNArgs = 9;
#endif
const int Nargs = argc + addNArgs;
const char* arguments[Nargs];
arguments[0] = name.c_str();
arguments[1] = "--control";
@@ -439,8 +451,11 @@ int main(int argc, char* argv[])
arguments[6] = config.c_str();
arguments[7] = "--severity";
arguments[8] = "debug";
#ifdef SIM_RUN5
arguments[9] = "--isRun5";
#endif
for (int i = 1; i < argc; ++i) {
arguments[8 + i] = argv[i];
arguments[addNArgs - 1 + i] = argv[i];
}
arguments[Nargs - 1] = nullptr;
for (int i = 0; i < Nargs; ++i) {

0 comments on commit aeb2f45

Please sign in to comment.