2323#include < CCDB/BasicCCDBManager.h>
2424#include < Framework/AnalysisDataModel.h>
2525#include < Framework/AnalysisHelpers.h>
26- #include < Framework/Configurable.h>
2726#include < Framework/Array2D.h>
28- #include < Framework/DeviceSpec .h>
27+ #include < Framework/Configurable .h>
2928#include < Framework/DataSpecUtils.h>
29+ #include < Framework/DeviceSpec.h>
3030#include < Framework/HistogramRegistry.h>
3131#include < Framework/HistogramSpec.h>
3232#include < Framework/RunningWorkflowInfo.h>
3636#include < TH2.h>
3737#include < TProfile.h>
3838#include < TRandom3.h>
39- #include < RtypesCore.h>
4039#include < TString.h>
4140
41+ #include < RtypesCore.h>
42+
4243#include < concepts>
4344#include < cstddef>
45+ #include < cstdint>
4446#include < cstdio>
4547#include < cstdlib>
46- #include < cstdint>
4748#include < memory>
4849#include < string>
4950#include < type_traits>
@@ -66,17 +67,16 @@ namespace mccentrality // avoid polluting other namespaces
6667// statics necessary for the configurables in this namespace
6768static constexpr int nParameters = 1 ;
6869static const std::vector<std::string> tableNames{
69- " McCentFV0As" ,
70- " McCentFT0Ms" ,
71- " McCentFT0As" ,
72- " McCentFT0Cs" ,
73- " McCentFT0CVariant1s" ,
74- " McCentFT0CVariant2s" ,
75- " McCentFDDMs" ,
76- " McCentNTPVs" ,
77- " McCentNGlobals" ,
78- " McCentMFTs"
79- };
70+ " McCentFV0As" ,
71+ " McCentFT0Ms" ,
72+ " McCentFT0As" ,
73+ " McCentFT0Cs" ,
74+ " McCentFT0CVariant1s" ,
75+ " McCentFT0CVariant2s" ,
76+ " McCentFDDMs" ,
77+ " McCentNTPVs" ,
78+ " McCentNGlobals" ,
79+ " McCentMFTs" };
8080
8181static constexpr int nTablesConst = 10 ;
8282static const std::vector<std::string> parameterNames{" enable" };
@@ -103,20 +103,19 @@ enum tableIndex { kFV0A = 0,
103103 kNTPV ,
104104 kNGlobal ,
105105 kMFT ,
106- kNestimators };
106+ kNestimators };
107107
108108static constexpr const char * DirList[] = {
109- " FV0A" ,
110- " FT0M" ,
111- " FT0A" ,
112- " FT0C" ,
113- " FT0CVariant1" ,
114- " FT0CVariant2" ,
115- " FDDM" ,
116- " NTPV" ,
117- " NGlobal" ,
118- " MFT"
119- };
109+ " FV0A" ,
110+ " FT0M" ,
111+ " FT0A" ,
112+ " FT0C" ,
113+ " FT0CVariant1" ,
114+ " FT0CVariant2" ,
115+ " FDDM" ,
116+ " NTPV" ,
117+ " NGlobal" ,
118+ " MFT" };
120119
121120// mcCentralityModule: 1st-order configurables
122121struct coreConfigurables : o2::framework::ConfigurableGroup {
@@ -136,7 +135,7 @@ struct coreConfigurables : o2::framework::ConfigurableGroup {
136135 ConfigurableAxis binsPercentileFine{" binsPercentileFine" , {VARIABLE_WIDTH , 0 , 0.001 , 0.01 , 1.0 , 5.0 , 10.0 , 15.0 , 20.0 , 25.0 , 30.0 , 40.0 , 50.0 , 60.0 , 70.0 , 80.0 , 90.0 , 100.0 }, " Binning of the percentile axis" };
137136 ConfigurableAxis binsMultiplicity{" binsMultiplicity" , {1000 , 0 , 5000 }, " Binning of the multiplicity axis" };
138137
139- // ccdb configurables
138+ // ccdb configurables
140139 Configurable<std::string> path{" path" , " /tmp/InputCalibMC.root" , " path to calib file or ccdb path if begins with ccdb://" };
141140
142141 // debug option
@@ -159,11 +158,11 @@ struct products : o2::framework::ProducesGroup {
159158
160159template <typename T>
161160concept HasMcMults = requires (typename T::iterator a) {
162- { a.multMCFT0A () } -> std::convertible_to<int >;
163- { a.multMCFT0C () } -> std::convertible_to<int >;
164- { a.multMCFV0A () } -> std::convertible_to<int >;
165- { a.multMCFDDA () } -> std::convertible_to<int >;
166- { a.multMCFDDC () } -> std::convertible_to<int >;
161+ { a.multMCFT0A () } -> std::convertible_to<int >;
162+ { a.multMCFT0C () } -> std::convertible_to<int >;
163+ { a.multMCFV0A () } -> std::convertible_to<int >;
164+ { a.multMCFDDA () } -> std::convertible_to<int >;
165+ { a.multMCFDDC () } -> std::convertible_to<int >;
167166 { a.multMCNParticlesEta08 () } -> std::convertible_to<int >;
168167 { a.multMCNParticlesEta05 () } -> std::convertible_to<int >;
169168};
@@ -378,7 +377,8 @@ struct BuilderModule {
378377 }
379378
380379 template <typename THist>
381- THist* getHist (const char * name) {
380+ THist* getHist (const char * name)
381+ {
382382 if (!this ->MCCentralityCalibObjects ) {
383383 return (THist*)0x0 ;
384384 }
@@ -396,17 +396,18 @@ struct BuilderModule {
396396 return hist;
397397 }
398398
399- TH1D * extractCentralityCalibration (int idx, const char * name, bool reverse = false ) {
399+ TH1D * extractCentralityCalibration (int idx, const char * name, bool reverse = false )
400+ {
400401
401- auto CalibMC = [&](TString estimator){
402+ auto CalibMC = [&](TString estimator) {
402403 LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> Starting...\n " , estimator.Data ());
403404
404405 std::vector<double > percentile_center (nCentBins);
405406 std::vector<double > epercentile_center (nCentBins);
406407
407- // Histograms
408- TH2D * h2dMultVsCent_Data = getHist<TH2D >(Form (" h2dMultVsCent%s_Data" , estimator.Data ()));
409- TH2D * h2dMultRecoVsMultGen_MC = getHist<TH2D >(Form (" hMultEta05VsGenMult%s" , estimator.Data ()));
408+ // Histograms
409+ TH2D * h2dMultVsCent_Data = getHist<TH2D >(Form (" h2dMultVsCent%s_Data" , estimator.Data ()));
410+ TH2D * h2dMultRecoVsMultGen_MC = getHist<TH2D >(Form (" hMultEta05VsGenMult%s" , estimator.Data ()));
410411 if (!h2dMultVsCent_Data || !h2dMultRecoVsMultGen_MC) {
411412 return (TH1D *)0x0 ;
412413 }
@@ -418,12 +419,12 @@ struct BuilderModule {
418419 TProfile* hPVData = hCalibPVData[idx].get ();
419420 TProfile* hPVMC = hCalibPVMC[idx].get ();
420421
421- TH1D * h1dCalib = h2dMultRecoVsMultGen_MC->ProjectionX (Form (" h1d%s" , estimator.Data ()), 1 , h2dMultRecoVsMultGen_MC->GetNbinsX ());
422+ TH1D * h1dCalib = h2dMultRecoVsMultGen_MC->ProjectionX (Form (" h1d%s" , estimator.Data ()), 1 , h2dMultRecoVsMultGen_MC->GetNbinsX ());
422423 h1dCalib->Reset ();
423424 h1dCalib->SetTitle (Form (" %s calibration object" , estimator.Data ()));
424425 h1dCalib->GetXaxis ()->SetTitle (Form (" #it{N}_{%s, gen.}" , estimator.Data ()));
425426 h1dCalib->GetYaxis ()->SetTitle (Form (" %s percentile (%%)" , estimator.Data ()));
426-
427+
427428 // NOTE: candidate-by-candidate assignment (assignCentralityPerCandidate) does not go through this
428429 // mean-matching path at all. It samples directly from the "hGenMultEta05VsCentrality<estimator>"
429430 // joint histogram (x = reco centrality of the matched MC collision, y = generated mult |eta|<0.5)
@@ -432,16 +433,16 @@ struct BuilderModule {
432433 if (reverse) {
433434 for (int i = 0 ; i < nCentBins; i++) {
434435 int irev = i;
435- percentile_center[i] = (centralityBins[irev] + centralityBins[irev+ 1 ]) / 2 ;
436- epercentile_center[i] = (centralityBins[irev] - centralityBins[irev+ 1 ]) / 2 ;
436+ percentile_center[i] = (centralityBins[irev] + centralityBins[irev + 1 ]) / 2 ;
437+ epercentile_center[i] = (centralityBins[irev] - centralityBins[irev + 1 ]) / 2 ;
437438 }
438439
439440 int startBinMc = h1dCalib->GetNbinsX ();
440441 for (int i = 0 ; i < nCentBins; i++) { // Loop over centrality bins
441442 // start from the end (from the high multiplicity collisions)
442443 int irev = i;
443- TH1D * projData = h2dMultVsCent_Data->ProjectionY (Form (" projData_%d" , i), h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev]+ 1e-5 ),
444- h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev+ 1 ]- 1e-5 ));
444+ TH1D * projData = h2dMultVsCent_Data->ProjectionY (Form (" projData_%d" , i), h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev] + 1e-5 ),
445+ h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev + 1 ] - 1e-5 ));
445446
446447 double meanMult_Data = projData->GetMean ();
447448
@@ -467,7 +468,7 @@ struct BuilderModule {
467468 endBinMc = j;
468469 }
469470 }
470- if (i == nCentBins- 1 ) {
471+ if (i == nCentBins - 1 ) {
471472 endBinMc = 1 ;
472473 }
473474
@@ -492,30 +493,30 @@ struct BuilderModule {
492493 }
493494 }
494495
495- LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n " , estimator.Data (), centralityBins[irev], centralityBins[irev+ 1 ]);
496+ LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n " , estimator.Data (), centralityBins[irev], centralityBins[irev + 1 ]);
496497 LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> MC multiplicity range %g-%g\n " , estimator.Data (), projMC->GetBinLowEdge (endBinMc), projMC->GetBinLowEdge (startBinMc));
497- LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> <PV> data = %.4f Vs <PV> MC = %.4f (MC/Data = %.4f%%)\n " , estimator.Data (), meanMult_Data, meanMult_MC, (meanMult_MC- meanMult_Data) * 100 / meanMult_Data);
498+ LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> <PV> data = %.4f Vs <PV> MC = %.4f (MC/Data = %.4f%%)\n " , estimator.Data (), meanMult_Data, meanMult_MC, (meanMult_MC - meanMult_Data) * 100 / meanMult_Data);
498499 LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> N entries Data = %g Vs N entries MC = %g\n " , estimator.Data (), projData->Integral (), projMC->Integral ());
499500 LOGF (info, " \n " );
500501 for (int ibin = 1 ; ibin <= h1dCalib->GetNbinsX (); ibin++) {
501- if (ibin <= startBinMc && ibin >= endBinMc){
502- h1dCalib->SetBinContent (ibin, percentile_center[i]);
502+ if (ibin <= startBinMc && ibin >= endBinMc) {
503+ h1dCalib->SetBinContent (ibin, percentile_center[i]);
503504 }
504505 }
505506 startBinMc = endBinMc;
506507 } // End loop over centrality bins
507508 } else {
508509 for (int i = 0 ; i < nCentBins; i++) {
509510 int irev = nCentBins - i;
510- percentile_center[i] = (centralityBins[irev- 1 ] + centralityBins[irev]) / 2 ;
511- epercentile_center[i] = (centralityBins[irev] - centralityBins[irev- 1 ]) / 2 ;
511+ percentile_center[i] = (centralityBins[irev - 1 ] + centralityBins[irev]) / 2 ;
512+ epercentile_center[i] = (centralityBins[irev] - centralityBins[irev - 1 ]) / 2 ;
512513 }
513514 int startBinMc = 1 ;
514515 for (int i = 0 ; i < nCentBins; i++) { // Loop over centrality bins
515516 // start from the end (from the low multiplicity collisions)
516517 int irev = nCentBins - i;
517- TH1D * projData = h2dMultVsCent_Data->ProjectionY (Form (" projData_%d" , i), h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev- 1 ]+ 1e-5 ),
518- h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev]- 1e-5 ));
518+ TH1D * projData = h2dMultVsCent_Data->ProjectionY (Form (" projData_%d" , i), h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev - 1 ] + 1e-5 ),
519+ h2dMultVsCent_Data->GetXaxis ()->FindBin (centralityBins[irev] - 1e-5 ));
519520
520521 double meanMult_Data = projData->GetMean ();
521522
@@ -541,8 +542,8 @@ struct BuilderModule {
541542 endBinMc = j;
542543 }
543544 }
544- if (i == nCentBins- 1 ) {
545- endBinMc = h2dMultRecoVsMultGen_MC->GetNbinsX ();
545+ if (i == nCentBins - 1 ) {
546+ endBinMc = h2dMultRecoVsMultGen_MC->GetNbinsX ();
546547 }
547548
548549 TH1D * projMC = h2dMultRecoVsMultGen_MC->ProjectionY (Form (" projMC_%d" , i), startBinMc, endBinMc);
@@ -566,17 +567,17 @@ struct BuilderModule {
566567 }
567568 }
568569
569- LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n " , estimator.Data (), centralityBins[irev- 1 ], centralityBins[irev]);
570- LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> MC multiplicity range %g-%g\n " , estimator.Data (), projMC->GetBinLowEdge (startBinMc), projMC->GetBinLowEdge (endBinMc+ 1 ));
570+ LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> Data centrality bin \e[1;31m%g-%g%%\e[0;00m\n " , estimator.Data (), centralityBins[irev - 1 ], centralityBins[irev]);
571+ LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> MC multiplicity range %g-%g\n " , estimator.Data (), projMC->GetBinLowEdge (startBinMc), projMC->GetBinLowEdge (endBinMc + 1 ));
571572 LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> <PV> data = %.4f Vs <PV> MC = %.4f\n " , estimator.Data (), meanMult_Data, meanMult_MC);
572573 LOGF (info, " \e[1;31mCalibration for %s estimator\e[0;00m -> N entries Data = %g Vs N entries MC = %g\n " , estimator.Data (), projData->Integral (), projMC->Integral ());
573574 for (int ibin = 1 ; ibin <= h1dCalib->GetNbinsX (); ibin++) {
574- if (ibin <= endBinMc && ibin >= startBinMc){
575- h1dCalib->SetBinContent (ibin, percentile_center[i]);
575+ if (ibin <= endBinMc && ibin >= startBinMc) {
576+ h1dCalib->SetBinContent (ibin, percentile_center[i]);
576577 }
577578 }
578579
579- startBinMc = endBinMc+ 1 ;
580+ startBinMc = endBinMc + 1 ;
580581 } // End loop over centrality bins
581582 }
582583
@@ -662,8 +663,8 @@ struct BuilderModule {
662663 // which has no systematic effect on the sampled distribution.
663664 ULong64_t computeSamplingSeed (int64_t collisionIndex, int tableIdx) const
664665 {
665- static constexpr ULong64_t kCollisionStride = 131ull ; // > kNestimators, so tableIdx can't alias into the collision term
666- static constexpr ULong64_t kRunStride = 1000003ull ; // prime, well above kCollisionStride * (typical collisions per DF)
666+ static constexpr ULong64_t kCollisionStride = 131ull ; // > kNestimators, so tableIdx can't alias into the collision term
667+ static constexpr ULong64_t kRunStride = 1000003ull ; // prime, well above kCollisionStride * (typical collisions per DF)
667668 return baseOpts.centralitySamplingSeed .value + kRunStride * static_cast <ULong64_t>(mRunNumber ) +
668669 kCollisionStride * static_cast <ULong64_t>(collisionIndex) + static_cast <ULong64_t>(tableIdx);
669670 }
@@ -717,15 +718,15 @@ struct BuilderModule {
717718 return percentile;
718719 };
719720
720- populateTable (products.centFV0A , h1dFV0A, h2dCentVsGenMult[kFV0A ], nFV0A, std::integral_constant<int , kFV0A >{});
721- populateTable (products.centFT0M , h1dFT0M, h2dCentVsGenMult[kFT0M ], nFT0M, std::integral_constant<int , kFT0M >{});
722- populateTable (products.centFT0A , h1dFT0A, h2dCentVsGenMult[kFT0A ], nFT0A, std::integral_constant<int , kFT0A >{});
723- populateTable (products.centFT0C , h1dFT0C, h2dCentVsGenMult[kFT0C ], nFT0C, std::integral_constant<int , kFT0C >{});
724- populateTable (products.centFT0CVariant1 , h1dFT0CVariant1, h2dCentVsGenMult[kFT0CVariant1 ], nFT0C, std::integral_constant<int , kFT0CVariant1 >{});
725- populateTable (products.centFT0CVariant2 , h1dFT0CVariant2, h2dCentVsGenMult[kFT0CVariant2 ], nFT0C, std::integral_constant<int , kFT0CVariant2 >{});
726- populateTable (products.centFDDM , h1dFDDM, h2dCentVsGenMult[kFDDM ], nFDDM, std::integral_constant<int , kFDDM >{});
727- populateTable (products.centNTPV , h1dNTPV, h2dCentVsGenMult[kNTPV ], nGlobal, std::integral_constant<int , kNTPV >{});
728- populateTable (products.centNGlobal , h1dNGlobal, h2dCentVsGenMult[kNGlobal ], nGlobal, std::integral_constant<int , kNGlobal >{});
721+ populateTable (products.centFV0A , h1dFV0A, h2dCentVsGenMult[kFV0A ], nFV0A, std::integral_constant<int , kFV0A >{});
722+ populateTable (products.centFT0M , h1dFT0M, h2dCentVsGenMult[kFT0M ], nFT0M, std::integral_constant<int , kFT0M >{});
723+ populateTable (products.centFT0A , h1dFT0A, h2dCentVsGenMult[kFT0A ], nFT0A, std::integral_constant<int , kFT0A >{});
724+ populateTable (products.centFT0C , h1dFT0C, h2dCentVsGenMult[kFT0C ], nFT0C, std::integral_constant<int , kFT0C >{});
725+ populateTable (products.centFT0CVariant1 , h1dFT0CVariant1, h2dCentVsGenMult[kFT0CVariant1 ], nFT0C, std::integral_constant<int , kFT0CVariant1 >{});
726+ populateTable (products.centFT0CVariant2 , h1dFT0CVariant2, h2dCentVsGenMult[kFT0CVariant2 ], nFT0C, std::integral_constant<int , kFT0CVariant2 >{});
727+ populateTable (products.centFDDM , h1dFDDM, h2dCentVsGenMult[kFDDM ], nFDDM, std::integral_constant<int , kFDDM >{});
728+ populateTable (products.centNTPV , h1dNTPV, h2dCentVsGenMult[kNTPV ], nGlobal, std::integral_constant<int , kNTPV >{});
729+ populateTable (products.centNGlobal , h1dNGlobal, h2dCentVsGenMult[kNGlobal ], nGlobal, std::integral_constant<int , kNGlobal >{});
729730 // populateTable(products.centMFT, h1dMFT, h2dCentVsGenMult[kMFT], nMFT, std::integral_constant<int, kMFT>{}); // to be added later
730731
731732 mcCollisionCounter++;
0 commit comments