Skip to content

Commit 944d27f

Browse files
committed
Manually loop over ditracks, and reset event counter before loop
1 parent cf45a87 commit 944d27f

File tree

1 file changed

+39
-36
lines changed

1 file changed

+39
-36
lines changed

PWGDQ/Tasks/myDitracksAnalyzer.cxx

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -60,48 +60,51 @@ struct myDitracksAnalyzer {
6060
histos.add("ND0Cand", "ND0Cand", kTH1I, {axisMultLow});
6161
}
6262

63-
void process(myDitracks::iterator const& ditrack)
63+
void process(myDitracks const& ditracks)
6464
{
65-
// Only process pairs with correct charge
66-
if (ditrack.sign() != fConfigPairSign.value) {
67-
return;
68-
}
65+
fEventCount.clear();
66+
for (auto &ditrack : ditracks) {
67+
// Only process pairs with correct charge
68+
if (ditrack.sign() != fConfigPairSign.value) {
69+
return;
70+
}
6971

70-
// Fill histograms before cuts
71-
histos.get<TH1>(HIST("Mass_BeforeCuts"))->Fill(ditrack.mass());
72-
histos.get<TH1>(HIST("MassD0region_BeforeCuts"))->Fill(ditrack.mass());
73-
histos.get<TH1>(HIST("Pt_BeforeCuts"))->Fill(ditrack.pt());
72+
// Fill histograms before cuts
73+
histos.get<TH1>(HIST("Mass_BeforeCuts"))->Fill(ditrack.mass());
74+
histos.get<TH1>(HIST("MassD0region_BeforeCuts"))->Fill(ditrack.mass());
75+
histos.get<TH1>(HIST("Pt_BeforeCuts"))->Fill(ditrack.pt());
7476

75-
// Apply cuts
76-
if (!ditrack.pairFilterMap_bit(fConfigPairFilterBit)) {
77-
return;
78-
}
79-
if (ditrack.mass() < fConfigLowMass.value || ditrack.mass() >= fConfigHighMass.value) {
80-
return;
81-
}
77+
// Apply cuts
78+
if (!ditrack.pairFilterMap_bit(fConfigPairFilterBit)) {
79+
return;
80+
}
81+
if (ditrack.mass() < fConfigLowMass.value || ditrack.mass() >= fConfigHighMass.value) {
82+
return;
83+
}
8284

83-
// Fill pair-level histograms after cuts
84-
histos.get<TH1>(HIST("Mass"))->Fill(ditrack.mass());
85-
histos.get<TH1>(HIST("MassD0region"))->Fill(ditrack.mass());
86-
histos.get<TH1>(HIST("Pt"))->Fill(ditrack.pt());
85+
// Fill pair-level histograms after cuts
86+
histos.get<TH1>(HIST("Mass"))->Fill(ditrack.mass());
87+
histos.get<TH1>(HIST("MassD0region"))->Fill(ditrack.mass());
88+
histos.get<TH1>(HIST("Pt"))->Fill(ditrack.pt());
8789

88-
if (fEventCount.find(ditrack.reducedeventId()) != fEventCount.end()) {
89-
LOGF(info, "!!! This event (%d) has been encountered %d times before", ditrack.reducedeventId(), fEventCount[ditrack.reducedeventId()]);
90-
// Remove one count from the old number
91-
int oldBin = histos.get<TH1>(HIST("ND0Cand"))->FindBin(fEventCount[ditrack.reducedeventId()]);
92-
histos.get<TH1>(HIST("ND0Cand"))->SetBinContent(oldBin, histos.get<TH1>(HIST("ND0Cand"))->GetBinContent(oldBin) - 1);
93-
// Update counter and histogram
94-
fEventCount[ditrack.reducedeventId()] += 1;
95-
histos.get<TH1>(HIST("ND0Cand"))->Fill(fEventCount[ditrack.reducedeventId()]);
96-
} else {
97-
// First time this event is encountered, fill event-level histograms
98-
fEventCount.insert({ditrack.reducedeventId(), 1});
99-
histos.get<TH1>(HIST("ND0Cand"))->Fill(1);
90+
if (fEventCount.find(ditrack.reducedeventId()) != fEventCount.end()) {
91+
LOGF(info, "!!! This event (%d) has been encountered %d times before", ditrack.reducedeventId(), fEventCount[ditrack.reducedeventId()]);
92+
// Remove one count from the old number
93+
int oldBin = histos.get<TH1>(HIST("ND0Cand"))->FindBin(fEventCount[ditrack.reducedeventId()]);
94+
histos.get<TH1>(HIST("ND0Cand"))->SetBinContent(oldBin, histos.get<TH1>(HIST("ND0Cand"))->GetBinContent(oldBin) - 1);
95+
// Update counter and histogram
96+
fEventCount[ditrack.reducedeventId()] += 1;
97+
histos.get<TH1>(HIST("ND0Cand"))->Fill(fEventCount[ditrack.reducedeventId()]);
98+
} else {
99+
// First time this event is encountered, fill event-level histograms
100+
fEventCount.insert({ditrack.reducedeventId(), 1});
101+
histos.get<TH1>(HIST("ND0Cand"))->Fill(1);
100102

101-
histos.get<TH1>(HIST("VtxNContribReal"))->Fill(ditrack.multNTracksPV());
102-
histos.get<TH1>(HIST("MultFT0A"))->Fill(ditrack.multFT0A());
103-
histos.get<TH1>(HIST("MultFT0C"))->Fill(ditrack.multFT0C());
104-
histos.get<TH1>(HIST("MultFV0A"))->Fill(ditrack.multFV0A());
103+
histos.get<TH1>(HIST("VtxNContribReal"))->Fill(ditrack.multNTracksPV());
104+
histos.get<TH1>(HIST("MultFT0A"))->Fill(ditrack.multFT0A());
105+
histos.get<TH1>(HIST("MultFT0C"))->Fill(ditrack.multFT0C());
106+
histos.get<TH1>(HIST("MultFV0A"))->Fill(ditrack.multFV0A());
107+
}
105108
}
106109
}
107110
};

0 commit comments

Comments
 (0)