Skip to content

Commit 1403019

Browse files
committed
Store GRPxxx objects under ccdb_object name
1 parent 87e866c commit 1403019

13 files changed

Lines changed: 54 additions & 26 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
5252
// Filename of general run parameters from ECS (GRPECS)
5353
static std::string getGRPECSFileName(const std::string_view prefix = STANDARDSIMPREFIX);
5454

55+
// Filename of general run parameters from LHCIF (GRPLHCIF)
56+
static std::string getGRPLHCIFFileName(const std::string_view prefix = STANDARDSIMPREFIX);
57+
5558
// Filename of general run parameters fof B field (GRPMagField)
5659
static std::string getGRPMagFieldFileName(const std::string_view prefix = STANDARDSIMPREFIX);
5760

@@ -133,6 +136,7 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
133136
static constexpr std::string_view DIGITS_STRING = "Digits"; // hardcoded
134137
static constexpr std::string_view GRP_STRING = "grp"; // hardcoded
135138
static constexpr std::string_view GRPECS_STRING = "grpecs"; // hardcoded
139+
static constexpr std::string_view GRPLHCIF_STRING = "grplhcif"; // hardcoded
136140
static constexpr std::string_view GRPMAGFIELD_STRING = "grpMagField"; // hardcoded
137141
static constexpr std::string_view KINE_STRING = "Kine"; // hardcoded
138142
static constexpr std::string_view MCHEADER_STRING = "MCHeader"; // hardcoded
@@ -151,6 +155,7 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
151155
// these are configurable paths for some commonly used files
152156
std::string mDirGRP = "none"; // directory for GRP file ("none" == "")
153157
std::string mDirGRPECS = "none"; // directory for GRPECS file ("none" == "")
158+
std::string mDirGRPLHCIF = "none"; // directory for GRPLHCIF file ("none" == "")
154159
std::string mDirGRPMagField = "none"; // directory for GRPMagField file ("none" == "")
155160
std::string mDirGeom = "none"; // directory for geometry file
156161
std::string mDirMatLUT = "none"; // directory for material LUT

DataFormats/Detectors/Common/src/NameConf.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ std::string NameConf::getGRPECSFileName(const std::string_view prefix)
6161
return buildFileName(prefix, "_", STANDARDSIMPREFIX, GRPECS_STRING, ROOT_EXT_STRING, Instance().mDirGRPECS);
6262
}
6363

64+
// Filename to store general run parameters from LHCIF (GRPLHCIF)
65+
std::string NameConf::getGRPLHCIFFileName(const std::string_view prefix)
66+
{
67+
return buildFileName(prefix, "_", STANDARDSIMPREFIX, GRPLHCIF_STRING, ROOT_EXT_STRING, Instance().mDirGRPLHCIF);
68+
}
69+
6470
// Filename to store general run parameters from ECS (GRPECS)
6571
std::string NameConf::getGRPMagFieldFileName(const std::string_view prefix)
6672
{

DataFormats/Parameters/include/DataFormatsParameters/GRPECSObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class GRPECSObject
102102
/// print itself
103103
void print() const;
104104

105-
static GRPECSObject* loadFrom(const std::string& grpecsFileName = "", const std::string& grpecsName = "GRPECS");
105+
static GRPECSObject* loadFrom(const std::string& grpecsFileName = "");
106106

107107
private:
108108
timePoint mTimeStart = 0; ///< DAQ_time_start entry from DAQ logbook

DataFormats/Parameters/include/DataFormatsParameters/GRPLHCIFData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class GRPLHCIFData
9595
/// helper function for BunchFilling
9696
void translateBucketsToBCNumbers(std::vector<int32_t>& bcNb, std::vector<int32_t>& buckets, int beam);
9797

98+
static GRPLHCIFData* loadFrom(const std::string& grpLHCIFFileName = "");
99+
98100
private:
99101
std::pair<long, int32_t> mBeamEnergyPerZ; // beam energy per charge
100102
std::pair<long, int32_t> mFillNumber;

DataFormats/Parameters/include/DataFormatsParameters/GRPObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class GRPObject
140140
/// print itself
141141
void print() const;
142142

143-
static GRPObject* loadFrom(const std::string& grpFileName = "", const std::string& grpName = "GRP");
143+
static GRPObject* loadFrom(const std::string& grpFileName = "");
144144

145145
private:
146146
timePoint mTimeStart = 0; ///< DAQ_time_start entry from DAQ logbook

DataFormats/Parameters/src/GRPECSObject.cxx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,18 @@ GRPECSObject::ROMode GRPECSObject::getDetROMode(o2::detectors::DetID id) const
7979
}
8080

