Skip to content

Commit 6dc8b71

Browse files
cnkosteralibuild
andauthored
[PWGCF] Add possibility to recenter for timestamp intervals and add cutanalys… (AliceO2Group#14402)
Co-authored-by: ALICE Action Bot <[email protected]>
1 parent 244773f commit 6dc8b71

File tree

1 file changed

+115
-26
lines changed

1 file changed

+115
-26
lines changed

PWGCF/Flow/TableProducer/zdcQVectors.cxx

Lines changed: 115 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int counter = 0;
7474
// Energy calibration:
7575
std::vector<TString> namesEcal(10, "");
7676
std::vector<std::vector<TString>> names(5, std::vector<TString>()); //(1x 4d 4x 1d)
77+
std::vector<TString> namesTS; // for timestamo recentering
7778
std::vector<TString> vnames = {"hvertex_vx", "hvertex_vy"};
7879

7980
// https://alice-notes.web.cern.ch/system/files/notes/analysis/620/017-May-31-analysis_note-ALICE_analysis_note_v2.pdf
@@ -97,6 +98,7 @@ int lastRunNumber = 0;
9798
std::vector<float> v(3, 0); // vx, vy, vz
9899
bool isSelected = true;
99100
std::vector<float> cents; // centrality estimaters
101+
uint64_t timestamp = 0;
100102

101103
} // namespace o2::analysis::qvectortask
102104

@@ -122,6 +124,11 @@ struct ZdcQVectors {
122124
O2_DEFINE_CONFIGURABLE(cfgCentMax, float, 90, "Maximum cenrality for selected events");
123125
} EvSel;
124126

