1414// multCentTable output
1515
1616#include " Common/CCDB/EventSelectionParams.h"
17- #include " Common/DataModel/Centrality.h"
1817#include " Common/DataModel/Multiplicity.h"
1918
2019#include < CCDB/BasicCCDBManager.h>
21- #include < DataFormatsParameters/GRPECSObject.h>
2220#include < Framework/AnalysisDataModel.h>
2321#include < Framework/AnalysisHelpers.h>
2422#include < Framework/AnalysisTask.h>
3432#include < TList.h>
3533#include < TProfile.h>
3634
37- #include < bitset>
3835#include < cstdint>
3936#include < format>
4037#include < map>
@@ -53,26 +50,36 @@ struct centralityStudypp {
5350 std::map<std::string, HistPtr> histPointers;
5451 std::string histPath;
5552 Service<o2::ccdb::BasicCCDBManager> ccdb;
56- int mRunNumber ;
57- uint64_t startOfRunTimestamp;
53+ int mRunNumber = -1 ;
5854
5955 // vertex Z equalization
60- TList* hCalibObjects;
61- TProfile* hVtxZFV0A;
62- TProfile* hVtxZFT0A;
63- TProfile* hVtxZFT0C;
64- TProfile* hVtxZNTracks;
65- TProfile* hVtxZNGlobals;
66- TProfile* hVtxZMFT;
67- TProfile* hVtxZFDDA;
68- TProfile* hVtxZFDDC;
56+ TList* hCalibObjects = nullptr ;
57+ TProfile* hVtxZFV0A = nullptr ;
58+ TProfile* hVtxZFT0A = nullptr ;
59+ TProfile* hVtxZFT0C = nullptr ;
60+ TProfile* hVtxZNTracks = nullptr ;
61+ TProfile* hVtxZNGlobals = nullptr ;
62+ TProfile* hVtxZMFT = nullptr ;
63+ TProfile* hVtxZFDDA = nullptr ;
64+ TProfile* hVtxZFDDC = nullptr ;
65+
66+ // calibration histograms
67+ TH1* hCentralityFV0A = nullptr ;
68+ TH1* hCentralityFT0A = nullptr ;
69+ TH1* hCentralityFT0C = nullptr ;
70+ TH1* hCentralityFT0M = nullptr ;
71+ TH1* hCentralityFDDM = nullptr ;
72+ TH1* hCentralityNTPV = nullptr ;
73+ TH1* hCentralityNGlo = nullptr ;
74+ TH1* hCentralityMFT = nullptr ;
6975
7076 // Configurables
7177 Configurable<bool > do2DPlots{" do2DPlots" , true , " 0 - no, 1 - yes" };
7278 // _______________________________________
7379 // event selection criteria
7480 Configurable<bool > applyVertexZEqualization{" applyVertexZEqualization" , false , " 0 - no, 1 - yes" };
7581 Configurable<bool > saveUnequalized{" saveUnequalized" , false , " save unequalized raw: 0 - no, 1 - yes" };
82+ Configurable<bool > doCentralityQA{" doCentralityQA" , false , " do centrality QA: 0 - no, 1 - yes" };
7683 Configurable<bool > applySel8{" applySel8" , true , " 0 - no, 1 - yes" };
7784 Configurable<bool > applyVtxZ{" applyVtxZ" , true , " 0 - no, 1 - yes" };
7885 Configurable<bool > requireINELgtZERO{" requireINELgtZERO" , true , " 0 no, 1 - yes" };
@@ -84,6 +91,8 @@ struct centralityStudypp {
8491 Configurable<bool > requireIsVertexTRDmatched{" requireIsVertexTRDmatched" , false , " require events with at least one of vertex contributors matched to TRD" };
8592 Configurable<bool > rejectSameBunchPileup{" rejectSameBunchPileup" , false , " reject collisions in case of pileup with another collision in the same foundBC" };
8693
94+ Configurable<float > vertexZcut{" vertexZcut" , 10 .0f , " vertex Z cut (cm)" };
95+
8796 // For one-dimensional plots, where binning is no issue
8897 ConfigurableAxis axisMultUltraFineFV0A{" axisMultUltraFineFV0A" , {60000 , 0 , 60000 }, " FV0A amplitude" };
8998 ConfigurableAxis axisMultUltraFineFT0A{" axisMultUltraFineFT0A" , {60000 , 0 , 60000 }, " FT0A amplitude" };
@@ -97,11 +106,14 @@ struct centralityStudypp {
97106 // For profile Z
98107 ConfigurableAxis axisPVz{" axisPVz" , {400 , -20 .0f , +20 .0f }, " PVz (cm)" };
99108 ConfigurableAxis axisZN{" axisZN" , {1100 , -50 .0f , +500 .0f }, " ZN" };
109+ // For centrality QA
110+ ConfigurableAxis axisCentrality{" axisCentrality" , {10000 , 0 , 100 }, " centrality percentile" };
100111
101112 // ccdb matters
102113 Configurable<std::string> ccdbURL{" ccdbURL" , " http://alice-ccdb.cern.ch" , " ccdb url" };
103114 Configurable<std::string> pathGRPECSObject{" pathGRPECSObject" , " GLO/Config/GRPECS" , " Path to GRPECS object" };
104115 Configurable<std::string> pathVertexZ{" pathVertexZ" , " Users/d/ddobrigk/Centrality/Calibration" , " Path to vertexZ profiles" };
116+ Configurable<std::string> pathCentrality{" pathCentrality" , " Users/d/ddobrigk/Centrality/Estimators" , " Path to centrality calibration" };
105117
106118 void init (InitContext&)
107119 {
@@ -115,6 +127,15 @@ struct centralityStudypp {
115127 hVtxZFDDA = nullptr ;
116128 hVtxZFDDC = nullptr ;
117129
130+ hCentralityFV0A = nullptr ;
131+ hCentralityFT0A = nullptr ;
132+ hCentralityFT0C = nullptr ;
133+ hCentralityFT0M = nullptr ;
134+ hCentralityFDDM = nullptr ;
135+ hCentralityNTPV = nullptr ;
136+ hCentralityNGlo = nullptr ;
137+ hCentralityMFT = nullptr ;
138+
118139 const AxisSpec axisCollisions{100 , -0 .5f , 99 .5f , " Number of collisions" };
119140 histos.add (" hCollisionSelection" , " hCollisionSelection" , kTH1D , {{20 , -0 .5f , +19 .5f }});
120141 histos.get <TH1>(HIST (" hCollisionSelection" ))->GetXaxis ()->SetBinLabel (1 , " All collisions" );
@@ -171,21 +192,39 @@ struct centralityStudypp {
171192 LOGF (info, " Acquiring vertex-Z profiles for run %i" , mRunNumber );
172193 hCalibObjects = ccdb->getForRun <TList>(pathVertexZ, mRunNumber );
173194
174- hVtxZFV0A = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFV0A" ));
175- hVtxZFT0A = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFT0A" ));
176- hVtxZFT0C = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFT0C" ));
177- hVtxZFDDA = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFDDA" ));
178- hVtxZFDDC = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFDDC" ));
179- hVtxZNTracks = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZNTracksPV" ));
180- hVtxZNGlobals = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZNGlobals" ));
181- hVtxZMFT = static_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZMFT" ));
195+ hVtxZFV0A = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFV0A" ));
196+ hVtxZFT0A = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFT0A" ));
197+ hVtxZFT0C = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFT0C" ));
198+ hVtxZFDDA = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFDDA" ));
199+ hVtxZFDDC = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZFDDC" ));
200+ hVtxZNTracks = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZNTracksPV" ));
201+ hVtxZNGlobals = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZNGlobals" ));
202+ hVtxZMFT = dynamic_cast <TProfile*>(hCalibObjects->FindObject (" hVtxZMFT" ));
182203
183204 // Capture error
184205 if (!hVtxZFV0A || !hVtxZFT0A || !hVtxZFT0C || !hVtxZFDDA || !hVtxZFDDC || !hVtxZNTracks || !hVtxZNGlobals || !hVtxZMFT) {
185206 LOGF (error, " Problem loading CCDB objects! Please check" );
186207 }
187208 }
188209
210+ if (doCentralityQA.value ) {
211+ // acquire vertex-Z equalization histograms if requested
212+ LOGF (info, " Acquiring vertex-Z profiles for run %i" , mRunNumber );
213+ TList* hCentralityObjects = nullptr ;
214+ hCentralityObjects = ccdb->getForRun <TList>(pathCentrality, mRunNumber );
215+
216+ hCentralityFV0A = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqFV0" ));
217+ hCentralityFT0A = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqFT0A" ));
218+ hCentralityFT0C = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqFT0C" ));
219+ hCentralityFT0M = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqFT0" ));
220+ hCentralityFDDM = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqFDD" ));
221+ hCentralityNTPV = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqNTracksPV" ));
222+ hCentralityNGlo = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqNGlobal" ));
223+ hCentralityMFT = dynamic_cast <TProfile*>(hCentralityObjects->FindObject (" hCalibZeqMFT" ));
224+
225+ // won't capture null pointers -> explicitly check for those when attempting to evaluate
226+ }
227+
189228 histPath = std::format (" Run_{}/" , mRunNumber );
190229
191230 histPointers.insert ({histPath + " hCollisionSelection" , histos.add ((histPath + " hCollisionSelection" ).c_str (), " hCollisionSelection" , {kTH1D , {{20 , -0 .5f , +19 .5f }}})});
@@ -227,6 +266,17 @@ struct centralityStudypp {
227266 histPointers.insert ({histPath + " hNPVContributors_Unequalized" , histos.add ((histPath + " hNPVContributors_Unequalized" ).c_str (), " hNPVContributors_Unequalized" , {kTH1D , {{axisMultUltraFinePVContributors}}})});
228267 }
229268
269+ if (doCentralityQA.value ) {
270+ histPointers.insert ({histPath + " hCentralityDistributionFV0A" , histos.add ((histPath + " hCentralityDistributionFV0A" ).c_str (), " hCentralityDistributionFV0A" , {kTH1D , {{axisCentrality}}})});
271+ histPointers.insert ({histPath + " hCentralityDistributionFT0A" , histos.add ((histPath + " hCentralityDistributionFT0A" ).c_str (), " hCentralityDistributionFT0A" , {kTH1D , {{axisCentrality}}})});
272+ histPointers.insert ({histPath + " hCentralityDistributionFT0C" , histos.add ((histPath + " hCentralityDistributionFT0C" ).c_str (), " hCentralityDistributionFT0C" , {kTH1D , {{axisCentrality}}})});
273+ histPointers.insert ({histPath + " hCentralityDistributionFT0M" , histos.add ((histPath + " hCentralityDistributionFT0M" ).c_str (), " hCentralityDistributionFT0M" , {kTH1D , {{axisCentrality}}})});
274+ histPointers.insert ({histPath + " hCentralityDistributionFDDM" , histos.add ((histPath + " hCentralityDistributionFDDM" ).c_str (), " hCentralityDistributionFDDM" , {kTH1D , {{axisCentrality}}})});
275+ histPointers.insert ({histPath + " hCentralityDistributionNPTV" , histos.add ((histPath + " hCentralityDistributionNPTV" ).c_str (), " hCentralityDistributionNPTV" , {kTH1D , {{axisCentrality}}})});
276+ histPointers.insert ({histPath + " hCentralityDistributionNGlobal" , histos.add ((histPath + " hCentralityDistributionNGlobal" ).c_str (), " hCentralityDistributionNGlobal" , {kTH1D , {{axisCentrality}}})});
277+ histPointers.insert ({histPath + " hCentralityDistributionMFT" , histos.add ((histPath + " hCentralityDistributionMFT" ).c_str (), " hCentralityDistributionMFT" , {kTH1D , {{axisCentrality}}})});
278+ }
279+
230280 histPointers.insert ({histPath + " hFT0AvsPVz_Collisions" , histos.add ((histPath + " hFT0AvsPVz_Collisions" ).c_str (), " hFT0AvsPVz_Collisions" , {kTProfile , {{axisPVz}}})});
231281 histPointers.insert ({histPath + " hFT0CvsPVz_Collisions" , histos.add ((histPath + " hFT0CvsPVz_Collisions" ).c_str (), " hFT0CvsPVz_Collisions" , {kTProfile , {{axisPVz}}})});
232282 histPointers.insert ({histPath + " hFDDAvsPVz_Collisions" , histos.add ((histPath + " hFDDAvsPVz_Collisions" ).c_str (), " hFDDAvsPVz_Collisions" , {kTProfile , {{axisPVz}}})});
@@ -245,8 +295,9 @@ struct centralityStudypp {
245295 histos.fill (HIST (" hCollisionSelection" ), 0 ); // all collisions
246296 getHist (TH1, histPath + " hCollisionSelection" )->Fill (0 );
247297
248- if (applySel8 && !collision.multSel8 ())
298+ if (applySel8 && !collision.multSel8 ()) {
249299 return ;
300+ }
250301 histos.fill (HIST (" hCollisionSelection" ), 1 );
251302 getHist (TH1, histPath + " hCollisionSelection" )->Fill (1 );
252303
@@ -331,8 +382,9 @@ struct centralityStudypp {
331382
332383 // _______________________________________________________
333384
334- if (applyVtxZ && TMath::Abs (collision.multPVz ()) > 10 )
385+ if (applyVtxZ && TMath::Abs (collision.multPVz ()) > vertexZcut. value ) {
335386 return ;
387+ }
336388 histos.fill (HIST (" hCollisionSelection" ), 2 );
337389 getHist (TH1, histPath + " hCollisionSelection" )->Fill (2 );
338390
@@ -418,6 +470,35 @@ struct centralityStudypp {
418470 getHist (TH1, histPath + " hNGlobalTracks_Unequalized" )->Fill (collision.multNTracksGlobal ());
419471 getHist (TH1, histPath + " hNMFTTracks_Unequalized" )->Fill (collision.mftNtracks ());
420472 }
473+
474+ if (doCentralityQA.value ) {
475+ // generate centralities on the spot in case the centrality histograms are in memory
476+ if (hCentralityFV0A) {
477+ getHist (TH1, histPath + " hCentralityDistributionFV0A" )->Fill (hCentralityFV0A->GetBinContent (hCentralityFV0A->FindBin (multFV0A)));
478+ }
479+ if (hCentralityFT0A) {
480+ getHist (TH1, histPath + " hCentralityDistributionFT0A" )->Fill (hCentralityFT0A->GetBinContent (hCentralityFT0A->FindBin (multFT0A)));
481+ }
482+ if (hCentralityFT0C) {
483+ getHist (TH1, histPath + " hCentralityDistributionFT0C" )->Fill (hCentralityFT0C->GetBinContent (hCentralityFT0C->FindBin (multFT0C)));
484+ }
485+ if (hCentralityFT0M) {
486+ getHist (TH1, histPath + " hCentralityDistributionFT0M" )->Fill (hCentralityFT0M->GetBinContent (hCentralityFT0M->FindBin (multFT0A + multFT0C)));
487+ }
488+ if (hCentralityFDDM) {
489+ getHist (TH1, histPath + " hCentralityDistributionFDDM" )->Fill (hCentralityFDDM->GetBinContent (hCentralityFDDM->FindBin (multFDDA + multFDDC)));
490+ }
491+ if (hCentralityNTPV) {
492+ // note: not vertex-Z-equalized to match what is done in central framework for this estimator
493+ getHist (TH1, histPath + " hCentralityDistributionNTPV" )->Fill (hCentralityNTPV->GetBinContent (hCentralityNTPV->FindBin (collision.multNTracksPV ())));
494+ }
495+ if (hCentralityNGlo) {
496+ getHist (TH1, histPath + " hCentralityDistributionNGlobal" )->Fill (hCentralityNGlo->GetBinContent (hCentralityNGlo->FindBin (multNTracksGlobal)));
497+ }
498+ if (hCentralityMFT) {
499+ getHist (TH1, histPath + " hCentralityDistributionMFT" )->Fill (hCentralityMFT->GetBinContent (hCentralityMFT->FindBin (mftNtracks)));
500+ }
501+ }
421502 }
422503
423504 void process (soa::Join<aod::MultsRun3, aod::MFTMults, aod::MultsExtra, aod::MultsGlobal, aod::MultSelections>::iterator const & collision)
0 commit comments