Skip to content

Commit fda5dd8

Browse files
committed
[PID TOF] Realign naming before upgrade
1 parent 2523ab3 commit fda5dd8

6 files changed

Lines changed: 70 additions & 45 deletions

File tree

Common/Core/PID/PIDTOF.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ class TOFResoParamsV2 : public o2::tof::Parameters<13>
178178
// LOG(info) << "TOFResoParamsV2 shift: correction for eta " << eta << " is for index " << etaIndex << " = " << shift;
179179
return mContent.at(etaIndex);
180180
}
181-
// To remove
182-
float getShift(float eta) const
183-
{
184-
return getMomentumChargeShift(eta);
185-
}
186181

187182
void printMomentumChargeShiftParameters() const
188183
{
@@ -195,12 +190,25 @@ class TOFResoParamsV2 : public o2::tof::Parameters<13>
195190
LOG(info) << "etaC" << i << ": " << mContent[i];
196191
}
197192
}
198-
// To remove
199-
void printShiftParameters() const
193+
194+
// Time shift for post calibration
195+
void setTimeShiftParameters(std::unordered_map<std::string, float> const& pars, bool positive)
200196
{
201-
printMomentumChargeShiftParameters();
202-
}
197+
std::string baseOpt = positive ? "TimeShift.Pos." : "TimeShift.Neg.";
203198

199+
if (pars.count(baseOpt + "GetN") == 0) { // If the map does not contain the number of eta bins, we assume that no correction has to be applied
200+
return;
201+
}
202+
const int nPoints = static_cast<int>(pars.at(baseOpt + "GetN"));
203+
if (nPoints <= 0) {
204+
LOG(fatal) << "TOFResoParamsV2 shift: time must be positive";
205+
}
206+
TGraph graph;
207+
for (int i = 0; i < nPoints; ++i) {
208+
graph.AddPoint(pars.at(Form("TimeShift.eta%i", i)), pars.at(Form("TimeShift.cor%i", i)));
209+
}
210+
setTimeShiftParameters(&graph, positive);
211+
}
204212
void setTimeShiftParameters(std::string const& filename, std::string const& objname, bool positive)
205213
{
206214
TFile f(filename.c_str(), "READ");
@@ -285,10 +293,10 @@ class ExpTimes
285293
return defaultReturnValue;
286294
}
287295
if (track.trackType() == o2::aod::track::Run2Track) {
288-
return ComputeExpectedTime(track.tofExpMom() * kCSPEDDInv / (1.f + track.sign() * parameters.getShift(track.eta())), track.length());
296+
return ComputeExpectedTime(track.tofExpMom() * kCSPEDDInv / (1.f + track.sign() * parameters.getMomentumChargeShift(track.eta())), track.length());
289297
}
290-
LOG(debug) << "TOF exp. mom. " << track.tofExpMom() << " shifted = " << track.tofExpMom() / (1.f + track.sign() * parameters.getShift(track.eta()));
291-
return ComputeExpectedTime(track.tofExpMom() / (1.f + track.sign() * parameters.getShift(track.eta())), track.length()) + parameters.getTimeShift(track.eta(), track.sign());
298+
LOG(debug) << "TOF exp. mom. " << track.tofExpMom() << " shifted = " << track.tofExpMom() / (1.f + track.sign() * parameters.getMomentumChargeShift(track.eta()));
299+
return ComputeExpectedTime(track.tofExpMom() / (1.f + track.sign() * parameters.getMomentumChargeShift(track.eta())), track.length()) + parameters.getTimeShift(track.eta(), track.sign());
292300
}
293301

294302
/// Gets the expected resolution of the t-texp-t0

Common/DataModel/PIDResponse.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ DECLARE_SOA_DYNAMIC_COLUMN(IsEvTimeTOFT0AC, isEvTimeTOFT0AC, //! True if the Eve
403403

404404
namespace pidtofsignal
405405
{
406-
DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time
406+
DECLARE_SOA_COLUMN(TOFSignal, tofSignal, float); //! TOF signal from track time
407+
DECLARE_SOA_DYNAMIC_COLUMN(EventCollisionTime, eventCollisionTime, //! Event collision time used for the track. Needs the TOF
408+
[](float signal, float tMinusTexp, float texp) -> float { return texp + tMinusTexp - signal; });
409+
407410
} // namespace pidtofsignal
408411

409412
namespace pidtofbeta
@@ -528,7 +531,8 @@ DEFINE_UNWRAP_NSIGMA_COLUMN(TOFNSigmaAl, tofNSigmaAl); //! Unwrapped (float) nsi
528531
} // namespace pidtof_tiny
529532

530533
DECLARE_SOA_TABLE(TOFSignal, "AOD", "TOFSignal", //! Table of the TOF signal
531-
pidtofsignal::TOFSignal);
534+
pidtofsignal::TOFSignal,
535+
pidtofsignal::EventCollisionTime<pidtofsignal::TOFSignal>);
532536

533537
DECLARE_SOA_TABLE(pidTOFFlags, "AOD", "pidTOFFlags", //! Table of the flags for TOF signal quality on the track level
534538
pidflags::GoodTOFMatch);

