Skip to content

Commit dfc0801

Browse files
authored
[Common] add efficiency to mean-pt (#13913)
1 parent 709e8e7 commit dfc0801

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

Common/Core/FFitWeights.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ void FFitWeights::fillWeights(float centrality, float qn, int nh, const char* pf
104104
th2->Fill(centrality, qn);
105105
};
106106

107-
void FFitWeights::fillPt(float centrality, float pt, bool first)
107+
void FFitWeights::fillPt(float centrality, float pt, float weight, bool first)
108108
{
109109
if (first) {
110-
ptProfCent->Fill(centrality, pt);
110+
ptProfCent->Fill(centrality, pt, weight);
111111
} else {
112-
h2ptCent->Fill(centrality, pt);
112+
h2ptCent->Fill(centrality, pt, weight);
113113
}
114114
};
115115
float FFitWeights::getPtMult(float centrality)

Common/Core/FFitWeights.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FFitWeights : public TNamed
4141

4242
void init();
4343
void fillWeights(float centrality, float qn, int nh, const char* pf = "");
44-
void fillPt(float centrality, float pt, bool first);
44+
void fillPt(float centrality, float pt, float weight, bool first);
4545
float getPtMult(float centrality);
4646
TObjArray* getDataArray() { return fW_data; }
4747

Common/TableProducer/eseTableProducer.cxx

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,19 @@ struct EseTableProducer {
105105

106106
Service<o2::ccdb::BasicCCDBManager> ccdb;
107107

108+
struct Config {
109+
TH1D* mEfficiency = nullptr;
110+
bool correctionsLoaded = false;
111+
} cfg;
112+
108113
Configurable<float> cfgVtxZ{"cfgVtxZ", 10.0f, "max z vertex position"};
109114
Configurable<float> cfgEta{"cfgEta", 0.8f, "max eta"};
110115
Configurable<float> cfgPtmin{"cfgPtmin", 0.2f, "min pt"};
111116
Configurable<float> cfgPtmax{"cfgPtmax", 5.0f, "max pt"};
112117
Configurable<float> cfgChi2PrITSCls{"cfgChi2PrITSCls", 4.0f, "max chi2 per ITS cluster"};
113118
Configurable<float> cfgChi2PrTPCCls{"cfgChi2PrTPCCls", 2.5f, "max chi2 per TPC cluster"};
114119
Configurable<float> cfgDCAz{"cfgDCAz", 2.0f, "max DCAz cut"};
120+
Configurable<std::string> cfgEfficiency{"cfgEfficiency", "", "CCDB path to efficiency object"};
115121

116122
// o2::framework::expressions::Filter collisionFilter = nabs(aod::collision::posZ) < cfgVtxZ;
117123
o2::framework::expressions::Filter trackFilter = nabs(aod::track::eta) < cfgEta && aod::track::pt > cfgPtmin&& aod::track::pt < cfgPtmax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == static_cast<uint8_t>(true))) && (aod::track::itsChi2NCl < cfgChi2PrITSCls) && (aod::track::tpcChi2NCl < cfgChi2PrTPCCls) && nabs(aod::track::dcaZ) < cfgDCAz;
@@ -158,6 +164,14 @@ struct EseTableProducer {
158164
LOGF(fatal, "failed loading qSelection with ese flag");
159165
LOGF(info, "successfully loaded qSelection");
160166
}
167+
if (!cfgEfficiency.value.empty()) {
168+
cfg.mEfficiency = ccdb->getForTimeStamp<TH1D>(cfgEfficiency, timestamp);
169+
if (cfg.mEfficiency == nullptr) {
170+
LOGF(fatal, "Could not load efficiency histogram from %s", cfgEfficiency.value.c_str());
171+
}
172+
LOGF(info, "Loaded efficiency histogram from %s (%p)", cfgEfficiency.value.c_str(), (void*)cfg.mEfficiency);
173+
cfg.correctionsLoaded = true;
174+
}
161175
}
162176

163177
float calcRedqn(const float& Qx, const float& Qy, const float& Mult)
@@ -256,17 +270,32 @@ struct EseTableProducer {
256270
};
257271

258272
template <typename TTracks, typename Cent>
259-
double calculateMeanPt(TTracks const& tracks, Cent const& centrality)
273+
std::pair<double, double> calculateMeanPt(TTracks const& tracks, Cent const& centrality)
260274
{
261-
std::vector<double> meanPtEvent;
275+
double meanPtEvent{0.0};
276+
double effEvent{0.0};
262277
for (const auto& track : tracks) {
263-
meanPtEvent.push_back(track.pt());
264-
weightsFFit->fillPt(centrality, track.pt(), true);
278+
double weff = getEfficiency(track);
279+
effEvent += weff;
280+
meanPtEvent += track.pt() * weff;
265281
}
266-
if (meanPtEvent.empty())
267-
return 0.0;
268-
auto mean = std::accumulate(meanPtEvent.begin(), meanPtEvent.end(), 0.0) / meanPtEvent.size();
269-
return mean;
282+
if (meanPtEvent == 0.0)
283+
return std::make_pair(0.0, 0.0);
284+
double mean = meanPtEvent / effEvent;
285+
weightsFFit->fillPt(centrality, mean, effEvent, true);
286+
return std::make_pair(mean, effEvent);
287+
}
288+
289+
template <typename TTrack>
290+
double getEfficiency(TTrack track)
291+
{
292+
double eff = 1.;
293+
if (cfg.mEfficiency)
294+
eff = cfg.mEfficiency->GetBinContent(cfg.mEfficiency->FindBin(track.pt()));
295+
if (eff == 0)
296+
return -1.;
297+
else
298+
return 1. / eff;
270299
}
271300

272301
void processESE(CollWithMults::iterator const& collision, aod::BCsWithTimestamps const&, aod::FV0As const&, aod::FT0s const&)
@@ -319,11 +348,11 @@ struct EseTableProducer {
319348
registry.fill(HIST("hMeanPtStat"), 1.5);
320349
} else {
321350
const auto avgpt = eventShape->getPtMult(centrality);
322-
if (mean == 0.0) {
351+
if (mean.first == 0.0) {
323352
registry.fill(HIST("hMeanPtStat"), cfgMeanPt == Step1 ? 2.5 : 3.5);
324353
} else {
325-
const auto binval = (mean - avgpt) / avgpt;
326-
weightsFFit->fillPt(centrality, binval, false);
354+
const auto binval = (mean.first - avgpt) / avgpt;
355+
weightsFFit->fillPt(centrality, binval, mean.second, false);
327356
meanPt[0] = binval;
328357
if (cfgMeanPt == Step1) {
329358
registry.fill(HIST("hMeanPtStat"), 2.5);

0 commit comments

Comments
 (0)