@@ -78,9 +78,10 @@ struct zdc2stagecalibration {
7878 Configurable<bool > deriveSpatialCalib{" deriveSpatialCalib" , false , " store spatial regression moments after gain correction" };
7979 Configurable<bool > deriveQRecentering{" deriveQRecentering" , false , " store Q-vector recentering regression moments after gain and spatial correction" };
8080 Configurable<bool > useQRecentering{" useQRecentering" , false , " apply Q-vector recentering calibration" };
81- Configurable<int > qRecenteringMethod{" qRecenteringMethod" , 0 , " Q recentering method: 0=current regression, 1=multidimensional cubic regression" };
81+ Configurable<int > qRecenteringMethod{" qRecenteringMethod" , 0 , " Q recentering method: 0=current regression, 1=multidimensional cubic regression, 4=structured71 regression " };
8282 Configurable<std::string> confQRecenteringPath{" confQRecenteringPath" , " " , " CCDB path to the current run-wise Q-vector recentering coefficients" };
8383 Configurable<std::string> confQRecenteringMultidimPath{" confQRecenteringMultidimPath" , " " , " CCDB path to the multidimensional cubic Q-vector recentering coefficients" };
84+ Configurable<std::string> confQRecenteringStructured71Path{" confQRecenteringStructured71Path" , " " , " CCDB path to the 71-feature structured Q-vector recentering coefficients" };
8485
8586 Configurable<int > cfgSpatialCalibBins{
8687 " cfgSpatialCalibBins" , 30 ,
@@ -128,8 +129,8 @@ struct zdc2stagecalibration {
128129 void init (o2::framework::InitContext&)
129130 {
130131 rctChecker.init (rctCut.cfgEvtRCTFlagCheckerLabel , rctCut.cfgEvtRCTFlagCheckerZDCCheck , rctCut.cfgEvtRCTFlagCheckerLimitAcceptAsBad );
131- if (qRecenteringMethod.value < 0 || qRecenteringMethod.value > 1 ) {
132- LOGF (fatal, " Unsupported qRecenteringMethod=%d. Use 0 for the current regression or 1 for the multidimensional cubic regression." , qRecenteringMethod.value );
132+ if (qRecenteringMethod.value != 0 && qRecenteringMethod.value != 1 && qRecenteringMethod. value != 4 ) {
133+ LOGF (fatal, " Unsupported qRecenteringMethod=%d. Use 0 for the current regression, 1 for the multidimensional cubic regression or 4 for the structured71 regression." , qRecenteringMethod.value );
133134 }
134135
135136 const int nTimeBins = static_cast <int >(std::ceil (cfgMaxRunHours.value * 60 .f / cfgTimeSliceMinutes.value ));
@@ -324,12 +325,19 @@ struct zdc2stagecalibration {
324325 }
325326 }
326327 if (calibrationStage.value == 2 && useQRecentering.value ) {
327- const std::string qRecenteringPath = qRecenteringMethod.value == 1 ? confQRecenteringMultidimPath.value : confQRecenteringPath.value ;
328+ const std::string qRecenteringPath = qRecenteringMethod.value == 4 ? confQRecenteringStructured71Path. value : (qRecenteringMethod. value == 1 ? confQRecenteringMultidimPath.value : confQRecenteringPath.value ) ;
328329 if (!qRecenteringPath.empty ()) {
329330 qRecenteringProfile = ccdb->getForTimeStamp <TH3D >(qRecenteringPath, timestamp);
330331 }
331332 if (!qRecenteringProfile) {
332333 LOGF (warn, " No ZDC Q-recentering calibration found for run %d at timestamp %llu" , runNumber, static_cast <unsigned long long >(timestamp));
334+ } else if (qRecenteringMethod.value == 4 ) {
335+ const bool structuredMapOK = qRecenteringProfile->GetYaxis ()->GetNbins () == kQRecenteringStructuredNFeatures &&
336+ std::string (qRecenteringProfile->GetYaxis ()->GetBinLabel (kQRecenteringMultidimNFeatures + 1 )) == " (T--0.8)_+^3" &&
337+ std::string (qRecenteringProfile->GetYaxis ()->GetBinLabel (kQRecenteringStructuredNFeatures )) == " (Vz-+0.8)_+^3" ;
338+ if (!structuredMapOK) {
339+ LOGF (fatal, " CCDB object at %s is not a valid structured71 map for run %d" , qRecenteringPath.c_str (), runNumber);
340+ }
333341 }
334342 }
335343 }
@@ -942,6 +950,24 @@ struct zdc2stagecalibration {
942950 }
943951 qValues[component] -= predictedBias;
944952 }
953+ } else if (qRecenteringMethod.value == 4 ) {
954+ const auto qFeatures = makeQRecenteringStructuredFeatures (timeFromSOR, vx, vy, vz);
955+ for (int component = 0 ; component < kQRecenteringNComponents ; ++component) {
956+ double predictedBias = 0.0 ;
957+ for (int i = 0 ; i < kQRecenteringStructuredNFeatures ; ++i) {
958+ const double coefficient = qRecenteringProfile->GetBinContent (qRecenteringProfile->FindBin (centrality, i + 0.5 , component + 0.5 ));
959+ if (!std::isfinite (coefficient)) {
960+ qRecenteringOK = false ;
961+ break ;
962+ }
963+ predictedBias += coefficient * qFeatures[i];
964+ }
965+ if (!qRecenteringOK || !std::isfinite (predictedBias)) {
966+ qRecenteringOK = false ;
967+ break ;
968+ }
969+ qValues[component] -= predictedBias;
970+ }
945971 } else {
946972 const auto qFeatures = makeQRecenteringMultidimFeatures (timeFromSOR, vx, vy, vz);
947973 for (int component = 0 ; component < kQRecenteringNComponents ; ++component) {
0 commit comments