Common/TableProducer/PID/pidTOF.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ struct tofPid {
157157
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
158158
}
159159
} else {
160-
mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value));
161-
mRespParamsV2.printShiftParameters();
160+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection.getPars(passName.value));
161+
mRespParamsV2.printMomentumChargeShiftParameters();
162162
}
163163
} else {
164164
mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value);
@@ -174,8 +174,8 @@ struct tofPid {
174174
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
175175
}
176176
} else { // Pass is available, load non standard parameters
177-
mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value));
178-
mRespParamsV2.printShiftParameters();
177+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection->getPars(passName.value));
178+
mRespParamsV2.printMomentumChargeShiftParameters();
179179
}
180180
}
181181
mRespParamsV2.print();

Common/TableProducer/PID/pidTOFBase.cxx

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "Common/DataModel/EventSelection.h"
3131
#include "Common/DataModel/FT0Corrected.h"
3232
#include "Common/DataModel/Multiplicity.h"
33+
#include "Framework/HistogramRegistry.h"
34+
#include "Framework/runDataProcessing.h"
3335
#include "TableHelper.h"
3436
#include "pidTOFBase.h"
3537

@@ -39,15 +41,6 @@ using namespace o2::pid;
3941
using namespace o2::framework::expressions;
4042
using namespace o2::track;
4143