127+
struct : ConfigurableGroup {
128+
O2_DEFINE_CONFIGURABLE(cfgRecenterForTimestamp, bool, false, "Add 1D recentering for timestamp");
129+
O2_DEFINE_CONFIGURABLE(cfgCCDBdir_Timestamp, std::string, "Users/c/ckoster/ZDC/LHC23_PbPb_pass5/Timestamp", "CCDB directory for Timestamp recentering");
130+
} extraTS;
131+
125132
ConfigurableAxis axisCent{"axisCent", {90, 0, 90}, "Centrality axis in 1% bins"};
126133
ConfigurableAxis axisCent10{"axisCent10", {9, 0, 90}, "Centrality axis in 10% bins"};
127134
ConfigurableAxis axisQ{"axisQ", {100, -2, 2}, "Q vector (xy) in ZDC"};
@@ -131,6 +138,7 @@ struct ZdcQVectors {
131138
ConfigurableAxis axisVx{"axisVx", {100, -0.01, 0.01}, "for Pos X of collision"};
132139
ConfigurableAxis axisVy{"axisVy", {100, -0.01, 0.01}, "for Pos Y of collision"};
133140
ConfigurableAxis axisVz{"axisVz", {100, -10, 10}, "for vz of collision"};
141+
ConfigurableAxis axisTimestamp{"axisTimestamp", {100, 0, 100}, "for timestamp of collision in (TSi - TS_start) / (TS_eind - TS_start) x 100% "};
134142

135143
// Centrality Estimators -> standard is FT0C
136144
O2_DEFINE_CONFIGURABLE(cfgFT0Cvariant1, bool, false, "Set centrality estimator to cfgFT0Cvariant1");
@@ -178,7 +186,8 @@ struct ZdcQVectors {
178186
enum CalibModes {
179187
kEnergyCal,
180188
kMeanv,
181-
kRec
189+
kRec,
190+
kTimestamp
182191
};
183192

184193
// Define output
@@ -188,8 +197,8 @@ struct ZdcQVectors {
188197

189198
// keep track of calibration histos for each given step and iteration
190199
struct Calib {
191-
std::vector<TList*> calibList = std::vector<TList*>(3, nullptr); // [0] Enerfy cal, [1] vmean, [2] recentering
192-
std::vector<bool> calibfilesLoaded = std::vector<bool>(3, false);
200+
std::vector<TList*> calibList = std::vector<TList*>(4, nullptr); // [0] Enerfy cal, [1] vmean, [2] recentering, [3] timestamp
201+
std::vector<bool> calibfilesLoaded = std::vector<bool>(4, false);
193202
int atStep = 0;
194203
int atIteration = 0;
195204

@@ -252,6 +261,7 @@ struct ZdcQVectors {
252261
names[2].push_back(TString::Format("hQ%s%s_mean_vx_run", coord, side));
253262
names[3].push_back(TString::Format("hQ%s%s_mean_vy_run", coord, side));
254263
names[4].push_back(TString::Format("hQ%s%s_mean_vz_run", coord, side));
264+
namesTS.push_back(TString::Format("hQ%s%s_mean_timestamp_run", coord, side));
255265
} // end of capCOORDS
256266
}
257267

@@ -271,6 +281,7 @@ struct ZdcQVectors {
271281
registry.add<TProfile>(Form("QA/before/hQ%sA_Q%sC_vs_vx", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_vx", COORD1, COORD2), kTProfile, {axisVx});
272282
registry.add<TProfile>(Form("QA/before/hQ%sA_Q%sC_vs_vy", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_vy", COORD1, COORD2), kTProfile, {axisVy});
273283
registry.add<TProfile>(Form("QA/before/hQ%sA_Q%sC_vs_vz", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_vz", COORD1, COORD2), kTProfile, {axisVz});
284+
registry.add<TProfile>(Form("QA/before/hQ%sA_Q%sC_vs_timestamp", COORD1, COORD2), Form("hQ%sA_Q%sC_vs_timestamp", COORD1, COORD2), kTProfile, {axisTimestamp});
274285
}
275286
}
276287

@@ -282,6 +293,7 @@ struct ZdcQVectors {
282293
registry.add(Form("QA/before/hQ%s%s_vs_vx", coord, side), Form("hQ%s%s_vs_vx", coord, side), {HistType::kTProfile, {axisVx}});
283294
registry.add(Form("QA/before/hQ%s%s_vs_vy", coord, side), Form("hQ%s%s_vs_vy", coord, side), {HistType::kTProfile, {axisVy}});
284295
registry.add(Form("QA/before/hQ%s%s_vs_vz", coord, side), Form("hQ%s%s_vs_vz", coord, side), {HistType::kTProfile, {axisVz}});
296+
registry.add(Form("QA/before/hQ%s%s_vs_timestamp", coord, side), Form("hQ%s%s_vs_timestamp", coord, side), {HistType::kTProfile, {axisTimestamp}});
285297
registry.add(Form("QA/Q%s%s_vs_iteration", coord, side), Form("hQ%s%s_vs_iteration", coord, side), {HistType::kTH2D, {{25, 0, 25}, axisQ}});
286298
} // end of capCOORDS
287299
} // end of sides
@@ -361,16 +373,25 @@ struct ZdcQVectors {
361373
// Tower mean energies vs. centrality used for tower gain equalisation
362374
int totalTowers = 10;
363375
for (int tower = 0; tower < totalTowers; tower++) {
364-
registry.add<TProfile2D>(Form("CutAnalysis/%s", namesEcal[tower].Data()), Form("%s", namesEcal[tower].Data()), kTProfile2D, {axisCent, {nEventSelections, 0, nEventSelections}});
376+
registry.add<TProfile2D>(Form("CutAnalysis/%s", namesEcal[tower].Data()), Form("%s", namesEcal[tower].Data()), kTProfile2D, {axisCent, {nEventSelections + 5, 0, nEventSelections + 5}});
365377
}
366378
// recentered q-vectors (to check what steps are finished in the end)
367-
registry.add<TProfile2D>("CutAnalysis/hvertex_vx", "hvertex_vx", kTProfile2D, {{1, 0., 1.}, {nEventSelections, 0, nEventSelections}});
368-
registry.add<TProfile2D>("CutAnalysis/hvertex_vy", "hvertex_vy", kTProfile2D, {{1, 0., 1.}, {nEventSelections, 0, nEventSelections}});
369-
registry.add<TProfile2D>("CutAnalysis/hvertex_vz", "hvertex_vz", kTProfile2D, {{1, 0., 1.}, {nEventSelections, 0, nEventSelections}});
379+
registry.add<TProfile2D>("CutAnalysis/hvertex_vx", "hvertex_vx", kTProfile2D, {{1, 0., 1.}, {nEventSelections + 5, 0, nEventSelections + 5}});
380+
registry.add<TProfile2D>("CutAnalysis/hvertex_vy", "hvertex_vy", kTProfile2D, {{1, 0., 1.}, {nEventSelections + 5, 0, nEventSelections + 5}});
381+
registry.add<TProfile2D>("CutAnalysis/hvertex_vz", "hvertex_vz", kTProfile2D, {{1, 0., 1.}, {nEventSelections + 5, 0, nEventSelections + 5}});
370382
}
371383
}
372384
}
373385

386+
double rescaleTimestamp(uint64_t timestamp, int runnumber)
387+
{
388+
auto& ccdb = o2::ccdb::BasicCCDBManager::instance();
389+
auto duration = ccdb.getRunDuration(runnumber);
390+
double ts = (static_cast<double>(timestamp - duration.first) / static_cast<double>(duration.second - duration.first)) * 100.0;
391+
392+
return ts;
393+
}
394+
374395
template <typename TCollision, typename TZdc>
375396
inline void fillCutAnalysis(TCollision collision, TZdc zdcBC, int evSel)
376397
{
@@ -379,6 +400,7 @@ struct ZdcQVectors {
379400

380401
if (!cfgFillCutAnalysis || cfgFillNothing)
381402
return;
403+
// Add default with different centrality estimators as well
382404
// Here we fill the Energy and mean vx, vy vz histograms with an extra dimension for all the event selections used.
383405
registry.get<TProfile2D>(HIST("CutAnalysis/hvertex_vx"))->Fill(Form("%d", runnumber), evSel, collision.posX());
384406
registry.get<TProfile2D>(HIST("CutAnalysis/hvertex_vy"))->Fill(Form("%d", runnumber), evSel, collision.posY());
@@ -394,6 +416,31 @@ struct ZdcQVectors {
394416
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t2_cent"))->Fill(centrality, evSel, zdcBC.energySectorZNC()[1], 1);
395417
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t3_cent"))->Fill(centrality, evSel, zdcBC.energySectorZNC()[2], 1);
396418
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t4_cent"))->Fill(centrality, evSel, zdcBC.energySectorZNC()[3], 1);
419+
420+
if (evSel == nEventSelections) {
421+
int centCounter = 0;
422+
423+
std::vector<float> cents = {
424+
collision.centFT0C(),
425+
collision.centFT0CVariant1(),
426+
collision.centFT0M(),
427+
collision.centFV0A(),
428+
collision.centNGlobal()};
429+
430+
for (const auto& cent : cents) {
431+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNA_mean_t0_cent"))->Fill(cent, evSel + centCounter, zdcBC.energyCommonZNA(), 1);
432+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNA_mean_t1_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNA()[0], 1);
433+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNA_mean_t2_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNA()[1], 1);
434+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNA_mean_t3_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNA()[2], 1);
435+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNA_mean_t4_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNA()[3], 1);
436+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t0_cent"))->Fill(cent, evSel + centCounter, zdcBC.energyCommonZNC(), 1);
437+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t1_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNC()[0], 1);
438+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t2_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNC()[1], 1);
439+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t3_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNC()[2], 1);
440+
registry.get<TProfile2D>(HIST("CutAnalysis/hZNC_mean_t4_cent"))->Fill(cent, evSel + centCounter, zdcBC.energySectorZNC()[3], 1);
441+
centCounter++;
442+
}
443+
}
397444
}
398445

