Skip to content

Commit f0145ae

Browse files
committed
Fix normalisation calculation
1 parent 085f5bf commit f0145ae

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

Common/Core/ZorroSummary.cxx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,26 @@ Long64_t ZorroSummary::Merge(TCollection* list)
5656
return n;
5757
}
5858

59-
double ZorroSummary::getNormalisationFactor(int toiId) const
59+
std::unordered_map<int, std::vector<double>> ZorroSummary::getPerRunNormalisationFactors() const
6060
{
61-
double totalTOI{0.}, totalTVX{0.};
62-
ULong64_t totalAnalysedTOI{0};
63-
for (const auto& [runNumber, toiCounters] : mTOIcounters) {
64-
totalTOI += toiCounters.at(toiId);
65-
}
66-
for (const auto& [runNumber, tvxCounters] : mTVXcounters) {
67-
totalTVX += tvxCounters;
68-
}
61+
std::unordered_map<int, std::vector<double>> runNormalisations;
6962
for (const auto& [runNumber, analysedTOIcounters] : mAnalysedTOIcounters) {
70-
totalAnalysedTOI += analysedTOIcounters.at(toiId);
63+
const double tvxCount = mTVXcounters.at(runNumber);
64+
for (int toiId = 0; toiId < mNtois; ++toiId) {
65+
double toiCount = mTOIcounters.at(runNumber).at(toiId);
66+
ULong64_t analysedTOI = analysedTOIcounters.at(toiId);
67+
runNormalisations[runNumber].push_back(tvxCount * analysedTOI / toiCount);
68+
}
7169
}
70+
return runNormalisations;
71+
}
7272

73-
return totalTVX * totalAnalysedTOI / totalTOI;
73+
double ZorroSummary::getNormalisationFactor(int toiId) const
74+
{
75+
double normalisationFactor{0.};
76+
auto runNormalisations = getPerRunNormalisationFactors();
77+
for (const auto& [runNumber, normalisations] : runNormalisations) {
78+
normalisationFactor += normalisations.at(toiId);
79+
}
80+
return normalisationFactor;
7481
}

Common/Core/ZorroSummary.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class ZorroSummary : public TNamed
5454
mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber];
5555
}
5656
double getNormalisationFactor(int toiId) const;
57+
std::unordered_map<int, std::vector<double>> getPerRunNormalisationFactors() const;
58+
5759
void increaseTOIcounter(int runNumber, int toiId)
5860
{
5961
if (runNumber != mRunNumber) {

0 commit comments

Comments
 (0)