Skip to content

Commit 73a31f3

Browse files
committed
Use Rubens name class (part 1)
1 parent 5b7d846 commit 73a31f3

16 files changed

Lines changed: 69 additions & 111 deletions

File tree

DataFormats/Detectors/Common/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ o2_add_library(DetectorsCommonDataFormats
2121
o2_target_root_dictionary(
2222
DetectorsCommonDataFormats
2323
HEADERS include/DetectorsCommonDataFormats/DetID.h
24-
include/DetectorsCommonDataFormats/FileNameGenerator.h
2524
include/DetectorsCommonDataFormats/SimTraits.h
2625
include/DetectorsCommonDataFormats/AlignParam.h
2726
include/DetectorsCommonDataFormats/NameConf.h

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/FileNameGenerator.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/NameConf.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,35 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
3131

3232
public:
3333
// The Hits file name are generated by hardcoded schema, only prefix is mutable to allow the embedding
34-
std::string getHitsFileName(o2::detectors::DetID d, const std::string_view prefix = DefSimFileNamePrefix) const
34+
static std::string getHitsFileName(o2::detectors::DetID d, const std::string_view prefix = STANDARDSIMPREFIX)
3535
{
36-
return o2::utils::concat_string(prefix, HitsFileName, d.getName(), ".root");
36+
return o2::utils::concat_string(prefix, "_", HITS_STRING, d.getName(), ".root");
3737
}
3838

3939
// The Digits file name are generated by hardcoded schema, only prefix is mutable to allow the embedding
40-
std::string getDigitsFileName(o2::detectors::DetID d, const std::string_view prefix = DefSimFileNamePrefix) const
40+
static std::string getDigitsFileName(o2::detectors::DetID d, const std::string_view prefix = STANDARDSIMPREFIX)
4141
{
42-
return o2::utils::concat_string(prefix, DigitsFileName, d.getName(), ".root");
42+
return o2::utils::concat_string(prefix, "_", DIGITS_STRING, d.getName(), ".root");
4343
}
4444

4545
// Filename to store kinematics + TrackRefs
46-
std::string getGRPFileName(const std::string_view prefix = DefSimFileNamePrefix) const
46+
static std::string getGRPFileName(const std::string_view prefix = STANDARDSIMPREFIX)
4747
{
48-
return o2::utils::concat_string(prefix, GRPFileName, ".root");
48+
return o2::utils::concat_string(prefix, "_", GRP_STRING, ".root");
4949
}
5050

5151
// Filename to store kinematics + TrackRefs
52-
std::string getMCTruthFileName(const std::string_view prefix = DefSimFileNamePrefix) const
52+
static std::string getMCKinematicsFileName(const std::string_view prefix = STANDARDSIMPREFIX)
5353
{
54-
return o2::utils::concat_string(prefix, mMCTruthFileName, ".root");
54+
return o2::utils::concat_string(prefix, "_", KINE_STRING, ".root");
5555
}
5656

5757
private:
58-
static constexpr std::string_view DefSimFileNamePrefix = "o2sim";
59-
static constexpr std::string_view HitsFileName = "Hits"; // hardcoded
60-
static constexpr std::string_view DigitsFileName = "Digits"; // hardcoded
61-
static constexpr std::string_view GRPFileName = "GRP"; // hardcoded
62-
63-
std::string mMCTruthFileName = "MCTruth";
58+
static constexpr std::string_view STANDARDSIMPREFIX = "o2sim";
59+
static constexpr std::string_view HITS_STRING = "Hits"; // hardcoded
60+
static constexpr std::string_view DIGITS_STRING = "Digits"; // hardcoded
61+
static constexpr std::string_view GRP_STRING = "grp"; // hardcoded
62+
static constexpr std::string_view KINE_STRING = "Kine"; // hardcoded
6463

6564
O2ParamDef(NameConf, "NameConf");
6665
};

DataFormats/Detectors/Common/src/DetectorsCommonDataFormatsLinkDef.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#pragma link C++ class o2::detectors::DetMatrixCache + ;
2222
#pragma link C++ class o2::detectors::DetMatrixCacheIndirect + ;
2323

24-
#pragma link C++ class o2::filenames::SimFileNameGenerator;
2524
#pragma link C++ class o2::detectors::SimTraits + ;
2625

2726
#pragma link C++ class o2::base::NameConf + ;

DataFormats/simulation/test/checkStack.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include <cassert>
1616
#include "FairLogger.h"
1717

18-
void checkStack(const char* name = "o2sim_kine.root")
18+
void checkStack(const char* nameprefix = "o2sim")
1919
{
2020
FairLogger::GetLogger()->SetLogScreenLevel("DEBUG");
21-
TFile f(name);
21+
TFile f(o2::base::NameConf::getMCKinematicsFileName(nameprefix).c_str());
2222

2323
LOG(DEBUG) << "Checking input file :" << f.GetPath();
2424

Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "SimReaderSpec.h"
2121
#include "CollisionTimePrinter.h"
2222
#include "DetectorsCommonDataFormats/DetID.h"
23+
#include "DetectorsCommonDataFormats/NameConf.h"
2324
#include "CommonUtils/ConfigurableParam.h"
2425

2526
// for TPC
@@ -138,10 +139,6 @@ void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
138139
workflowOptions.push_back(
139140
ConfigParamSpec{"tpc-reco-type", VariantType::String, "", {tpcrthelp}});
140141

141-
std::string grphelp("GRP file describing the simulation");
142-
workflowOptions.push_back(
143-
ConfigParamSpec{"GRP", VariantType::String, "o2sim_grp.root", {grphelp}});
144-
145142
std::string simhelp("Comma separated list of simulation prefixes (for background, signal productions)");
146143
workflowOptions.push_back(
147144
ConfigParamSpec{"sims", VariantType::String, "o2sim", {simhelp}});
@@ -219,7 +216,7 @@ bool wantCollisionTimePrinter()
219216

220217
// ------------------------------------------------------------------
221218

222-
std::shared_ptr<o2::parameters::GRPObject> readGRP(std::string inputGRP = "o2sim_grp.root")
219+
std::shared_ptr<o2::parameters::GRPObject> readGRP(std::string inputGRP)
223220
{
224221
// init magnetic field
225222
o2::base::Propagator::initFieldFromGRP(inputGRP);
@@ -334,8 +331,8 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
334331
}
335332

336333
// First, read the GRP to detect which components need instantiations
337-
// (for the moment this assumes the file o2sim_grp.root to be in the current directory)
338-
const auto grp = readGRP(configcontext.options().get<std::string>("GRP"));
334+
auto grpfile = o2::base::NameConf::getGRPFileName(simPrefixes[0]);
335+
const auto grp = readGRP(grpfile.c_str());
339336
if (!grp) {
340337
return WorkflowSpec{};
341338
}
@@ -537,7 +534,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
537534
}
538535

539536
// GRP updater: must come after all detectors since requires their list
540-
specs.emplace_back(o2::parameters::getGRPUpdaterSpec(configcontext.options().get<std::string>("GRP"), detList));
537+
specs.emplace_back(o2::parameters::getGRPUpdaterSpec(grpfile, detList));
541538

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

Steer/include/Steer/HitProcessingManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "CommonDataFormat/InteractionRecord.h"
1515
#include "SimulationDataFormat/RunContext.h"
1616
#include "Steer/InteractionSampler.h"
17-
#include "DetectorsCommonDataFormats/FileNameGenerator.h"
17+
#include "DetectorsCommonDataFormats/NameConf.h"
1818
#include <TGeoManager.h>
1919
#include <string>
2020
#include <vector>

Steer/src/HitProcessingManager.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ bool HitProcessingManager::setupChain()
5454
auto& c = *mSimChains[0];
5555
c.Reset();
5656
for (auto& filename : mBackgroundFileNames) {
57-
c.AddFile(o2::filenames::SimFileNameGenerator::getKinematicsFileName(filename.data()).c_str());
57+
c.AddFile(o2::base::NameConf::getMCKinematicsFileName(filename.data()).c_str());
5858
}
5959

6060
for (auto& pair : mSignalFileNames) {
6161
const auto& signalid = pair.first;
6262
const auto& filenamevector = pair.second;
6363
auto& chain = *mSimChains[signalid];
6464
for (auto& filename : filenamevector) {
65-
chain.AddFile(o2::filenames::SimFileNameGenerator::getKinematicsFileName(filename.data()).c_str());
65+
chain.AddFile(o2::base::NameConf::getMCKinematicsFileName(filename.data()).c_str());
6666
}
6767
}
6868

macro/analyzeDigitLabels.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ struct LabelStats {
7171
template <typename LabelType, typename Accumulator = LabelStats>
7272
void analyse(TTree* tr, const char* brname, Accumulator& prop)
7373
{
74+
if (!tr) {
75+
return;
76+
}
7477
auto br = tr->GetBranch(brname);
7578
if (!br) {
7679
return;

macro/analyzeHits.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "MIDSimulation/Hit.h"
1717
#include "CPVBase/Hit.h"
1818
#include "ZDCSimulation/Hit.h"
19-
#include "DetectorsCommonDataFormats/FileNameGenerator.h"
19+
#include "DetectorsCommonDataFormats/NameConf.h"
2020
#include "DataFormatsParameters/GRPObject.h"
2121
#endif
2222

@@ -357,10 +357,10 @@ TTree* getHitTree(o2::parameters::GRPObject const* grp, const char* filebase, o2
357357
return nullptr;
358358
}
359359

360-
std::string filename(o2::filenames::SimFileNameGenerator::getHitFileName(detid, filebase).c_str());
360+
std::string filename(o2::base::NameConf::getHitsFileName(detid, filebase).c_str());
361361

362362
// shamefully leaking memory as the TTree cannot live without the file...
363-
TFile* file = new TFile(o2::filenames::SimFileNameGenerator::getHitFileName(detid, filebase).c_str(), "OPEN");
363+
TFile* file = new TFile(filename.c_str(), "OPEN");
364364
auto t = (TTree*)file->Get("o2sim");
365365
return t;
366366
}
@@ -377,7 +377,7 @@ void analyzeHits(const char* filebase = "o2sim", const char* prefix = "")
377377
gPrefix = prefix;
378378

379379
// READ GRP AND ITERATE OVER DETECTED PARTS
380-
auto grp = o2::parameters::GRPObject::loadFrom(o2::filenames::SimFileNameGenerator::getGRPFileName(filebase).c_str());
380+
auto grp = o2::parameters::GRPObject::loadFrom(o2::base::NameConf::getGRPFileName(filebase).c_str());
381381

382382
// should correspond to the same number as defined in DetID
383383
analyzeITS(getHitTree(grp, filebase, o2::detectors::DetID::ITS));

0 commit comments

Comments
 (0)