Skip to content

Commit e30eaa5

Browse files
committed
Add truth charge column
1 parent 5304339 commit e30eaa5

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

PWGJE/TableProducer/EECTreeCreator.cxx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ DECLARE_SOA_COLUMN(TruthPt, truthPt, std::vector<float>);
3232
DECLARE_SOA_COLUMN(TruthEta, truthEta, std::vector<float>);
3333
DECLARE_SOA_COLUMN(TruthPhi, truthPhi, std::vector<float>);
3434
DECLARE_SOA_COLUMN(TruthE, truthE, std::vector<float>);
35+
DECLARE_SOA_COLUMN(TruthCharge, truthCharge, std::vector<int>);
3536
DECLARE_SOA_COLUMN(PDG, pdg, std::vector<int>);
3637
}
3738

@@ -48,6 +49,7 @@ DECLARE_SOA_TABLE(TREE, "AOD", "TREE",
4849
tree::TruthEta,
4950
tree::TruthPhi,
5051
tree::TruthE,
52+
tree::TruthCharge,
5153
tree::PDG);
5254
}
5355

@@ -78,6 +80,16 @@ struct EECTreeCreatorTask
7880
return std::abs(charge) >= chargeUnit;
7981
}
8082

83+
int getCharge(int code) {
84+
auto p = pdg->GetParticle(code);
85+
if (!p) {
86+
LOG(fatal) << "Cannot find particle with PDG code " << code;
87+
return 0;
88+
}
89+
auto charge = p->Charge() / 3.0;
90+
return std::lround(charge);
91+
}
92+
8193
void init(InitContext const&)
8294
{
8395
eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(eventSelections);
@@ -96,6 +108,7 @@ struct EECTreeCreatorTask
96108
std::vector<int> detCharge;
97109

98110
std::vector<float> truthPt, truthEta, truthPhi, truthE;
111+
std::vector<int> truthCharge;
99112
std::vector<int> pdg;
100113

101114
for (auto const& track : tracks)
@@ -129,11 +142,12 @@ struct EECTreeCreatorTask
129142
truthEta.push_back(p.eta());
130143
truthPhi.push_back(p.phi());
131144
truthE.push_back(p.e());
145+
truthCharge.push_back(getCharge(p.pdgCode()));
132146
pdg.push_back(p.pdgCode());
133147
}
134148
}
135149

136-
tree( collision.posZ(), w, pthard, collision.multFT0C(), detPt, detEta, detPhi, detCharge, truthPt, truthEta, truthPhi, truthE, pdg);}
150+
tree( collision.posZ(), w, pthard, collision.multFT0C(), detPt, detEta, detPhi, detCharge, truthPt, truthEta, truthPhi, truthE, truthCharge, pdg);}
137151

138152
PROCESS_SWITCH(EECTreeCreatorTask, processMC, "MC processing", true);
139153
};

0 commit comments

Comments
 (0)