Skip to content

Commit 3aaff9a

Browse files
Module to check v0 to collision association + minor changes
1 parent 42febb7 commit 3aaff9a

File tree

2 files changed

+108
-16
lines changed

2 files changed

+108
-16
lines changed

PWGLF/TableProducer/Strangeness/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ o2physics_add_dpl_workflow(cascademlselection
144144

145145
o2physics_add_dpl_workflow(sigma0builder
146146
SOURCES sigma0builder.cxx
147-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore
147+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::MLCore O2Physics::AnalysisCCDB
148148
COMPONENT_NAME Analysis)
149149

150150
o2physics_add_dpl_workflow(lambdajetpolarizationbuilder

PWGLF/TableProducer/Strangeness/sigma0builder.cxx

Lines changed: 107 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "Common/DataModel/EventSelection.h"
3939
#include "Common/DataModel/Centrality.h"
4040
#include "Common/DataModel/PIDResponse.h"
41+
#include "Common/CCDB/ctpRateFetcher.h"
4142
#include "PWGLF/DataModel/LFStrangenessTables.h"
4243
#include "PWGLF/DataModel/LFStrangenessPIDTables.h"
4344
#include "PWGLF/DataModel/LFStrangenessMLTables.h"
@@ -59,6 +60,9 @@ using V0DerivedMCDatas = soa::Join<aod::V0Cores, aod::V0CollRefs, aod::V0Extras,
5960
using V0StandardDerivedDatas = soa::Join<aod::V0Cores, aod::V0CollRefs, aod::V0Extras, aod::V0TOFPIDs, aod::V0TOFNSigmas, aod::V0LambdaMLScores, aod::V0AntiLambdaMLScores, aod::V0GammaMLScores>;
6061

6162
struct sigma0builder {
63+
Service<o2::ccdb::BasicCCDBManager> ccdb;
64+
ctpRateFetcher rateFetcher;
65+
6266
SliceCache cache;
6367

6468
Produces<aod::Sigma0Cores> sigma0cores; // save sigma0 candidates for analysis
@@ -84,9 +88,13 @@ struct sigma0builder {
8488
Configurable<bool> fillQAhistos{"fillQAhistos", false, "if true, fill QA histograms"};
8589
Configurable<bool> fillBkgQAhistos{"fillBkgQAhistos", false, "if true, fill MC QA histograms for Bkg study"};
8690
Configurable<bool> doPi0QA{"doPi0QA", true, "Flag to fill QA histos for pi0 rejection study."};
91+
Configurable<bool> doAssocStudy{"doAssocStudy", false, "Do v0 to collision association study."};
8792

88-
// Event selection
93+
// Event level
8994
Configurable<bool> doPPAnalysis{"doPPAnalysis", true, "if in pp, set to true"};
95+
Configurable<bool> fGetIR{"fGetIR", false, "Flag to retrieve the IR info."};
96+
Configurable<bool> fIRCrashOnNull{"fIRCrashOnNull", false, "Flag to avoid CTP RateFetcher crash."};
97+
Configurable<std::string> irSource{"irSource", "T0VTX", "Estimator of the interaction rate (Recommended: pp --> T0VTX, Pb-Pb --> ZNC hadronic)"};
9098

9199
struct : ConfigurableGroup {
92100
Configurable<bool> requireSel8{"requireSel8", true, "require sel8 event selection"};
@@ -157,9 +165,7 @@ struct sigma0builder {
157165
// Axis
158166
// base properties
159167
ConfigurableAxis axisPt{"axisPt", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "pt axis for analysis"};
160-
ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Centrality"};
161-
ConfigurableAxis axisInvPt{"axisInvPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 5.0, 10.0, 20.0, 50.0}, ""};
162-
ConfigurableAxis axisDeltaPt{"axisDeltaPt", {200, -500.0, 500.0}, ""};
168+
ConfigurableAxis axisCentrality{"axisCentrality", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.0f, 110.0f}, "Centrality"};
163169

164170
// Invariant Mass
165171
ConfigurableAxis axisSigmaMass{"axisSigmaMass", {500, 1.10f, 1.30f}, "M_{#Sigma^{0}} (GeV/c^{2})"};
@@ -180,13 +186,20 @@ struct sigma0builder {
180186
ConfigurableAxis axisXY{"axisXY", {120, -120.0f, 120.0f}, "XY axis"};
181187
ConfigurableAxis axisDCAdau{"axisDCAdau", {50, 0.0f, 5.0f}, "DCA (cm)"};
182188
ConfigurableAxis axisRadius{"axisRadius", {240, 0.0f, 120.0f}, "V0 radius (cm)"};
189+
ConfigurableAxis axisPA{"axisPA", {100, 0.0f, 1}, "Pointing angle"};
183190
ConfigurableAxis axisRapidity{"axisRapidity", {100, -2.0f, 2.0f}, "Rapidity"};
184191
ConfigurableAxis axisCandSel{"axisCandSel", {7, 0.5f, +7.5f}, "Candidate Selection"};
185192
ConfigurableAxis axisMonteCarloNch{"axisMonteCarloNch", {300, 0.0f, 3000.0f}, "N_{ch} MC"};
193+
ConfigurableAxis axisIRBinning{"axisIRBinning", {150, 0, 1500}, "Binning for the interaction rate (kHz)"};
186194

187195
int nSigmaCandidates = 0;
188196
void init(InitContext const&)
189197
{
198+
// setting CCDB service
199+
ccdb->setURL("http://alice-ccdb.cern.ch");
200+
ccdb->setCaching(true);
201+
ccdb->setFatalWhenNull(false);
202+
190203
// Event Counters
191204
histos.add("hEventSelection", "hEventSelection", kTH1D, {{19, -0.5f, +18.5f}});
192205
histos.get<TH1>(HIST("hEventSelection"))->GetXaxis()->SetBinLabel(1, "All collisions");
@@ -272,6 +285,23 @@ struct sigma0builder {
272285
histos.add("GeneralQA/h2dMassGammaVsLambdaAfterMassSel", "h2dMassGammaVsLambdaAfterMassSel", kTH2D, {axisPhotonMass, axisLambdaMass});
273286
histos.add("GeneralQA/h2dV0XY", "h2dV0XY", kTH2F, {axisXY, axisXY});
274287
}
288+
289+
if (fGetIR){
290+
histos.add("GeneralQA/hRunNumberNegativeIR", "", kTH1D, {{1, 0., 1.}});
291+
histos.add("GeneralQA/hInteractionRate", "hInteractionRate", kTH1F, {axisIRBinning});
292+
}
293+
294+
if (doAssocStudy && doprocessMonteCarlo){
295+
histos.add("V0AssoQA/h2dIRVsPt_TrueGamma", "h2dIRVsPt_TrueGamma", kTH2F, {axisIRBinning, axisPt});
296+
histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueGamma", "h3dPAVsIRVsPt_TrueGamma", kTH3F, {axisPA, axisIRBinning, axisPt});
297+
histos.add("V0AssoQA/h2dIRVsPt_TrueGamma_BadCollAssig", "h2dIRVsPt_TrueGamma_BadCollAssig", kTH2F, {axisIRBinning, axisPt});
298+
histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueGamma_BadCollAssig", "h3dPAVsIRVsPt_TrueGamma_BadCollAssig", kTH3F, {axisPA, axisIRBinning, axisPt});
299+
300+
histos.add("V0AssoQA/h2dIRVsPt_TrueLambda", "h2dIRVsPt_TrueLambda", kTH2F, {axisIRBinning, axisPt});
301+
histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueLambda", "h3dPAVsIRVsPt_TrueLambda", kTH3F, {axisPA, axisIRBinning, axisPt});
302+
histos.add("V0AssoQA/h2dIRVsPt_TrueLambda_BadCollAssig", "h2dIRVsPt_TrueLambda_BadCollAssig", kTH2F, {axisIRBinning, axisPt});
303+
histos.add("V0AssoQA/h3dPAVsIRVsPt_TrueLambda_BadCollAssig", "h3dPAVsIRVsPt_TrueLambda_BadCollAssig", kTH3F, {axisPA, axisIRBinning, axisPt});
304+
}
275305

276306
// MC
277307
if (doprocessMonteCarlo){
@@ -449,6 +479,39 @@ struct sigma0builder {
449479
}
450480
}
451481

482+
template <typename TCollision, typename TV0Object>
483+
void analyzeV0CollAssoc(TCollision const& collision, TV0Object const& fullv0s, std::vector<int> selV0Indices, double IR)
484+
{
485+
auto v0MCCollision = collision.template straMCCollision_as<soa::Join<aod::StraMCCollisions, aod::StraMCCollMults>>();
486+
487+
for (size_t i = 0; i < selV0Indices.size(); ++i) {
488+
auto v0 = fullv0s.rawIteratorAt(selV0Indices[i]);
489+
auto v0MC = v0.template v0MCCore_as<soa::Join<aod::V0MCCores, aod::V0MCCollRefs>>();
490+
491+
float V0MCpT = RecoDecay::pt(array<float, 2>{v0MC.pxMC(), v0MC.pyMC()});
492+
float V0PA = TMath::ACos(v0.v0cosPA());
493+
bool fIsV0CorrectlyAssigned = (v0MC.straMCCollisionId() == v0MCCollision.globalIndex());
494+
495+
if (v0MC.pdgCode() == 22) { // True Gamma
496+
histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueGamma"), IR, V0MCpT);
497+
histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueGamma"), V0PA, IR, V0MCpT);
498+
499+
if (!fIsV0CorrectlyAssigned){
500+
histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueGamma_BadCollAssig"), IR, V0MCpT);
501+
histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueGamma_BadCollAssig"), V0PA, IR, V0MCpT);
502+
}
503+
}
504+
if (v0MC.pdgCode() == 3122) { // True Lambda
505+
histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueLambda"), IR, V0MCpT);
506+
histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueLambda"), V0PA, IR, V0MCpT);
507+
508+
if (!fIsV0CorrectlyAssigned){
509+
histos.fill(HIST("V0AssoQA/h2dIRVsPt_TrueLambda_BadCollAssig"), IR, V0MCpT);
510+
histos.fill(HIST("V0AssoQA/h3dPAVsIRVsPt_TrueLambda_BadCollAssig"), V0PA, IR, V0MCpT);
511+
}
512+
}
513+
}
514+
}
452515
template <typename TV0Object>
453516
void runPi0QA(TV0Object const& gamma1, TV0Object const& gamma2)
454517
{
@@ -636,7 +699,7 @@ struct sigma0builder {
636699
///////////
637700
// Process sigma candidate and store properties in object
638701
template <typename TV0Object>
639-
bool processSigmaCandidate(TV0Object const& lambda, TV0Object const& gamma)
702+
bool buildSigma0(TV0Object const& lambda, TV0Object const& gamma)
640703
{
641704
// Checking if both V0s are made of the very same tracks
642705
if (gamma.posTrackExtraId() == lambda.posTrackExtraId() ||
@@ -849,20 +912,31 @@ struct sigma0builder {
849912
bool fhasMCColl=false;
850913
if (coll.has_straMCCollision())
851914
fhasMCColl=true;
915+
916+
//_______________________________________________
917+
// Retrieving IR info
918+
double interactionRate = -1;
919+
if (fGetIR){
920+
interactionRate = rateFetcher.fetch(ccdb.service, coll.timestamp(), coll.runNumber(), irSource, fIRCrashOnNull) * 1.e-3;
921+
922+
if (interactionRate<0)
923+
histos.get<TH1>(HIST("GeneralQA/hRunNumberNegativeIR"))->Fill(Form("%d", coll.runNumber()), 1);
852924

925+
histos.fill(HIST("GeneralQA/hInteractionRate"), interactionRate);
926+
}
927+
853928
std::vector<int> bestGammasArray;
854929
std::vector<int> bestLambdasArray;
855930
int v0TableOffset = V0s.offset();
856931

857932
//_______________________________________________
858-
// Photon-only loop
859-
for (auto& gamma : V0s) { // selecting photons from Sigma0
860-
933+
// Photon-only loop
934+
for (auto& gamma : V0s) { // selecting photons from Sigma0
861935
if (!gamma.has_v0MCCore())
862936
continue;
863937

864938
auto gammaMC = gamma.v0MCCore_as<soa::Join<aod::V0MCCores, aod::V0MCCollRefs>>();
865-
939+
866940
if (gammaMC.pdgCode() == 22) {
867941
histos.fill(HIST("MC/h2dGammaXYConversion"), gamma.x(), gamma.y());
868942
float GammaY = TMath::Abs(RecoDecay::y(std::array{gamma.px(), gamma.py(), gamma.pz()}, o2::constants::physics::MassGamma));
@@ -914,6 +988,13 @@ struct sigma0builder {
914988
}
915989
}
916990

991+
//_______________________________________________
992+
// Wrongly collision association study
993+
if (doAssocStudy && fhasMCColl){
994+
analyzeV0CollAssoc(coll, V0s, bestGammasArray, interactionRate); // Gamma
995+
analyzeV0CollAssoc(coll, V0s, bestLambdasArray, interactionRate); // Lambda
996+
}
997+
917998
//_______________________________________________
918999
// Sigma0 loop
9191000
for (size_t i = 0; i < bestGammasArray.size(); ++i) {
@@ -984,11 +1065,11 @@ struct sigma0builder {
9841065

9851066
histos.fill(HIST("SigmaSel/h3dMassSigma0BeforeSel"), centrality, SigmapT, SigmaMass);
9861067

987-
// Selecting sigma0 candidate
988-
if (!processSigmaCandidate(lambda, gamma))
1068+
// Build sigma0 candidate, please
1069+
if (!buildSigma0(lambda, gamma))
9891070
continue;
9901071

991-
// Calculating properties and filling histos
1072+
// Filling histos and tables
9921073
histos.fill(HIST("SigmaSel/h3dMassSigma0AfterSel"), centrality, SigmapT, SigmaMass);
9931074

9941075
if (SigmaY < 0.5){
@@ -1022,10 +1103,21 @@ struct sigma0builder {
10221103

10231104
float centrality = coll.centFT0C();
10241105
histos.fill(HIST("hEventCentrality"), centrality);
1106+
1107+
//_______________________________________________
1108+
// Retrieving IR info
1109+
if (fGetIR){
1110+
interactionRate = rateFetcher.fetch(ccdb.service, coll.timestamp(), coll.runNumber(), irSource, fIRCrashOnNull) * 1.e-3;
1111+
1112+
if (interactionRate<0)
1113+
histos.get<TH1>(HIST("GeneralQA/hRunNumberNegativeIR"))->Fill(Form("%d", coll.runNumber()), 1);
1114+
1115+
histos.fill(HIST("GeneralQA/hInteractionRate"), interactionRate);
1116+
}
10251117

10261118
std::vector<int> bestGammasArray;
10271119
std::vector<int> bestLambdasArray;
1028-
int v0TableOffset = V0s.offset();
1120+
int v0TableOffset = V0s.offset(); // We need this because we're dealing with a "grouped table"
10291121

10301122
//_______________________________________________
10311123
// Photon-only loop
@@ -1076,8 +1168,8 @@ struct sigma0builder {
10761168

10771169
histos.fill(HIST("SigmaSel/h3dMassSigma0BeforeSel"), centrality, SigmapT, SigmaMass);
10781170

1079-
// Selecting sigma0 candidate
1080-
if (!processSigmaCandidate(lambda, gamma))
1171+
// Building sigma0 candidate
1172+
if (!buildSigma0(lambda, gamma))
10811173
continue;
10821174

10831175
fillTables(lambda, gamma, coll); // filling tables with accepted candidates

0 commit comments

Comments
 (0)