Skip to content

Commit ae0e6c6

Browse files
Use TEfficiency for efficiencies (#7321)
1 parent f017821 commit ae0e6c6

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Detectors/GlobalTracking/include/GlobalTracking/MatchITSTPCQC.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <TH1F.h>
2020
#include <TH2F.h>
21+
#include <TEfficiency.h>
2122
#include <TObjArray.h>
2223
#include "DataFormatsGlobalTracking/RecoContainer.h"
2324
#include "Framework/ProcessingContext.h"
@@ -41,7 +42,8 @@ class MatchITSTPCQC
4142
void finalize();
4243
void reset();
4344
TH1F* getHistoPtTPC() const { return mPtTPC; }
44-
TH1F* getHistoFractionITSTPCmatch() const { return mFractionITSTPCmatch; }
45+
TEfficiency* getFractionITSTPCmatch() const { return mFractionITSTPCmatch; }
46+
TEfficiency* getHistoFractionITSTPCmatch() const { return mFractionITSTPCmatch; }
4547
TH1F* getHistoPt() const { return mPt; }
4648
TH1F* getHistoEta() const { return mEta; }
4749
TH1F* getHistoChi2Matching() const { return mChi2Matching; }
@@ -83,7 +85,7 @@ class MatchITSTPCQC
8385
float mBz = 0; ///< nominal Bz
8486

8587
TH1F* mPtTPC = nullptr;
86-
TH1F* mFractionITSTPCmatch = nullptr;
88+
TEfficiency* mFractionITSTPCmatch = nullptr;
8789
TH1F* mPt = nullptr;
8890
TH1F* mEta = nullptr;
8991
TH1F* mChi2Matching = nullptr;

Detectors/GlobalTracking/src/MatchITSTPCQC.cxx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ void MatchITSTPCQC::deleteHistograms()
4444
void MatchITSTPCQC::reset()
4545
{
4646
mPtTPC->Reset();
47-
mFractionITSTPCmatch->Reset();
4847
mPt->Reset();
4948
mEta->Reset();
5049
mChi2Matching->Reset();
@@ -58,13 +57,16 @@ bool MatchITSTPCQC::init()
5857
{
5958

6059
mPtTPC = new TH1F("mPtTPC", "Pt distribution of TPC tracks; Pt; dNdPt", 100, 0.f, 20.f);
61-
mFractionITSTPCmatch = new TH1F("mFractionITSTPCmatch", "Fraction of ITSTPC matched tracks vs Pt; Pt; Eff", 100, 0.f, 20.f);
60+
mFractionITSTPCmatch = new TEfficiency("mFractionITSTPCmatch", "Fraction of ITSTPC matched tracks vs Pt; Pt; Eff", 100, 0.f, 20.f);
6261
mPt = new TH1F("mPt", "Pt distribution of matched tracks; Pt; dNdPt", 100, 0.f, 20.f);
6362
mEta = new TH1F("mEta", "Eta distribution of matched tracks; Eta; dNdEta", 100, -1.2f, 1.2f);
6463
mChi2Matching = new TH1F("mChi2Matching", "Chi2 of matching; chi2", 200, 0, 20);
6564
mChi2Refit = new TH1F("mChi2Refit", "Chi2 of refit; chi2", 200, 0, 20);
6665
mTimeResVsPt = new TH2F("mTimeResVsPt", "Time resolution vs Pt; Pt; time res", 100, 0.f, 20.f, 100, 0.f, 2.f);
6766

67+
mPtTPC->Sumw2();
68+
mPt->Sumw2();
69+
6870
mSrc &= mAllowedSources;
6971

7072
if ((mSrc[GID::Source::ITSTPC] == 0 || mSrc[GID::Source::TPC] == 0)) {
@@ -110,7 +112,7 @@ void MatchITSTPCQC::run(o2::framework::ProcessingContext& ctx)
110112
mChi2Matching->Fill(trk.getChi2Match());
111113
mChi2Refit->Fill(trk.getChi2Refit());
112114
mTimeResVsPt->Fill(trkTpc.getPt(), trk.getTimeMUS().getTimeStampError());
113-
LOG(INFO) << "*** chi2Matching = " << trk.getChi2Match() << ", chi2refit = " << trk.getChi2Refit() << ", timeResolution = " << trk.getTimeMUS().getTimeStampError();
115+
LOG(DEBUG) << "*** chi2Matching = " << trk.getChi2Match() << ", chi2refit = " << trk.getChi2Refit() << ", timeResolution = " << trk.getTimeMUS().getTimeStampError();
114116
++mNITSTPCSelectedTracks;
115117
}
116118
}
@@ -145,9 +147,14 @@ bool MatchITSTPCQC::selectTrack(o2::tpc::TrackTPC const& track)
145147
void MatchITSTPCQC::finalize()
146148
{
147149

150+
// first we use mPt and mPtTPC to set the TEfficiency; later they are scaled
151+
if (!mFractionITSTPCmatch->SetTotalHistogram(*mPtTPC, "") ||
152+
!mFractionITSTPCmatch->SetPassedHistogram(*mPt, "")) {
153+
LOG(FATAL) << "Something wrong when defining the efficiency histograms!";
154+
}
155+
148156
float scaleFactTPC = 1. / mNTPCSelectedTracks;
149157
float scaleFactITSTPC = 1. / mNITSTPCSelectedTracks;
150-
mFractionITSTPCmatch->Divide(mPt, mPtTPC, 1, 1, "b");
151158
mPtTPC->Scale(scaleFactTPC);
152159
mPt->Scale(scaleFactITSTPC);
153160
mEta->Scale(scaleFactITSTPC);

0 commit comments

Comments
 (0)