Skip to content

Commit 0cec2f1

Browse files
[PWGDQ] Add EMCal cluster skimming to tableMaker_withAssoc
- New ReducedEMCals table: standalone skimmed EMCal cluster table (unique clusters only for now; isAmbiguous flag reserved for the ambiguous clusters treatment) - New ReducedTracksBarrelEMCal table: joinable to ReducedTracks, one entry per skimmed track with the index of the best matched (smallest delta-R) skimmed cluster (-1 if none) and the matching residuals - VarManager: TrackEMCal object type, kEMCal* variables incl. E/p and matching residuals, FillTrackEMCal() usable both with EMCALClusters and ReducedEMCals rows - HistogramsLibrary: emcal and emcalmatch histogram subgroups - tableMaker_withAssoc: skimEMCal() (Preslice-based, runs before the track skimming so matching indices are available), JSON cluster cuts, QA and stats, new processPPBarrelOnlyWithEMCal process function (requires the emcal-correction-task upstream in the workflow) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PMjqae9gYxRGYHfychqECY
1 parent b39849c commit 0cec2f1

5 files changed

Lines changed: 308 additions & 4 deletions

File tree

PWGDQ/Core/HistogramsLibrary.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,21 @@ void o2::aod::dqhistograms::DefineHistograms(HistogramManager* hm, const char* h
10461046
}
10471047
}
10481048
}
1049+
if (subGroupStr.Contains("emcal")) {
1050+
hm->AddHistogram(histClass, "EMCalEnergy", "EMCal cluster energy", false, 500, 0.0, 50.0, VarManager::kEMCalEnergy);
1051+
hm->AddHistogram(histClass, "EMCalCoreEnergy", "EMCal cluster core energy", false, 500, 0.0, 50.0, VarManager::kEMCalCoreEnergy);
1052+
hm->AddHistogram(histClass, "EMCalEta_Phi", "EMCal cluster #eta vs #varphi", false, 100, -1.0, 1.0, VarManager::kEMCalEta, 180, 0.0, TMath::TwoPi(), VarManager::kEMCalPhi);
1053+
hm->AddHistogram(histClass, "EMCalM02", "EMCal cluster M02", false, 200, 0.0, 2.0, VarManager::kEMCalM02);
1054+
hm->AddHistogram(histClass, "EMCalM20", "EMCal cluster M20", false, 200, 0.0, 2.0, VarManager::kEMCalM20);
1055+
hm->AddHistogram(histClass, "EMCalNCells", "EMCal cluster no. cells", false, 50, -0.5, 49.5, VarManager::kEMCalNCells);
1056+
hm->AddHistogram(histClass, "EMCalTime", "EMCal cluster time", false, 400, -100.0, 100.0, VarManager::kEMCalTime);
1057+
hm->AddHistogram(histClass, "EMCalEnergy_Time", "EMCal cluster energy vs time", false, 100, 0.0, 50.0, VarManager::kEMCalEnergy, 200, -100.0, 100.0, VarManager::kEMCalTime);
1058+
if (subGroupStr.Contains("emcalmatch")) {
1059+
hm->AddHistogram(histClass, "EMCalEoverP", "EMCal E/p", false, 300, 0.0, 3.0, VarManager::kEMCalEoverP);
1060+
hm->AddHistogram(histClass, "Pt_EMCalEoverP", "p_{T} vs EMCal E/p", false, 200, 0.0, 20.0, VarManager::kPt, 300, 0.0, 3.0, VarManager::kEMCalEoverP);
1061+
hm->AddHistogram(histClass, "EMCalMatchDeltaEta_DeltaPhi", "EMCal matching #Delta#eta vs #Delta#varphi", false, 100, -0.1, 0.1, VarManager::kEMCalMatchDeltaEta, 100, -0.1, 0.1, VarManager::kEMCalMatchDeltaPhi);
1062+
}
1063+
}
10491064
if (subGroupStr.Contains("muon")) {
10501065
if (!subGroupStr.Contains("ambiguity")) {
10511066
hm->AddHistogram(histClass, "MuonNClusters", "", false, 100, 0.0, 10.0, VarManager::kMuonNClusters);

PWGDQ/Core/VarManager.cxx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,38 @@ void VarManager::SetDefaultVarNames()
999999
fgVariableUnits[kTRDsignal] = "";
10001000
fgVariableNames[kTOFbeta] = "TOF #beta";
10011001
fgVariableUnits[kTOFbeta] = "";
1002+
fgVariableNames[kEMCalEnergy] = "EMCal cluster energy";
1003+
fgVariableUnits[kEMCalEnergy] = "GeV";
1004+
fgVariableNames[kEMCalCoreEnergy] = "EMCal cluster core energy";
1005+
fgVariableUnits[kEMCalCoreEnergy] = "GeV";
1006+
fgVariableNames[kEMCalRawEnergy] = "EMCal cluster raw energy";
1007+
fgVariableUnits[kEMCalRawEnergy] = "GeV";
1008+
fgVariableNames[kEMCalEta] = "EMCal cluster #eta";
1009+
fgVariableUnits[kEMCalEta] = "";
1010+
fgVariableNames[kEMCalPhi] = "EMCal cluster #varphi";
1011+
fgVariableUnits[kEMCalPhi] = "rad.";
1012+
fgVariableNames[kEMCalM02] = "EMCal cluster M02";
1013+
fgVariableUnits[kEMCalM02] = "";
1014+
fgVariableNames[kEMCalM20] = "EMCal cluster M20";
1015+
fgVariableUnits[kEMCalM20] = "";
1016+
fgVariableNames[kEMCalNCells] = "EMCal cluster no. cells";
1017+
fgVariableUnits[kEMCalNCells] = "";
1018+
fgVariableNames[kEMCalTime] = "EMCal cluster time";
1019+
fgVariableUnits[kEMCalTime] = "ns";
1020+
fgVariableNames[kEMCalIsExotic] = "EMCal cluster is exotic";
1021+
fgVariableUnits[kEMCalIsExotic] = "";
1022+
fgVariableNames[kEMCalDistanceToBadChannel] = "EMCal cluster distance to bad channel";
1023+
fgVariableUnits[kEMCalDistanceToBadChannel] = "";
1024+
fgVariableNames[kEMCalNLM] = "EMCal cluster no. local maxima";
1025+
fgVariableUnits[kEMCalNLM] = "";
1026+
fgVariableNames[kEMCalDefinition] = "EMCal cluster definition";
1027+
fgVariableUnits[kEMCalDefinition] = "";
1028+
fgVariableNames[kEMCalEoverP] = "E_{EMCal}/p_{track}";
1029+
fgVariableUnits[kEMCalEoverP] = "";
1030+
fgVariableNames[kEMCalMatchDeltaEta] = "#Delta#eta (track-cluster)";
1031+
fgVariableUnits[kEMCalMatchDeltaEta] = "";
1032+
fgVariableNames[kEMCalMatchDeltaPhi] = "#Delta#varphi (track-cluster)";
1033+
fgVariableUnits[kEMCalMatchDeltaPhi] = "";
10021034
fgVariableNames[kTrackLength] = "track length";
10031035
fgVariableUnits[kTrackLength] = "cm";
10041036
fgVariableNames[kTrackDCAxy] = "DCA_{xy}";
@@ -2272,6 +2304,22 @@ void VarManager::SetDefaultVarNames()
22722304
fgVarNamesMap["kTRDsignal"] = kTRDsignal;
22732305
fgVarNamesMap["kTRDPattern"] = kTRDPattern;
22742306
fgVarNamesMap["kTOFbeta"] = kTOFbeta;
2307+
fgVarNamesMap["kEMCalEnergy"] = kEMCalEnergy;
2308+
fgVarNamesMap["kEMCalCoreEnergy"] = kEMCalCoreEnergy;
2309+
fgVarNamesMap["kEMCalRawEnergy"] = kEMCalRawEnergy;
2310+
fgVarNamesMap["kEMCalEta"] = kEMCalEta;
2311+
fgVarNamesMap["kEMCalPhi"] = kEMCalPhi;
2312+
fgVarNamesMap["kEMCalM02"] = kEMCalM02;
2313+
fgVarNamesMap["kEMCalM20"] = kEMCalM20;
2314+
fgVarNamesMap["kEMCalNCells"] = kEMCalNCells;
2315+
fgVarNamesMap["kEMCalTime"] = kEMCalTime;
2316+
fgVarNamesMap["kEMCalIsExotic"] = kEMCalIsExotic;
2317+
fgVarNamesMap["kEMCalDistanceToBadChannel"] = kEMCalDistanceToBadChannel;
2318+
fgVarNamesMap["kEMCalNLM"] = kEMCalNLM;
2319+
fgVarNamesMap["kEMCalDefinition"] = kEMCalDefinition;
2320+
fgVarNamesMap["kEMCalEoverP"] = kEMCalEoverP;
2321+
fgVarNamesMap["kEMCalMatchDeltaEta"] = kEMCalMatchDeltaEta;
2322+
fgVarNamesMap["kEMCalMatchDeltaPhi"] = kEMCalMatchDeltaPhi;
22752323
fgVarNamesMap["kTrackLength"] = kTrackLength;
22762324
fgVarNamesMap["kTrackDCAxy"] = kTrackDCAxy;
22772325
fgVarNamesMap["kTrackDCAxyProng1"] = kTrackDCAxyProng1;

PWGDQ/Core/VarManager.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ class VarManager : public TObject
152152
MFTCov = BIT(27),
153153
TrackTOFService = BIT(28),
154154
ParticleMC = BIT(29),
155-
MuonDca = BIT(30)
155+
MuonDca = BIT(30),
156+
TrackEMCal = BIT(31) // NOTE: last free bit of the uint32 track fill maps; used both for aod::EMCALClusters and ReducedEMCals
156157
};
157158

158159
enum PairCandidateType {
@@ -633,6 +634,22 @@ class VarManager : public TObject
633634
kIsDalitzLeg, // Up to 8 dalitz selections
634635
kBarrelNAssocsInBunch = kIsDalitzLeg + 8, // number of in bunch collision associations
635636
kBarrelNAssocsOutOfBunch, // number of out of bunch collision associations
637+
kEMCalEnergy, // EMCal cluster energy
638+
kEMCalCoreEnergy, // EMCal cluster core energy
639+
kEMCalRawEnergy, // EMCal cluster raw energy
640+
kEMCalEta, // EMCal cluster pseudorapidity
641+
kEMCalPhi, // EMCal cluster azimuthal angle
642+
kEMCalM02, // EMCal shower shape long axis
643+
kEMCalM20, // EMCal shower shape short axis
644+
kEMCalNCells, // number of cells in the EMCal cluster
645+
kEMCalTime, // EMCal cluster time
646+
kEMCalIsExotic, // exotic EMCal cluster flag
647+
kEMCalDistanceToBadChannel, // distance of the EMCal cluster to the closest bad channel
648+
kEMCalNLM, // number of local maxima of the EMCal cluster
649+
kEMCalDefinition, // EMCal cluster definition
650+
kEMCalEoverP, // EMCal cluster energy over matched track momentum
651+
kEMCalMatchDeltaEta, // eta residual of the matched EMCal cluster w.r.t. the track
652+
kEMCalMatchDeltaPhi, // phi residual of the matched EMCal cluster w.r.t. the track
636653
kNBarrelTrackVariables,
637654

638655
// Muon track variables
@@ -1407,6 +1424,8 @@ class VarManager : public TObject
14071424
static void FillTrack(T const& track, float* values = nullptr);
14081425
template <uint32_t fillMap, typename T>
14091426
static void FillPhoton(T const& photon, float* values = nullptr);
1427+
template <typename T>
1428+
static void FillTrackEMCal(T const& cluster, float trackP = -1.0f, float deltaEta = -999.0f, float deltaPhi = -999.0f, float* values = nullptr);
14101429
template <uint32_t fillMap, typename T, typename C>
14111430
static void FillTrackCollision(T const& track, C const& collision, float* values = nullptr);
14121431
template <int candidateType, uint32_t fillMap, typename T1, typename T2, typename C>
@@ -3440,6 +3459,35 @@ void VarManager::FillPhoton(T const& track, float* values)
34403459
}
34413460
}
34423461

