Skip to content

Commit f4177bd

Browse files
committed
Digitizer workflow: Ability to use arbitrary GRP file
This commit fixes a problem in the digitizer workflow. Up until now, this was only working with files named "o2sim.root" and "o2sim_grp.root". Now it is possible to use arbitrary names ``` o2-sim-digitizer-workflow --GRP o2simTRD_grp.root --simFile o2simTRD.root -b --onlyDet TRD ```
1 parent 958902d commit f4177bd

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

Steer/DigitizerWorkflow/src/GRPUpdaterSpec.cxx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,23 @@ class GRPDPLUpdatedTask
3838
using GRP = o2::parameters::GRPObject;
3939

4040
public:
41+
GRPDPLUpdatedTask(const std::string& grpfilename) : mGRPFileName{grpfilename} {}
42+
4143
void init(framework::InitContext& ic)
4244
{
4345
// nothing special to be set up
4446
}
4547

4648
void run(framework::ProcessingContext& pc)
4749
{
48-
const std::string inputGRP = "o2sim_grp.root";
4950
const std::string grpName = "GRP";
5051
if (mFinished) {
5152
return;
5253
}
5354

54-
TFile flGRP(inputGRP.c_str(), "update");
55+
TFile flGRP(mGRPFileName.c_str(), "update");
5556
if (flGRP.IsZombie()) {
56-
LOG(ERROR) << "Failed to open in update mode " << inputGRP;
57+
LOG(ERROR) << "Failed to open in update mode " << mGRPFileName;
5758
return;
5859
}
5960
std::unique_ptr<GRP> grp(static_cast<GRP*>(flGRP.GetObjectChecked(grpName.c_str(), GRP::Class())));
@@ -65,7 +66,7 @@ class GRPDPLUpdatedTask
6566
}
6667
grp->setDetROMode(det, roMode);
6768
}
68-
LOG(INFO) << "Updated GRP in " << inputGRP << " for detectors RO mode";
69+
LOG(INFO) << "Updated GRP in " << mGRPFileName << " for detectors RO mode";
6970
grp->print();
7071
flGRP.WriteObjectAny(grp.get(), grp->Class(), grpName.c_str());
7172
flGRP.Close();
@@ -76,10 +77,11 @@ class GRPDPLUpdatedTask
7677

7778
private:
7879
bool mFinished = false;
80+
std::string mGRPFileName = "o2sim_grp.root";
7981
};
8082

8183
/// create the processor spec
82-
o2::framework::DataProcessorSpec getGRPUpdaterSpec(const std::vector<o2::detectors::DetID>& detList)
84+
o2::framework::DataProcessorSpec getGRPUpdaterSpec(const std::string& grpfilename, const std::vector<o2::detectors::DetID>& detList)
8385
{
8486
sDetList = detList;
8587
static constexpr std::array<o2::header::DataOrigin, o2::detectors::DetID::nDetectors> sOrigins = {
@@ -101,7 +103,7 @@ o2::framework::DataProcessorSpec getGRPUpdaterSpec(const std::vector<o2::detecto
101103
"GRPUpdater",
102104
inputs, // input status from each detector
103105
{}, // no output
104-
AlgorithmSpec{adaptFromTask<GRPDPLUpdatedTask>()},
106+
AlgorithmSpec{adaptFromTask<GRPDPLUpdatedTask>(grpfilename)},
105107
Options{/* for the moment no options */}};
106108
}
107109

Steer/DigitizerWorkflow/src/GRPUpdaterSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace parameters
2121
{
2222

2323
o2::framework::DataProcessorSpec
24-
getGRPUpdaterSpec(const std::vector<o2::detectors::DetID>& detList);
24+
getGRPUpdaterSpec(const std::string& grpfilename, const std::vector<o2::detectors::DetID>& detList);
2525

2626
} // end namespace parameters
2727
} // end namespace o2

Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
134134
workflowOptions.push_back(
135135
ConfigParamSpec{"tpc-reco-type", VariantType::String, "", {tpcrthelp}});
136136

137+
std::string grphelp("GRP file describing the simulation");
138+
workflowOptions.push_back(
139+
ConfigParamSpec{"GRP", VariantType::String, "o2sim_grp.root", {grphelp}});
140+
137141
// option allowing to set parameters
138142
std::string keyvaluehelp("Semicolon separated key=value strings (e.g.: 'TPC.gasDensity=1;...')");
139143
workflowOptions.push_back(
@@ -314,7 +318,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
314318

315319
// First, read the GRP to detect which components need instantiations
316320
// (for the moment this assumes the file o2sim_grp.root to be in the current directory)
317-
const auto grp = readGRP();
321+
const auto grp = readGRP(configcontext.options().get<std::string>("GRP"));
318322
if (!grp) {
319323
return WorkflowSpec{};
320324
}
@@ -509,7 +513,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
509513
}
510514

511515
// GRP updater: must come after all detectors since requires their list
512-
specs.emplace_back(o2::parameters::getGRPUpdaterSpec(detList));
516+
specs.emplace_back(o2::parameters::getGRPUpdaterSpec(configcontext.options().get<std::string>("GRP"), detList));
513517

514518
// The SIM Reader. NEEDS TO BE LAST
515519
specs[0] = o2::steer::getSimReaderSpec(fanoutsize, tpcsectors, tpclanes);

0 commit comments

Comments
 (0)