399446
template <typename TCollision, typename TBunchCrossing>
@@ -474,6 +521,9 @@ struct ZdcQVectors {
474521
fillCutAnalysis(collision, bunchCrossing, evSel_RCTFlagsZDC);
475522
}
476523

524+
// Fill for centrality estimators!
525+
fillCutAnalysis(collision, bunchCrossing, nEventSelections);
526+
477527
return selectionBits;
478528
}
479529

@@ -529,6 +579,16 @@ struct ZdcQVectors {
529579
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QXC_vs_vz"), v[2], qya * qxc);
530580
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QYC_vs_vz"), v[2], qxa * qyc);
531581

582+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qxa);
583+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qya);
584+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXC_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qxc);
585+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYC_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qyc);
586+
587+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QXC_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qxa * qxc);
588+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QYC_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qya * qyc);
589+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQYA_QXC_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qya * qxc);
590+
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/hQXA_QYC_vs_timestamp"), rescaleTimestamp(timestamp, runnumber), qxa * qyc);
591+
532592
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNA_Qx_vs_Centrality"), centrality, qxa);
533593
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNA_Qy_vs_Centrality"), centrality, qya);
534594
registry.fill(HIST("QA/") + HIST(Time[ft]) + HIST("/ZNC_Qx_vs_Centrality"), centrality, qxc);
@@ -544,7 +604,7 @@ struct ZdcQVectors {
544604
}
545605

