Skip to content

Commit 7e08c2e

Browse files
committed
TPC VDrift helper class
1 parent 9cbba3b commit 7e08c2e

6 files changed

Lines changed: 208 additions & 7 deletions

File tree

DataFormats/Detectors/TPC/include/DataFormatsTPC/VDriftCorrFact.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@
1919
#ifndef AliceO2_TPC_VDRIFT_CORRFACT_H
2020
#define AliceO2_TPC_VDRIFT_CORRFACT_H
2121

22+
#include "GPUCommonRtypes.h"
23+
2224
namespace o2::tpc
2325
{
2426

2527
struct VDriftCorrFact {
26-
long firstTime{}; ///< first time stamp of processed TFs
27-
long lastTime{}; ///< last time stamp of processed TFs
28-
long creationTime{}; ///< time of creation
29-
float corrFact{}; ///< drift velocity correction factor (multiplicative)
30-
float corrFactErr{}; ///< stat error of correction factor
31-
float refVDrift{}; ///< reference vdrift for which factor was extracted
28+
long firstTime{}; ///< first time stamp of processed TFs
29+
long lastTime{}; ///< last time stamp of processed TFs
30+
long creationTime{}; ///< time of creation
31+
float corrFact{1.0}; ///< drift velocity correction factor (multiplicative)
32+
float corrFactErr{0.0}; ///< stat error of correction factor
33+
float refVDrift{0.}; ///< reference vdrift for which factor was extracted
34+
3235
ClassDefNV(VDriftCorrFact, 1);
3336
};
3437

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum class CDBType {
4545
CalPadGainFull, ///< Full pad gain calibration
4646
CalPadGainResidual, ///< ResidualpPad gain calibration (e.g. from tracks)
4747
CalLaserTracks, ///< Laser track calibration data
48+
CalVDriftTgl, ///< ITS-TPC difTgl vdrift calibration
4849
CalTimeGain, ///< Gain variation over time
4950
CalGas, ///< DCS gas measurements
5051
CalTemperature, ///< DCS temperature measurements
@@ -98,6 +99,7 @@ const std::unordered_map<CDBType, const std::string> CDBTypeMap{
9899
{CDBType::CalTemperature, "TPC/Calib/Temperature"},
99100
{CDBType::CalHV, "TPC/Calib/HV"},
100101
{CDBType::CalTopologyGain, "TPC/Calib/TopologyGain"},
102+
{CDBType::CalVDriftTgl, "TPC/Calib/VDriftTgl"},
101103
//
102104
{CDBType::ConfigFEEPad, "TPC/Config/FEEPad"},
103105
//

Detectors/TPC/calibration/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ o2_add_library(TPCCalibration
4747
src/SACFactorization.cxx
4848
src/SACParameter.cxx
4949
src/SACDrawHelper.cxx
50+
src/VDriftHelper.cxx
5051
PUBLIC_LINK_LIBRARIES O2::DataFormatsTPC O2::TPCBase
5152
O2::TPCReconstruction ROOT::Minuit
5253
Microsoft.GSL::GSL
@@ -91,7 +92,8 @@ o2_target_root_dictionary(TPCCalibration
9192
include/TPCCalibration/TPCVDriftTglCalibration.h
9293
include/TPCCalibration/SACFactorization.h
9394
include/TPCCalibration/SACParameter.h
94-
include/TPCCalibration/SACDrawHelper.h)
95+
include/TPCCalibration/SACDrawHelper.h
96+
include/TPCCalibration/VDriftHelper.h)
9597

9698
o2_add_test_root_macro(macro/comparePedestalsAndNoise.C
9799
PUBLIC_LINK_LIBRARIES O2::TPCBase
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file VDriftHelper.h
13+
/// \brief Helper class to extract VDrift from different sources
14+
/// \author ruben.shahoian@cern.ch
15+
16+
#ifndef TPC_VDRIFT_HELPER_H_
17+
#define TPC_VDRIFT_HELPER_H_
18+
19+
#include "GPUCommonRtypes.h"
20+
#include "DataFormatsTPC/VDriftCorrFact.h"
21+
#include <array>
22+
#include <vector>
23+
#include <string_view>
24+
25+
namespace o2::framework
26+
{
27+
class ProcessingContext;
28+
class ConcreteDataMatcher;
29+
class InputSpec;
30+
} // namespace o2::framework
31+
32+
namespace o2::tpc
33+
{
34+
class LtrCalibData;
35+
36+
class VDriftHelper
37+
{
38+
public:
39+
enum Source : int { GasParam,
40+
Laser,
41+
ITSTPCTgl,
42+
NSources
43+
};
44+
static constexpr std::array<std::string_view, NSources> SourceNames = {
45+
"GasParam",
46+
"Laser",
47+
"TPCITSTgl"};
48+
49+
VDriftHelper();
50+
void accountLaserCalibration(const LtrCalibData* calib, long fallBackTimeStamp = 2);
51+
void accountDriftCorrectionITSTPCTgl(const VDriftCorrFact* calib);
52+
bool isUpdated() const { return mUpdated; }
53+
void acknowledgeUpdate() { mUpdated = false; }
54+
55+
const VDriftCorrFact& getVDriftObject() const { return mVD; }
56+
Source getSource() const { return mSource; }
57+
std::string_view getSourceName() const { return SourceNames[mSource]; }
58+
59+
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher& matcher, void* obj);
60+
static void requestCCDBInputs(std::vector<o2::framework::InputSpec>& inputs, bool laser = true, bool itstpcTgl = true);
61+
static void extractCCDBInputs(o2::framework::ProcessingContext& pc, bool laser = true, bool itstpcTgl = true);
62+
63+
protected:
64+
static void addInput(std::vector<o2::framework::InputSpec>& inputs, o2::framework::InputSpec&& isp);
65+
66+
VDriftCorrFact mVD{};
67+
Source mSource{}; // update source
68+
bool mUpdated = false; // signal update, must be reset once new value is fetched
69+
70+
ClassDefNV(VDriftHelper, 1);
71+
};
72+
} // namespace o2::tpc
73+
#endif

Detectors/TPC/calibration/src/TPCCalibrationLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@
101101
#pragma link C++ class o2::calibration::TimeSlot < o2::tpc::TPCVDTglContainer> + ;
102102
#pragma link C++ class o2::calibration::TimeSlotCalibration < o2::dataformats::Pair < float, float>, o2::tpc::TPCVDTglContainer> + ;
103103
#pragma link C++ class o2::tpc::TPCVDriftTglCalibration + ;
104+
#pragma link C++ class o2::tpc::VDriftHelper + ;
104105

105106
#endif
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include "TPCBase/CDBInterface.h"
13+
#include "TPCCalibration/VDriftHelper.h"
14+
#include "DataFormatsTPC/LtrCalibData.h"
15+
#include "TPCBase/ParameterGas.h"
16+
#include "Framework/Logger.h"
17+
#include "Framework/ProcessingContext.h"
18+
#include "Framework/CCDBParamSpec.h"
19+
#include "Framework/InputRecord.h"
20+
#include "Framework/ConcreteDataMatcher.h"
21+
22+
using namespace o2::tpc;
23+
using namespace o2::framework;
24+
25+
//________________________________________________________
26+
VDriftHelper::VDriftHelper()
27+
{
28+
const auto& gaspar = o2::tpc::ParameterGas::Instance();
29+
mVD.corrFact = 1.0;
30+
mVD.refVDrift = gaspar.DriftV;
31+
// was it imposed from the command line?
32+
if (o2::conf::ConfigurableParam::getProvenance("TPCGasParam.DriftV") == o2::conf::ConfigurableParam::EParamProvenance::kRT) { // we stick to this value
33+
mVD.creationTime = std::numeric_limits<long>::max();
34+
LOGP(info, "TPC VDrift was set from command line to {}, will neglect update from CCDB", mVD.refVDrift);
35+
} else {
36+
mVD.creationTime = 1; // just to be above 0
37+
}
38+
mUpdated = true;
39+
mSource = Source::GasParam;
40+
}
41+
42+
//________________________________________________________
43+
void VDriftHelper::accountLaserCalibration(const LtrCalibData* calib, long fallBackTimeStamp)
44+
{
45+
if (!calib) {
46+
return;
47+
}
48+
// old entries of laser calib have no update time assigned
49+
long updateTS = calib->creationTime > 0 ? calib->creationTime : fallBackTimeStamp;
50+
LOG(info) << "accountLaserCalibration " << calib->getDriftVCorrection() << " t " << updateTS << " vs " << mVD.creationTime;
51+
if (updateTS < mVD.creationTime) { // prefer current value
52+
return;
53+
}
54+
// old entries of laser calib have no reference assigned
55+
float ref = calib->refVDrift > 0. ? calib->refVDrift : o2::tpc::ParameterGas::Instance().DriftV;
56+
float corr = calib->getDriftVCorrection();
57+
if (corr > 0.) { // laser correction is inverse multiplicative
58+
mVD.refVDrift = ref;
59+
mVD.corrFact = 1. / corr;
60+
mUpdated = true;
61+
mSource = Source::Laser;
62+
}
63+
}
64+
65+
//________________________________________________________
66+
void VDriftHelper::accountDriftCorrectionITSTPCTgl(const VDriftCorrFact* calib)
67+
{
68+
LOG(info) << "accountDriftCorrectionITSTPCTgl " << calib->corrFact << " t " << calib->creationTime << " vs " << mVD.creationTime;
69+
if (!calib || calib->creationTime < mVD.creationTime) { // prefer current value
70+
return;
71+
}
72+
mVD = *calib;
73+
mUpdated = true;
74+
mSource = Source::ITSTPCTgl;
75+
}
76+
77+
//________________________________________________________
78+
void VDriftHelper::extractCCDBInputs(ProcessingContext& pc, bool laser, bool itstpcTgl)
79+
{
80+
if (laser) {
81+
pc.inputs().get<o2::tpc::LtrCalibData*>("laserCalib");
82+
}
83+
if (itstpcTgl) {
84+
pc.inputs().get<o2::tpc::VDriftCorrFact*>("vdriftTgl");
85+
}
86+
}
87+
88+
//________________________________________________________
89+
void VDriftHelper::requestCCDBInputs(std::vector<InputSpec>& inputs, bool laser, bool itstpcTgl)
90+
{
91+
if (laser) {
92+
addInput(inputs, {"laserCalib", "TPC", "CalibLaserTracks", 0, Lifetime::Condition, ccdbParamSpec(CDBTypeMap.at(CDBType::CalLaserTracks))});
93+
}
94+
if (itstpcTgl) {
95+
// VDrift calibration may change during the run (in opposite to Laser calibration, at least at the moment), so ask per-TF query
96+
addInput(inputs, {"vdriftTgl", "TPC", "VDriftTgl", 0, Lifetime::Condition, ccdbParamSpec(CDBTypeMap.at(CDBType::CalVDriftTgl), {}, 1)});
97+
}
98+
}
99+
100+
//________________________________________________________
101+
void VDriftHelper::addInput(std::vector<InputSpec>& inputs, InputSpec&& isp)
102+
{
103+
if (std::find(inputs.begin(), inputs.end(), isp) == inputs.end()) {
104+
inputs.emplace_back(isp);
105+
}
106+
}
107+
108+
//________________________________________________________
109+
bool VDriftHelper::accountCCDBInputs(const ConcreteDataMatcher& matcher, void* obj)
110+
{
111+
if (matcher == ConcreteDataMatcher("TPC", "VDriftTgl", 0)) {
112+
accountDriftCorrectionITSTPCTgl(static_cast<VDriftCorrFact*>(obj));
113+
return true;
114+
}
115+
if (matcher == ConcreteDataMatcher("TPC", "CalibLaserTracks", 0)) {
116+
accountLaserCalibration(static_cast<LtrCalibData*>(obj));
117+
return true;
118+
}
119+
return false;
120+
}

0 commit comments

Comments
 (0)