8181
//_______________________________________________
82-
GRPECSObject* GRPECSObject::loadFrom(const std::string& grpecsFileName, const std::string& grpecsName)
82+
GRPECSObject* GRPECSObject::loadFrom(const std::string& grpecsFileName)
8383
{
8484
// load object from file
85-
auto fname = o2::base::NameConf::getGRPECSFileName(grpecsFileName);
86-
TFile flGRPECS(fname.c_str());
87-
if (flGRPECS.IsZombie()) {
85+
auto fname = o2::base::NameConf::getGRPFileName(grpecsFileName);
86+
TFile flGRP(fname.c_str());
87+
if (flGRP.IsZombie()) {
8888
LOG(ERROR) << "Failed to open " << fname;
89-
throw std::runtime_error("Failed to open GRP ECS file");
89+
throw std::runtime_error("Failed to open GRPECS file");
9090
}
91-
auto grpecs = reinterpret_cast<o2::parameters::GRPECSObject*>(
92-
flGRPECS.GetObjectChecked(grpecsName.data(), o2::parameters::GRPECSObject::Class()));
93-
if (!grpecs) {
94-
LOG(ERROR) << "Did not find GRP ECS object named " << grpecsName;
95-
throw std::runtime_error("Failed to load GRP ECS object");
91+
auto grp = reinterpret_cast<o2::parameters::GRPECSObject*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
92+
if (!grp) {
93+
throw std::runtime_error(fmt::format("Failed to load GRPECS object from {}", fname));
9694
}
97-
return grpecs;
95+
return grp;
9896
}

DataFormats/Parameters/src/GRPLHCIFData.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \brief Implementation of the LHC InterFace data
1414

1515
#include "DataFormatsParameters/GRPLHCIFData.h"
16+
#include "DetectorsCommonDataFormats/NameConf.h"
1617
#include "CommonConstants/PhysicsConstants.h"
1718
#include <cmath>
1819
#include <FairLogger.h>
@@ -82,3 +83,20 @@ void GRPLHCIFData::translateBucketsToBCNumbers(std::vector<int32_t>& bcNb, std::
8283
bcNb.push_back(i = 0 ? 0 : (i / 10 + o2::constants::lhc::BunchOffsetsP2[beam]) % o2::constants::lhc::LHCMaxBunches);
8384
}
8485
}
86+
87+
//_______________________________________________
88+
GRPLHCIFData* GRPLHCIFData::loadFrom(const std::string& grpFileName)
89+
{
90+
// load object from file
91+
auto fname = o2::base::NameConf::getGRPFileName(grpFileName);
92+
TFile flGRP(fname.c_str());
93+
if (flGRP.IsZombie()) {
94+
LOG(ERROR) << "Failed to open " << fname;
95+
throw std::runtime_error("Failed to open GRPLHCIF file");
96+
}
97+
auto grp = reinterpret_cast<o2::parameters::GRPLHCIFData*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
98+
if (!grp) {
99+
throw std::runtime_error(fmt::format("Failed to load GRPLHCIF object from {}", fname));
100+
}
101+
return grp;
102+
}

DataFormats/Parameters/src/GRPObject.cxx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ GRPObject::ROMode GRPObject::getDetROMode(o2::detectors::DetID id) const
111111
}
112112

113113
//_______________________________________________
114-
GRPObject* GRPObject::loadFrom(const std::string& grpFileName, const std::string& grpName)
114+
GRPObject* GRPObject::loadFrom(const std::string& grpFileName)
115115
{
116116
// load object from file
117117
auto fname = o2::base::NameConf::getGRPFileName(grpFileName);
@@ -120,11 +120,9 @@ GRPObject* GRPObject::loadFrom(const std::string& grpFileName, const std::string
120120
LOG(ERROR) << "Failed to open " << fname;
121121
throw std::runtime_error("Failed to open GRP file");
122122
}
123-
auto grp = reinterpret_cast<o2::parameters::GRPObject*>(
124-
flGRP.GetObjectChecked(grpName.data(), o2::parameters::GRPObject::Class()));
125-
if (!grp) {
126-
LOG(ERROR) << "Did not find GRP object named " << grpName;
127-
throw std::runtime_error("Failed to load GRP object");
123+
auto grp = reinterpret_cast<o2::parameters::GRPObject*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
124+
if (!grp && !(grp = reinterpret_cast<o2::parameters::GRPObject*>(flGRP.GetObjectChecked("GRP", Class())))) { // for BWD compatibility
125+
throw std::runtime_error(fmt::format("Failed to load GRP object from {}", fname));
128126
}
129127
return grp;
130128
}

Detectors/Base/include/DetectorsBase/Propagator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class PropagatorImpl
138138
}
139139

140140
static int initFieldFromGRP(const o2::parameters::GRPObject* grp, bool verbose = false);
141-
static int initFieldFromGRP(const std::string grpFileName = "", std::string grpName = "GRP", bool verbose = false);
141+
static int initFieldFromGRP(const std::string grpFileName = "", bool verbose = false);
142142
#endif
143143

144144
GPUd() MatBudget getMatBudget(MatCorrType corrType, const o2::math_utils::Point3D<value_type>& p0, const o2::math_utils::Point3D<value_type>& p1) const;

Detectors/Base/src/Propagator.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ PropagatorImpl<value_T>::PropagatorImpl(bool uninitialized)
6363

6464
//____________________________________________________________
6565
template <typename value_T>
66-
int PropagatorImpl<value_T>::initFieldFromGRP(const std::string grpFileName, std::string grpName, bool verbose)
66+
int PropagatorImpl<value_T>::initFieldFromGRP(const std::string grpFileName, bool verbose)
6767
{
6868
/// load grp and init magnetic field
6969
if (verbose) {
7070
LOG(INFO) << "Loading field from GRP of " << grpFileName;
7171
}
72-
const auto grp = o2::parameters::GRPObject::loadFrom(grpFileName, grpName);
72+
const auto grp = o2::parameters::GRPObject::loadFrom(grpFileName);
7373
if (!grp) {
7474
return -1;
7575
}

0 commit comments

Comments
 (0)