@@ -75,7 +75,11 @@ struct zdc2stagecalibration {
7575 Configurable<std::string> confGainPath{" confGainPath" , " " , " CCDB path to the run-wise stage-1 gain map" };
7676 Configurable<bool > useSpatialCalib{" useSpatialCalib" , false , " use ZDC spatial calibration" };
7777 Configurable<std::string> confSpatialPath{" confSpatialPath" , " " , " CCDB path to ZDC spatial calibration" };
78+ Configurable<bool > deriveSpatialCalib{" deriveSpatialCalib" , false , " store spatial regression moments after gain correction" };
7879
80+ Configurable<int > cfgSpatialCalibBins{
81+ " cfgSpatialCalibBins" , 30 ,
82+ " number of bins per cross coordinate for spatial calibration" };
7983 struct : ConfigurableGroup {
8084 Configurable<bool > requireRCTFlagChecker{" requireRCTFlagChecker" , true , " Check event quality in run condition table" };
8185 Configurable<std::string> cfgEvtRCTFlagCheckerLabel{" cfgEvtRCTFlagCheckerLabel" , " CBT" , " Evt sel: RCT flag checker label" };
@@ -98,11 +102,12 @@ struct zdc2stagecalibration {
98102 const int nTimeBins = static_cast <int >(std::ceil (cfgMaxRunHours.value * 60 .f / cfgTimeSliceMinutes.value ));
99103 AxisSpec timeAxis = {nTimeBins, 0.0 , cfgMaxRunHours.value , " time from SOR (h)" };
100104 AxisSpec towerAxis = {4 , 0.0 , 4.0 , " tower" };
101- AxisSpec crossCoordAxis = {2 , 0.0 , 2.0 , " coordinate" };
102- AxisSpec ratioAxis = {240 , 0.0 , 2.4 , " #Sigma tower/common" };
103105 AxisSpec crossAxis = {120 , -1.0 , 1.0 , " cross asymmetry" };
104106 AxisSpec momentAxis = {15 , 0.0 , 15.0 , " regression moment" };
107+ AxisSpec spatialCalibAxis = {cfgSpatialCalibBins.value , -1.0 , 1.0 , " cross asymmetry" };
105108 AxisSpec phiAxis = {72 , -3.14159265358979323846 , 3.14159265358979323846 , " #phi" };
109+ AxisSpec crossCoordAxis = {2 , 0.0 , 2.0 , " coordinate" };
110+ AxisSpec ratioAxis = {240 , 0.0 , 2.4 , " #Sigma tower/common" };
106111
107112 histos.add (" hEvtSelInfo" , " hEvtSelInfo" , kTH1F , {{10 , 0.0 , 10.0 }});
108113 auto hEvtSelInfo = histos.get <TH1 >(HIST (" hEvtSelInfo" ));
@@ -145,6 +150,8 @@ struct zdc2stagecalibration {
145150 // Stage-1 correction input. For each time bin the first 10 y bins contain sum(T_i*T_j), the next 4 contain sum(C*T_i), and the last contains the event count.
146151 histos.add (" GainCalibration/hGainMomentsZNA" , " ZNA linear-regression moments;time from SOR (h);moment index" , kTH2D , {timeAxis, momentAxis});
147152 histos.add (" GainCalibration/hGainMomentsZNC" , " ZNC linear-regression moments;time from SOR (h);moment index" , kTH2D , {timeAxis, momentAxis});
153+ histos.add (" SpatialCalibration/hSpatialMomentsZNA" , " ZNA spatial regression moments;X cross;Y cross;moment index" , kTH3D , {spatialCalibAxis, spatialCalibAxis, momentAxis});
154+ histos.add (" SpatialCalibration/hSpatialMomentsZNC" , " ZNC spatial regression moments;X cross;Y cross;moment index" , kTH3D , {spatialCalibAxis, spatialCalibAxis, momentAxis});
148155
149156 ccdb->setURL (cfgCcdbParam.cfgURL );
150157 ccdb->setCaching (true );
@@ -364,6 +371,37 @@ struct zdc2stagecalibration {
364371 const double crossLookupYA = (znaCorr[2 ] - znaCorr[1 ]) / (znaCorr[2 ] + znaCorr[1 ]);
365372 const double crossLookupXC = (zncCorr[3 ] - zncCorr[0 ]) / (zncCorr[3 ] + zncCorr[0 ]);
366373 const double crossLookupYC = (zncCorr[2 ] - zncCorr[1 ]) / (zncCorr[2 ] + zncCorr[1 ]);
374+ if (calibrationStage.value == 2 && useGainCallib.value && deriveSpatialCalib.value && !useSpatialCalib.value ) {
375+
376+ std::array<double , 15 > spatialMomentsA{};
377+ std::array<double , 15 > spatialMomentsC{};
378+
379+ int moment = 0 ;
380+
381+ for (int i = 0 ; i < 4 ; ++i) {
382+ for (int j = i; j < 4 ; ++j) {
383+ spatialMomentsA[moment] = znaCorr[i] * znaCorr[j];
384+ spatialMomentsC[moment] = zncCorr[i] * zncCorr[j];
385+ ++moment;
386+ }
387+ }
388+
389+ for (int i = 0 ; i < 4 ; ++i) {
390+ spatialMomentsA[10 + i] =
391+ static_cast <double >(znaEnergycommon) * znaCorr[i];
392+
393+ spatialMomentsC[10 + i] =
394+ static_cast <double >(zncEnergycommon) * zncCorr[i];
395+ }
396+
397+ spatialMomentsA[14 ] = 1.0 ;
398+ spatialMomentsC[14 ] = 1.0 ;
399+
400+ for (int i = 0 ; i < 15 ; ++i) {
401+ histos.fill (HIST (" SpatialCalibration/hSpatialMomentsZNA" ), crossLookupXA, crossLookupYA, i + 0.5 , spatialMomentsA[i]);
402+ histos.fill (HIST (" SpatialCalibration/hSpatialMomentsZNC" ), crossLookupXC, crossLookupYC, i + 0.5 , spatialMomentsC[i]);
403+ }
404+ }
367405
368406 bool spatialOK = true ;
369407 if (calibrationStage.value == 2 && useSpatialCalib.value ) {
0 commit comments