@@ -63,6 +63,7 @@ using namespace o2::framework;
6363using namespace o2 ::framework::expressions;
6464using namespace o2 ::aod::track;
6565using namespace o2 ::aod::evsel;
66+ using namespace o2 ::aod::rctsel;
6667
6768namespace o2 ::analysis::qvectortask
6869{
@@ -95,6 +96,9 @@ int lastRunNumber = 0;
9596std::vector<double > v (3 , 0 ); // vx, vy, vz
9697bool isSelected = true ;
9798
99+ TProfile3D* shiftprofileC = nullptr ;
100+ TProfile3D* shiftprofileA = nullptr ;
101+
98102} // namespace o2::analysis::qvectortask
99103
100104using namespace o2 ::analysis::qvectortask;
@@ -103,6 +107,15 @@ struct ZdcQVectors {
103107
104108 Produces<aod::SPTableZDC> spTableZDC;
105109
110+ struct : ConfigurableGroup {
111+ Configurable<bool > cfgEvtUseRCTFlagChecker{" cfgEvtUseRCTFlagChecker" , false , " Evt sel: use RCT flag checker" };
112+ Configurable<std::string> cfgEvtRCTFlagCheckerLabel{" cfgEvtRCTFlagCheckerLabel" , " CBT_hadronPID" , " Evt sel: RCT flag checker label (CBT, CBT_hadronPID)" }; // all Labels can be found in Common/CCDB/RCTSelectionFlags.h
113+ Configurable<bool > cfgEvtRCTFlagCheckerZDCCheck{" cfgEvtRCTFlagCheckerZDCCheck" , false , " Evt sel: RCT flag checker ZDC check" };
114+ Configurable<bool > cfgEvtRCTFlagCheckerLimitAcceptAsBad{" cfgEvtRCTFlagCheckerLimitAcceptAsBad" , false , " Evt sel: RCT flag checker treat Limited Acceptance As Bad" };
115+ } rctFlags;
116+
117+ RCTFlagsChecker rctChecker;
118+
106119 ConfigurableAxis axisCent{" axisCent" , {90 , 0 , 90 }, " Centrality axis in 1% bins" };
107120 ConfigurableAxis axisCent10{" axisCent10" , {9 , 0 , 90 }, " Centrality axis in 10% bins" };
108121 ConfigurableAxis axisQ{" axisQ" , {100 , -2 , 2 }, " Q vector (xy) in ZDC" };
@@ -121,10 +134,10 @@ struct ZdcQVectors {
121134
122135 O2_DEFINE_CONFIGURABLE (cfgVtxZ, float , 10 .0f , " Accepted z-vertex range" )
123136 O2_DEFINE_CONFIGURABLE (cfgMagField, float , 99999 , " Configurable magnetic field; default CCDB will be queried" )
124- O2_DEFINE_CONFIGURABLE (cfgEnergyCal, std::string, " Users/c/ckoster/ZDC/LHC23_zzh_pass4 /Energy" , " ccdb path for energy calibration histos" )
125- O2_DEFINE_CONFIGURABLE (cfgMeanv, std::string, " Users/c/ckoster/ZDC/LHC23_zzh_pass4 /vmean" , " ccdb path for mean v histos" )
137+ O2_DEFINE_CONFIGURABLE (cfgEnergyCal, std::string, " Users/c/ckoster/ZDC/LHC23_PbPb_pass5 /Energy" , " ccdb path for energy calibration histos" )
138+ O2_DEFINE_CONFIGURABLE (cfgMeanv, std::string, " Users/c/ckoster/ZDC/LHC23_PbPb_pass5 /vmean" , " ccdb path for mean v histos" )
126139 O2_DEFINE_CONFIGURABLE (cfgMinEntriesSparseBin, int , 100 , " Minimal number of entries allowed in 4D recentering histogram to use for recentering." )
127- O2_DEFINE_CONFIGURABLE (cfgRec, std::string, " Users/c/ckoster/ZDC/LHC23_PbPb_pass4 " , " ccdb path for recentering histos" );
140+ O2_DEFINE_CONFIGURABLE (cfgRec, std::string, " Users/c/ckoster/ZDC/LHC23_PbPb_pass5 " , " ccdb path for recentering histos" );
128141 O2_DEFINE_CONFIGURABLE (cfgFillCommonRegistry, bool , true , " Fill common registry with histograms" );
129142
130143 // Additional event selections
@@ -138,13 +151,17 @@ struct ZdcQVectors {
138151 O2_DEFINE_CONFIGURABLE (cfgEvSelsCentMin, float , 0 , " Minimum cenrality for selected events" );
139152 O2_DEFINE_CONFIGURABLE (cfgEvSelsCentMax, float , 90 , " Maximum cenrality for selected events" );
140153
154+ O2_DEFINE_CONFIGURABLE (cfgUseShift, bool , false , " Use shift for PsiA and PsiC ZDC" );
155+ O2_DEFINE_CONFIGURABLE (cfgCCDBdir_Shift, std::string, " Users/c/ckoster/ZDC/LHC23_PbPb_pass5/Shift" , " CCDB directory for Shift ZDC" );
156+
141157 // define my.....
142158 // Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ;
143159 using UsedCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs, aod::CentFT0CVariant1s, aod::CentFT0Ms, aod::CentFV0As, aod::CentNGlobals>;
144160 using BCsRun3 = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels, aod::Run3MatchedToBCSparse>;
145161
146162 enum SelectionCriteria {
147163 evSel_FilteredEvent,
164+ evSel_RCTFlagsZDC,
148165 evSel_Zvtx,
149166 evSel_sel8,
150167 evSel_occupancy,
@@ -191,6 +208,8 @@ struct ZdcQVectors {
191208 int64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ();
192209 ccdb->setCreatedNotAfter (now);
193210
211+ rctChecker.init (rctFlags.cfgEvtRCTFlagCheckerLabel , rctFlags.cfgEvtRCTFlagCheckerZDCCheck , rctFlags.cfgEvtRCTFlagCheckerLimitAcceptAsBad );
212+
194213 std::vector<const char *> sides = {" A" , " C" };
195214 std::vector<const char *> capCOORDS = {" X" , " Y" };
196215
@@ -236,6 +255,13 @@ struct ZdcQVectors {
236255 registry.add <TProfile>(" QA/ZNA_Energy" , " ZNA_Energy" , kTProfile , {{8 , 0 , 8 }});
237256 registry.add <TProfile>(" QA/ZNC_Energy" , " ZNC_Energy" , kTProfile , {{8 , 0 , 8 }});
238257
258+ registry.add <TProfile3D>(" QA/ShiftZDCC" , " ShiftZDCC" , kTProfile3D , {{100 ,0 ,100 }, {2 ,0 ,2 }, {10 ,0 ,10 }});
259+ registry.add <TProfile3D>(" QA/ShiftZDCA" , " ShiftZDCA" , kTProfile3D , {{100 ,0 ,100 }, {2 ,0 ,2 }, {10 ,0 ,10 }});
260+ registry.add <TH1 >(" QA/psiZDCA" , " psiZDCA" , kTH1D , {{100 , -4 , 4 }});
261+ registry.add <TH1 >(" QA/psiZDCA_shift" , " psiZDCA_shift" , kTH1D , {{100 , -4 , 4 }});
262+ registry.add <TH1 >(" QA/psiZDCC" , " psiZDCC" , kTH1D , {{100 , -4 , 4 }});
263+ registry.add <TH1 >(" QA/psiZDCC_shift" , " psiZDCC_shift" , kTH1D , {{100 , -4 , 4 }});
264+
239265 registry.add <TProfile>(" QA/before/ZNA_pmC" , " ZNA_pmC" , kTProfile , {{1 , 0 , 1 .}});
240266 registry.add <TProfile>(" QA/before/ZNA_pm1" , " ZNA_pm1" , kTProfile , {{1 , 0 , 1 .}});
241267 registry.add <TProfile>(" QA/before/ZNA_pm2" , " ZNA_pm2" , kTProfile , {{1 , 0 , 1 .}});
@@ -295,6 +321,7 @@ struct ZdcQVectors {
295321
296322 registry.add (" hEventCount" , " Number of Event; Cut; #Events Passed Cut" , {HistType::kTH1D , {{nEventSelections, 0 , nEventSelections}}});
297323 registry.get <TH1 >(HIST (" hEventCount" ))->GetXaxis ()->SetBinLabel (evSel_FilteredEvent + 1 , " Filtered events" );
324+ registry.get <TH1 >(HIST (" hEventCount" ))->GetXaxis ()->SetBinLabel (evSel_RCTFlagsZDC + 1 , " RCT Flags ZDC" );
298325 registry.get <TH1 >(HIST (" hEventCount" ))->GetXaxis ()->SetBinLabel (evSel_Zvtx + 1 , " Z vertex cut event" );
299326 registry.get <TH1 >(HIST (" hEventCount" ))->GetXaxis ()->SetBinLabel (evSel_sel8 + 1 , " Sel8" );
300327 registry.get <TH1 >(HIST (" hEventCount" ))->GetXaxis ()->SetBinLabel (evSel_occupancy + 1 , " kOccupancy" );
@@ -560,34 +587,46 @@ struct ZdcQVectors {
560587 if (cfgNGlobal)
561588 cent = collision.centNGlobal ();
562589
590+ v[0 ] = collision.posX ();
591+ v[1 ] = collision.posY ();
592+ v[2 ] = collision.posZ ();
593+ centrality = cent;
594+
595+ const auto & foundBC = collision.foundBC_as <BCsRun3>();
596+ runnumber = foundBC.runNumber ();
597+
563598 if (cfgFillCommonRegistry)
564599 registry.fill (HIST (" QA/centrality_before" ), cent);
565600
566601 registry.fill (HIST (" hEventCount" ), evSel_FilteredEvent);
567602
568- if (! eventSelected (collision, cent )) {
603+ if (rctFlags. cfgEvtUseRCTFlagChecker && ! rctChecker (collision)) {
569604 // event not selected
570605 isSelected = false ;
571606 spTableZDC (runnumber, cent, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
572607 counter++;
608+ lastRunNumber = runnumber;
573609 return ;
574610 }
611+ registry.fill (HIST (" hEventCount" ), evSel_RCTFlagsZDC);
575612
576- const auto & foundBC = collision.foundBC_as <BCsRun3>();
613+ if (!eventSelected (collision, cent)) {
614+ // event not selected
615+ isSelected = false ;
616+ spTableZDC (runnumber, cent, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
617+ counter++;
618+ lastRunNumber = runnumber;
619+ return ;
620+ }
577621
578622 if (!foundBC.has_zdc ()) {
579623 isSelected = false ;
580624 spTableZDC (runnumber, cent, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
581625 counter++;
626+ lastRunNumber = runnumber;
582627 return ;
583628 }
584629
585- v[0 ] = collision.posX ();
586- v[1 ] = collision.posY ();
587- v[2 ] = collision.posZ ();
588- centrality = cent;
589- runnumber = foundBC.runNumber ();
590-
591630 // load new calibrations for new runs only
592631 if (runnumber != lastRunNumber) {
593632 cal.calibfilesLoaded [0 ] = false ;
@@ -598,8 +637,6 @@ struct ZdcQVectors {
598637
599638 cal.calibfilesLoaded [2 ] = false ;
600639 cal.calibList [2 ] = nullptr ;
601-
602- lastRunNumber = runnumber;
603640 }
604641
605642 const auto & zdcCol = foundBC.zdc ();
@@ -663,6 +700,7 @@ struct ZdcQVectors {
663700 counter++;
664701 isSelected = false ;
665702 spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
703+ lastRunNumber = runnumber;
666704 return ;
667705 }
668706
@@ -673,6 +711,7 @@ struct ZdcQVectors {
673711 counter++;
674712 isSelected = false ;
675713 spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
714+ lastRunNumber = runnumber;
676715 return ;
677716 }
678717
@@ -814,7 +853,8 @@ struct ZdcQVectors {
814853
815854 spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], q[0 ], q[1 ], q[2 ], q[3 ], isSelected, 0 , 0 );
816855 counter++;
817- return ;
856+ lastRunNumber = runnumber;
857+ return ;
818858 } else {
819859 if (cfgFillCommonRegistry)
820860 fillCommonRegistry<kBefore >(q[0 ], q[1 ], q[2 ], q[3 ], v, centrality);
@@ -867,14 +907,72 @@ struct ZdcQVectors {
867907 registry.get <TProfile>(HIST (" QA/after/ZNC_Qy" ))->Fill (Form (" %d" , runnumber), qRec[3 ]);
868908 }
869909
870- spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], qRec[0 ], qRec[1 ], qRec[2 ], qRec[3 ], isSelected, cal.atIteration , cal.atStep );
910+ // do shift for psi.
911+ double psiZDCA = 1.0 * std::atan2 (qRec[1 ], qRec[0 ]);
912+ double psiZDCC = 1.0 * std::atan2 (qRec[3 ], qRec[2 ]);
871913
872- qRec. clear ();
914+ int nshift = 10 ; // no. of iterations
873915
874- counter++;
875- return ;
916+ if (cfgFillCommonRegistry) {
917+ for (int ishift = 1 ; ishift <= nshift; ishift++) {
918+ registry.fill (HIST (" QA/ShiftZDCC" ), centrality, 0.5 , ishift - 0.5 , TMath::Sin (ishift * 1.0 * psiZDCC));
919+ registry.fill (HIST (" QA/ShiftZDCC" ), centrality, 1.5 , ishift - 0.5 , TMath::Cos (ishift * 1.0 * psiZDCC));
920+ registry.fill (HIST (" QA/ShiftZDCA" ), centrality, 0.5 , ishift - 0.5 , TMath::Sin (ishift * 1.0 * psiZDCA));
921+ registry.fill (HIST (" QA/ShiftZDCA" ), centrality, 1.5 , ishift - 0.5 , TMath::Cos (ishift * 1.0 * psiZDCA));
922+ }
923+ }
924+
925+ double psiZDCAshift = psiZDCA;
926+ double psiZDCCshift = psiZDCC;
927+
928+ double deltaPsiZDCA = 0 ;
929+ double deltaPsiZDCC = 0 ;
930+
931+ if (cfgUseShift && !cfgCCDBdir_Shift.value .empty ()) {
932+ if (lastRunNumber != runnumber){
933+ TList* hcorrList = ccdb->getForTimeStamp <TList>(cfgCCDBdir_Shift.value , foundBC.timestamp ());
934+ shiftprofileC = reinterpret_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCC" ));
935+ shiftprofileA = reinterpret_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCA" ));
936+ }
937+
938+ auto deltaPsiZDCC = 0.0 ;
939+ auto deltaPsiZDCA = 0.0 ;
940+
941+ for (int ishift = 1 ; ishift <= nshift; ishift++) {
942+ auto coeffshiftxZDCC = shiftprofileC->GetBinContent (shiftprofileC->FindBin (centrality, 0.5 , ishift - 0.5 ));
943+ auto coeffshiftyZDCC = shiftprofileC->GetBinContent (shiftprofileC->FindBin (centrality, 1.5 , ishift - 0.5 ));
944+ auto coeffshiftxZDCA = shiftprofileA->GetBinContent (shiftprofileA->FindBin (centrality, 0.5 , ishift - 0.5 ));
945+ auto coeffshiftyZDCA = shiftprofileA->GetBinContent (shiftprofileA->FindBin (centrality, 1.5 , ishift - 0.5 ));
946+ deltaPsiZDCC += deltaPsiZDCC + ((2 / (1.0 * ishift)) * (-coeffshiftxZDCC * TMath::Cos (ishift * 1.0 * psiZDCC) + coeffshiftyZDCC * TMath::Sin (ishift * 1.0 * psiZDCC)));
947+ deltaPsiZDCA += deltaPsiZDCA + ((2 / (1.0 * ishift)) * (-coeffshiftxZDCA * TMath::Cos (ishift * 1.0 * psiZDCA) + coeffshiftyZDCA * TMath::Sin (ishift * 1.0 * psiZDCA)));
948+ }
949+ }
950+
951+ psiZDCCshift += deltaPsiZDCC;
952+ psiZDCAshift += deltaPsiZDCA;
953+
954+ if (cfgFillCommonRegistry) {
955+ registry.fill (HIST (" QA/psiZDCA" ), psiZDCAshift);
956+ registry.fill (HIST (" QA/psiZDCC" ), psiZDCCshift);
957+ registry.fill (HIST (" QA/psiZDCA_shift" ), psiZDCAshift);
958+ registry.fill (HIST (" QA/psiZDCC_shift" ), psiZDCCshift);
959+ }
960+
961+ double qXaShift = std::hypot (qRec[1 ], qRec[0 ]) * TMath::Cos (psiZDCAshift);
962+ double qYaShift = std::hypot (qRec[1 ], qRec[0 ]) * TMath::Sin (psiZDCAshift);
963+ double qXcShift = std::hypot (qRec[2 ], qRec[3 ]) * TMath::Cos (psiZDCCshift);
964+ double qYcShift = std::hypot (qRec[2 ], qRec[3 ]) * TMath::Sin (psiZDCCshift);
965+
966+ spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], qXaShift, qYaShift, qXcShift, qYcShift, isSelected, cal.atIteration , cal.atStep );
967+
968+ qRec.clear ();
969+
970+ counter++;
971+ lastRunNumber = runnumber;
972+ return ;
876973 }
877974 LOGF (warning, " We return without saving table... -> THis is a problem" );
975+ lastRunNumber = runnumber;
878976 } // end of process
879977};
880978
0 commit comments