546606
template <CalibModes cm>
547-
void loadCalibrations(uint64_t timestamp, std::string ccdb_dir)
607+
void loadCalibrations(std::string ccdb_dir)
548608
{
549609
// iteration = 0 (Energy calibration) -> step 0 only
550610
// iteration 1,2,3,4,5 = recentering -> 5 steps per iteration (1x 4D + 4x 1D)
@@ -570,11 +630,11 @@ struct ZdcQVectors {
570630
T* hist = nullptr;
571631
double calibConstant{0};
572632

573-
if (cm == kEnergyCal) {
633+
if (cm == kEnergyCal || cm == kMeanv) {
574634
TList* list = cal.calibList[cm];
575635
hist = reinterpret_cast<T*>(list->FindObject(Form("%s", objName)));
576-
} else if (cm == kMeanv) {
577-
TList* list = cal.calibList[cm];
636+
} else if (cm == kTimestamp) {
637+
TList* list = reinterpret_cast<TList*>(cal.calibList[cm]->FindObject(Form("it%i_step%i", iteration, step)));
578638
hist = reinterpret_cast<T*>(list->FindObject(Form("%s", objName)));
579639
} else if (cm == kRec) {
580640
TList* list = reinterpret_cast<TList*>(cal.calibList[cm]->FindObject(Form("it%i_step%i", iteration, step)));
@@ -588,7 +648,6 @@ struct ZdcQVectors {
588648
cal.atStep = step;
589649
cal.atIteration = iteration;
590650
}
591-
592651
if (!hist) {
593652
LOGF(fatal, "%s not available.. Abort..", objName);
594653
}
@@ -604,16 +663,24 @@ struct ZdcQVectors {
604663
TProfile* h = reinterpret_cast<TProfile*>(hist);
605664
TString name = h->GetName();
606665
int bin{};
607-
if (name.Contains("mean_vx"))
666+
if (name.Contains("mean_vx")) {
608667
bin = h->GetXaxis()->FindBin(v[0]);
609-
if (name.Contains("mean_vy"))
668+
}
669+
if (name.Contains("mean_vy")) {
610670
bin = h->GetXaxis()->FindBin(v[1]);
611-
if (name.Contains("mean_vz"))
671+
}
672+
if (name.Contains("mean_vz")) {
612673
bin = h->GetXaxis()->FindBin(v[2]);
613-
if (name.Contains("mean_cent"))
674+
}
675+
if (name.Contains("mean_cent")) {
614676
bin = h->GetXaxis()->FindBin(centrality);
615-
if (name.Contains("vertex"))
677+
}
678+
if (name.Contains("vertex")) {
616679
bin = h->GetXaxis()->FindBin(TString::Format("%i", runnumber));
680+
}
681+
if (name.Contains("timestamp")) {
682+
bin = h->GetXaxis()->FindBin(rescaleTimestamp(timestamp, runnumber));
683+
}
617684
calibConstant = h->GetBinContent(bin);
618685
} else if (hist->InheritsFrom("THnSparse")) {
619686
std::vector<int> sparsePars;
@@ -693,6 +760,8 @@ struct ZdcQVectors {
693760

694761
registry.fill(HIST("hEventCount"), evSel_FilteredEvent);
695762

763+
timestamp = foundBC.timestamp();
764+
696765
if (!foundBC.has_zdc()) {
697766
isSelected = false;
698767
spTableZDC(runnumber, cents, v, foundBC.timestamp(), 0, 0, 0, 0, isSelected, 0);
@@ -761,21 +830,24 @@ struct ZdcQVectors {
761830
cal.calibfilesLoaded[2] = false;
762831
cal.calibList[2] = nullptr;
763832

833+
cal.calibfilesLoaded[3] = false;
834+
cal.calibList[3] = nullptr;
835+
764836
cal.isShiftProfileFound = false;
765837
cal.shiftprofileC = nullptr;
766838
cal.shiftprofileA = nullptr;
767839
}
768840

769841
// load the calibration histos for iteration 0 step 0 (Energy Calibration)
770-
loadCalibrations<kEnergyCal>(foundBC.timestamp(), cfgEnergyCal.value);
842+
loadCalibrations<kEnergyCal>(cfgEnergyCal.value);
771843

772844
if (!cal.calibfilesLoaded[0]) {
773845
if (counter < 1) {
774846
LOGF(info, " --> No Energy calibration files found.. -> Only Energy calibration will be done. ");
775847
}
776848
}
777849
// load the calibrations for the mean v
778-
loadCalibrations<kMeanv>(foundBC.timestamp(), cfgMeanv.value);
850+
loadCalibrations<kMeanv>(cfgMeanv.value);
779851

780852
if (!cfgFillNothing) {
781853
registry.get<TProfile>(HIST("vmean/hvertex_vx"))->Fill(Form("%d", runnumber), v[0]);
@@ -928,7 +1000,11 @@ struct ZdcQVectors {
9281000
return;
9291001
}
9301002

931-
loadCalibrations<kRec>(foundBC.timestamp(), cfgRec.value);
1003+
loadCalibrations<kRec>(cfgRec.value);
1004+
1005+
if (extraTS.cfgRecenterForTimestamp) {
1006+
loadCalibrations<kTimestamp>(extraTS.cfgCCDBdir_Timestamp.value);
1007+
}
9321008

9331009
std::vector<double> qRec(q);
9341010

@@ -981,15 +1057,28 @@ struct ZdcQVectors {
9811057
corrQyC.push_back(getCorrection<TProfile, kRec>(names[step - 1][3].Data(), it, step));
9821058
pb++;
9831059
}
1060+
1061+
if (extraTS.cfgRecenterForTimestamp) {
1062+
corrQxA.push_back(getCorrection<TProfile, kTimestamp>(namesTS[0].Data(), it, 6));
1063+
corrQyA.push_back(getCorrection<TProfile, kTimestamp>(namesTS[1].Data(), it, 6));
1064+
corrQxC.push_back(getCorrection<TProfile, kTimestamp>(namesTS[2].Data(), it, 6));
1065+
corrQyC.push_back(getCorrection<TProfile, kTimestamp>(namesTS[3].Data(), it, 6));
1066+
pb++;
1067+
}
9841068
}
9851069

986-
for (int cor = 0; cor < pb; cor++) {
987-
qRec[0] -= corrQxA[cor];
988-
qRec[1] -= corrQyA[cor];
989-
qRec[2] -= corrQxC[cor];
990-
qRec[3] -= corrQyC[cor];
1070+
double totalCorrectionQxA = std::accumulate(corrQxA.begin(), corrQxA.end(), 0.0);
1071+
double totalCorrectionQyA = std::accumulate(corrQyA.begin(), corrQyA.end(), 0.0);
1072+
double totalCorrectionQxC = std::accumulate(corrQxC.begin(), corrQxC.end(), 0.0);
1073+
double totalCorrectionQyC = std::accumulate(corrQyC.begin(), corrQyC.end(), 0.0);
1074+
1075+
qRec[0] -= totalCorrectionQxA;
1076+
qRec[1] -= totalCorrectionQyA;
1077+
qRec[2] -= totalCorrectionQxC;
1078+
qRec[3] -= totalCorrectionQyC;
9911079

992-
if (cfgFillHistRegistry && !cfgFillNothing) {
1080+
if (cfgFillHistRegistry && !cfgFillNothing) {
1081+
for (int cor = 0; cor < pb; cor++) {
9931082
registry.get<TH2>(HIST("QA/QXA_vs_iteration"))->Fill(cor, qRec[0]);
9941083
registry.get<TH2>(HIST("QA/QYA_vs_iteration"))->Fill(cor, qRec[1]);
9951084
registry.get<TH2>(HIST("QA/QXC_vs_iteration"))->Fill(cor, qRec[2]);

0 commit comments

Comments
 (0)