@@ -181,10 +181,10 @@ double getMeanQFromMap(THn* h, double cent, double vx, double vy, double vz)
181181 return 0.0 ;
182182 }
183183
184- int binCent = axCent->FindBin (cent);
185- int binVx = axVx->FindBin (vx);
186- int binVy = axVy->FindBin (vy);
187- int binVz = axVz->FindBin (vz);
184+ int binCent = axCent->FindFixBin (cent);
185+ int binVx = axVx->FindFixBin (vx);
186+ int binVy = axVy->FindFixBin (vy);
187+ int binVz = axVz->FindFixBin (vz);
188188
189189 int idx[4 ] = {binCent, binVx, binVy, binVz};
190190 double meanQ = h->GetBinContent (idx);
@@ -199,7 +199,7 @@ double getMeanQ1D(TH1* h, double x)
199199 if (!h) {
200200 return 0.0 ;
201201 }
202- int bin = h->FindBin (x);
202+ int bin = h->FindFixBin (x);
203203 if (bin < 1 || bin > h->GetNbinsX ()) {
204204 return 0.0 ;
205205 }
@@ -237,6 +237,8 @@ struct ZdcExtraTableReader {
237237
238238 Configurable<int > phiNbins{" phiNbins" , 60 , " Bins in phi" };
239239
240+ Configurable<int > nTowersFired{" nTowersFired" , 2 , " Minimum number of towers fired for Q-vector determination" };
241+
240242 Configurable<int > qNbins5D{" qNbins5D" , 4 , " Bins in each dimension for 5D histograms" };
241243 Configurable<bool > plot5D{" plot5D" , false , " Flag to plot 5D histograms" };
242244
@@ -301,8 +303,8 @@ struct ZdcExtraTableReader {
301303 TH1* hMeanVy{nullptr };
302304
303305 // Phase shift correction cache
304- TProfile3D* hShiftZNA {nullptr };
305- TProfile3D* hShiftZNC {nullptr };
306+ TProfile3D* mShiftProfileZNA {nullptr };
307+ TProfile3D* mShiftProfileZNC {nullptr };
306308
307309 HistogramRegistry histos{
308310 " histos" ,
@@ -377,13 +379,13 @@ struct ZdcExtraTableReader {
377379 delete step.hMeanQxVyZNC ;
378380 delete step.hMeanQyVyZNC ;
379381
380- if (hShiftZNA ) {
381- delete hShiftZNA ;
382- hShiftZNA = nullptr ;
382+ if (mShiftProfileZNA ) {
383+ delete mShiftProfileZNA ;
384+ mShiftProfileZNA = nullptr ;
383385 }
384- if (hShiftZNC ) {
385- delete hShiftZNC ;
386- hShiftZNC = nullptr ;
386+ if (mShiftProfileZNC ) {
387+ delete mShiftProfileZNC ;
388+ mShiftProfileZNC = nullptr ;
387389 }
388390 }
389391 mCalibCache .clear ();
@@ -611,21 +613,21 @@ struct ZdcExtraTableReader {
611613
612614 if (lst) {
613615 // Important: Object names must match exactly what was saved
614- hShiftZNA = safeClone<TProfile3D>(lst->FindObject (" hShiftZNA " ));
615- hShiftZNC = safeClone<TProfile3D>(lst->FindObject (" hShiftZNC " ));
616+ mShiftProfileZNA = safeClone<TProfile3D>(lst->FindObject (" ShiftProfileZNA " ));
617+ mShiftProfileZNC = safeClone<TProfile3D>(lst->FindObject (" ShiftProfileZNC " ));
616618
617- if (hShiftZNA ) {
618- hShiftZNA ->SetDirectory (nullptr ); // Detach from file
619+ if (mShiftProfileZNA ) {
620+ mShiftProfileZNA ->SetDirectory (nullptr ); // Detach from file
619621 LOGF (info, " >> ShiftProfileZNA found! Entries: %.0f, Mean: %f" ,
620- hShiftZNA ->GetEntries (), hShiftZNA ->GetMean ());
622+ mShiftProfileZNA ->GetEntries (), mShiftProfileZNA ->GetMean ());
621623 } else {
622624 LOGF (error, " >> ShiftProfileZNA NOT found in TList! Content follows:" );
623625 lst->Print ();
624626 }
625627
626- if (hShiftZNC ) {
627- hShiftZNC ->SetDirectory (nullptr );
628- LOGF (info, " >> ShiftProfileZNC found! Entries: %.0f" , hShiftZNC ->GetEntries ());
628+ if (mShiftProfileZNC ) {
629+ mShiftProfileZNC ->SetDirectory (nullptr );
630+ LOGF (info, " >> ShiftProfileZNC found! Entries: %.0f" , mShiftProfileZNC ->GetEntries ());
629631 } else {
630632 LOGF (error, " >> ShiftProfileZNC NOT found in TList!" );
631633 }
@@ -744,6 +746,22 @@ struct ZdcExtraTableReader {
744746 }
745747 //
746748
749+
750+ bool isZNASpDeterminable = false ;
751+ bool isZNCSpDeterminable = false ;
752+
753+ if (isZNAhit) {
754+ int activeTowersZNA = (zdc.znaTow1 () > 0 .) + (zdc.znaTow2 () > 0 .) + (zdc.znaTow3 () > 0 .) + (zdc.znaTow4 () > 0 .);
755+ float znaSum = zdc.znaTow1 () + zdc.znaTow2 () + zdc.znaTow3 () + zdc.znaTow4 ();
756+ if (activeTowersZNA >= nTowersFired && znaSum > 0 && zdc.znaQx () < 990 .0f ) isZNASpDeterminable = true ;
757+ }
758+
759+ if (isZNChit) {
760+ int activeTowersZNC = (zdc.zncTow1 () > 0 .) + (zdc.zncTow2 () > 0 .) + (zdc.zncTow3 () > 0 .) + (zdc.zncTow4 () > 0 .);
761+ float zncSum = zdc.zncTow1 () + zdc.zncTow2 () + zdc.zncTow3 () + zdc.zncTow4 ();
762+ if (activeTowersZNC >= nTowersFired && zncSum > 0 && zdc.zncQx () < 990 .0f ) isZNCSpDeterminable = true ;
763+ }
764+
747765 if (plotPMs) {
748766 if (isZNAhit) {
749767 gCurrentPmcZNA ->Fill (zdc.znaTowC ());
@@ -789,7 +807,7 @@ struct ZdcExtraTableReader {
789807 }
790808
791809 // -------- ZNA --------
792- if (isZNAhit ) {
810+ if (isZNASpDeterminable ) {
793811 double qx = zdc.znaQx ();
794812 double qy = zdc.znaQy ();
795813
@@ -856,7 +874,7 @@ struct ZdcExtraTableReader {
856874
857875 // Apply Correction (Read Mode)
858876 // Checks if correction is enabled AND if the map from CCDB was loaded successfully
859- if (ifShiftCorrection && hShiftZNA ) {
877+ if (ifShiftCorrection && mShiftProfileZNA ) {
860878 double deltaPsi = 0.0 ;
861879
862880 // Loop over harmonics (usually 1 to 10)
@@ -867,11 +885,11 @@ struct ZdcExtraTableReader {
867885 // Y: Type (0.5 for Sin, 1.5 for Cos)
868886 // Z: Harmonic index (ishift - 0.5 maps to bin 1, 2, etc.)
869887
870- int binSin = hShiftZNA-> FindBin (cent, 0.5 , static_cast <double >(ishift) - 0.5 );
871- int binCos = hShiftZNA-> FindBin (cent, 1.5 , static_cast <double >(ishift) - 0.5 );
888+ int binSin = mShiftProfileZNA -> FindFixBin (cent, 0.5 , static_cast <double >(ishift) - 0.5 );
889+ int binCos = mShiftProfileZNA -> FindFixBin (cent, 1.5 , static_cast <double >(ishift) - 0.5 );
872890
873- double coeffSin = hShiftZNA ->GetBinContent (binSin);
874- double coeffCos = hShiftZNA ->GetBinContent (binCos);
891+ double coeffSin = mShiftProfileZNA ->GetBinContent (binSin);
892+ double coeffCos = mShiftProfileZNA ->GetBinContent (binCos);
875893
876894 // Fourier flattening formula:
877895 // DeltaPsi = sum( (2/k) * ( <cos>*sin(k*psi) - <sin>*cos(k*psi) ) )
@@ -912,7 +930,7 @@ struct ZdcExtraTableReader {
912930 }
913931
914932 // -------- ZNC --------
915- if (isZNChit ) {
933+ if (isZNCSpDeterminable ) {
916934 double qx = zdc.zncQx ();
917935 double qy = zdc.zncQy ();
918936
@@ -990,7 +1008,7 @@ struct ZdcExtraTableReader {
9901008
9911009 // Apply Correction (Read Mode)
9921010 // Checks if correction is enabled AND if the map from CCDB was loaded successfully
993- if (ifShiftCorrection && hShiftZNC ) {
1011+ if (ifShiftCorrection && mShiftProfileZNC ) {
9941012 double deltaPsi = 0.0 ;
9951013
9961014 // Loop over harmonics (usually 1 to 10)
@@ -1001,11 +1019,11 @@ struct ZdcExtraTableReader {
10011019 // Y: Type (0.5 for Sin, 1.5 for Cos)
10021020 // Z: Harmonic index (ishift - 0.5 maps to bin 1, 2, etc.)
10031021
1004- int binSin = hShiftZNC-> FindBin (cent, 0.5 , static_cast <double >(ishift) - 0.5 );
1005- int binCos = hShiftZNC-> FindBin (cent, 1.5 , static_cast <double >(ishift) - 0.5 );
1022+ int binSin = mShiftProfileZNC -> FindFixBin (cent, 0.5 , static_cast <double >(ishift) - 0.5 );
1023+ int binCos = mShiftProfileZNC -> FindFixBin (cent, 1.5 , static_cast <double >(ishift) - 0.5 );
10061024
1007- double coeffSin = hShiftZNC ->GetBinContent (binSin);
1008- double coeffCos = hShiftZNC ->GetBinContent (binCos);
1025+ double coeffSin = mShiftProfileZNC ->GetBinContent (binSin);
1026+ double coeffCos = mShiftProfileZNC ->GetBinContent (binCos);
10091027
10101028 // Fourier flattening formula:
10111029 // DeltaPsi = sum( (2/k) * ( <cos>*sin(k*psi) - <sin>*cos(k*psi) ) )
@@ -1035,7 +1053,7 @@ struct ZdcExtraTableReader {
10351053 gCurrentPsiZNC ->Fill (psiZNC);
10361054 }
10371055
1038- if (isZNAhit && isZNChit ) {
1056+ if (isZNASpDeterminable && isZNCSpDeterminable ) {
10391057 gCurrentQxQyVsCent ->Fill (cent, qxZNArec * qyZNCrec);
10401058 gCurrentQyQxVsCent ->Fill (cent, qyZNArec * qxZNCrec);
10411059 gCurrentQxQxVsCent ->Fill (cent, qxZNArec * qxZNCrec);
0 commit comments