diff --git a/Common/Core/CollisionTypeHelper.cxx b/Common/Core/CollisionTypeHelper.cxx index 1d4b383c7da..c22510ec82e 100644 --- a/Common/Core/CollisionTypeHelper.cxx +++ b/Common/Core/CollisionTypeHelper.cxx @@ -32,7 +32,6 @@ std::string CollisionSystemType::getCollisionSystemName(collType collSys) case kCollSyspPb: return "pPb"; default: - LOG(fatal) << "Undefined collision system"; return "Undefined"; } } @@ -41,6 +40,7 @@ int CollisionSystemType::getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* g { const int ZBeamA = grplhcif->getBeamZ(o2::constants::lhc::BeamDirection::BeamA); const int ZBeamC = grplhcif->getBeamZ(o2::constants::lhc::BeamDirection::BeamC); + LOG(debug) << "Collision system: " << ZBeamA << " * " << ZBeamC << " detected"; switch (ZBeamA * ZBeamC) { case 1: // pp 1*1 return kCollSyspp; @@ -51,7 +51,7 @@ int CollisionSystemType::getCollisionTypeFromGrp(o2::parameters::GRPLHCIFData* g case 82: // p-Pb 82*1 return kCollSyspPb; default: - LOG(fatal) << "Undefined collision system"; + LOG(fatal) << "Undefined collision system in getCollisionTypeFromGrp with BeamA = " << ZBeamA << " and BeamC = " << ZBeamC; return kCollSysUndef; } return kCollSysUndef; diff --git a/Common/TableProducer/PID/pidTOFMerge.cxx b/Common/TableProducer/PID/pidTOFMerge.cxx index df746fc6a94..68bd490f041 100644 --- a/Common/TableProducer/PID/pidTOFMerge.cxx +++ b/Common/TableProducer/PID/pidTOFMerge.cxx @@ -59,78 +59,108 @@ using Run2Trks = o2::soa::Join; using Run2TrksWtofWevTime = soa::Join; // Configuration common to all tasks -struct TOFCalibConfig : ConfigurableGroup { - // Configurable options - Configurable mUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable mPathGrpLhcIf{"ccdb-path-grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; - Configurable mTimestamp{"ccdb-timestamp", -1, "timestamp of the object"}; - Configurable mTimeShiftCCDBPath{"timeShiftCCDBPath", "", "Path of the TOF time shift vs eta. If empty none is taken"}; - Configurable mParamFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; - Configurable mParametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; - Configurable mReconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}}; - Configurable mLoadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; - Configurable mFatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; - Configurable mEnableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"}; - Configurable mCollisionSystem{"collisionSystem", -1, "Collision system: -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"}; - Configurable mAutoSetProcessFunctions{"mAutoSetProcessFunctions", true, "Flag to autodetect the process functions to use"}; +struct TOFCalibConfig { + template + void init(const CfgType& opt) + { + mUrl = opt.cfgUrl.value; + mPathGrpLhcIf = opt.cfgPathGrpLhcIf.value; + mTimestamp = opt.cfgTimestamp.value; + mTimeShiftCCDBPathPos = opt.cfgTimeShiftCCDBPathPos.value; + mTimeShiftCCDBPathNeg = opt.cfgTimeShiftCCDBPathNeg.value; + mParamFileName = opt.cfgParamFileName.value; + mParametrizationPath = opt.cfgParametrizationPath.value; + mReconstructionPass = opt.cfgReconstructionPass.value; + mLoadResponseFromCCDB = opt.cfgLoadResponseFromCCDB.value; + mFatalOnPassNotAvailable = opt.cfgFatalOnPassNotAvailable.value; + mEnableTimeDependentResponse = opt.cfgEnableTimeDependentResponse.value; + mCollisionSystem = opt.cfgCollisionSystem.value; + mAutoSetProcessFunctions = opt.cfgAutoSetProcessFunctions.value; + } + + template + void getCfg(o2::framework::InitContext& initContext, const std::string name, VType& v, const std::string task) + { + if (!getTaskOptionValue(initContext, task, name, v, true)) { + LOG(fatal) << "Could not get " << name << " from " << task << " task"; + } + } + void inheritFromBaseTask(o2::framework::InitContext& initContext, const std::string task = "tof-signal") + { + mInitMode = 2; + getCfg(initContext, "ccdb-url", mUrl, task); + getCfg(initContext, "ccdb-path-grplhcif", mPathGrpLhcIf, task); + getCfg(initContext, "ccdb-timestamp", mTimestamp, task); + getCfg(initContext, "timeShiftCCDBPathPos", mTimeShiftCCDBPathPos, task); + getCfg(initContext, "timeShiftCCDBPathNeg", mTimeShiftCCDBPathPos, task); + getCfg(initContext, "paramFileName", mParamFileName, task); + getCfg(initContext, "parametrizationPath", mParametrizationPath, task); + getCfg(initContext, "reconstructionPass", mReconstructionPass, task); + getCfg(initContext, "loadResponseFromCCDB", mLoadResponseFromCCDB, task); + getCfg(initContext, "fatalOnPassNotAvailable", mFatalOnPassNotAvailable, task); + getCfg(initContext, "enableTimeDependentResponse", mEnableTimeDependentResponse, task); + getCfg(initContext, "collisionSystem", mCollisionSystem, task); + getCfg(initContext, "autoSetProcessFunctions", mAutoSetProcessFunctions, task); + } // @brief Set up the configuration from the calibration object from the init function of the task template void initSetup(o2::pid::tof::TOFResoParamsV3& mRespParamsV3, CCDBObject ccdb) { + mInitMode = 1; // First we set the CCDB manager - ccdb->setURL(mUrl.value); - ccdb->setTimestamp(mTimestamp.value); + ccdb->setURL(mUrl); + ccdb->setTimestamp(mTimestamp); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); // Not later than now objects ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); // Then the information about the metadata - if (mReconstructionPass.value == "metadata") { + if (mReconstructionPass == "metadata") { LOG(info) << "Getting pass from metadata"; if (metadataInfo.isMC()) { - mReconstructionPass.value = metadataInfo.get("AnchorPassName"); + mReconstructionPass = metadataInfo.get("AnchorPassName"); } else { - mReconstructionPass.value = metadataInfo.get("RecoPassName"); + mReconstructionPass = metadataInfo.get("RecoPassName"); } - LOG(info) << "Passed autodetect mode for pass. Taking '" << mReconstructionPass.value << "'"; + LOG(info) << "Passed autodetect mode for pass. Taking '" << mReconstructionPass << "'"; } - LOG(info) << "Using parameter collection, starting from pass '" << mReconstructionPass.value << "'"; + LOG(info) << "Using parameter collection, starting from pass '" << mReconstructionPass << "'"; - const std::string fname = mParamFileName.value; + const std::string fname = mParamFileName; if (!fname.empty()) { // Loading the parametrization from file - LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << mParametrizationPath.value; + LOG(info) << "Loading exp. sigma parametrization from file " << fname << ", using param: " << mParametrizationPath; if (1) { o2::tof::ParameterCollection paramCollection; - paramCollection.loadParamFromFile(fname, mParametrizationPath.value); + paramCollection.loadParamFromFile(fname, mParametrizationPath); LOG(info) << "+++ Loaded parameter collection from file +++"; - if (!paramCollection.retrieveParameters(mRespParamsV3, mReconstructionPass.value)) { + if (!paramCollection.retrieveParameters(mRespParamsV3, mReconstructionPass)) { if (mFatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.value.data()); + LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.value.data()); + LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } } else { - mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPass.value)); + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection.getPars(mReconstructionPass)); mRespParamsV3.printMomentumChargeShiftParameters(); } } else { - mRespParamsV3.loadParamFromFile(fname.data(), mParametrizationPath.value); + mRespParamsV3.loadParamFromFile(fname.data(), mParametrizationPath); } } else if (mLoadResponseFromCCDB) { // Loading it from CCDB - LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << mParametrizationPath.value << " for timestamp " << mTimestamp.value; - o2::tof::ParameterCollection* paramCollection = ccdb->template getForTimeStamp(mParametrizationPath.value, mTimestamp.value); + LOG(info) << "Loading exp. sigma parametrization from CCDB, using path: " << mParametrizationPath << " for timestamp " << mTimestamp; + o2::tof::ParameterCollection* paramCollection = ccdb->template getForTimeStamp(mParametrizationPath, mTimestamp); paramCollection->print(); - if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPass.value)) { // Attempt at loading the parameters with the pass defined + if (!paramCollection->retrieveParameters(mRespParamsV3, mReconstructionPass)) { // Attempt at loading the parameters with the pass defined if (mFatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.value.data()); + LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.value.data()); + LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } } else { // Pass is available, load non standard parameters - mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass.value)); + mRespParamsV3.setMomentumChargeShiftParameters(paramCollection->getPars(mReconstructionPass)); mRespParamsV3.printMomentumChargeShiftParameters(); } } @@ -138,13 +168,30 @@ struct TOFCalibConfig : ConfigurableGroup { mRespParamsV3.print(); // Loading additional calibration objects - if (mTimeShiftCCDBPath.value != "") { - if (mTimeShiftCCDBPath.value.find(".root") != std::string::npos) { - mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPath.value, "gmean_Pos", true); - mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPath.value, "gmean_Neg", false); + if (mTimeShiftCCDBPathPos != "") { + if (mTimeShiftCCDBPathPos.find(".root") != std::string::npos) { + mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPathPos, "ccdb_object", true); + } else { + if (mReconstructionPass == "") { + mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(mTimeShiftCCDBPathPos, mTimestamp), true); + } else { + std::map metadata; + metadata["RecoPassName"] = mReconstructionPass; + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(mTimeShiftCCDBPathPos, mTimestamp, metadata), true); + } + } + } + if (mTimeShiftCCDBPathNeg != "") { + if (mTimeShiftCCDBPathNeg.find(".root") != std::string::npos) { + mRespParamsV3.setTimeShiftParameters(mTimeShiftCCDBPathNeg, "ccdb_object", false); } else { - mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(Form("%s/pos", mTimeShiftCCDBPath.value.c_str()), mTimestamp.value), true); - mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(Form("%s/neg", mTimeShiftCCDBPath.value.c_str()), mTimestamp.value), false); + if (mReconstructionPass == "") { + mRespParamsV3.setTimeShiftParameters(ccdb->template getForTimeStamp(mTimeShiftCCDBPathNeg, mTimestamp), false); + } else { + std::map metadata; + metadata["RecoPassName"] = mReconstructionPass; + mRespParamsV3.setTimeShiftParameters(ccdb->template getSpecific(mTimeShiftCCDBPathNeg, mTimestamp, metadata), false); + } } } } @@ -154,43 +201,64 @@ struct TOFCalibConfig : ConfigurableGroup { CCDBObject ccdb, const BcType& bc) { + LOG(debug) << "Processing setup for run number " << bc.runNumber() << " from run " << mLastRunNumber; // First we check if this run number was already processed if (mLastRunNumber == bc.runNumber()) { return; } mLastRunNumber = bc.runNumber(); - mTimestamp.value = bc.timestamp(); + mTimestamp = bc.timestamp(); // Check the beam type - o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp(mPathGrpLhcIf.value, - mTimestamp.value); - mCollisionSystem.value = CollisionSystemType::getCollisionTypeFromGrp(grpo); + o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp(mPathGrpLhcIf, + mTimestamp); + if (mCollisionSystem == -1) { + mCollisionSystem = CollisionSystemType::getCollisionTypeFromGrp(grpo); + } else { + LOG(debug) << "Not setting collisions system as already set to " << mCollisionSystem << " " << CollisionSystemType::getCollisionSystemName(mCollisionSystem); + } if (!mEnableTimeDependentResponse) { return; } - LOG(debug) << "Updating parametrization from path '" << mParametrizationPath.value << "' and timestamp " << mTimestamp.value; - if (!ccdb->template getForTimeStamp(mParametrizationPath.value, mTimestamp.value)->retrieveParameters(mRespParamsV3, mReconstructionPass.value)) { + LOG(debug) << "Updating parametrization from path '" << mParametrizationPath << "' and timestamp " << mTimestamp; + if (!ccdb->template getForTimeStamp(mParametrizationPath, mTimestamp)->retrieveParameters(mRespParamsV3, mReconstructionPass)) { if (mFatalOnPassNotAvailable) { - LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.value.data()); + LOGF(fatal, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } else { - LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.value.data()); + LOGF(warning, "Pass '%s' not available in the retrieved CCDB object", mReconstructionPass.data()); } } return; } + bool autoSetProcessFunctions() const { return mAutoSetProcessFunctions; } + int collisionSystem() const { return mCollisionSystem; } + private: int mLastRunNumber = -1; // Last run number for which the calibration was loaded + int mInitMode = 0; // 0: no init, 1: init, 2: inherit + + // Configurable options + std::string mUrl; + std::string mPathGrpLhcIf; + int64_t mTimestamp; + std::string mTimeShiftCCDBPathPos; + std::string mTimeShiftCCDBPathNeg; + std::string mParamFileName; + std::string mParametrizationPath; + std::string mReconstructionPass; + bool mLoadResponseFromCCDB; + bool mFatalOnPassNotAvailable; + bool mEnableTimeDependentResponse; + int mCollisionSystem; + bool mAutoSetProcessFunctions; }; // Part 1 TOF signal definition /// Selection criteria for tracks used for TOF event time -float trackDistanceForGoodMatch = 999.f; -float trackDistanceForGoodMatchLowMult = 999.f; -int multiplicityThreshold = 0; -bool isTrackGoodMatchForTOFPID(const Run3Trks::iterator& tr, const Run3Cols& /*ev*/) +bool isTrackGoodMatchForTOFPID(const Run3Trks::iterator& tr) { if (!tr.hasTOF()) { return false; @@ -206,16 +274,33 @@ struct tofSignal { // Running flags bool enableTableTOFSignal = false; // Flag to check if the TOF signal table is requested or not bool enableTablepidTOFFlags = false; // Flag to check if the TOF signal flags table is requested or not - TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration - Configurable distanceForGoodMatch{"distanceForGoodMatch", 999.f, "Maximum distance to consider a good match"}; - Configurable distanceForGoodMatchLowMult{"distanceForGoodMatchLowMult", 999.f, "Maximum distance to consider a good match for low multiplicity events"}; - Configurable multThreshold{"multThreshold", 0, "Multiplicity threshold to consider a low multiplicity event"}; // Output histograms Configurable enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"}; HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + // Detector response and input parameters + o2::pid::tof::TOFResoParamsV3 mRespParamsV3; + Service ccdb; + struct : ConfigurableGroup { + Configurable cfgUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + Configurable cfgPathGrpLhcIf{"ccdb-path-grplhcif", "GLO/Config/GRPLHCIF", "Path on the CCDB for the GRPLHCIF object"}; + Configurable cfgTimestamp{"ccdb-timestamp", -1, "timestamp of the object"}; + Configurable cfgTimeShiftCCDBPathPos{"timeShiftCCDBPathPos", "", "Path of the TOF time shift vs eta for pos. tracks. If empty none is taken"}; + Configurable cfgTimeShiftCCDBPathNeg{"timeShiftCCDBPathNeg", "", "Path of the TOF time shift vs eta for neg. tracks. If empty none is taken"}; + Configurable cfgParamFileName{"paramFileName", "", "Path to the parametrization object. If empty the parametrization is not taken from file"}; + Configurable cfgParametrizationPath{"parametrizationPath", "TOF/Calib/Params", "Path of the TOF parametrization on the CCDB or in the file, if the paramFileName is not empty"}; + Configurable cfgReconstructionPass{"reconstructionPass", "", {"Apass to use when fetching the calibration tables. Empty (default) does not check for any pass. Use `metadata` to fetch it from the AO2D metadata. Otherwise it will override the metadata."}}; + Configurable cfgLoadResponseFromCCDB{"loadResponseFromCCDB", false, "Flag to load the response from the CCDB"}; + Configurable cfgFatalOnPassNotAvailable{"fatalOnPassNotAvailable", true, "Flag to throw a fatal if the pass is not available in the retrieved CCDB object"}; + Configurable cfgEnableTimeDependentResponse{"enableTimeDependentResponse", false, "Flag to use the collision timestamp to fetch the PID Response"}; + Configurable cfgCollisionSystem{"collisionSystem", -1, "Collision system: -1 (autoset), 0 (pp), 1 (PbPb), 2 (XeXe), 3 (pPb)"}; + Configurable cfgAutoSetProcessFunctions{"autoSetProcessFunctions", true, "Flag to autodetect the process functions to use"}; + } cfg; // Configurables (only defined here and inherited from other tasks) + + TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.init(cfg); // Checking that the table is requested in the workflow and enabling it enableTableTOFSignal = isTableRequiredInWorkflow(initContext, "TOFSignal"); if (enableTableTOFSignal) { @@ -231,7 +316,7 @@ struct tofSignal { LOG(info) << "No table or process is enabled. Disabling task"; return; } - if (mTOFCalibConfig.mAutoSetProcessFunctions) { + if (mTOFCalibConfig.autoSetProcessFunctions()) { LOG(info) << "Autodetecting process functions"; if (metadataInfo.isFullyDefined() && !doprocessRun2 && !doprocessRun3) { // Check if the metadata is initialized (only if not forced from the workflow configuration) if (metadataInfo.isRun3()) { @@ -249,11 +334,7 @@ struct tofSignal { if (!doprocessRun2 && !doprocessRun3) { LOG(fatal) << "Neither processRun2 nor processRun3 are enabled. Pick one of the two"; } - - trackDistanceForGoodMatch = distanceForGoodMatch; - trackDistanceForGoodMatchLowMult = distanceForGoodMatchLowMult; - multiplicityThreshold = multThreshold; - LOG(info) << "Configuring selections for good match: " << trackDistanceForGoodMatch << " low mult " << trackDistanceForGoodMatchLowMult << " mult. threshold " << multiplicityThreshold; + mTOFCalibConfig.initSetup(mRespParamsV3, ccdb); // Getting the parametrization parameters if (!enableQaHistograms) { return; } @@ -266,7 +347,7 @@ struct tofSignal { /// Dummy process function for BCs, needed in case both Run2 and Run3 process functions are disabled void process(aod::BCs const&) {} - void processRun3(Run3Trks const& tracks, Run3Cols const& collisions) + void processRun3(Run3Trks const& tracks) { if (!enableTableTOFSignal) { return; @@ -275,18 +356,18 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& t : tracks) { - const auto s = o2::pid::tof::TOFSignal::GetTOFSignal(t); + for (auto& trk : tracks) { + const float& sig = o2::pid::tof::TOFSignal::GetTOFSignal(trk); if (enableQaHistograms) { - histos.fill(HIST("tofSignal"), s); + histos.fill(HIST("tofSignal"), sig); } - table(s); + table(sig); if (!enableTablepidTOFFlags) { continue; } - const auto b = isTrackGoodMatchForTOFPID(t, collisions); + const auto& b = isTrackGoodMatchForTOFPID(trk); if (enableQaHistograms) { - histos.fill(HIST("goodForPIDFlags"), s); + histos.fill(HIST("goodForPIDFlags"), sig); } tableFlags(b); } @@ -302,8 +383,8 @@ struct tofSignal { if (enableTablepidTOFFlags) { tableFlags.reserve(tracks.size()); } - for (auto& t : tracks) { - table(o2::pid::tof::TOFSignal::GetTOFSignal(t)); + for (auto& trk : tracks) { + table(o2::pid::tof::TOFSignal::GetTOFSignal(trk)); if (!enableTablepidTOFFlags) { continue; } @@ -370,6 +451,7 @@ struct tofEventTime { void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.inheritFromBaseTask(initContext); // Checking that the table is requested in the workflow and enabling it enableTableTOFEvTime = isTableRequiredInWorkflow(initContext, "TOFEvTime"); @@ -388,7 +470,7 @@ struct tofEventTime { return; } - if (mTOFCalibConfig.mAutoSetProcessFunctions) { + if (mTOFCalibConfig.autoSetProcessFunctions()) { LOG(info) << "Autodetecting process functions"; if (metadataInfo.isFullyDefined()) { if (metadataInfo.isRun3()) { @@ -481,7 +563,7 @@ struct tofEventTime { if (enableTableEvTimeTOFOnly) { tableEvTimeTOFOnly.reserve(tracks.size()); } - + bool calibUpdated = false; for (auto const& track : tracks) { // Loop on all tracks if (!track.has_collision()) { // Skipping tracks without collisions continue; @@ -491,23 +573,31 @@ struct tofEventTime { continue; } mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters + calibUpdated = true; + break; } // Autoset the processing mode for the event time computation - switch (mTOFCalibConfig.mCollisionSystem.value) { - case CollisionSystemType::kCollSyspp: // pp - mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 0 : mComputeEvTimeWithTOF.value); - mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 1 : mComputeEvTimeWithFT0.value); - break; - case CollisionSystemType::kCollSysPbPb: // PbPb - mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 1 : mComputeEvTimeWithTOF.value); - mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 0 : mComputeEvTimeWithFT0.value); - break; - default: - LOG(fatal) << "Collision system " << mTOFCalibConfig.mCollisionSystem.value << " " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.mCollisionSystem) << " not supported for TOF event time computation"; - break; + if (calibUpdated) { + if (mComputeEvTimeWithTOF == -1 || mComputeEvTimeWithFT0 == -1) { + switch (mTOFCalibConfig.collisionSystem()) { + case CollisionSystemType::kCollSyspp: // pp + mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 0 : mComputeEvTimeWithTOF.value); + mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 1 : mComputeEvTimeWithFT0.value); + break; + case CollisionSystemType::kCollSysPbPb: // PbPb + mComputeEvTimeWithTOF.value = ((mComputeEvTimeWithTOF == -1) ? 1 : mComputeEvTimeWithTOF.value); + mComputeEvTimeWithFT0.value = ((mComputeEvTimeWithFT0 == -1) ? 0 : mComputeEvTimeWithFT0.value); + break; + default: + LOG(fatal) << "Collision system " << mTOFCalibConfig.collisionSystem() << " " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.collisionSystem()) << " not supported for TOF event time computation"; + break; + } + } + } else { + LOG(warning) << "Calibration not updated on " << tracks.size() << " tracks !!"; } - LOG(debug) << "Running on " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.mCollisionSystem) << " mComputeEvTimeWithTOF " << mComputeEvTimeWithTOF.value << " mComputeEvTimeWithFT0 " << mComputeEvTimeWithFT0.value; + LOG(debug) << "Running on " << CollisionSystemType::getCollisionSystemName(mTOFCalibConfig.collisionSystem()) << " mComputeEvTimeWithTOF " << mComputeEvTimeWithTOF.value << " mComputeEvTimeWithFT0 " << mComputeEvTimeWithFT0.value; if (mComputeEvTimeWithTOF == 1 && mComputeEvTimeWithFT0 == 1) { int lastCollisionId = -1; // Last collision ID analysed @@ -711,7 +801,6 @@ struct tofPidMerge { o2::pid::tof::TOFResoParamsV3 mRespParamsV3; Service ccdb; TOFCalibConfig mTOFCalibConfig; // TOF Calib configuration - // Configurable inheritFromBaseTask{"inheritFromBaseTask", true, "Flag to iherit all common configurables from the TOF base task"}; Configurable enableQaHistograms{"enableQaHistograms", false, "Flag to enable the QA histograms"}; // Configuration flags to include and exclude particle hypotheses @@ -730,6 +819,7 @@ struct tofPidMerge { std::vector mEnabledParticlesFull; // Vector of enabled PID hypotheses to loop on when making full tables void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.inheritFromBaseTask(initContext); // Checking the tables are requested in the workflow and enabling them for (int i = 0; i < nSpecies; i++) { // First checking tiny @@ -966,6 +1056,7 @@ struct tofPidMerge { continue; } mTOFCalibConfig.processSetup(mRespParamsV3, ccdb, coll.bc_as()); // Update the calibration parameters + break; } for (auto const& pidId : mEnabledParticles) { @@ -1129,6 +1220,7 @@ struct tofPidBeta { bool enableTableMass = false; void init(o2::framework::InitContext& initContext) { + mTOFCalibConfig.inheritFromBaseTask(initContext); enableTableBeta = isTableRequiredInWorkflow(initContext, "pidTOFbeta"); enableTableMass = isTableRequiredInWorkflow(initContext, "pidTOFmass"); if (!enableTableBeta && !enableTableMass && !doprocessRun2 && !doprocessRun3) { @@ -1136,7 +1228,7 @@ struct tofPidBeta { return; } - if (mTOFCalibConfig.mAutoSetProcessFunctions) { + if (mTOFCalibConfig.autoSetProcessFunctions()) { LOG(info) << "Autodetecting process functions"; if (metadataInfo.isFullyDefined()) { if (metadataInfo.isRun3()) {