Skip to content

Commit 9aa8f01

Browse files
committed
moved duplicate checking to start of loop
1 parent 638d5b4 commit 9aa8f01

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

MyTasks/W/wMuonFwdEfficiency.cxx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ struct wMuonFwdEfficiency {
2020
{
2121
// define axes you want to use
2222
const AxisSpec axisCounter{1, 0, +1, ""};
23-
const AxisSpec axisEta{10, -4.0, -2.5, "#eta"};
23+
const AxisSpec axisEta{20, -4.0, -2.5, "#eta"};
2424
const AxisSpec axisPt{20, 0.0, +80.0, "p_{T} (GeV/c)"};
25-
const AxisSpec axisDeltaPt{24, 0.0, +6.0, "|p_{T}^{true} - p_{T}^{reco}|(GeV/c)"};
25+
const AxisSpec axisDeltaPt{40, 0.0, +20.0, "|p_{T}^{true} - p_{T}^{reco}|(GeV/c)"};
26+
const AxisSpec axisChi2{100, 0.0, +100.0, "#chi^2"};
2627

2728
// create histograms
2829
histos.add("eventCounterReco", "eventCounterReco", kTH1F, {axisCounter});
@@ -32,24 +33,35 @@ struct wMuonFwdEfficiency {
3233
histos.add("PtRecoHist", "PtRecoHist", kTH1F, {axisPt});
3334
histos.add("PtTruthHist", "PtTruthHist", kTH1F, {axisPt});
3435
histos.add("PtResolution", "PtResolution", kTH1F, {axisDeltaPt});
36+
histos.add("chi2", "chi2", kTH1F, {axisChi2});
3537
}
3638

3739
using muonTracks = soa::Join<aod::FwdTracks, aod::McFwdTrackLabels>;
3840

39-
void processReco(aod::Collision const& collision, muonTracks const& tracks, aod::McParticles const&)
41+
void processReco(aod::Collision const& collision, muonTracks const& tracks, aod::McParticles const&) // run with collisions
42+
//void processReco(muonTracks const& tracks, aod::McParticles const&) // run without collisions
4043
{
4144
histos.fill(HIST("eventCounterReco"), 0.5);
4245
for (auto& track : tracks) {
4346
if(track.has_mcParticle()){
4447
auto mcParticle = track.mcParticle();
4548
auto statusCode = abs(mcParticle.getGenStatusCode());
46-
if (abs(mcParticle.pdgCode())==13) {
49+
50+
if (abs(mcParticle.pdgCode())==13) { // check if associated MC track is a muon
51+
// check if duplicate (ambiguous track)
52+
auto muID = mcParticle.globalIndex();
53+
int occuranceCount = count(selectedTracksID.begin(), selectedTracksID.end(), muID);
54+
55+
if (occuranceCount > 0) { // if already selected, move on
56+
continue;
57+
}
58+
59+
// check if muon is from W decay
4760
auto muMother = mcParticle.mothers_first_as<aod::McParticles>();
4861
auto muMotherPDG = abs(muMother.pdgCode());
49-
auto muID = mcParticle.globalIndex();
62+
5063
bool hasWmother = false;
51-
std::cout << "==== Mu decay chain: 13(" << mcParticle.eta() << "," << mcParticle.pt() << ")"
52-
<< " <- " << muMotherPDG << "(" << muMother.eta() << "," << muMother.pt() << ")";
64+
std::cout << "==== Mu decay chain: 13 <- " << muMotherPDG;
5365

5466
if (muMotherPDG != 24) {
5567
// check if W mother in decay chain
@@ -59,7 +71,7 @@ struct wMuonFwdEfficiency {
5971
while (mcPart.has_mothers()) {
6072
mcPart = *(mcPart.mothers_first_as<aod::McParticles>());
6173
mcPartPDG = abs(mcPart.pdgCode());
62-
std::cout << " <- " << mcPartPDG << "(" << mcPart.eta() << "," << mcPart.pt() << ")";
74+
std::cout << " <- " << mcPartPDG;
6375

6476
if (mcPartPDG == 24) {
6577
hasWmother = true;
@@ -73,15 +85,11 @@ struct wMuonFwdEfficiency {
7385
std::cout << std::endl;
7486

7587
if (hasWmother) {
76-
// check if duplicate (ambiguous track)
77-
int occuranceCount = count(selectedTracksID.begin(), selectedTracksID.end(), muID);
78-
79-
if (occuranceCount < 1) {
80-
selectedTracksID.emplace(selectedTracksID.end(), muID); // add track ID to selected tracks
81-
histos.fill(HIST("PtRecoHist"), mcParticle.pt());
82-
histos.fill(HIST("yPtRecoHist"), mcParticle.pt(), mcParticle.eta());
83-
histos.fill(HIST("PtResolution"), abs(mcParticle.pt()-track.pt()));
84-
}
88+
selectedTracksID.emplace(selectedTracksID.end(), muID); // add track ID to already processed selected tracks
89+
histos.fill(HIST("PtRecoHist"), mcParticle.pt());
90+
histos.fill(HIST("yPtRecoHist"), mcParticle.pt(), mcParticle.eta());
91+
histos.fill(HIST("PtResolution"), abs(mcParticle.pt()-track.pt()));
92+
histos.fill(HIST("chi2"), track.chi2());
8593
}
8694
}
8795
}

0 commit comments

Comments
 (0)