@@ -81,6 +81,10 @@ struct RadialFlowDecorr {
8181 // 0 = nominal (0.2, 3], 1 = (0.5, 3] (suffix _pt1), 2 = (0.2, 5] (suffix _pt2). Tracks and MC particles are
8282 // selected in the map range [KPtMin, KPtMax] in every pass; each range is applied by ptRangeMask.
8383 static constexpr int KNPtMax = 3 ;
84+ static constexpr int KNFlatAxes = 5 ; // flattening weight maps: (vz, sign, pT, eta, phi); raw maps add the weight-type axis
85+ static constexpr std::size_t KMinEdges = 2 ; // a binning needs at least two edges
86+ static constexpr std::size_t KNAlignHalves = 2 ; // FT0 / FV0 alignment: one entry per detector half
87+ static constexpr float KFwdTruthEtaMin = 1 .5f ; // forward truth signal: charged primaries with |eta| >= this
8488 static constexpr std::array<std::array<float , 2 >, KNPtMax> KPtRanges = {{{0 .2f , 3 .f }, {0 .5f , 3 .f }, {0 .2f , 5 .f }}};
8589
8690 // Bootstrap: at most KMaxBoot replicas; range 0 in histosBoot, the further pT ranges in histosBoot2, each registry
@@ -701,19 +705,9 @@ struct RadialFlowDecorr {
701705 std::array<std::array<std::array<double , KNHarmComp>, KNHarm>, KNEtaMax> harm{};
702706 void reset ()
703707 {
704- for (auto & a : harm) {
705- for (auto & b : a) {
706- b.fill (0 .);
707- }
708- }
709- for (auto & a : pmwk) {
710- for (auto & b : a) {
711- b.fill (0 .);
712- }
713- }
714- for (auto & a : wk) {
715- a.fill (0 .);
716- }
708+ harm = {};
709+ pmwk = {};
710+ wk = {};
717711 }
718712 void add (int ieta, double pt, double w)
719713 {
@@ -785,9 +779,9 @@ struct RadialFlowDecorr {
785779 std::array<std::array<PtSums, kNLevels >, kNSyst > sums{};
786780 void resetSums (int v)
787781 {
788- for (auto & lev : sums[v] ) {
782+ for (int l = 0 ; l < kNLevels ; ++l ) {
789783 for (int ipt = 0 ; ipt < ptRange.n ; ++ipt) {
790- lev [ipt].reset ();
784+ sums[v][l] [ipt].reset ();
791785 }
792786 }
793787 }
@@ -1140,7 +1134,7 @@ struct RadialFlowDecorr {
11401134 int etaBinsOf (float eta, std::array<int , 2 >& bins) const
11411135 {
11421136 int n = 0 ;
1143- for (int ieta = 0 ; ieta < nEta && n < 2 ; ++ieta) {
1137+ for (int ieta = 0 ; ieta < nEta && n < static_cast < int >(bins. size ()) ; ++ieta) {
11441138 if (eta > etaLw[ieta] && eta <= etaUp[ieta]) {
11451139 bins[n++] = ieta;
11461140 }
@@ -1224,7 +1218,7 @@ struct RadialFlowDecorr {
12241218 if (!h) {
12251219 return 0.0 ;
12261220 }
1227- std::array<int , 5 > bins{};
1221+ std::array<int , KNFlatAxes > bins{};
12281222 bins[0 ] = h->GetAxis (0 )->FindBin (vz);
12291223 bins[1 ] = h->GetAxis (1 )->FindBin (chg);
12301224 bins[2 ] = h->GetAxis (2 )->FindBin (pt);
@@ -1340,7 +1334,7 @@ struct RadialFlowDecorr {
13401334 int fwdSubBin (int det, float eta) const
13411335 {
13421336 const auto & e = fwdEdges[det];
1343- if (e.size () < 2 || eta < e.front () || eta >= e.back ()) {
1337+ if (e.size () < KMinEdges || eta < e.front () || eta >= e.back ()) {
13441338 return -1 ;
13451339 }
13461340 const int i = static_cast <int >(std::upper_bound (e.begin (), e.end (), eta) - e.begin ()) - 1 ;
@@ -1399,7 +1393,7 @@ struct RadialFlowDecorr {
13991393
14001394 auto * alFT0 = ccdb->getForTimeStamp <std::vector<o2::detectors::AlignParam>>(" FT0/Calib/Align" , ts);
14011395 auto * alFV0 = ccdb->getForTimeStamp <std::vector<o2::detectors::AlignParam>>(" FV0/Calib/Align" , ts);
1402- if (!alFT0 || alFT0->size () < 2 || !alFV0 || alFV0->size () < 2 ) {
1396+ if (!alFT0 || alFT0->size () < KNAlignHalves || !alFV0 || alFV0->size () < KNAlignHalves ) {
14031397 LOGF (fatal, " Could not load FT0/FV0 alignment (FT0/Calib/Align, FV0/Calib/Align) for timestamp %llu" , ts);
14041398 return ;
14051399 }
@@ -1509,7 +1503,7 @@ struct RadialFlowDecorr {
15091503 continue ;
15101504 }
15111505 const float eta = particle.eta ();
1512- if (std::abs (eta) < 1 . 5f ) {
1506+ if (std::abs (eta) < KFwdTruthEtaMin ) {
15131507 continue ;
15141508 }
15151509 auto * pd = pdg->GetParticle (particle.pdgCode ());
@@ -2061,8 +2055,8 @@ struct RadialFlowDecorr {
20612055 }
20622056 static void dropBinSumw2 (const FlucHists& h)
20632057 {
2064- for (const auto * p : {& h.obs , & h.c2Sub2D , & h.cNN2D , & h.c2TA2D , & h.c1Sub2D , & h.c3Sub2D , & h.gapSum2D , & h.c3GapSum2D , & h.covFwdPt , & h.covFwdN , & h.covFwdFwd }) {
2065- dropBinSumw2 (* p);
2058+ for (const auto & p : {h.obs , h.c2Sub2D , h.cNN2D , h.c2TA2D , h.c1Sub2D , h.c3Sub2D , h.gapSum2D , h.c3GapSum2D , h.covFwdPt , h.covFwdN , h.covFwdFwd }) {
2059+ dropBinSumw2 (p);
20662060 }
20672061 for (const auto & p : h.cn2D ) {
20682062 dropBinSumw2 (p);
@@ -2143,11 +2137,12 @@ struct RadialFlowDecorr {
21432137 declareFlat (maskFlat, " " );
21442138 if (TESTBIT (maskAll, kSystFlat ) && cfgFlatRunSplit > 0 ) {
21452139 auto & h = hists.flat [kSystFlat ];
2146- for (auto * m : {&h.early , &h.late }) {
2147- const char * nm = (m == &h.early ) ? " hFlatMapsEarly" : " hFlatMapsLate" ;
2148- *m = reg (kSystFlat ).add <THnSparse>((systPrefix (kSystFlat ) + nm).c_str (), " ;vz;sign;pt;eta;phi;weight" , kTHnSparseF ,
2149- {{vzAxis}, {chgAxis}, {pTAxis}, {etaFlatAxis}, {phiAxis}, {kNFlatType , -0.5 , static_cast <double >(kNFlatType ) - 0.5 }});
2150- }
2140+ auto book = [&](const char * nm) {
2141+ return reg (kSystFlat ).add <THnSparse>((systPrefix (kSystFlat ) + nm).c_str (), " ;vz;sign;pt;eta;phi;weight" , kTHnSparseF ,
2142+ {{vzAxis}, {chgAxis}, {pTAxis}, {etaFlatAxis}, {phiAxis}, {kNFlatType , -0.5 , static_cast <double >(kNFlatType ) - 0.5 }});
2143+ };
2144+ h.early = book (" hFlatMapsEarly" );
2145+ h.late = book (" hFlatMapsLate" );
21512146 }
21522147 }
21532148
@@ -2192,26 +2187,26 @@ struct RadialFlowDecorr {
21922187 // Dense weight map (THnF): the builder sets every cell, so a sparse map would hold all of them anyway.
21932188 THnF* buildWeightMapFromRaw (const THnSparse* hRaw, int type, const char * mapName)
21942189 {
2195- if (!hRaw || hRaw->GetNdimensions () != 6 ) {
2190+ if (!hRaw || hRaw->GetNdimensions () != KNFlatAxes + 1 ) {
21962191 LOGF (error, " Raw eta-phi map for '%s' is null or not 6D; no flattening will be applied." , mapName);
21972192 return nullptr ;
21982193 }
2199- std::array<int , 5 > nb{};
2200- for (int i = 0 ; i < 5 ; ++i) {
2194+ std::array<int , KNFlatAxes > nb{};
2195+ for (int i = 0 ; i < KNFlatAxes ; ++i) {
22012196 nb[i] = hRaw->GetAxis (i)->GetNbins ();
22022197 }
2203- std::array<double , 5 > xMin{}, xMax{};
2204- for (int i = 0 ; i < 5 ; ++i) {
2198+ std::array<double , KNFlatAxes > xMin{}, xMax{};
2199+ for (int i = 0 ; i < KNFlatAxes ; ++i) {
22052200 xMin[i] = hRaw->GetAxis (i)->GetXmin ();
22062201 xMax[i] = hRaw->GetAxis (i)->GetXmax ();
22072202 }
2208- auto * hWMap = new THnF (mapName, Form (" Flattening Weight Map %s (w_{#phi} = <N_{#phi}> / N_{#phi})" , mapName), 5 , nb.data (), xMin.data (), xMax.data ());
2209- for (int i = 0 ; i < 5 ; ++i) {
2203+ auto * hWMap = new THnF (mapName, Form (" Flattening Weight Map %s (w_{#phi} = <N_{#phi}> / N_{#phi})" , mapName), KNFlatAxes , nb.data (), xMin.data (), xMax.data ());
2204+ for (int i = 0 ; i < KNFlatAxes ; ++i) {
22102205 copyAxis (hWMap->GetAxis (i), hRaw->GetAxis (i));
22112206 }
22122207
2213- std::array<int , 6 > bins{};
2214- std::array<int , 5 > wbins{};
2208+ std::array<int , KNFlatAxes + 1 > bins{};
2209+ std::array<int , KNFlatAxes > wbins{};
22152210 bins[5 ] = type + 1 ;
22162211 for (int iv = 1 ; iv <= nb[0 ]; ++iv) {
22172212 bins[0 ] = wbins[0 ] = iv;
@@ -2498,7 +2493,7 @@ struct RadialFlowDecorr {
24982493 nFwd = kNFwdDet ;
24992494 for (int det = 0 ; det < kNFwdDet ; ++det) {
25002495 auto & e = fwdEdges[det];
2501- if (e.size () < 2 || !std::is_sorted (e.begin (), e.end ())) {
2496+ if (e.size () < KMinEdges || !std::is_sorted (e.begin (), e.end ())) {
25022497 LOGF (fatal, " %s eta edges must be >= 2 increasing values" , detName[det]);
25032498 }
25042499 fwdOffset[det] = nFwd;
0 commit comments