@@ -70,12 +70,8 @@ using BCsRun3 = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels, aod::Run3Match
7070
7171namespace o2 ::analysis::qvectortask
7272{
73-
7473int counter = 0 ;
7574
76- // step0 -> Energy calib
77- std::shared_ptr<TProfile2D> energyZN[10 ] = {{nullptr }};
78-
7975// Define histogrm names here to use same names for creating and later uploading and retrieving data from ccdb
8076// Energy calibration:
8177std::vector<TString> namesEcal (10 , " " );
@@ -89,7 +85,6 @@ double alphaZDC = 0.395;
8985
9086// q-vectors before (q) and after (qRec) recentering.
9187std::vector<double > q (4 ); // start values of [QxA, QyA, QxC, QyC]
92- std::vector<double > qRec (4 ); // Recentered values of [QxA, QyA, QxC, QyC]
9388
9489// for energy calibration
9590std::vector<double > eZN (8 ); // uncalibrated energy for the 2x4 towers (a1, a2, a3, a4, c1, c2, c3, c4)
@@ -178,7 +173,7 @@ struct ZdcQVectors {
178173 // Tower mean energies vs. centrality used for tower gain equalisation
179174 for (int tower = 0 ; tower < 10 ; tower++) {
180175 namesEcal[tower] = TString::Format (" hZN%s_mean_t%i_cent" , sides[(tower < 5 ) ? 0 : 1 ], tower % 5 );
181- energyZN[tower] = registry.add <TProfile2D>(Form (" Energy/%s" , namesEcal[tower].Data ()), Form (" %s" , namesEcal[tower].Data ()), kTProfile2D , {{1 , 0 , 1 }, axisCent});
176+ registry.add <TProfile2D>(Form (" Energy/%s" , namesEcal[tower].Data ()), Form (" %s" , namesEcal[tower].Data ()), kTProfile2D , {{1 , 0 , 1 }, axisCent});
182177 }
183178
184179 registry.add <TH2>(Form (" before/QA/hSPplaneA" ), " hSPplaneA" , kTH2D , {{100 , -4 , 4 }, axisCent10});
@@ -293,8 +288,8 @@ struct ZdcQVectors {
293288 }
294289 }
295290 // Try to cast to TProfile
296- if (TProfile* profile2D = dynamic_cast <TProfile*>(obj)) {
297- if (profile2D ->GetEntries () < 1 ) {
291+ if (TProfile* profile = dynamic_cast <TProfile*>(obj)) {
292+ if (profile ->GetEntries () < 1 ) {
298293 if (counter < 1 )
299294 LOGF (info, " %s (TProfile) is empty! Produce calibration file at given step" , names[i].Data ());
300295 cal.calibfilesLoaded [iteration][step] = false ;
@@ -385,14 +380,20 @@ struct ZdcQVectors {
385380 for (std::size_t i = 0 ; i < sparsePars.size (); i++) {
386381 h->GetAxis (i)->SetRange (sparsePars[i], sparsePars[i]);
387382 }
388- calibConstant = h->Projection (4 )->GetMean ();
389383
390- if (h->Projection (4 )->GetEntries () < cfgMinEntriesSparseBin) {
384+ TH1D* tempProj = h->Projection (4 );
385+ calibConstant = tempProj->GetMean ();
386+
387+ if (tempProj->GetEntries () < cfgMinEntriesSparseBin) {
391388 LOGF (debug, " 1 entry in sparse bin! Not used... (increase binsize)" );
392389 calibConstant = 0 ;
393390 isSelected = false ;
394391 }
392+
393+ delete tempProj;
394+
395395 }
396+
396397 return calibConstant;
397398 }
398399
@@ -422,6 +423,7 @@ struct ZdcQVectors {
422423 if (cent < 0 || cent > 90 ) {
423424 isSelected = false ;
424425 spTableZDC (runnumber, cent, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
426+ counter++;
425427 return ;
426428 }
427429
@@ -432,6 +434,7 @@ struct ZdcQVectors {
432434 if (!foundBC.has_zdc ()) {
433435 isSelected = false ;
434436 spTableZDC (runnumber, cent, v[0 ], v[1 ], v[2 ], 0 , 0 , 0 , 0 , isSelected, 0 , 0 );
437+ counter++;
435438 return ;
436439 }
437440
@@ -443,7 +446,11 @@ struct ZdcQVectors {
443446
444447 // load new calibrations for new runs only
445448 if (runnumber != lastRunNumber) {
446- cal.calibfilesLoaded = std::vector<std::vector<bool >>(7 , std::vector<bool >(8 , false ));
449+ cal.calibfilesLoaded .clear ();
450+ cal.calibfilesLoaded .resize (7 , std::vector<bool >(8 , false ));
451+
452+ cal.calibList .clear ();
453+ cal.calibList .resize (7 , std::vector<TList*>(8 , nullptr ));
447454 lastRunNumber = runnumber;
448455 }
449456
@@ -473,9 +480,6 @@ struct ZdcQVectors {
473480 registry.get <TProfile>(HIST (" vmean/hvertex_vz" ))->Fill (Form (" %d" , runnumber), v[2 ]);
474481 }
475482
476- if (counter < 1 )
477- LOGF (info, " =====================> .....Start Energy Calibration..... <=====================" );
478-
479483 bool isZNAhit = true ;
480484 bool isZNChit = true ;
481485
@@ -492,20 +496,19 @@ struct ZdcQVectors {
492496 isZNChit = false ;
493497
494498 // Fill to get mean energy per tower in 1% centrality bins
495- for (int tower = 0 ; tower < 5 ; tower++) {
496- if (tower == 0 ) {
497- if (isZNAhit)
498- energyZN[tower]->Fill (Form (" %d" , runnumber), cent, zdcCol.energyCommonZNA (), 1 );
499- if (isZNChit)
500- energyZN[tower + 5 ]->Fill (Form (" %d" , runnumber), cent, zdcCol.energyCommonZNC (), 1 );
501- LOGF (debug, " Common A tower filled with: %i, %.2f, %.2f" , runnumber, cent, zdcCol.energyCommonZNA ());
502- } else {
503- if (isZNAhit)
504- energyZN[tower]->Fill (Form (" %d" , runnumber), cent, eZN[tower - 1 ], 1 );
505- if (isZNChit)
506- energyZN[tower + 5 ]->Fill (Form (" %d" , runnumber), cent, eZN[tower - 1 + 4 ], 1 );
507- LOGF (debug, " Tower ZNC[%i] filled with: %i, %.2f, %.2f" , tower, runnumber, cent, eZN[tower - 1 + 4 ]);
508- }
499+ if (isZNAhit){
500+ registry.get <TProfile2D>(HIST (" Energy/hZNA_mean_t0_cent" ))->Fill (Form (" %d" , runnumber), cent, zdcCol.energyCommonZNA (), 1 );
501+ registry.get <TProfile2D>(HIST (" Energy/hZNA_mean_t1_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[0 ], 1 );
502+ registry.get <TProfile2D>(HIST (" Energy/hZNA_mean_t2_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[1 ], 1 );
503+ registry.get <TProfile2D>(HIST (" Energy/hZNA_mean_t3_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[2 ], 1 );
504+ registry.get <TProfile2D>(HIST (" Energy/hZNA_mean_t4_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[3 ], 1 );
505+ }
506+ if (isZNChit){
507+ registry.get <TProfile2D>(HIST (" Energy/hZNC_mean_t0_cent" ))->Fill (Form (" %d" , runnumber), cent, zdcCol.energyCommonZNC (), 1 );
508+ registry.get <TProfile2D>(HIST (" Energy/hZNC_mean_t1_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[4 ], 1 );
509+ registry.get <TProfile2D>(HIST (" Energy/hZNC_mean_t2_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[5 ], 1 );
510+ registry.get <TProfile2D>(HIST (" Energy/hZNC_mean_t3_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[6 ], 1 );
511+ registry.get <TProfile2D>(HIST (" Energy/hZNC_mean_t4_cent" ))->Fill (Form (" %d" , runnumber), cent, eZN[7 ], 1 );
509512 }
510513
511514 // if ZNA or ZNC not hit correctly.. do not use event in q-vector calculation
@@ -523,13 +526,6 @@ struct ZdcQVectors {
523526 return ;
524527 }
525528
526- if (counter < 1 )
527- LOGF (info, " files for step 0 (energy Calibraton) are open!" );
528-
529- if (counter < 1 ) {
530- LOGF (info, " =====================> .....Start Calculating Q-Vectors..... <=====================" );
531- }
532-
533529 // Now start gain equalisation!
534530 // Fill the list with calibration constants.
535531 for (int tower = 0 ; tower < 10 ; tower++) {
@@ -548,6 +544,7 @@ struct ZdcQVectors {
548544 calibtower++;
549545 }
550546
547+
551548 for (int i = 0 ; i < 4 ; i++) {
552549 float bincenter = i + .5 ;
553550 registry.fill (HIST (" QA/ZNA_Energy" ), bincenter, eZN[i]);
@@ -575,8 +572,6 @@ struct ZdcQVectors {
575572 }
576573
577574 if (cal.calibfilesLoaded [0 ][1 ]) {
578- if (counter < 1 )
579- LOGF (info, " =====================> Setting v to vmean!" );
580575 v[0 ] = v[0 ] - getCorrection<TProfile>(0 , 1 , vnames[0 ].Data ());
581576 v[1 ] = v[1 ] - getCorrection<TProfile>(0 , 1 , vnames[1 ].Data ());
582577 }
@@ -599,21 +594,17 @@ struct ZdcQVectors {
599594 }
600595 }
601596
602- if (counter < 1 )
603- LOGF (info, " We evaluate cal.atIteration=%i and cal.atStep=%i " , cal.atIteration , cal.atStep );
597+ std::vector<double > qRec (q);
604598
605599 if (cal.atIteration == 0 ) {
606- if (counter < 1 )
607- LOGF (warning, " Calibation files missing!!! Output created with q-vectors right after energy gain eq. !!" );
608600 if (isSelected)
609601 fillCommonRegistry<kBefore >(q[0 ], q[1 ], q[2 ], q[3 ], v, centrality);
602+
610603 spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], q[0 ], q[1 ], q[2 ], q[3 ], isSelected, 0 , 0 );
611604 counter++;
612605 return ;
613606 } else if (cal.atIteration == 5 && cal.atStep == 4 ) {
614- std::vector<double > qRec (4 );
615607 fillCommonRegistry<kBefore >(q[0 ], q[1 ], q[2 ], q[3 ], v, centrality);
616- qRec = q;
617608
618609 // vector of 4
619610 std::vector<double > corrQxA;
@@ -628,7 +619,6 @@ struct ZdcQVectors {
628619 corrQyA.push_back (getCorrection<THnSparse>(it, 0 , names[0 ][1 ].Data ()));
629620 corrQxC.push_back (getCorrection<THnSparse>(it, 0 , names[0 ][2 ].Data ()));
630621 corrQyC.push_back (getCorrection<THnSparse>(it, 0 , names[0 ][3 ].Data ()));
631-
632622 pb++;
633623
634624 for (int step = 1 ; step < 5 ; step++) {
@@ -647,14 +637,16 @@ struct ZdcQVectors {
647637 qRec[3 ] -= corrQyC[cor];
648638 }
649639
650- if (counter < 1 )
651- LOGF (info, " Output created with q-vectors at iteration %i and step %i!!!!" , cal.atIteration , cal.atStep + 1 );
652640 if (isSelected) {
653641 fillCommonRegistry<kAfter >(qRec[0 ], qRec[1 ], qRec[2 ], qRec[3 ], v, centrality);
654642 registry.fill (HIST (" QA/centrality_after" ), centrality);
655643 }
644+
656645 spTableZDC (runnumber, centrality, v[0 ], v[1 ], v[2 ], qRec[0 ], qRec[1 ], qRec[2 ], qRec[3 ], isSelected, cal.atIteration , cal.atStep );
657- counter++;
646+
647+ qRec.clear ();
648+
649+ counter++;
658650 return ;
659651 } else {
660652 if (counter < 1 )
0 commit comments