diff --git a/EventFiltering/PWGCF/CFFilter.cxx b/EventFiltering/PWGCF/CFFilter.cxx index 270d138fcb6..380f11e710f 100644 --- a/EventFiltering/PWGCF/CFFilter.cxx +++ b/EventFiltering/PWGCF/CFFilter.cxx @@ -34,12 +34,8 @@ #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" -#include -#include "DataFormatsParameters/GRPObject.h" - #include #include - #include namespace @@ -103,8 +99,6 @@ struct CFFilter { HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry registryQA{"registryQA", {}, OutputObjHandlingPolicy::AnalysisObject}; - Service ccdb; /// Accessing the CCDB - // FemtoDreamPairCleaner pairCleanerTT; Currently not used, will be needed later FemtoDreamPairCleaner pairCleanerTV; FemtoDreamDetaDphiStar closePairRejectionTT; @@ -171,31 +165,6 @@ struct CFFilter { registry.add("fMinvLambda", "Invariant mass of lambdas ", HistType::kTH1F, {{1000, 0.7, 1.5}}); registry.add("fMinvAntiLambda", "Invariant mass of antilambdas ", HistType::kTH1F, {{1000, 0.7, 1.5}}); } - - /// Initializing CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - - long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - ccdb->setCreatedNotAfter(now); - } - - /// Function to retrieve the nominal mgnetic field in kG (0.1T) and convert it directly to T - float getMagneticFieldTesla(uint64_t timestamp) - { - // TODO done only once (and not per run). Will be replaced by CCDBConfigurable - static o2::parameters::GRPObject* grpo = nullptr; - if (grpo == nullptr) { - grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); - if (grpo == nullptr) { - LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); - return 0; - } - LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); - } - float output = 0.1 * (grpo->getNominalL3Field()); - return output; } float mMassProton = TDatabasePDG::Instance()->GetParticle(2212)->Mass(); @@ -208,8 +177,7 @@ struct CFFilter { auto partsProton1 = partsProton1Part->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); auto partsLambda1 = partsLambda1Part->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); - auto tmstamp = col.timestamp(); - auto mafneticField = getMagneticFieldTesla(tmstamp); + auto magneticField = col.magField(); registry.get(HIST("fProcessedEvents"))->Fill(0); registry.get(HIST("fMultiplicityBefore"))->Fill(col.multV0M()); registry.get(HIST("fZvtxBefore"))->Fill(col.posZ()); @@ -255,13 +223,13 @@ struct CFFilter { } // Think if pair cleaning is needed in current framework // Run close pair rejection - if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, mafneticField)) { + if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, magneticField)) { continue; } - if (closePairRejectionTT.isClosePair(p1, p3, partsFemto, mafneticField)) { + if (closePairRejectionTT.isClosePair(p1, p3, partsFemto, magneticField)) { continue; } - if (closePairRejectionTT.isClosePair(p2, p3, partsFemto, mafneticField)) { + if (closePairRejectionTT.isClosePair(p2, p3, partsFemto, magneticField)) { continue; } auto Q3 = FemtoDreamMath::getQ3(p1, mMassProton, p2, mMassProton, p3, mMassProton); @@ -281,13 +249,13 @@ struct CFFilter { } // Think if pair cleaning is needed in current framework // Run close pair rejection - if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, mafneticField)) { + if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, magneticField)) { continue; } - if (closePairRejectionTT.isClosePair(p1, p3, partsFemto, mafneticField)) { + if (closePairRejectionTT.isClosePair(p1, p3, partsFemto, magneticField)) { continue; } - if (closePairRejectionTT.isClosePair(p2, p3, partsFemto, mafneticField)) { + if (closePairRejectionTT.isClosePair(p2, p3, partsFemto, magneticField)) { continue; } auto Q3 = FemtoDreamMath::getQ3(p1, mMassProton, p2, mMassProton, p3, mMassProton); @@ -313,13 +281,13 @@ struct CFFilter { if (!isFullPIDSelectedProton(p1.pidcut(), p1.p()) || !isFullPIDSelectedProton(p2.pidcut(), p2.p())) { continue; } - if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, getMagneticFieldTesla(tmstamp))) { + if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, magneticField)) { continue; } - if (closePairRejectionTV0.isClosePair(p1, partLambda, partsFemto, getMagneticFieldTesla(tmstamp))) { + if (closePairRejectionTV0.isClosePair(p1, partLambda, partsFemto, magneticField)) { continue; } - if (closePairRejectionTV0.isClosePair(p2, partLambda, partsFemto, getMagneticFieldTesla(tmstamp))) { + if (closePairRejectionTV0.isClosePair(p2, partLambda, partsFemto, magneticField)) { continue; } auto Q3 = FemtoDreamMath::getQ3(p1, mMassProton, p2, mMassProton, partLambda, mMassLambda); @@ -343,13 +311,13 @@ struct CFFilter { if (!isFullPIDSelectedProton(p1.pidcut(), p1.p()) || !isFullPIDSelectedProton(p2.pidcut(), p2.p())) { continue; } - if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, getMagneticFieldTesla(tmstamp))) { + if (closePairRejectionTT.isClosePair(p1, p2, partsFemto, magneticField)) { continue; } - if (closePairRejectionTV0.isClosePair(p1, partLambda, partsFemto, getMagneticFieldTesla(tmstamp))) { + if (closePairRejectionTV0.isClosePair(p1, partLambda, partsFemto, magneticField)) { continue; } - if (closePairRejectionTV0.isClosePair(p2, partLambda, partsFemto, getMagneticFieldTesla(tmstamp))) { + if (closePairRejectionTV0.isClosePair(p2, partLambda, partsFemto, magneticField)) { continue; } auto Q3 = FemtoDreamMath::getQ3(p1, mMassProton, p2, mMassProton, partLambda, mMassLambda); diff --git a/PWGCF/DataModel/FemtoDerived.h b/PWGCF/DataModel/FemtoDerived.h index 568a6e82b56..6f2e916165d 100644 --- a/PWGCF/DataModel/FemtoDerived.h +++ b/PWGCF/DataModel/FemtoDerived.h @@ -29,6 +29,7 @@ namespace femtodreamcollision { DECLARE_SOA_COLUMN(MultV0M, multV0M, float); //! V0M multiplicity DECLARE_SOA_COLUMN(Sphericity, sphericity, float); //! Sphericity of the event +DECLARE_SOA_COLUMN(MagField, magField, float); //! Sphericity of the event } // namespace femtodreamcollision @@ -37,7 +38,7 @@ DECLARE_SOA_TABLE(FemtoDreamCollisions, "AOD", "FEMTODREAMCOLS", o2::aod::collision::PosZ, femtodreamcollision::MultV0M, femtodreamcollision::Sphericity, - timestamp::Timestamp); + femtodreamcollision::MagField); using FemtoDreamCollision = FemtoDreamCollisions::iterator; /// FemtoDreamTrack diff --git a/PWGCF/FemtoDream/FemtoUtils.h b/PWGCF/FemtoDream/FemtoUtils.h index 3fc4f3a988d..65f6acb2795 100644 --- a/PWGCF/FemtoDream/FemtoUtils.h +++ b/PWGCF/FemtoDream/FemtoUtils.h @@ -98,25 +98,5 @@ bool isFullPIDSelected(aod::femtodreamparticle::cutContainerType const& pidCut, return pidSelection; }; -/// function to retrieve the nominal mgnetic field in kG (0.1T) and convert it directly to T -/// \param timestamp timestamp corresponding the the collision -/// \param ccdb CCDB object that contains the configuration for the event -/// \return magnetic field in Tesla - -float getMagneticFieldTesla(const uint64_t& timestamp, const Service& ccdb) -{ - // TODO done only once (and not per run). Will be replaced by CCDBConfigurable - static o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); - if (!grpo) { - LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); - return 0; - } else { - LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); - } - - return 0.1 * (grpo->getNominalL3Field()); -} - } // namespace o2::analysis::femtoDream - #endif diff --git a/PWGCF/FemtoDream/femtoDreamPairTaskTrackTrack.cxx b/PWGCF/FemtoDream/femtoDreamPairTaskTrackTrack.cxx index e717a2b5e5c..2bdb550a088 100644 --- a/PWGCF/FemtoDream/femtoDreamPairTaskTrackTrack.cxx +++ b/PWGCF/FemtoDream/femtoDreamPairTaskTrackTrack.cxx @@ -19,8 +19,6 @@ #include "Framework/ASoAHelpers.h" #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" -#include -#include "DataFormatsParameters/GRPObject.h" #include "PWGCF/DataModel/FemtoDerived.h" #include "FemtoDreamParticleHisto.h" @@ -112,8 +110,6 @@ struct femtoDreamPairTaskTrackTrack { HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry MixQaRegistry{"MixQaRegistry", {}, OutputObjHandlingPolicy::AnalysisObject}; - Service ccdb; /// Accessing the CCDB - void init(InitContext&) { eventHisto.init(&qaRegistry); @@ -136,14 +132,6 @@ struct femtoDreamPairTaskTrackTrack { vPIDPartOne = ConfPIDPartOne; vPIDPartTwo = ConfPIDPartTwo; - - /// Initializing CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - - long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - ccdb->setCreatedNotAfter(now); } /// This function processes the same event and takes care of all the histogramming @@ -153,8 +141,7 @@ struct femtoDreamPairTaskTrackTrack { { MixQaRegistry.fill(HIST("MixingQA/hSECollisionBins"), colBinning.getBin({col.posZ(), col.multV0M()})); - const auto& tmstamp = col.timestamp(); - const auto& magFieldTesla = getMagneticFieldTesla(tmstamp, ccdb); + const auto& magFieldTesla = col.magField(); auto groupPartsOne = partsOne->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); @@ -220,11 +207,8 @@ struct femtoDreamPairTaskTrackTrack { auto groupPartsOne = partsOne->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, collision1.globalIndex()); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, collision2.globalIndex()); - const auto& tmstamp1 = collision1.timestamp(); - const auto& magFieldTesla1 = getMagneticFieldTesla(tmstamp1, ccdb); - - const auto& tmstamp2 = collision2.timestamp(); - const auto& magFieldTesla2 = getMagneticFieldTesla(tmstamp2, ccdb); + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); if (magFieldTesla1 != magFieldTesla2) { continue; diff --git a/PWGCF/FemtoDream/femtoDreamPairTaskTrackV0.cxx b/PWGCF/FemtoDream/femtoDreamPairTaskTrackV0.cxx index 3acde27db2c..5454de849f2 100644 --- a/PWGCF/FemtoDream/femtoDreamPairTaskTrackV0.cxx +++ b/PWGCF/FemtoDream/femtoDreamPairTaskTrackV0.cxx @@ -19,8 +19,6 @@ #include "Framework/ASoAHelpers.h" #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" -#include -#include "DataFormatsParameters/GRPObject.h" #include "PWGCF/DataModel/FemtoDerived.h" #include "FemtoDreamParticleHisto.h" @@ -103,8 +101,6 @@ struct femtoDreamPairTaskTrackV0 { HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; - Service ccdb; /// Accessing the CCDB - void init(InitContext&) { eventHisto.init(&qaRegistry); @@ -121,14 +117,6 @@ struct femtoDreamPairTaskTrackV0 { } vPIDPartOne = ConfPIDPartOne; - - /// Initializing CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - - long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - ccdb->setCreatedNotAfter(now); } /// This function processes the same event and takes care of all the histogramming @@ -136,8 +124,7 @@ struct femtoDreamPairTaskTrackV0 { void processSameEvent(o2::aod::FemtoDreamCollision& col, o2::aod::FemtoDreamParticles& parts) { - const auto& tmstamp = col.timestamp(); - const auto& magFieldTesla = getMagneticFieldTesla(tmstamp, ccdb); + const auto& magFieldTesla = col.magField(); auto groupPartsOne = partsOne->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); @@ -193,11 +180,8 @@ struct femtoDreamPairTaskTrackV0 { auto groupPartsOne = partsOne->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, collision1.globalIndex()); auto groupPartsTwo = partsTwo->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, collision2.globalIndex()); - const auto& tmstamp1 = collision1.timestamp(); - const auto& magFieldTesla1 = getMagneticFieldTesla(tmstamp1, ccdb); - - const auto& tmstamp2 = collision2.timestamp(); - const auto& magFieldTesla2 = getMagneticFieldTesla(tmstamp2, ccdb); + const auto& magFieldTesla1 = collision1.magField(); + const auto& magFieldTesla2 = collision2.magField(); if (magFieldTesla1 != magFieldTesla2) { continue; diff --git a/PWGCF/FemtoDream/femtoDreamProducerReducedTask.cxx b/PWGCF/FemtoDream/femtoDreamProducerReducedTask.cxx index 514113a930b..04bdd5490d2 100644 --- a/PWGCF/FemtoDream/femtoDreamProducerReducedTask.cxx +++ b/PWGCF/FemtoDream/femtoDreamProducerReducedTask.cxx @@ -28,8 +28,10 @@ #include "ReconstructionDataFormats/Track.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/StrangenessTables.h" +#include "DataFormatsParameters/GRPObject.h" #include "Math/Vector4D.h" #include "TMath.h" +#include using namespace o2; using namespace o2::analysis::femtoDream; @@ -89,6 +91,10 @@ struct femtoDreamProducerReducedTask { HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject}; + int mRunNumber; + float mMagField; + Service ccdb; /// Accessing the CCDB + void init(InitContext&) { colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, ConfIsRun3); @@ -112,11 +118,42 @@ struct femtoDreamProducerReducedTask { trackCuts.setSelection(ConfTrkPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit); trackCuts.setPIDSpecies(ConfTrkTPIDspecies); trackCuts.init(&qaRegistry); + mRunNumber = 0; + mMagField = 0.0; + /// Initializing CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + } + + /// Function to retrieve the nominal mgnetic field in kG (0.1T) and convert it directly to T + float getMagneticFieldTesla(uint64_t timestamp) + { + // TODO done only once (and not per run). Will be replaced by CCDBConfigurable + static o2::parameters::GRPObject* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + float output = 0.1 * (grpo->getNominalL3Field()); + return output; } void process(aod::FemtoFullCollision const& col, aod::BCsWithTimestamps const&, aod::FemtoFullTracks const& tracks) /// \todo with FilteredFullV0s { - auto bc = col.bc_as(); /// adding timestamp to access magnetic field later + // get magnetic field for run + auto bc = col.bc_as(); + if (mRunNumber != bc.runNumber()) { + mMagField = getMagneticFieldTesla(bc.timestamp()); + mRunNumber = bc.runNumber(); + } const auto vtxZ = col.posZ(); const auto spher = colCuts.computeSphericity(col, tracks); /// For benchmarking on Run 2, V0M in FemtoDreamRun2 is defined V0M/2 @@ -132,14 +169,14 @@ struct femtoDreamProducerReducedTask { // in case of trigger run - store such collisions but don't store any particle candidates for such collisions if (!colCuts.isSelected(col)) { if (ConfIsTrigger) { - outputCollision(col.posZ(), mult, colCuts.computeSphericity(col, tracks), bc.timestamp()); + outputCollision(col.posZ(), mult, colCuts.computeSphericity(col, tracks), mMagField); } return; } colCuts.fillQA(col); // now the table is filled - outputCollision(vtxZ, mult, spher, bc.timestamp()); + outputCollision(vtxZ, mult, spher, mMagField); int childIDs[2] = {0, 0}; // these IDs are necessary to keep track of the children for (auto& track : tracks) { diff --git a/PWGCF/FemtoDream/femtoDreamProducerTask.cxx b/PWGCF/FemtoDream/femtoDreamProducerTask.cxx index 968f67d8b51..4bed91c1055 100644 --- a/PWGCF/FemtoDream/femtoDreamProducerTask.cxx +++ b/PWGCF/FemtoDream/femtoDreamProducerTask.cxx @@ -29,8 +29,10 @@ #include "ReconstructionDataFormats/Track.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/StrangenessTables.h" +#include "DataFormatsParameters/GRPObject.h" #include "Math/Vector4D.h" #include "TMath.h" +#include using namespace o2; using namespace o2::analysis::femtoDream; @@ -149,6 +151,10 @@ struct femtoDreamProducerTask { HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject}; + int mRunNumber; + float mMagField; + Service ccdb; /// Accessing the CCDB + void init(InitContext&) { colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, ConfIsRun3); @@ -202,19 +208,52 @@ struct femtoDreamProducerTask { o2PhysicsTrackSelection->SetRequireHitsInITSLayers(1, {0, 1, 2, 3}); } } + + mRunNumber = 0; + mMagField = 0.0; + /// Initializing CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + } + + /// Function to retrieve the nominal mgnetic field in kG (0.1T) and convert it directly to T + float getMagneticFieldTesla(uint64_t timestamp) + { + // TODO done only once (and not per run). Will be replaced by CCDBConfigurable + static o2::parameters::GRPObject* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + float output = 0.1 * (grpo->getNominalL3Field()); + return output; } void process(aod::FemtoFullCollision const& col, aod::BCsWithTimestamps const&, aod::FemtoFullTracks const& tracks, o2::aod::V0Datas const& fullV0s) /// \todo with FilteredFullV0s { - auto bc = col.bc_as(); /// adding timestamp to access magnetic field later + // get magnetic field for run + auto bc = col.bc_as(); + if (mRunNumber != bc.runNumber()) { + mMagField = getMagneticFieldTesla(bc.timestamp()); + mRunNumber = bc.runNumber(); + } + /// First thing to do is to check whether the basic event selection criteria are fulfilled // If the basic selection is NOT fullfilled: // in case of skimming run - don't store such collisions // in case of trigger run - store such collisions but don't store any particle candidates for such collisions if (!colCuts.isSelected(col)) { if (ConfIsTrigger) { - outputCollision(col.posZ(), col.multFV0M(), colCuts.computeSphericity(col, tracks), bc.timestamp()); + outputCollision(col.posZ(), col.multFV0M(), colCuts.computeSphericity(col, tracks), mMagField); } return; } @@ -226,9 +265,9 @@ struct femtoDreamProducerTask { // now the table is filled if (ConfIsRun3) { - outputCollision(vtxZ, col.multFT0M(), spher, bc.timestamp()); + outputCollision(vtxZ, col.multFT0M(), spher, mMagField); } else { - outputCollision(vtxZ, mult, spher, bc.timestamp()); + outputCollision(vtxZ, mult, spher, mMagField); } int childIDs[2] = {0, 0}; // these IDs are necessary to keep track of the children diff --git a/PWGCF/FemtoDream/femtoDreamProducerTaskV0Only.cxx b/PWGCF/FemtoDream/femtoDreamProducerTaskV0Only.cxx index e270d6b4bb4..898723fa3be 100644 --- a/PWGCF/FemtoDream/femtoDreamProducerTaskV0Only.cxx +++ b/PWGCF/FemtoDream/femtoDreamProducerTaskV0Only.cxx @@ -29,8 +29,10 @@ #include "ReconstructionDataFormats/Track.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/StrangenessTables.h" +#include "DataFormatsParameters/GRPObject.h" #include "Math/Vector4D.h" #include "TMath.h" +#include using namespace o2; using namespace o2::analysis::femtoDream; @@ -130,6 +132,10 @@ struct femtoDreamProducerTaskV0Only { HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject}; + int mRunNumber; + float mMagField; + Service ccdb; /// Accessing the CCDB + void init(InitContext&) { colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, ConfIsRun3); @@ -163,19 +169,51 @@ struct femtoDreamProducerTaskV0Only { v0Cuts.setKaonInvMassLimits(ConfInvKaonMassLowLimit, ConfInvKaonMassUpLimit); } } + mRunNumber = 0; + mMagField = 0.0; + /// Initializing CCDB + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + + long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + ccdb->setCreatedNotAfter(now); + } + + /// Function to retrieve the nominal mgnetic field in kG (0.1T) and convert it directly to T + float getMagneticFieldTesla(uint64_t timestamp) + { + // TODO done only once (and not per run). Will be replaced by CCDBConfigurable + static o2::parameters::GRPObject* grpo = nullptr; + if (grpo == nullptr) { + grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); + if (grpo == nullptr) { + LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); + return 0; + } + LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); + } + float output = 0.1 * (grpo->getNominalL3Field()); + return output; } void process(aod::FemtoFullCollision const& col, aod::BCsWithTimestamps const&, aod::FemtoFullTracks const& tracks, o2::aod::V0Datas const& fullV0s) /// \todo with FilteredFullV0s { - auto bc = col.bc_as(); /// adding timestamp to access magnetic field later + // get magnetic field for run + auto bc = col.bc_as(); + if (mRunNumber != bc.runNumber()) { + mMagField = getMagneticFieldTesla(bc.timestamp()); + mRunNumber = bc.runNumber(); + } + /// First thing to do is to check whether the basic event selection criteria are fulfilled // If the basic selection is NOT fullfilled: // in case of skimming run - don't store such collisions // in case of trigger run - store such collisions but don't store any particle candidates for such collisions if (!colCuts.isSelected(col)) { if (ConfIsTrigger) { - outputCollision(col.posZ(), col.multFV0M(), colCuts.computeSphericity(col, tracks), bc.timestamp()); + outputCollision(col.posZ(), col.multFV0M(), colCuts.computeSphericity(col, tracks), mMagField); } return; } @@ -187,9 +225,9 @@ struct femtoDreamProducerTaskV0Only { // now the table is filled if (ConfIsRun3) { - outputCollision(vtxZ, col.multFT0M(), spher, bc.timestamp()); + outputCollision(vtxZ, col.multFT0M(), spher, mMagField); } else { - outputCollision(vtxZ, mult, spher, bc.timestamp()); + outputCollision(vtxZ, mult, spher, mMagField); } int childIDs[2] = {0, 0}; // these IDs are necessary to keep track of the children diff --git a/PWGCF/FemtoWorld/Core/FemtoWorldUtils.h b/PWGCF/FemtoWorld/Core/FemtoWorldUtils.h index 074739fff0b..6be2c489724 100644 --- a/PWGCF/FemtoWorld/Core/FemtoWorldUtils.h +++ b/PWGCF/FemtoWorld/Core/FemtoWorldUtils.h @@ -99,25 +99,6 @@ bool isFullPIDSelected(aod::femtodreamparticle::cutContainerType const& pidCut, return pidSelection; }; -/// function to retrieve the nominal mgnetic field in kG (0.1T) and convert it directly to T -/// \param timestamp timestamp corresponding the the collision -/// \param ccdb CCDB object that contains the configuration for the event -/// \return magnetic field in Tesla - -float getMagneticFieldTesla(const uint64_t& timestamp, const Service& ccdb) -{ - // TODO done only once (and not per run). Will be replaced by CCDBConfigurable - static o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp("GLO/GRP/GRP", timestamp); - if (!grpo) { - LOGF(fatal, "GRP object not found for timestamp %llu", timestamp); - return 0; - } else { - LOGF(info, "Retrieved GRP for timestamp %llu with magnetic field of %d kG", timestamp, grpo->getNominalL3Field()); - } - - return 0.1 * (grpo->getNominalL3Field()); -} - } // namespace o2::analysis::femtoWorld #endif diff --git a/PWGCF/FemtoWorld/Tasks/femtoWorldPairTaskTrackTrack.cxx b/PWGCF/FemtoWorld/Tasks/femtoWorldPairTaskTrackTrack.cxx index 609bd7c2332..714dc1199f6 100644 --- a/PWGCF/FemtoWorld/Tasks/femtoWorldPairTaskTrackTrack.cxx +++ b/PWGCF/FemtoWorld/Tasks/femtoWorldPairTaskTrackTrack.cxx @@ -19,8 +19,6 @@ #include "Framework/ASoAHelpers.h" #include "Framework/RunningWorkflowInfo.h" #include "Framework/StepTHn.h" -#include -#include "DataFormatsParameters/GRPObject.h" #include "PWGCF/DataModel/FemtoDerived.h" #include "PWGCF/FemtoWorld/Core/FemtoWorldParticleHisto.h" @@ -118,8 +116,6 @@ struct femtoWorldPairTaskTrackTrack { HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject}; HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject}; - Service ccdb; /// Accessing the CCDB - void init(InitContext&) { eventHisto.init(&qaRegistry); @@ -139,14 +135,6 @@ struct femtoWorldPairTaskTrackTrack { vPIDPartOne = ConfPIDPartOne; vPIDPartTwo = ConfPIDPartTwo; - - /// Initializing CCDB - ccdb->setURL("http://alice-ccdb.cern.ch"); - ccdb->setCaching(true); - ccdb->setLocalObjectValidityChecking(); - - long now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - ccdb->setCreatedNotAfter(now); } /// This function processes the same event and takes care of all the histogramming @@ -154,8 +142,7 @@ struct femtoWorldPairTaskTrackTrack { void processSameEvent(o2::aod::FemtoDreamCollision& col, o2::aod::FemtoWorldParticles& parts) { - const auto& tmstamp = col.timestamp(); - const auto& magFieldTesla = getMagneticFieldTesla(tmstamp, ccdb); + const auto& magFieldTesla = col.magField(); auto groupPartsOne = partsOne->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, col.globalIndex()); @@ -223,11 +210,9 @@ struct femtoWorldPairTaskTrackTrack { auto groupPartsTwo = partsTwo->sliceByCached(aod::femtodreamparticle::femtoDreamCollisionId, collision2.globalIndex()); - const auto& tmstamp1 = collision1.timestamp(); - const auto& magFieldTesla1 = getMagneticFieldTesla(tmstamp1, ccdb); + const auto& magFieldTesla1 = collision1.magField(); - const auto& tmstamp2 = collision2.timestamp(); - const auto& magFieldTesla2 = getMagneticFieldTesla(tmstamp2, ccdb); + const auto& magFieldTesla2 = collision2.magField(); if (magFieldTesla1 != magFieldTesla2) { continue;