Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 13 additions & 45 deletions EventFiltering/PWGCF/CFFilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"

#include <CCDB/BasicCCDBManager.h>
#include "DataFormatsParameters/GRPObject.h"

#include <cmath>
#include <string>

#include <bitset>

namespace
Expand Down Expand Up @@ -103,8 +99,6 @@ struct CFFilter {
HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject};
HistogramRegistry registryQA{"registryQA", {}, OutputObjHandlingPolicy::AnalysisObject};

Service<o2::ccdb::BasicCCDBManager> ccdb; /// Accessing the CCDB

// FemtoDreamPairCleaner<aod::femtodreamparticle::ParticleType::kTrack, aod::femtodreamparticle::ParticleType::kTrack> pairCleanerTT; Currently not used, will be needed later
FemtoDreamPairCleaner<aod::femtodreamparticle::ParticleType::kTrack, aod::femtodreamparticle::ParticleType::kV0> pairCleanerTV;
FemtoDreamDetaDphiStar<aod::femtodreamparticle::ParticleType::kTrack, aod::femtodreamparticle::ParticleType::kTrack> closePairRejectionTT;
Expand Down Expand Up @@ -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::milliseconds>(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<o2::parameters::GRPObject>("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();
Expand All @@ -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<TH1>(HIST("fProcessedEvents"))->Fill(0);
registry.get<TH1>(HIST("fMultiplicityBefore"))->Fill(col.multV0M());
registry.get<TH1>(HIST("fZvtxBefore"))->Fill(col.posZ());
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion PWGCF/DataModel/FemtoDerived.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
20 changes: 0 additions & 20 deletions PWGCF/FemtoDream/FemtoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<o2::ccdb::BasicCCDBManager>& ccdb)
{
// TODO done only once (and not per run). Will be replaced by CCDBConfigurable
static o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>("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
22 changes: 3 additions & 19 deletions PWGCF/FemtoDream/femtoDreamPairTaskTrackTrack.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "Framework/ASoAHelpers.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Framework/StepTHn.h"
#include <CCDB/BasicCCDBManager.h>
#include "DataFormatsParameters/GRPObject.h"

#include "PWGCF/DataModel/FemtoDerived.h"
#include "FemtoDreamParticleHisto.h"
Expand Down Expand Up @@ -112,8 +110,6 @@ struct femtoDreamPairTaskTrackTrack {
HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject};
HistogramRegistry MixQaRegistry{"MixQaRegistry", {}, OutputObjHandlingPolicy::AnalysisObject};

Service<o2::ccdb::BasicCCDBManager> ccdb; /// Accessing the CCDB

void init(InitContext&)
{
eventHisto.init(&qaRegistry);
Expand All @@ -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::milliseconds>(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
Expand All @@ -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());
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 3 additions & 19 deletions PWGCF/FemtoDream/femtoDreamPairTaskTrackV0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "Framework/ASoAHelpers.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Framework/StepTHn.h"
#include <CCDB/BasicCCDBManager.h>
#include "DataFormatsParameters/GRPObject.h"

#include "PWGCF/DataModel/FemtoDerived.h"
#include "FemtoDreamParticleHisto.h"
Expand Down Expand Up @@ -103,8 +101,6 @@ struct femtoDreamPairTaskTrackV0 {
HistogramRegistry qaRegistry{"TrackQA", {}, OutputObjHandlingPolicy::AnalysisObject};
HistogramRegistry resultRegistry{"Correlations", {}, OutputObjHandlingPolicy::AnalysisObject};

Service<o2::ccdb::BasicCCDBManager> ccdb; /// Accessing the CCDB

void init(InitContext&)
{
eventHisto.init(&qaRegistry);
Expand All @@ -121,23 +117,14 @@ 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::milliseconds>(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
/// \todo the trivial loops over the tracks should be factored out since they will be common to all combinations of T-T, T-V0, V0-V0, ...
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());
Expand Down Expand Up @@ -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;
Expand Down
43 changes: 40 additions & 3 deletions PWGCF/FemtoDream/femtoDreamProducerReducedTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CCDB/BasicCCDBManager.h>

using namespace o2;
using namespace o2::analysis::femtoDream;
Expand Down Expand Up @@ -89,6 +91,10 @@ struct femtoDreamProducerReducedTask {

HistogramRegistry qaRegistry{"QAHistos", {}, OutputObjHandlingPolicy::QAObject};

int mRunNumber;
float mMagField;
Service<o2::ccdb::BasicCCDBManager> ccdb; /// Accessing the CCDB

void init(InitContext&)
{
colCuts.setCuts(ConfEvtZvtx, ConfEvtTriggerCheck, ConfEvtTriggerSel, ConfEvtOfflineCheck, ConfIsRun3);
Expand All @@ -112,11 +118,42 @@ struct femtoDreamProducerReducedTask {
trackCuts.setSelection(ConfTrkPIDnSigmaMax, femtoDreamTrackSelection::kPIDnSigmaMax, femtoDreamSelection::kAbsUpperLimit);
trackCuts.setPIDSpecies(ConfTrkTPIDspecies);
trackCuts.init<aod::femtodreamparticle::ParticleType::kTrack, aod::femtodreamparticle::TrackType::kNoChild, aod::femtodreamparticle::cutContainerType>(&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::milliseconds>(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<o2::parameters::GRPObject>("GLO/GRP/GRP", timestamp);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have in mind that for Run 3 data the CCDB endpoint and the layout of the magnetic field information has changed
You will need to consider that if you address JUN Pilot beam data and/or Run 3 data

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<aod::BCsWithTimestamps>(); /// adding timestamp to access magnetic field later
// get magnetic field for run
auto bc = col.bc_as<aod::BCsWithTimestamps>();
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
Expand All @@ -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) {
Expand Down
Loading