Skip to content

Commit cdb3836

Browse files
tklemenzshahor02
authored andcommitted
TPC CDBInterface: pick specific file from CCDB with timestamp and meta data filter + newZSCalib helper function for TPC QC
1 parent 70742b0 commit cdb3836

6 files changed

Lines changed: 80 additions & 12 deletions

File tree

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ class CCDBManagerInstance
7474
template <typename T>
7575
T* getForTimeStamp(std::string const& path, long timestamp);
7676

77+
/// retrieve an object of type T from CCDB as stored under path, timestamp and metaData
78+
template <typename T>
79+
T* getSpecific(std::string const& path, long timestamp = -1, std::map<std::string, std::string> metaData = std::map<std::string, std::string>())
80+
{
81+
// TODO: add some error info/handling when failing
82+
mMetaData = metaData;
83+
return getForTimeStamp<T>(path, timestamp);
84+
}
85+
7786
/// retrieve an object of type T from CCDB as stored under path; will use the timestamp member
7887
template <typename T>
7988
T* get(std::string const& path)
@@ -167,6 +176,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
167176
ptr = reinterpret_cast<T*>(cached.objPtr.get());
168177
}
169178
mHeaders.clear();
179+
mMetaData.clear();
170180
return ptr;
171181
}
172182

Detectors/TPC/base/include/TPCBase/CDBInterface.h

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ class CDBInterface
122122
/// \return gain map object
123123
const CalPad& getGainMap();
124124

125-
/// Return any CalPad object
126-
///
127-
/// The function returns the CalPad object stored at the given path in the CCDB
128-
/// \return CalPad object
129-
const CalPad& getCalPad(const std::string_view path);
130-
131125
/// Return the Detector parameters
132126
///
133127
/// The function checks if the object is already loaded and returns it
@@ -156,6 +150,17 @@ class CDBInterface
156150
/// \return GEM parameters
157151
const ParameterGEM& getParameterGEM();
158152

153+
/// Return a CalPad object form the CCDB
154+
/// Deprecated
155+
const CalPad& getCalPad(const std::string_view path);
156+
157+
/// Return any templated object
158+
///
159+
/// The function returns the object stored at the given path, timestamp and metaData in the CCDB
160+
/// \return object
161+
template <typename T>
162+
T& getSpecificObjectFromCDB(const std::string_view path, long timestamp = -1, const std::map<std::string, std::string>& metaData = std::map<std::string, std::string>());
163+
159164
/// Set noise and pedestal object from file
160165
///
161166
/// This assumes that the objects are stored under the name
@@ -238,6 +243,25 @@ inline T& CDBInterface::getObjectFromCDB(std::string_view path)
238243
return *object;
239244
}
240245

246+
/// Get a CalPad object stored in templated formats from the CCDB.
247+
/// @tparam T
248+
/// @param path
249+
/// @param timestamp
250+
/// @param metaData
251+
/// @return The object from the CCDB, ownership is transferred to the caller.
252+
/// @todo Consider removing in favour of calling directly the manager::get method.
253+
template <typename T>
254+
inline T& CDBInterface::getSpecificObjectFromCDB(std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData)
255+
{
256+
static auto& cdb = o2::ccdb::BasicCCDBManager::instance();
257+
auto* object = cdb.getSpecific<T>(path.data(), timestamp, metaData);
258+
return *object;
259+
}
260+
261+
template CalPad& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
262+
template std::vector<CalPad>& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
263+
template std::unordered_map<std::string, o2::tpc::CalPad>& CDBInterface::getSpecificObjectFromCDB(const std::string_view path, long timestamp, const std::map<std::string, std::string>& metaData);
264+
241265
/// \class CDBStorage
242266
/// Simple interface to store TPC CCDB types. Also provide interface functions to upload data from
243267
/// a file.

Detectors/TPC/base/src/CDBInterface.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ const CalPad& CDBInterface::getGainMap()
116116
return *mGainMap;
117117
}
118118

