Skip to content
137 changes: 74 additions & 63 deletions DPG/Tasks/AOTTrack/qaMatchEff.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,29 @@
//

#include "Common/CCDB/EventSelectionParams.h"
#include "Common/Core/RecoDecay.h"
#include "Common/Core/TrackSelection.h"
#include "Common/Core/TrackSelectionDefaults.h"
#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/PIDResponseTOF.h"
#include "Common/DataModel/PIDResponseTPC.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include <CCDB/BasicCCDBManager.h>
#include <CCDB/CcdbApi.h>
#include <CommonConstants/MathConstants.h>
#include <Framework/ASoA.h>
#include <Framework/AnalysisDataModel.h>
#include <Framework/AnalysisHelpers.h>
#include <Framework/AnalysisTask.h>
#include <Framework/Array2D.h>
#include <Framework/Configurable.h>
#include <Framework/Expressions.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/HistogramSpec.h>
#include <Framework/InitContext.h>
#include <Framework/OutputObjHeader.h>
#include <Framework/runDataProcessing.h>

#include <TH1.h>
#include <THnSparse.h>
#include <TMathBase.h>

#include <RtypesCore.h>

#include <algorithm>
#include "CCDB/BasicCCDBManager.h"
#include "CommonConstants/MathConstants.h"
//
#include "Framework/AnalysisTask.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Framework/runDataProcessing.h"
//
#include <cmath>
#include <cstdint>
#include <iterator>
#include <set>
#include <string>
#include <vector>

