Skip to content

Commit dbb6c47

Browse files
committed
Update
1 parent bfd5a6c commit dbb6c47

1 file changed

Lines changed: 56 additions & 45 deletions

File tree

Common/TableProducer/PID/pidTOFMerge.cxx

Lines changed: 56 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct TOFCalibConfig : ConfigurableGroup {
6969
Configurable<bool> mFatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"};
7070
Configurable<bool> mEnableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"};
7171
Configurable<int> mCollisionSystem{"collisionSystem", -1, "Collision system: -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"};
72+
Configurable<bool> mAutoSetProcessFunctions{"mAutoSetProcessFunctions", true, "Flag to autodetect the process functions to use"};
7273

7374
// @brief Set up the configuration from the calibration object from the init function of the task
7475
template <typename CCDBObject>
@@ -145,10 +146,10 @@ struct TOFCalibConfig : ConfigurableGroup {
145146
}
146147
}
147148

148-
template <typename CCDBObject>
149+
template <typename CCDBObject, typename TrackType>
149150
void processSetup(o2::pid::tof::TOFResoParamsV3& mRespParamsV3,
150151
CCDBObject ccdb,
151-
const Run3TrksWtofWevTime& tracks)
152+
const TrackType& tracks)
152153
{
153154
for (auto const& track : tracks) { // Loop on all tracks
154155
if (!track.has_collision()) { // Skipping tracks without collisions
@@ -158,7 +159,7 @@ struct TOFCalibConfig : ConfigurableGroup {
158159
if (!coll.has_bc()) {
159160
continue;
160161
}
161-
const auto& bc = coll.bc_as<aod::BCsWithTimestamps>();
162+
const auto& bc = coll.template bc_as<aod::BCsWithTimestamps>();
162163

163164
// First we check if this run number was already processed
164165
if (mLastRunNumber == bc.runNumber()) {
@@ -237,11 +238,14 @@ struct tofSignal {
237238
LOG(info) << "No table or process is enabled. Disabling task";
238239
return;
239240
}
240-
if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration)
241-
if (metadataInfo.isRun3()) {
242-
doprocessRun3.value = true;
243-
} else {
244-
doprocessRun2.value = false;
241+
if (mTOFCalibConfig.mAutoSetProcessFunctions) {
242+
LOG(info) << "Autodetecting process functions";
243+
if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration)
244+
if (metadataInfo.isRun3()) {
245+
doprocessRun3.value = true;
246+
} else {
247+
doprocessRun2.value = false;
248+
}
245249
}
246250
}
247251

@@ -391,8 +395,24 @@ struct tofEventTime {
391395
return;
392396
}
393397

394-
if (metadataInfo.isFullyDefined() && metadataInfo.isRun3() && doprocessRun2) {
395-
LOG(fatal) << "Run2 process function is enabled but the metadata says it is Run3";
398+
if (mTOFCalibConfig.mAutoSetProcessFunctions) {
399+
LOG(info) << "Autodetecting process functions";
400+
if (metadataInfo.isFullyDefined()) {
401+
if (metadataInfo.isRun3()) {
402+
doprocessRun3.value = true;
403+
} else {
404+
doprocessRun2.value = true;
405+
}
406+
}
407+
}
408+
409+
if (metadataInfo.isFullyDefined()) {
410+
if (metadataInfo.isRun3() && doprocessRun2) {
411+
LOG(fatal) << "Run2 process function is enabled but the metadata says it is Run3";
412+
}
413+
if (!metadataInfo.isRun3() && doprocessRun3) {
414+
LOG(fatal) << "Run3 process function is enabled but the metadata says it is Run2";
415+
}
396416
}
397417

398418
trackSampleMinMomentum = minMomentum;
@@ -445,7 +465,7 @@ struct tofEventTime {
445465
tableEvTime(t.collision().collisionTime() * 1000.f, t.collision().collisionTimeRes() * 1000.f);
446466
}
447467
}
448-
PROCESS_SWITCH(tofEventTime, processRun2, "Process with Run2 data", false);
468+
PROCESS_SWITCH(tofEventTime, processRun2, "Process with Run2 data", true);
449469

450470
///
451471
/// Process function to prepare the event for each track on Run 3 data without the FT0
@@ -469,34 +489,21 @@ struct tofEventTime {
469489
tableEvTimeTOFOnly.reserve(tracks.size());
470490
}
471491

472-
// mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, tracks); // Update the calibration parameters
492+
mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, tracks); // Update the calibration parameters
473493

474494
// Autoset the processing mode for the event time computation
475-
if (mComputeEvTimeWithTOF == -1) {
476-
switch (mTOFCalibConfig.mCollisionSystem.value) {
477-
case CollisionSystemType::kCollSyspp: // pp
478-
mComputeEvTimeWithTOF.value = 0;
479-
break;
480-
case CollisionSystemType::kCollSysPbPb: // PbPb
481-
mComputeEvTimeWithTOF.value = 1;
482-
break;
483-
default:
484-
LOG(fatal) << "Collision system not supported for TOF event time computation";
485-
break;
486-
}
487-
}
488-
if (mComputeEvTimeWithFT0 == -1) {
489-
switch (mTOFCalibConfig.mCollisionSystem.value) {
490-
case CollisionSystemType::kCollSyspp: // pp
491-
mComputeEvTimeWithFT0.value = 0;
492-
break;
493-
case CollisionSystemType::kCollSysPbPb: // PbPb
494-
mComputeEvTimeWithFT0.value = 1;
495-
break;
496-
default:
497-
LOG(fatal) << "Collision system not supported for TOF event time computation";
498-
break;
499-
}
495+
switch (mTOFCalibConfig.mCollisionSystem.value) {
496+
case CollisionSystemType::kCollSyspp: // pp
497+
mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 0 : mComputeEvTimeWithTOF.value);
498+
mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 1 : mComputeEvTimeWithFT0.value);
499+
break;
500+
case CollisionSystemType::kCollSysPbPb: // PbPb
501+
mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 1 : mComputeEvTimeWithTOF.value);
502+
mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 0 : mComputeEvTimeWithFT0.value);
503+
break;
504+
default:
505+
LOG(fatal) << "Collision system " << mTOFCalibConfig.mCollisionSystem.value << " " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.mCollisionSystem) << " not supported for TOF event time computation";
506+
break;
500507
}
501508