3462+
template <typename T>
3463+
void VarManager::FillTrackEMCal(T const& cluster, float trackP, float deltaEta, float deltaPhi, float* values)
3464+
{
3465+
// Fill the EMCal cluster quantities; the cluster can be either an aod::EMCALCluster (skimming)
3466+
// or an aod::ReducedEMCal (analysis on skimmed data), the column schemas are identical.
3467+
// trackP: momentum of the matched track, used to compute E/p when called in a track-cluster matching context;
3468+
// the default (negative) value leaves E/p at the -999 sentinel, as for tracks without a matched cluster.
3469+
if (!values) {
3470+
values = fgValues;
3471+
}
3472+
3473+
values[kEMCalEnergy] = cluster.energy();
3474+
values[kEMCalCoreEnergy] = cluster.coreEnergy();
3475+
values[kEMCalRawEnergy] = cluster.rawEnergy();
3476+
values[kEMCalEta] = cluster.eta();
3477+
values[kEMCalPhi] = cluster.phi();
3478+
values[kEMCalM02] = cluster.m02();
3479+
values[kEMCalM20] = cluster.m20();
3480+
values[kEMCalNCells] = cluster.nCells();
3481+
values[kEMCalTime] = cluster.time();
3482+
values[kEMCalIsExotic] = cluster.isExotic();
3483+
values[kEMCalDistanceToBadChannel] = cluster.distanceToBadChannel();
3484+
values[kEMCalNLM] = cluster.nlm();
3485+
values[kEMCalDefinition] = cluster.definition();
3486+
values[kEMCalEoverP] = (trackP > 0.0f ? cluster.energy() / trackP : -999.0f);
3487+
values[kEMCalMatchDeltaEta] = deltaEta;
3488+
values[kEMCalMatchDeltaPhi] = deltaPhi;
3489+
}
3490+
34433491
template <typename U, typename T>
34443492
void VarManager::FillTrackMC(const U& mcStack, T const& track, float* values)
34453493
{

PWGDQ/DataModel/ReducedInfoTables.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,39 @@ DECLARE_SOA_TABLE(ReducedFITs, "AOD", "REDUCEDFIT", //! FIT detector information
366366

367367
using ReducedFIT = ReducedFITs::iterator;
368368

369+
namespace reducedemcal
370+
{
371+
// EMCal cluster information (from aod::EMCALClusters, see PWGJE/DataModel/EMCALClusters.h)
372+
DECLARE_SOA_INDEX_COLUMN(ReducedEvent, reducedevent); //!
373+
DECLARE_SOA_BITMAP_COLUMN(FilteringFlags, filteringFlags, 64); //! Bitmap of the cluster selections
374+
DECLARE_SOA_COLUMN(Energy, energy, float); //! cluster energy (GeV)
375+
DECLARE_SOA_COLUMN(CoreEnergy, coreEnergy, float); //! cluster core energy (GeV)
376+
DECLARE_SOA_COLUMN(RawEnergy, rawEnergy, float); //! raw cluster energy (GeV)
377+
DECLARE_SOA_COLUMN(Eta, eta, float); //! cluster pseudorapidity (calculated using vertex)
378+
DECLARE_SOA_COLUMN(Phi, phi, float); //! cluster azimuthal angle (calculated using vertex)
379+
DECLARE_SOA_COLUMN(M02, m02, float); //! shower shape long axis
380+
DECLARE_SOA_COLUMN(M20, m20, float); //! shower shape short axis
381+
DECLARE_SOA_COLUMN(NCells, nCells, int); //! number of cells in cluster
382+
DECLARE_SOA_COLUMN(Time, time, float); //! cluster time (ns)
383+
DECLARE_SOA_COLUMN(IsExotic, isExotic, bool); //! flag to mark cluster as exotic
384+
DECLARE_SOA_COLUMN(DistanceToBadChannel, distanceToBadChannel, float); //! distance to bad channel
385+
DECLARE_SOA_COLUMN(NLM, nlm, int); //! number of local maxima
386+
DECLARE_SOA_COLUMN(Definition, definition, int); //! cluster definition, see EMCALClusterDefinition.h
387+
DECLARE_SOA_COLUMN(IsAmbiguous, isAmbiguous, bool); //! true for clusters from BCs with no or multiple collisions
388+
} // namespace reducedemcal
389+
390+
// Skimmed EMCal cluster information; standalone table (not joinable to the barrel track tables),
391+
// the matching to barrel tracks is stored as an index column in the ReducedTracksBarrelEMCal table
392+
DECLARE_SOA_TABLE(ReducedEMCals, "AOD", "REDUCEDEMCAL", //!
393+
o2::soa::Index<>, reducedemcal::ReducedEventId, reducedemcal::FilteringFlags,
394+
reducedemcal::Energy, reducedemcal::CoreEnergy, reducedemcal::RawEnergy,
395+
reducedemcal::Eta, reducedemcal::Phi, reducedemcal::M02, reducedemcal::M20,
396+
reducedemcal::NCells, reducedemcal::Time, reducedemcal::IsExotic,
397+
reducedemcal::DistanceToBadChannel, reducedemcal::NLM, reducedemcal::Definition,
398+
reducedemcal::IsAmbiguous);
399+
400+
using ReducedEMCal = ReducedEMCals::iterator;
401+
369402
namespace reducedtrack
370403
{
371404
// basic track information
@@ -399,6 +432,9 @@ DECLARE_SOA_DYNAMIC_COLUMN(Pz, pz, //!
399432
[](float pt, float eta) -> float { return pt * std::sinh(eta); });
400433
DECLARE_SOA_DYNAMIC_COLUMN(P, p, //!
401434
[](float pt, float eta) -> float { return pt * std::cosh(eta); });
435+
DECLARE_SOA_INDEX_COLUMN(ReducedEMCal, matchedEMCalCluster); //! matching index pointing to the ReducedEMCals table, -1 if no matched cluster
436+
DECLARE_SOA_COLUMN(EMCalMatchDeltaEta, emcalMatchDeltaEta, float); //! eta residual of the matched EMCal cluster w.r.t. the track
437+
DECLARE_SOA_COLUMN(EMCalMatchDeltaPhi, emcalMatchDeltaPhi, float); //! phi residual of the matched EMCal cluster w.r.t. the track
402438
} // namespace reducedtrack
403439

404440
// basic track information
@@ -447,11 +483,18 @@ DECLARE_SOA_TABLE(ReducedTracksBarrelPID, "AOD", "RTBARRELPID", //!
447483
DECLARE_SOA_TABLE(ReducedTracksBarrelInfo, "AOD", "RTBARRELINFO",
448484
reducedtrack::CollisionId, collision::PosX, collision::PosY, collision::PosZ, reducedtrack::TrackId);
449485

486+
// barrel track EMCal matching information (joined with ReducedTracks);
487+
// one entry per skimmed barrel track, the index is -1 for tracks without a matched cluster
488+
DECLARE_SOA_TABLE(ReducedTracksBarrelEMCal, "AOD", "RTBARRELEMCAL", //!
489+
reducedtrack::ReducedEMCalId,
490+
reducedtrack::EMCalMatchDeltaEta, reducedtrack::EMCalMatchDeltaPhi);
491+
450492
using ReducedTrack = ReducedTracks::iterator;
451493
using ReducedTrackBarrel = ReducedTracksBarrel::iterator;
452494
using ReducedTrackBarrelCov = ReducedTracksBarrelCov::iterator;
453495
using ReducedTrackBarrelPID = ReducedTracksBarrelPID::iterator;
454496
using ReducedTrackBarrelInfo = ReducedTracksBarrelInfo::iterator;
497+
using ReducedTrackBarrelEMCal = ReducedTracksBarrelEMCal::iterator;
455498

456499
namespace reducedtrackMC
457500
{

0 commit comments

Comments
 (0)