119-
//______________________________________________________________________________
120-
const CalPad& CDBInterface::getCalPad(const std::string_view path)
121-
{
122-
return getObjectFromCDB<CalPad>(path.data());
123-
}
124-
125119
//______________________________________________________________________________
126120
const ParameterDetector& CDBInterface::getParameterDetector()
127121
{
@@ -166,6 +160,12 @@ const ParameterGEM& CDBInterface::getParameterGEM()
166160
return getObjectFromCDB<ParameterGEM>(CDBTypeMap.at(CDBType::ParGEM));
167161
}
168162

163+
//______________________________________________________________________________
164+
const CalPad& CDBInterface::getCalPad(const std::string_view path)
165+
{
166+
return getSpecificObjectFromCDB<CalPad>(path);
167+
}
168+
169169
//______________________________________________________________________________
170170
void CDBInterface::loadNoiseAndPedestalFromFile()
171171
{

Detectors/TPC/qc/include/TPCQC/Helpers.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define AliceO2_TPC_HELPERS_H
1919

2020
#include <vector>
21+
#include "TPCBase/CalDet.h"
2122

2223
class TH1F;
2324
class TH2F;
@@ -49,6 +50,13 @@ void setStyleHistogram2D(TH2& histo);
4950
/// Set nice style for vector of 2D histograms
5051
void setStyleHistogram2D(std::vector<TH2F>& histos);
5152

53+
/// Check if at least one pad in refPedestal and pedestal differs by 3*refNoise to see if new ZS calibration data should be uploaded to the FECs.
54+
/// @param refPedestal
55+
/// @param refNoise
56+
/// @param pedestal
57+
/// @return true if refPedestal - pedestal > 3*refNoise on at least one pad
58+
bool newZSCalib(const o2::tpc::CalDet<float>& refPedestal, const o2::tpc::CalDet<float>& refNoise, const o2::tpc::CalDet<float>& pedestal);
59+
5260
} // namespace helpers
5361
} // namespace qc
5462
} // namespace tpc

Detectors/TPC/qc/src/Helpers.cxx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
//o2 includes
1919
#include "TPCQC/Helpers.h"
20+
#include "TPCBase/Mapper.h"
21+
#include "TPCBase/ROC.h"
2022

2123
using namespace o2::tpc::qc;
2224

@@ -70,3 +72,26 @@ void helpers::setStyleHistogram2D(std::vector<TH2F>& histos)
7072
helpers::setStyleHistogram2D(hist);
7173
}
7274
}
75+
76+
//______________________________________________________________________________
77+
bool helpers::newZSCalib(const o2::tpc::CalDet<float>& refPedestal, const o2::tpc::CalDet<float>& refNoise, const o2::tpc::CalDet<float>& pedestal)
78+
{
79+
static const o2::tpc::Mapper& mapper = o2::tpc::Mapper::instance();
80+
81+
o2::tpc::CalDet<float> diffCalDet = refPedestal - pedestal;
82+
83+
for (o2::tpc::ROC roc; !roc.looped(); ++roc) {
84+
const int nrows = mapper.getNumberOfRowsROC(roc);
85+
for (int irow = 0; irow < nrows; ++irow) {
86+
const int npads = mapper.getNumberOfPadsInRowROC(roc, irow);
87+
for (int ipad = 0; ipad < npads; ++ipad) {
88+
const auto val = diffCalDet.getValue(roc, irow, ipad);
89+
if (std::abs(val) > 3 * refNoise.getValue(roc, irow, ipad)) {
90+
return true;
91+
}
92+
}
93+
}
94+
}
95+
96+
return false;
97+
}

Detectors/TPC/qc/src/TPCQCLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning+;
2525
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D+;
2626
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D+;
27+
#pragma link C++ function o2::tpc::qc::helpers::newZSCalib+;
2728

2829
#endif

0 commit comments

Comments
 (0)