5454#include < string_view>
5555#include < vector>
5656
57- #include < stdlib.h >
57+ #include < cstdlib >
5858
5959#define O2_DEFINE_CONFIGURABLE (NAME, TYPE, DEFAULT, HELP ) Configurable<TYPE > NAME {#NAME , DEFAULT , HELP };
6060
@@ -68,7 +68,7 @@ using namespace o2::constants::math;
6868
6969namespace o2 ::analysis::qvectortask
7070{
71- int counter = 0 ;
71+
7272
7373// Define histogrm names here to use same names for creating and later uploading and retrieving data from ccdb
7474// Energy calibration:
@@ -415,7 +415,7 @@ struct ZdcQVectors {
415415 }
416416
417417 template <typename TCollision, typename TZdc>
418- inline void fillCutAnalysis (TCollision collision, TZdc zdcBC, int evSel)
418+ inline void fillCutAnalysis (const TCollision& collision, const TZdc& zdcBC, int evSel)
419419 {
420420 registry.fill (HIST (" hEventCount" ), evSel);
421421 // FT0C is the default centrality estimator
@@ -466,10 +466,10 @@ struct ZdcQVectors {
466466 }
467467
468468 template <typename TCollision, typename TBunchCrossing>
469- uint16_t eventSelected (TCollision collision, TBunchCrossing bunchCrossing, bool & isEventSelected, const int & multTrk)
469+ uint16_t eventSelected (const TCollision& collision, const TBunchCrossing& bunchCrossing, bool & isEventSelected, const int & multTrk)
470470 {
471471 uint16_t selectionBits = 0 ;
472- bool selected;
472+ bool selected = false ;
473473
474474 // Define selection criteria
475475 // If event is selected (passed the cut), set the corresponding bit in the selectionBits variable
@@ -578,16 +578,21 @@ struct ZdcQVectors {
578578 auto multNTracksPV = collision.multNTracksPV ();
579579 selected = true ;
580580
581- if (vtxz > cfgVtxZ || vtxz < -cfgVtxZ)
581+ if (vtxz > cfgVtxZ || vtxz < -cfgVtxZ){
582582 selected = false ;
583- if (multNTracksPV < fMultPVCutLow ->Eval (collision.centFT0C ()))
583+ }
584+ if (multNTracksPV < fMultPVCutLow ->Eval (collision.centFT0C ())){
584585 selected = false ;
585- if (multNTracksPV > fMultPVCutHigh ->Eval (collision.centFT0C ()))
586+ }
587+ if (multNTracksPV > fMultPVCutHigh ->Eval (collision.centFT0C ())){
586588 selected = false ;
587- if (multTrk < fMultCutLow ->Eval (collision.centFT0C ()))
589+ }
590+ if (multTrk < fMultCutLow ->Eval (collision.centFT0C ())){
588591 selected = false ;
589- if (multTrk > fMultCutHigh ->Eval (collision.centFT0C ()))
592+ }
593+ if (multTrk > fMultCutHigh ->Eval (collision.centFT0C ())){
590594 selected = false ;
595+ }
591596
592597 if (selected) {
593598 selectionBits |= static_cast <uint16_t >(0x1u << evSel_MultCut);
@@ -606,9 +611,10 @@ struct ZdcQVectors {
606611 {
607612 // loop for filling multiple histograms with different naming patterns
608613 // Always fill the uncentered "raw" Q-vector histos!
609- if (cfgFillNothing)
614+ if (cfgFillNothing){
610615 return ;
611- static constexpr std::string_view Time[] = {" before" , " after" };
616+ }
617+ static constexpr std::array<std::string_view, 2 > Time = {" before" , " after" }; // todo move to struct like in flowSP
612618
613619 registry.fill (HIST (" recentering/" ) + HIST (Time[ft]) + HIST (" /hZNA_Qx_vs_Qy" ), qxa, qya);
614620 registry.fill (HIST (" recentering/" ) + HIST (Time[ft]) + HIST (" /hZNC_Qx_vs_Qy" ), qxc, qyc);
@@ -678,7 +684,7 @@ struct ZdcQVectors {
678684 }
679685
680686 template <CalibModes cm>
681- void loadCalibrations (std::string ccdb_dir, uint64_t timestamp)
687+ void loadCalibrations (const std::string & ccdb_dir, uint64_t timestamp)
682688 {
683689 // iteration = 0 (Energy calibration) -> step 0 only
684690 // iteration 1,2,3,4,5 = recentering -> 5 steps per iteration (1x 4D + 4x 1D)
@@ -687,7 +693,7 @@ struct ZdcQVectors {
687693 return ;
688694 }
689695
690- if (ccdb_dir.empty () == false ) {
696+ if (! ccdb_dir.empty ()) {
691697 cal.calibList [cm] = ccdb->getForTimeStamp <TList>(ccdb_dir, timestamp);
692698 cal.calibfilesLoaded [cm] = true ;
693699 LOGF (info, " Loaded calibration histos from %s" , ccdb_dir.c_str ());
@@ -706,16 +712,16 @@ struct ZdcQVectors {
706712
707713 if (cm == kEnergyCal || cm == kMeanv ) {
708714 TList* list = cal.calibList [cm];
709- hist = reinterpret_cast <T*>(list->FindObject (Form (" %s" , objName)));
715+ hist = dynamic_cast <T*>(list->FindObject (Form (" %s" , objName)));
710716 } else if (cm == kTimestamp ) {
711- auto list = reinterpret_cast <TList*>(cal.calibList [cm]->FindObject (Form (" it%i_step%i" , iteration, step)));
712- hist = reinterpret_cast <T*>(list->FindObject (Form (" %s" , objName)));
717+ auto list = dynamic_cast <TList*>(cal.calibList [cm]->FindObject (Form (" it%i_step%i" , iteration, step)));
718+ hist = dynamic_cast <T*>(list->FindObject (Form (" %s" , objName)));
713719 } else if (cm == kRec ) {
714- auto list = reinterpret_cast <TList*>(cal.calibList [cm]->FindObject (Form (" it%i_step%i" , iteration, step)));
720+ auto list = dynamic_cast <TList*>(cal.calibList [cm]->FindObject (Form (" it%i_step%i" , iteration, step)));
715721 if (!list) {
716722 LOGF (fatal, " No calibration list for iteration %i and step %i" , iteration, step);
717723 }
718- hist = reinterpret_cast <T*>(list->FindObject (Form (" %s" , objName)));
724+ hist = dynamic_cast <T*>(list->FindObject (Form (" %s" , objName)));
719725 if (!hist) {
720726 LOGF (fatal, " No calibration histo for iteration %i and step %i -> %s" , iteration, step, objName);
721727 }
@@ -728,13 +734,13 @@ struct ZdcQVectors {
728734
729735 if (hist->InheritsFrom (" TProfile2D" )) {
730736 // needed for energy calibration!
731- auto h = reinterpret_cast <TProfile2D*>(hist);
737+ auto h = dynamic_cast <TProfile2D*>(hist);
732738 TString name = h->GetName ();
733739 int binrunnumber = h->GetXaxis ()->FindBin (TString::Format (" %d" , cal.runnumber ));
734740 int bin = h->GetYaxis ()->FindBin (cal.centrality );
735741 calibConstant = h->GetBinContent (binrunnumber, bin);
736742 } else if (hist->InheritsFrom (" TProfile" )) {
737- auto h = reinterpret_cast <TProfile*>(hist);
743+ auto h = dynamic_cast <TProfile*>(hist);
738744 TString name = h->GetName ();
739745 int bin{};
740746 if (name.Contains (" mean_vx" )) {
@@ -758,7 +764,7 @@ struct ZdcQVectors {
758764 calibConstant = h->GetBinContent (bin);
759765 } else if (hist->InheritsFrom (" THnSparse" )) {
760766 std::vector<int > sparsePars;
761- auto h = reinterpret_cast <THnSparseD*>(hist);
767+ auto h = dynamic_cast <THnSparseD*>(hist);
762768 sparsePars.push_back (h->GetAxis (0 )->FindBin (cal.centrality ));
763769 sparsePars.push_back (h->GetAxis (1 )->FindBin (cal.v [0 ]));
764770 sparsePars.push_back (h->GetAxis (2 )->FindBin (cal.v [1 ]));
@@ -857,9 +863,9 @@ struct ZdcQVectors {
857863 int nTowersPerSide = 4 ;
858864
859865 // for energy calibration
860- std::array<double , 8 > eZN; // uncalibrated energy for the 2x4 towers (a1, a2, a3, a4, c1, c2, c3, c4)
861- std::array<double , 10 > meanEZN; // mean energies from calibration histos (common A, t1-4 A,common C, t1-4C)
862- std::array<double , 8 > e; // calibrated energies (a1, a2, a3, a4, c1, c2, c3, c4))
866+ std::array<double , 8 > eZN{} ; // uncalibrated energy for the 2x4 towers (a1, a2, a3, a4, c1, c2, c3, c4)
867+ std::array<double , 10 > meanEZN{} ; // mean energies from calibration histos (common A, t1-4 A,common C, t1-4C)
868+ std::array<double , 8 > e{} ; // calibrated energies (a1, a2, a3, a4, c1, c2, c3, c4))
863869
864870 for (int tower = 0 ; tower < nTowers; tower++) {
865871 eZN[tower] = (tower < nTowersPerSide) ? zdcCol.energySectorZNA ()[tower] : zdcCol.energySectorZNC ()[tower % nTowersPerSide];
@@ -1066,7 +1072,8 @@ struct ZdcQVectors {
10661072 spTableZDC (runnumber, cents, cal.v , foundBC.timestamp (), q[0 ], q[1 ], q[2 ], q[3 ], cal.isSelected , eventSelectionFlags);
10671073 cal.lastRunNumber = runnumber;
10681074 return ;
1069- } else {
1075+ }
1076+
10701077 if (cfgFillHistRegistry && isEventSelected)
10711078 fillCommonRegistry<kBefore >(q[0 ], q[1 ], q[2 ], q[3 ], cal.v , cent, rsTimestamp);
10721079
@@ -1149,11 +1156,11 @@ struct ZdcQVectors {
11491156 double deltaPsiZDCA = 0 ;
11501157 double deltaPsiZDCC = 0 ;
11511158
1152- if (!cfgCCDBdir_Shift.value .empty () && cal.isShiftProfileFound == false ) {
1159+ if (!cfgCCDBdir_Shift.value .empty () && ! cal.isShiftProfileFound ) {
11531160 LOGF (info, " Getting shift profile from CCDB for runnumber: %d" , runnumber);
11541161 TList* hcorrList = ccdb->getForTimeStamp <TList>(cfgCCDBdir_Shift.value , foundBC.timestamp ());
1155- cal.shiftprofileC = reinterpret_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCC" ));
1156- cal.shiftprofileA = reinterpret_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCA" ));
1162+ cal.shiftprofileC = dynamic_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCC" ));
1163+ cal.shiftprofileA = dynamic_cast <TProfile3D*>(hcorrList->FindObject (" ShiftZDCA" ));
11571164 if (!cal.shiftprofileC || !cal.shiftprofileA ) {
11581165 LOGF (error, " Shift profile not found in CCDB for runnumber: %d" , runnumber);
11591166 cal.isShiftProfileFound = false ;
@@ -1236,7 +1243,7 @@ struct ZdcQVectors {
12361243
12371244 cal.lastRunNumber = runnumber;
12381245 return ;
1239- }
1246+
12401247 LOGF (warning, " We return without saving table... -> THis is a problem" );
12411248 cal.lastRunNumber = runnumber;
12421249 } // end of process
0 commit comments