@@ -355,17 +355,70 @@ struct SpectatorPlaneTableProducer {
355355 return true ;
356356 }
357357
358- void gainCalib (bool const & loadGainCalib, float const & vz, std::array<float , 4 >& eA, std::array<float , 4 >& eC)
358+ // Load Gain Calibrations and ZDC Q-Vector Recentering Corrections
359+ void loadCorrections ()
359360 {
360- // Store gain calibration histograms per run number
361- if (loadGainCalib ) {
361+ // Load ZDC gain calibration
362+ if (cDoGainCalib ) {
362363 std::string ccdbPath = static_cast <std::string>(cCcdbPath) + " /GainCalib" + " /Run" + std::to_string (cRunNum);
363364 auto ccdbObj = ccdbService->getForTimeStamp <TList>(ccdbPath, -1 );
364365 CorrectionHistContainer.hGainCalib [0 ] = reinterpret_cast <TH2F*>(ccdbObj->FindObject (" hZNASignal" ));
365366 CorrectionHistContainer.hGainCalib [1 ] = reinterpret_cast <TH2F*>(ccdbObj->FindObject (" hZNCSignal" ));
366367 }
367368
368- // Apply gain calibration
369+ // Load shift corrections for ZDC Q-Vectors
370+ if (cApplyRecentCorr) {
371+ std::vector<int > vCorrFlags = static_cast <std::vector<int >>(cCorrFlagVector);
372+ int nitr = vCorrFlags.size ();
373+ CorrectionType corrType = kFineCorr ;
374+
375+ for (int i = 0 ; i < nitr; ++i) {
376+ // Skip correction if corrFlag != 1
377+ if (vCorrFlags[i] != 1 ) {
378+ continue ;
379+ }
380+
381+ // Set correction type
382+ if (i % kNCorr == 0 ) {
383+ corrType = kCoarseCorr ;
384+ } else {
385+ corrType = kFineCorr ;
386+ }
387+
388+ // Set ccdb path
389+ std::string ccdbPath = static_cast <std::string>(cCcdbPath) + " /CorrItr_" + std::to_string (i + 1 ) + " /Run" + std::to_string (cRunNum);
390+
391+ // Get object from CCDB
392+ auto ccdbObject = ccdbService->getForTimeStamp <TList>(ccdbPath, -1 );
393+
394+ // Check CCDB Object
395+ if (!ccdbObject) {
396+ LOGF (warning, " CCDB OBJECT NOT FOUND" );
397+ return ;
398+ }
399+
400+ // Store histograms in Hist Container
401+ std::vector<std::vector<std::string>> vHistNames = corrTypeHistNameMap.at (corrType);
402+ int cntrx = 0 ;
403+ for (auto const & x : vHistNames) {
404+ int cntry = 0 ;
405+ for (auto const & y : x) {
406+ if (corrType == kFineCorr ) {
407+ CorrectionHistContainer.vFineCorrHist [i][cntrx][cntry] = reinterpret_cast <TProfile*>(ccdbObject->FindObject (y.c_str ()));
408+ } else {
409+ CorrectionHistContainer.vCoarseCorrHist [i][cntrx][cntry] = reinterpret_cast <THnSparseF*>(ccdbObject->FindObject (y.c_str ()));
410+ }
411+ ++cntry;
412+ }
413+ ++cntrx;
414+ }
415+ }
416+ }
417+ }
418+
419+ // Apply gain calibrations
420+ void gainCalib (float const & vz, std::array<float , 4 >& eA, std::array<float , 4 >& eC)
421+ {
369422 float vA = 0 ., vC = 0 .;
370423 for (int i = 0 ; i < static_cast <int >(eA.size ()); ++i) {
371424 vA = CorrectionHistContainer.hGainCalib [0 ]->GetBinContent (CorrectionHistContainer.hGainCalib [0 ]->FindBin (i + 0.5 , vz + 0.00001 ));
@@ -406,12 +459,11 @@ struct SpectatorPlaneTableProducer {
406459 return vAvgOutput;
407460 }
408461
409- void applyCorrection (bool const & loadShiftCorr, std::array<float , 4 > const & inputParam, std::array<float , 4 >& outputParam)
462+ void applyCorrection (std::array<float , 4 > const & inputParam, std::array<float , 4 >& outputParam)
410463 {
411464 std::vector<int > vCorrFlags = static_cast <std::vector<int >>(cCorrFlagVector);
412465 int nitr = vCorrFlags.size ();
413466 CorrectionType corrType = kFineCorr ;
414- std::string ccdbPath;
415467
416468 // Correction iterations
417469 for (int i = 0 ; i < nitr; ++i) {
@@ -427,37 +479,6 @@ struct SpectatorPlaneTableProducer {
427479 corrType = kFineCorr ;
428480 }
429481
430- // Check current and last run number, fetch ccdb object and store corrections in container
431- if (loadShiftCorr) {
432- // Set ccdb path
433- ccdbPath = static_cast <std::string>(cCcdbPath) + " /CorrItr_" + std::to_string (i + 1 ) + " /Run" + std::to_string (cRunNum);
434-
435- // Get object from CCDB
436- auto ccdbObject = ccdbService->getForTimeStamp <TList>(ccdbPath, -1 );
437-
438- // Check CCDB Object
439- if (!ccdbObject) {
440- LOGF (warning, " CCDB OBJECT NOT FOUND" );
441- return ;
442- }
443-
444- // Store histograms in Hist Container
445- std::vector<std::vector<std::string>> vHistNames = corrTypeHistNameMap.at (corrType);
446- int cntrx = 0 ;
447- for (auto const & x : vHistNames) {
448- int cntry = 0 ;
449- for (auto const & y : x) {
450- if (corrType == kFineCorr ) {
451- CorrectionHistContainer.vFineCorrHist [i][cntrx][cntry] = reinterpret_cast <TProfile*>(ccdbObject->FindObject (y.c_str ()));
452- } else {
453- CorrectionHistContainer.vCoarseCorrHist [i][cntrx][cntry] = reinterpret_cast <THnSparseF*>(ccdbObject->FindObject (y.c_str ()));
454- }
455- ++cntry;
456- }
457- ++cntrx;
458- }
459- }
460-
461482 // Get averages
462483 std::vector<float > vAvg = getAvgCorrFactors (i, corrType, inputParam);
463484
@@ -497,8 +518,8 @@ struct SpectatorPlaneTableProducer {
497518 histos.fill (HIST (" CorrHist/hYZNCVsVz" ), vCollParam[kVz ], vSP[kYc ]);
498519 }
499520
500- template <typename C>
501- bool analyzeCollision (C const & collision, std::array<float , 4 >& vSP)
521+ template <typename C, typename B >
522+ bool analyzeCollision (B const & bc, C const & collision, std::array<float , 4 >& vSP)
502523 {
503524 // Event selection
504525 if (!selCollision (collision)) {
@@ -515,17 +536,6 @@ struct SpectatorPlaneTableProducer {
515536 histos.fill (HIST (" Event/hVy" ), posY);
516537 histos.fill (HIST (" Event/hVz" ), posZ);
517538
518- // Get bunch crossing
519- auto bc = collision.template foundBC_as <BCsRun3>();
520- cRunNum = collision.template foundBC_as <BCsRun3>().runNumber ();
521-
522- // Load calibration flags
523- bool loadGainCalib = false , loadShiftCorr = false ;
524- if (cRunNum != lRunNum) {
525- loadGainCalib = true ;
526- loadShiftCorr = true ;
527- }
528-
529539 // check zdc
530540 if (!bc.has_zdc ()) {
531541 return false ;
@@ -552,7 +562,7 @@ struct SpectatorPlaneTableProducer {
552562
553563 // Do gain calibration
554564 if (cDoGainCalib) {
555- gainCalib (loadGainCalib, vCollParam[kVz ], znaEnergy, zncEnergy);
565+ gainCalib (vCollParam[kVz ], znaEnergy, zncEnergy);
556566 }
557567
558568 // Fill zdc signal
@@ -599,7 +609,7 @@ struct SpectatorPlaneTableProducer {
599609
600610 // Do corrections
601611 if (cApplyRecentCorr) {
602- applyCorrection (loadShiftCorr, vCollParam, vSP);
612+ applyCorrection (vCollParam, vSP);
603613 }
604614
605615 // Fill X and Y histograms for corrections after each iteration
@@ -675,9 +685,17 @@ struct SpectatorPlaneTableProducer {
675685
676686 void processSpectatorPlane (CollisionsRun3::iterator const & collision, BCsRun3 const &, aod::Zdcs const &)
677687 {
688+ // Get bunch crossing
689+ auto bc = collision.template foundBC_as <BCsRun3>();
690+ cRunNum = collision.template foundBC_as <BCsRun3>().runNumber ();
691+
692+ if (lRunNum != cRunNum) {
693+ loadCorrections ();
694+ }
695+
678696 // Analyze collision and get Spectator Plane Vector
679697 std::array<float , 4 > vSP = {0 ., 0 ., 0 ., 0 .};
680- bool colSPExtFlag = analyzeCollision (collision, vSP);
698+ bool colSPExtFlag = analyzeCollision (bc, collision, vSP);
681699
682700 // Update run number
683701 lRunNum = cRunNum;
@@ -870,6 +888,7 @@ struct FlowEventPlane {
870888 histos.add (" V0/Lambda/Flow/hQuA" , " hQuA" , kTProfile3D , {axisCent, axisTrackRap, axisLambdaInvMass});
871889 histos.add (" V0/Lambda/Flow/hQuC" , " hQuC" , kTProfile3D , {axisCent, axisTrackRap, axisLambdaInvMass});
872890 histos.addClone (" V0/Lambda/" , " V0/AntiLambda/" );
891+ histos.addClone (" V0/Lambda/" , " V0/LambdaAntiLambda/" );
873892 histos.add (" V0/K0Short/hMassVsRap" , " hMassVsRap" , kTH3F , {axisCent, axisK0ShortInvMass, axisTrackEta});
874893 histos.add (" V0/K0Short/Flow/hQuA" , " hQuA" , kTProfile3D , {axisCent, axisTrackRap, axisK0ShortInvMass});
875894 histos.add (" V0/K0Short/Flow/hQuC" , " hQuC" , kTProfile3D , {axisCent, axisTrackRap, axisK0ShortInvMass});
@@ -1208,6 +1227,9 @@ struct FlowEventPlane {
12081227 histos.fill (HIST (" V0/Lambda/hMassVsRap" ), cent, v0.mLambda (), v0.eta ());
12091228 histos.fill (HIST (" V0/Lambda/Flow/hQuA" ), cent, v0.eta (), v0.mLambda (), v1a);
12101229 histos.fill (HIST (" V0/Lambda/Flow/hQuC" ), cent, v0.eta (), v0.mLambda (), v1c);
1230+ histos.fill (HIST (" V0/LambdaAntiLambda/hMassVsRap" ), cent, v0.mLambda (), v0.eta ());
1231+ histos.fill (HIST (" V0/LambdaAntiLambda/Flow/hQuA" ), cent, v0.eta (), v0.mLambda (), v1a);
1232+ histos.fill (HIST (" V0/LambdaAntiLambda/Flow/hQuC" ), cent, v0.eta (), v0.mLambda (), v1c);
12111233 }
12121234
12131235 // AntiLambda
@@ -1216,6 +1238,9 @@ struct FlowEventPlane {
12161238 histos.fill (HIST (" V0/AntiLambda/hMassVsRap" ), cent, v0.mAntiLambda (), v0.eta ());
12171239 histos.fill (HIST (" V0/AntiLambda/Flow/hQuA" ), cent, v0.eta (), v0.mAntiLambda (), v1a);
12181240 histos.fill (HIST (" V0/AntiLambda/Flow/hQuC" ), cent, v0.eta (), v0.mAntiLambda (), v1c);
1241+ histos.fill (HIST (" V0/LambdaAntiLambda/hMassVsRap" ), cent, v0.mAntiLambda (), v0.eta ());
1242+ histos.fill (HIST (" V0/LambdaAntiLambda/Flow/hQuA" ), cent, v0.eta (), v0.mAntiLambda (), v1a);
1243+ histos.fill (HIST (" V0/LambdaAntiLambda/Flow/hQuC" ), cent, v0.eta (), v0.mAntiLambda (), v1c);
12191244 }
12201245 }
12211246 }
0 commit comments