Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions PWGLF/TableProducer/Common/zdc2stagecalibration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@
Configurable<std::string> confGainPath{"confGainPath", "", "CCDB path to the run-wise stage-1 gain map"};
Configurable<bool> useSpatialCalib{"useSpatialCalib", false, "use ZDC spatial calibration"};
Configurable<std::string> confSpatialPath{"confSpatialPath", "", "CCDB path to ZDC spatial calibration"};
Configurable<bool> deriveSpatialCalib{"deriveSpatialCalib", false, "store spatial regression moments after gain correction"};

Configurable<int> cfgSpatialCalibBins{
"cfgSpatialCalibBins", 30,
"number of bins per cross coordinate for spatial calibration"};
struct : ConfigurableGroup {
Configurable<bool> requireRCTFlagChecker{"requireRCTFlagChecker", true, "Check event quality in run condition table"};
Configurable<std::string> cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT", "Evt sel: RCT flag checker label"};
Expand All @@ -98,11 +102,12 @@
const int nTimeBins = static_cast<int>(std::ceil(cfgMaxRunHours.value * 60.f / cfgTimeSliceMinutes.value));
AxisSpec timeAxis = {nTimeBins, 0.0, cfgMaxRunHours.value, "time from SOR (h)"};
AxisSpec towerAxis = {4, 0.0, 4.0, "tower"};
AxisSpec crossCoordAxis = {2, 0.0, 2.0, "coordinate"};
AxisSpec ratioAxis = {240, 0.0, 2.4, "#Sigma tower/common"};
AxisSpec crossAxis = {120, -1.0, 1.0, "cross asymmetry"};
AxisSpec momentAxis = {15, 0.0, 15.0, "regression moment"};
AxisSpec spatialCalibAxis = {cfgSpatialCalibBins.value, -1.0, 1.0, "cross asymmetry"};
AxisSpec phiAxis = {72, -3.14159265358979323846, 3.14159265358979323846, "#phi"};
AxisSpec crossCoordAxis = {2, 0.0, 2.0, "coordinate"};
AxisSpec ratioAxis = {240, 0.0, 2.4, "#Sigma tower/common"};

histos.add("hEvtSelInfo", "hEvtSelInfo", kTH1F, {{10, 0.0, 10.0}});
auto hEvtSelInfo = histos.get<TH1>(HIST("hEvtSelInfo"));
Expand Down Expand Up @@ -145,6 +150,8 @@
// 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.
histos.add("GainCalibration/hGainMomentsZNA", "ZNA linear-regression moments;time from SOR (h);moment index", kTH2D, {timeAxis, momentAxis});
histos.add("GainCalibration/hGainMomentsZNC", "ZNC linear-regression moments;time from SOR (h);moment index", kTH2D, {timeAxis, momentAxis});
histos.add("SpatialCalibration/hSpatialMomentsZNA", "ZNA spatial regression moments;X cross;Y cross;moment index", kTH3D, {spatialCalibAxis, spatialCalibAxis, momentAxis});
histos.add("SpatialCalibration/hSpatialMomentsZNC", "ZNC spatial regression moments;X cross;Y cross;moment index", kTH3D, {spatialCalibAxis, spatialCalibAxis, momentAxis});

ccdb->setURL(cfgCcdbParam.cfgURL);
ccdb->setCaching(true);
Expand All @@ -165,13 +172,13 @@
bcSOR = static_cast<int64_t>(runInfo.orbitSOR) * static_cast<int64_t>(o2::constants::lhc::LHCMaxBunches);
gainprofile = nullptr;
spatialprofile = nullptr;
if (calibrationStage.value == 2 && useGainCallib.value && !confGainPath.value.empty()) {

Check failure on line 175 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
gainprofile = ccdb->getForTimeStamp<TH2D>(confGainPath.value, timestamp);
if (!gainprofile) {
LOGF(warn, "No ZDC stage-1 gain map found for run %d at timestamp %llu", runNumber, static_cast<unsigned long long>(timestamp));
}
}
if (calibrationStage.value == 2 && useSpatialCalib.value && !confSpatialPath.value.empty()) {

Check failure on line 181 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
spatialprofile = ccdb->getForTimeStamp<TH3D>(confSpatialPath.value, timestamp);

if (!spatialprofile) {
Expand All @@ -191,7 +198,7 @@

double getGain(float timeFromSOR, int channel, bool& gainOK) const
{
if (calibrationStage.value != 2 || !useGainCallib.value) {

Check failure on line 201 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return 1.0;
}
if (!gainprofile || timeFromSOR < 0.f) {
Expand Down Expand Up @@ -247,7 +254,7 @@
histos.fill(HIST("hEvtSelInfo"), 2.5);

bool validTowers = true;
for (int i = 0; i < 4; ++i) {

Check failure on line 257 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
if (!std::isfinite(znaEnergy[i]) || !std::isfinite(zncEnergy[i]) || znaEnergy[i] <= 0.f || zncEnergy[i] <= 0.f) {
validTowers = false;
}
Expand Down Expand Up @@ -284,7 +291,7 @@
double rawYC = 0.0;
double rawSumA = 0.0;
double rawSumC = 0.0;
for (int i = 0; i < 4; ++i) {

Check failure on line 294 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
rawXA -= znaEnergy[i] * x[i];
rawYA += znaEnergy[i] * y[i];
rawXC += zncEnergy[i] * x[i];
Expand All @@ -305,20 +312,20 @@
std::array<double, 15> momentsA{};
std::array<double, 15> momentsC{};
int moment = 0;
for (int i = 0; i < 4; ++i) {

Check failure on line 315 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
for (int j = i; j < 4; ++j) {

Check failure on line 316 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
momentsA[moment] = static_cast<double>(znaEnergy[i]) * static_cast<double>(znaEnergy[j]);
momentsC[moment] = static_cast<double>(zncEnergy[i]) * static_cast<double>(zncEnergy[j]);
++moment;
}
}
for (int i = 0; i < 4; ++i) {

Check failure on line 322 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
momentsA[10 + i] = static_cast<double>(znaEnergycommon) * static_cast<double>(znaEnergy[i]);
momentsC[10 + i] = static_cast<double>(zncEnergycommon) * static_cast<double>(zncEnergy[i]);
}
momentsA[14] = 1.0;
momentsC[14] = 1.0;
for (int i = 0; i < 15; ++i) {

Check failure on line 328 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
histos.fill(HIST("GainCalibration/hGainMomentsZNA"), timeFromSOR, i + 0.5, momentsA[i]);
histos.fill(HIST("GainCalibration/hGainMomentsZNC"), timeFromSOR, i + 0.5, momentsC[i]);
}
Expand All @@ -327,7 +334,7 @@
bool gainOK = true;
std::array<double, 4> znaCorr{};
std::array<double, 4> zncCorr{};
for (int i = 0; i < 4; ++i) {

Check failure on line 337 in PWGLF/TableProducer/Common/zdc2stagecalibration.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
znaCorr[i] = getGain(timeFromSOR, i, gainOK) * znaEnergy[i];
zncCorr[i] = getGain(timeFromSOR, i + 4, gainOK) * zncEnergy[i];
}
Expand Down Expand Up @@ -364,6 +371,37 @@
const double crossLookupYA = (znaCorr[2] - znaCorr[1]) / (znaCorr[2] + znaCorr[1]);
const double crossLookupXC = (zncCorr[3] - zncCorr[0]) / (zncCorr[3] + zncCorr[0]);
const double crossLookupYC = (zncCorr[2] - zncCorr[1]) / (zncCorr[2] + zncCorr[1]);
if (calibrationStage.value == 2 && useGainCallib.value && deriveSpatialCalib.value && !useSpatialCalib.value) {

std::array<double, 15> spatialMomentsA{};
std::array<double, 15> spatialMomentsC{};

int moment = 0;

for (int i = 0; i < 4; ++i) {
for (int j = i; j < 4; ++j) {
spatialMomentsA[moment] = znaCorr[i] * znaCorr[j];
spatialMomentsC[moment] = zncCorr[i] * zncCorr[j];
++moment;
}
}

for (int i = 0; i < 4; ++i) {
spatialMomentsA[10 + i] =
static_cast<double>(znaEnergycommon) * znaCorr[i];

spatialMomentsC[10 + i] =
static_cast<double>(zncEnergycommon) * zncCorr[i];
}

spatialMomentsA[14] = 1.0;
spatialMomentsC[14] = 1.0;

for (int i = 0; i < 15; ++i) {
histos.fill(HIST("SpatialCalibration/hSpatialMomentsZNA"), crossLookupXA, crossLookupYA, i + 0.5, spatialMomentsA[i]);
histos.fill(HIST("SpatialCalibration/hSpatialMomentsZNC"), crossLookupXC, crossLookupYC, i + 0.5, spatialMomentsC[i]);
}
}

bool spatialOK = true;
if (calibrationStage.value == 2 && useSpatialCalib.value) {
Expand Down
Loading