@@ -96,9 +96,6 @@ int lastRunNumber = 0;
9696std::vector<double > v (3 , 0 ); // vx, vy, vz
9797bool isSelected = true ;
9898
99- TProfile3D* shiftprofileC = nullptr ;
100- TProfile3D* shiftprofileA = nullptr ;
101-
10299} // namespace o2::analysis::qvectortask
103100
104101using namespace o2 ::analysis::qvectortask;
@@ -192,6 +189,12 @@ struct ZdcQVectors {
192189 std::vector<bool > calibfilesLoaded = std::vector<bool >(3 , false );
193190 int atStep = 0 ;
194191 int atIteration = 0 ;
192+
193+ TProfile3D* shiftprofileC = nullptr ;
194+ TProfile3D* shiftprofileA = nullptr ;
195+
196+ bool isShiftProfileFound = false ;
197+
195198 } cal;
196199
197200 enum FillType {
@@ -913,15 +916,6 @@ struct ZdcQVectors {
913916
914917 int nshift = 10 ; // no. of iterations
915918
916- if (cfgFillCommonRegistry) {
917- for (int ishift = 1 ; ishift <= nshift; ishift++) {
918- registry.fill (HIST (" QA/ShiftZDCC" ), centrality, 0.5 , ishift - 0.5 , std::sin (ishift * 1.0 * psiZDCC));
919- registry.fill (HIST (" QA/ShiftZDCC" ), centrality, 1.5 , ishift - 0.5 , std::cos (ishift * 1.0 * psiZDCC));
920- registry.fill (HIST (" QA/ShiftZDCA" ), centrality, 0.5 , ishift - 0.5 , std::sin (ishift * 1.0 * psiZDCA));
921- registry.fill (HIST (" QA/ShiftZDCA" ), centrality, 1.5 , ishift - 0.5 , std::cos (ishift * 1.0 * psiZDCA));
922- }
923- }
924-
925919 double psiZDCAshift = psiZDCA;
926920 double psiZDCCshift = psiZDCC;
927921
@@ -930,19 +924,45 @@ struct ZdcQVectors {
930924
931925 if (cfgUseShift && !cfgCCDBdir_Shift.value .empty ()) {
932926 if (lastRunNumber != runnumber) {
927+ cal.isShiftProfileFound = false ;
928+ LOGF (info, " Getting shift profile from CCDB for runnumber: %d" , runnumber);
933929 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" ));
930+ cal.shiftprofileC = reinterpret_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCC" ));
931+ cal.shiftprofileA = reinterpret_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCA" ));
932+ if (!cal.shiftprofileC || !cal.shiftprofileA ) {
933+ LOGF (error, " Shift profile not found in CCDB for runnumber: %d" , runnumber);
934+ } else {
935+ LOGF (error, " Shift profile found in CCDB for runnumber: %d" , runnumber);
936+ cal.isShiftProfileFound = true ;
937+ }
936938 }
939+ }
937940
938- auto deltaPsiZDCC = 0.0 ;
939- auto deltaPsiZDCA = 0.0 ;
941+ float coeffshiftxZDCC = 0.0 ;
942+ float coeffshiftyZDCC = 0.0 ;
943+ float coeffshiftxZDCA = 0.0 ;
944+ float coeffshiftyZDCA = 0.0 ;
945+
946+ for (int ishift = 1 ; ishift <= nshift; ishift++) {
947+ if (cfgFillCommonRegistry) {
948+ registry.fill (HIST (" QA/ShiftZDCC" ), centrality, 0.5 , ishift - 0.5 , std::sin (ishift * 1.0 * psiZDCC));
949+ registry.fill (HIST (" QA/ShiftZDCC" ), centrality, 1.5 , ishift - 0.5 , std::cos (ishift * 1.0 * psiZDCC));
950+ registry.fill (HIST (" QA/ShiftZDCA" ), centrality, 0.5 , ishift - 0.5 , std::sin (ishift * 1.0 * psiZDCA));
951+ registry.fill (HIST (" QA/ShiftZDCA" ), centrality, 1.5 , ishift - 0.5 , std::cos (ishift * 1.0 * psiZDCA));
952+ }
940953
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 ));
954+ if (cal.isShiftProfileFound ){
955+ int binshiftxZDCC = cal.shiftprofileC ->FindBin (centrality, 0.5 , ishift - 0.5 );
956+ int binshiftyZDCC = cal.shiftprofileC ->FindBin (centrality, 1.5 , ishift - 0.5 );
957+ int binshiftxZDCA = cal.shiftprofileA ->FindBin (centrality, 0.5 , ishift - 0.5 );
958+ int binshiftyZDCA = cal.shiftprofileA ->FindBin (centrality, 1.5 , ishift - 0.5 );
959+
960+ if (binshiftxZDCC > 0 && binshiftyZDCC > 0 && binshiftxZDCA > 0 && binshiftyZDCA > 0 ){
961+ coeffshiftxZDCC = cal.shiftprofileC ->GetBinContent (binshiftxZDCC);
962+ coeffshiftyZDCC = cal.shiftprofileC ->GetBinContent (binshiftyZDCC);
963+ coeffshiftxZDCA = cal.shiftprofileA ->GetBinContent (binshiftxZDCA);
964+ coeffshiftyZDCA = cal.shiftprofileA ->GetBinContent (binshiftyZDCA);
965+ }
946966 deltaPsiZDCC += deltaPsiZDCC + ((2 / (1.0 * ishift)) * (-coeffshiftxZDCC * std::cos (ishift * 1.0 * psiZDCC) + coeffshiftyZDCC * std::sin (ishift * 1.0 * psiZDCC)));
947967 deltaPsiZDCA += deltaPsiZDCA + ((2 / (1.0 * ishift)) * (-coeffshiftxZDCA * std::cos (ishift * 1.0 * psiZDCA) + coeffshiftyZDCA * std::sin (ishift * 1.0 * psiZDCA)));
948968 }
@@ -951,9 +971,13 @@ struct ZdcQVectors {
951971 psiZDCCshift += deltaPsiZDCC;
952972 psiZDCAshift += deltaPsiZDCA;
953973
974+ // Normalize angles to [-pi, pi]
975+ psiZDCCshift = std::atan2 (std::sin (psiZDCCshift), std::cos (psiZDCCshift));
976+ psiZDCAshift = std::atan2 (std::sin (psiZDCAshift), std::cos (psiZDCAshift));
977+
954978 if (cfgFillCommonRegistry) {
955- registry.fill (HIST (" QA/psiZDCA" ), psiZDCAshift );
956- registry.fill (HIST (" QA/psiZDCC" ), psiZDCCshift );
979+ registry.fill (HIST (" QA/psiZDCA" ), psiZDCA );
980+ registry.fill (HIST (" QA/psiZDCC" ), psiZDCC );
957981 registry.fill (HIST (" QA/psiZDCA_shift" ), psiZDCAshift);
958982 registry.fill (HIST (" QA/psiZDCC_shift" ), psiZDCCshift);
959983 }
0 commit comments