//
namespace extConfPar
{
static constexpr int nParDCA = 1;
Expand Down Expand Up @@ -95,7 +80,6 @@
using MCTracks = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::McTrackLabels>;
using MCTracksIU = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TracksDCA, aod::McTrackLabels>;

//
struct qaMatchEff {
int lastRunNumber = -1;
bool timeMonitorSetUp = false;
Expand Down Expand Up @@ -166,21 +150,21 @@
// TRD presence
Configurable<int> isTRDThere{"isTRDThere", 2, "Integer to turn the presence of TRD off, on, don't care (0,1,anything else)"};
Configurable<int> isTOFThere{"isTOFThere", 2, "Integer to turn the presence of TOF off, on, don't care (0,1,anything else)"};
//

Configurable<bool> isitMC{"isitMC", false, "Reading MC files, data if false"};
Configurable<bool> doDebug{"doDebug", false, "Flag of debug information"};
// Histogram configuration
//

// histos bins
Configurable<int> etaBins{"eta-bins", 40, "Number of eta bins"};
Configurable<int> phiBins{"phi-bins", 18, "Number of phi bins"};
Configurable<int> qoptBins{"qopt-bins", 500, "Number of Q/pt bins"};
//

// special histo, few particles explicitly stored, then pdg>3000
Configurable<int> pdgBins{"pdg-bins", 14, "Number of pdg values counted"};
//

// histo axes
//

ConfigurableAxis ptBins{"ptBins", {100, 0.f, 20.f}, "pT binning"};
ConfigurableAxis XBins{"XBins", {400, -2.f, 2.f}, "X binning"};
ConfigurableAxis ZBins{"ZBins", {400, -20.f, 20.f}, "Z binning"};
Expand All @@ -193,23 +177,21 @@
// pdg codes vector
std::vector<int> pdgChoice = {211, 213, 215, 217, 219, 221, 223, 321, 411, 521, 2212, 1114, 2214};

//
// Tracks selection object
TrackSelection cutObject;
//

// do you want pt comparison 2d's ?
Configurable<bool> makept2d{"makept2d", false, "choose if produce pt reco/TPC derived pt 2dims "};
//

// common flags for PID
Configurable<bool> isPIDPionRequired{"isPIDPionRequired", false, "choose if apply pion PID"};
Configurable<bool> isPIDKaonRequired{"isPIDKaonRequired", false, "choose if apply kaon PID"};
Configurable<bool> isPIDProtonRequired{"isPIDProtonRequired", false, "choose if apply proton PID"};
//

// limit for z position of primary vertex
Configurable<float> zPrimVtxMax{"zPrimVtxax", 999.f, "Maximum asbolute value of z of primary vertex"};
//
// configuration for THnSparse's
//

ConfigurableAxis thnd0{"thnd0", {150, -3.0f, 3.0f}, "impact parameter in xy [cm]"};
ConfigurableAxis thndz{"thndz", {150, -10.0f, 10.0f}, "impact parameter in z [cm]"};
ConfigurableAxis thnPt{"thnPt", {80, 0.0f, 20.0f}, "pt [GeV/c]"};
Expand Down Expand Up @@ -1412,7 +1394,7 @@
/// Using pt calculated at the inner wall of TPC
/// Caveat: tgl still from tracking: this is not the value of tgl at the
/// inner wall of TPC
return track.tpcInnerParam() / sqrt(1.f + track.tgl() * track.tgl());
return track.tpcInnerParam() / std::sqrt(1.f + track.tgl() * track.tgl());
}

/// Function applying the kinematic selections
Expand Down Expand Up @@ -1566,7 +1548,8 @@
//
// here n of clusters of TPC assigned to float for histos (and to hack it if needed) :)
//
Float_t clustpc = (Float_t)track.tpcNClsFound();
float clustpc = track.tpcNClsFound();

// Float_t findcltpc = (Float_t)track.tpcNClsFindable();
// Float_t crowstpc = (Float_t)track.tpcNClsCrossedRows();
// Float_t finclusmincrotpc = (Float_t)track.tpcNClsFindableMinusCrossedRows();
Expand All @@ -1583,7 +1566,7 @@
countData++;
//
// keep sign of track
Int_t signOfTrack = track.signed1Pt() > 0 ? 1 : -1;
int signOfTrack = track.signed1Pt() > 0 ? 1 : -1;
//
// PID sigmas
if constexpr (!IS_MC) {
Expand Down Expand Up @@ -1620,16 +1603,16 @@
int sayPrim = -99, specind = -9999;
if constexpr (IS_MC) {
auto mcpart = track.mcParticle();
siPDGCode = mcpart.pdgCode();
tpPDGCode = TMath::Abs(siPDGCode);
auto siPDGCode = mcpart.pdgCode();
auto tpPDGCode = std::abs(siPDGCode);
if (mcpart.isPhysicalPrimary()) {
// histos.get<TH1>(HIST("MC/control/etahist_diff"))->Fill(mcpart.eta() - track.eta());
auto delta = mcpart.phi() - track.phi();
if (delta > PI) {
delta -= TwoPI;
auto delta = RecoDecay::constrainAngle(mcpart.phi() - track.phi(), -o2::constants::math::PI);
if (delta > o2::constants::math::PI) {
delta -= o2::constants::math::TwoPI;

Check failure on line 1612 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
}
if (delta < -PI) {
delta += TwoPI;
if (delta < o2::constants::math::PI) {
delta += o2::constants::math::TwoPI;

Check failure on line 1615 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[two-pi-add-subtract]

Use RecoDecay::constrainAngle to restrict angle to a given range.
}
// histos.get<TH1>(HIST("MC/control/phihist_diff"))->Fill(delta);
}
Expand Down Expand Up @@ -1705,7 +1688,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1691 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1722,7 +1705,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1708 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1739,7 +1722,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1725 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1756,7 +1739,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1742 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1773,7 +1756,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1759 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1790,7 +1773,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1776 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1807,7 +1790,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1793 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand All @@ -1824,7 +1807,7 @@
if (makethn) {
if constexpr (IS_MC) {
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
if (siPDGCode == 211 || siPDGCode == 321) // pions and kaons together

Check failure on line 1810 in DPG/Tasks/AOTTrack/qaMatchEff.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
histos.fill(HIST("MC/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), 10, signOfTrack, hasdet);
} else {
histos.fill(HIST("data/sparse/thnsforfrac"), track.dcaXY(), track.dcaZ(), trackPt, track.eta(), sayPrim, track.phi(), specind, signOfTrack, hasdet);
Expand Down Expand Up @@ -3318,10 +3301,17 @@
//////////////////////////////////////////////
void processMC(CollisionsEvSel::iterator const& collision, soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::McTrackLabels> const& tracks, aod::McParticles const& mcParticles)
{
if (isEnableEventSelection && !collision.sel8()) {
if (doDebug)
LOGF(info, "Event selection not passed, skipping...");
return;
if (isEnableEventSelection) {
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to TriggerTVX and TFBorder, skipping...");
return;
}
if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to ITSROFrame border, skipping...");
return;
}
}
fillHistograms<true>(tracks, mcParticles, mcParticles); /// 3rd argument non-sense in this case
fillGeneralHistos<true>(collision);
Expand All @@ -3338,10 +3328,17 @@
LOGF(warning, "Centrality not defined for pp collision type, return...");
return;
}
if (isEnableEventSelection && !collision.sel8()) {
if (doDebug)
LOGF(info, "Event selection not passed, skipping...");
return;
if (isEnableEventSelection) {
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to TriggerTVX and TFBorder, skipping...");
return;
}
if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to ITSROFrame border, skipping...");
return;
}
}
float centrality = collision.centFT0C();
if (isCentralityRequired) {
Expand Down Expand Up @@ -3389,10 +3386,17 @@
// tracks.rawIteratorAt(0).collision().bc_as<BCsWithTimeStamp>().timestamp(); /// NB: in ms
setUpTimeMonitoring(bcs);
}
if (isEnableEventSelection && !collision.sel8()) {
if (doDebug)
LOGF(info, "Event selection not passed, skipping...");
return;
if (isEnableEventSelection) {
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to TriggerTVX and TFBorder, skipping...");
return;
}
if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to ITSROFrame border, skipping...");
return;
}
}
fillHistograms<false>(tracks, tracks, bcs); // 2nd argument not used in this case
fillGeneralHistos<false>(collision);
Expand All @@ -3412,10 +3416,17 @@
if (enableMonitorVsTime) {
setUpTimeMonitoring(bcs);
}
if (isEnableEventSelection && !collision.sel8()) {
if (doDebug)
LOGF(info, "Event selection not passed, skipping...");
return;
if (isEnableEventSelection) {
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to TriggerTVX and TFBorder, skipping...");
return;
}
if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) {
if (doDebug)
LOGF(info, "Event selection not passed to ITSROFrame border, skipping...");
return;
}
}
const float centrality = collision.centFT0C();
const int occupancy = collision.trackOccupancyInTimeRange();
Expand Down
Loading