42-
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
43-
{
44-
std::vector<ConfigParamSpec> options{{"add-qa", VariantType::Int, 0, {"Legacy. No effect."}},
45-
{"evtime", VariantType::Int, 1, {"Produce the table for the Event Time"}}};
46-
std::swap(workflowOptions, options);
47-
}
48-
49-
#include "Framework/runDataProcessing.h"
50-
5144
/// Selection criteria for tracks used for TOF event time
5245
float trackDistanceForGoodMatch = 999.f;
5346
float trackDistanceForGoodMatchLowMult = 999.f;
@@ -69,6 +62,8 @@ bool isTrackGoodMatchForTOFPID(const Run3Trks::iterator& tr, const Run3Cols& /*e
6962
struct tofSignal {
7063
o2::framework::Produces<o2::aod::TOFSignal> table;
7164
o2::framework::Produces<o2::aod::pidTOFFlags> tableFlags;
65+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
66+
7267
bool enableTable = false; // Flag to check if the TOF signal table is requested or not
7368
bool enableTableFlags = false; // Flag to check if the TOF signal flags table is requested or not
7469
// CCDB configuration
@@ -78,6 +73,7 @@ struct tofSignal {
7873
Configurable<float> distanceForGoodMatch{"distanceForGoodMatch", 999.f, "Maximum distance to consider a good match"};
7974
Configurable<float> distanceForGoodMatchLowMult{"distanceForGoodMatchLowMult", 999.f, "Maximum distance to consider a good match for low multiplicity events"};
8075
Configurable<int> multThreshold{"multThreshold", 0, "Multiplicity threshold to consider a low multiplicity event"};
76+
Configurable<bool> enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"};
8177

8278
void init(o2::framework::InitContext& initContext)
8379
{
@@ -90,17 +86,26 @@ struct tofSignal {
9086

9187
// Checking that the table is requested in the workflow and enabling it
9288
enableTable = isTableRequiredInWorkflow(initContext, "TOFSignal");
89+
enableTable = true;
9390
if (enableTable) {
9491
LOG(info) << "Table TOFSignal enabled!";
9592
}
9693
enableTableFlags = isTableRequiredInWorkflow(initContext, "pidTOFFlags");
94+
enableTableFlags = true;
9795
if (enableTableFlags) {
9896
LOG(info) << "Table pidTOFFlags enabled!";
9997
}
10098
trackDistanceForGoodMatch = distanceForGoodMatch;
10199
trackDistanceForGoodMatchLowMult = distanceForGoodMatchLowMult;
102100
multiplicityThreshold = multThreshold;
103101
LOG(info) << "Configuring selections for good match: " << trackDistanceForGoodMatch << " low mult " << trackDistanceForGoodMatchLowMult << " mult. threshold " << multiplicityThreshold;
102+
if (!enableQaHistograms) {
103+
return;
104+
}
105+
histos.add("tofSignal", "tofSignal", kTH1D, {{1000, -1000, 1000000, "tofSignal (ps)"}});
106+
if (enableTableFlags) {
107+
histos.add("goodForPIDFlags", "goodForPIDFlags", kTH1D, {{3, 0, 3, "flags"}});
108+
}
104109
}
105110
void processRun3(Run3Trks const& tracks, Run3Cols const& collisions)
106111
{
@@ -112,11 +117,19 @@ struct tofSignal {
112117
tableFlags.reserve(tracks.size());
113118
}
114119
for (auto& t : tracks) {
115-
table(o2::pid::tof::TOFSignal<Run3Trks::iterator>::GetTOFSignal(t));
120+
const auto s = o2::pid::tof::TOFSignal<Run3Trks::iterator>::GetTOFSignal(t);
121+
if (enableQaHistograms) {
122+
histos.fill(HIST("tofSignal"), s);
123+
}
124+
table(s);
116125
if (!enableTableFlags) {
117126
continue;
118127
}
119-
tableFlags(isTrackGoodMatchForTOFPID(t, collisions));
128+
const auto b = isTrackGoodMatchForTOFPID(t, collisions);
129+
if (enableQaHistograms) {
130+
histos.fill(HIST("goodForPIDFlags"), s);
131+
}
132+
tableFlags(b);
120133
}
121134
}
122135
PROCESS_SWITCH(tofSignal, processRun3, "Process Run3 data i.e. input is TrackIU", true);
@@ -235,13 +248,16 @@ struct tofEventTime {
235248
}
236249
// Checking that the table is requested in the workflow and enabling it
237250
enableTable = isTableRequiredInWorkflow(initContext, "TOFEvTime");
251+
enableTable = true;
252+
238253
if (!enableTable) {
239254
LOG(info) << "Table for TOF Event time (TOFEvTime) is not required, disabling it";
240255
return;
241256
}
242257
LOG(info) << "Table TOFEvTime enabled!";
243258

244259
enableTableTOFOnly = isTableRequiredInWorkflow(initContext, "EvTimeTOFOnly");
260+
enableTableTOFOnly = true;
245261
if (enableTableTOFOnly) {
246262
LOG(info) << "Table EvTimeTOFOnly enabled!";
247263
}
@@ -279,8 +295,8 @@ struct tofEventTime {
279295
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
280296
}
281297
} else {
282-
mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value));
283-
mRespParamsV2.printShiftParameters();
298+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection.getPars(passName.value));
299+
mRespParamsV2.printMomentumChargeShiftParameters();
284300
}
285301
} else {
286302
mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value);
@@ -297,8 +313,8 @@ struct tofEventTime {
297313
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
298314
}
299315
} else {
300-
mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value));
301-
mRespParamsV2.printShiftParameters();
316+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection->getPars(passName.value));
317+
mRespParamsV2.printMomentumChargeShiftParameters();
302318
}
303319
}
304320
mRespParamsV2.print();
@@ -537,9 +553,6 @@ struct tofEventTime {
537553
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
538554
{
539555
auto workflow = WorkflowSpec{adaptAnalysisTask<tofSignal>(cfgc)};
540-
if (!cfgc.options().get<int>("evtime")) {
541-
return workflow;
542-
}
543556
workflow.push_back(adaptAnalysisTask<tofEventTime>(cfgc));
544557
return workflow;
545558
}

Common/TableProducer/PID/pidTOFFull.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ struct tofPidFull {
157157
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
158158
}
159159
} else {
160-
mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value));
161-
mRespParamsV2.printShiftParameters();
160+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection.getPars(passName.value));
161+
mRespParamsV2.printMomentumChargeShiftParameters();
162162
}
163163
} else {
164164
mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value);
@@ -174,8 +174,8 @@ struct tofPidFull {
174174
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
175175
}
176176
} else { // Pass is available, load non standard parameters
177-
mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value));
178-
mRespParamsV2.printShiftParameters();
177+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection->getPars(passName.value));
178+
mRespParamsV2.printMomentumChargeShiftParameters();
179179
}
180180
}
181181
mRespParamsV2.print();

Common/TableProducer/PID/pidTOFbeta.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ struct tofPidBeta {
9898
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
9999
}
100100
} else {
101-
mRespParamsV2.setShiftParameters(paramCollection.getPars(passName.value));
102-
mRespParamsV2.printShiftParameters();
101+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection.getPars(passName.value));
102+
mRespParamsV2.printMomentumChargeShiftParameters();
103103
}
104104
} else {
105105
mRespParamsV2.loadParamFromFile(fname.data(), parametrizationPath.value);
@@ -116,8 +116,8 @@ struct tofPidBeta {
116116
LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", passName.value.data());
117117
}
118118
} else {
119-
mRespParamsV2.setShiftParameters(paramCollection->getPars(passName.value));
120-
mRespParamsV2.printShiftParameters();
119+
mRespParamsV2.setMomentumChargeShiftParameters(paramCollection->getPars(passName.value));
120+
mRespParamsV2.printMomentumChargeShiftParameters();
121121
}
122122
}
123123
mRespParamsV2.print();
@@ -142,7 +142,7 @@ struct tofPidBeta {
142142
}
143143
if (enableTableMass) {
144144
if (enableTOFParams) {
145-
tablePIDTOFMass(o2::pid::tof::TOFMass<Trks::iterator>::GetTOFMass(trk.tofExpMom() / (1.f + trk.sign() * mRespParamsV2.getShift(trk.eta())), beta));
145+
tablePIDTOFMass(o2::pid::tof::TOFMass<Trks::iterator>::GetTOFMass(trk.tofExpMom() / (1.f + trk.sign() * mRespParamsV2.getMomentumChargeShift(trk.eta())), beta));
146146
} else {
147147
tablePIDTOFMass(o2::pid::tof::TOFMass<Trks::iterator>::GetTOFMass(trk, beta));
148148
}

0 commit comments

Comments
 (0)