502509
if (mComputeEvTimeWithTOF == 1 && mComputeEvTimeWithFT0 == 1) {
@@ -646,7 +653,7 @@ struct tofEventTime {
646653
LOG(fatal) << "Invalid configuration for TOF event time computation";
647654
}
648655
}
649-
PROCESS_SWITCH(tofEventTime, processRun3, "Process the Run3 data", false);
656+
PROCESS_SWITCH(tofEventTime, processRun3, "Process the Run3 data", true);
650657
};
651658

652659
// Part 3 Nsigma computation
@@ -1114,11 +1121,15 @@ struct tofPidBeta {
11141121
LOG(info) << "No table or process is enabled. Disabling task";
11151122
return;
11161123
}
1117-
if (metadataInfo.isFullyDefined()) {
1118-
if (metadataInfo.isRun3()) {
1119-
doprocessRun3.value = true;
1120-
} else {
1121-
doprocessRun2.value = true;
1124+
1125+
if (mTOFCalibConfig.mAutoSetProcessFunctions) {
1126+
LOG(info) << "Autodetecting process functions";
1127+
if (metadataInfo.isFullyDefined()) {
1128+
if (metadataInfo.isRun3()) {
1129+
doprocessRun3.value = true;
1130+
} else {
1131+
doprocessRun2.value = true;
1132+
}
11221133
}
11231134
}
11241135

@@ -1153,7 +1164,7 @@ struct tofPidBeta {
11531164
}
11541165
}
11551166
}
1156-
PROCESS_SWITCH(tofPidBeta, processRun2, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", false);
1167+
PROCESS_SWITCH(tofPidBeta, processRun2, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", true);
11571168

11581169
o2::pid::tof::Beta<Run3TrksWtofWevTime::iterator> responseBeta;
11591170
void processRun3(Run3TrksWtofWevTime const& tracks)
@@ -1178,7 +1189,7 @@ struct tofPidBeta {
11781189
}
11791190
}
11801191
}
1181-
PROCESS_SWITCH(tofPidBeta, processRun3, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", false);
1192+
PROCESS_SWITCH(tofPidBeta, processRun3, "Process Run3 data i.e. input is TrackIU. If false, taken from metadata automatically", true);
11821193
};
11831194

11841195
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)