10 m_truthClassifier(
"MCTruthClassifier",this) {
14 declareProperty(
"veto_lepton_origins",
m_lepton_veto_origins = {3, 5, 6, 7, 8, 9, 23, 24, 25, 26, 27, 28, 29, 30, 31,
15 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42});
16 declareProperty(
"preferred_lepton_origins",
m_preferred_lepton_origins = {1, 2, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21});
18 declareProperty(
"veto_photon_origins",
m_veto_photon_origins = {9, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 42});
35 ATH_MSG_ERROR(origin <<
" in both lepton origin and lepton veto origin, this is not correct.");
51 const std::vector<TLorentzVector>* leptons,
52 const std::vector<TLorentzVector>* photons,
53 const std::vector<int>* lepton_origins,
54 const std::vector<int>* photon_origins)
const {
55 std::vector<float> photon_pts;
58 return StatusCode::SUCCESS;
65 const std::vector<TLorentzVector>* leptons,
66 const std::vector<TLorentzVector>* photons,
67 const std::vector<int>* lepton_origins,
68 const std::vector<int>* photon_origins)
const {
69 std::map<float, std::vector<float> > photon_pt_map;
72 return StatusCode::SUCCESS;
79 const std::vector<TLorentzVector>* leptons,
80 const std::vector<TLorentzVector>* photons,
81 const std::vector<int>* lepton_origins,
82 const std::vector<int>* photon_origins)
const {
84 return StatusCode::SUCCESS;
92 const std::vector<float>& drCuts,
93 const std::vector<TLorentzVector>* leptons,
94 const std::vector<TLorentzVector>* photons,
95 const std::vector<int>* lepton_origins,
96 const std::vector<int>* photon_origins)
const {
98 std::vector<TLorentzVector> good_leptons;
99 std::vector<TLorentzVector> good_photons;
100 ANA_CHECK(
setInput(good_leptons,good_photons,leptons,photons,lepton_origins,photon_origins));
103 for (
const auto& drCut : drCuts) {
104 result[drCut] = std::vector<float>();
105 for (
const auto&
photon : good_photons) {
106 bool tooCloseToLepton =
false;
108 const float dr =
photon.DeltaR(good_leptons[i_lep]);
110 tooCloseToLepton =
true;
114 if (!tooCloseToLepton)
result[drCut].push_back(
photon.Pt());
120 return StatusCode::SUCCESS;
126 std::vector<TLorentzVector>& photons_out,
127 const std::vector<TLorentzVector>* lepton_p4s,
128 const std::vector<TLorentzVector>* photon_p4s,
129 const std::vector<int>* lepton_origins,
130 const std::vector<int>* photon_origins)
const {
136 if(lepton_p4s==0 || photon_p4s==0){
146 if(lepton_origins!=0){
150 leptons_out = *lepton_p4s;
157 if(photon_origins!=0){
161 photons_out = *photon_p4s;
165 ATH_MSG_DEBUG(
"VGammaORTool::setInput" <<
": Found " << photons_out.size() <<
" photons.");
166 ATH_MSG_DEBUG(
"VGammaORTool::setInput" <<
": Found " << leptons_out.size() <<
" leptons.");
170 "VGammaORTool::setInput" <<
": Found " << leptons_out.size() <<
" leptons but expected " <<
m_n_leptons <<
".");
173 return StatusCode::SUCCESS;
179 const std::vector<int>& photon_origins)
const {
181 if (photon_candidates.size() != photon_origins.size()) {
183 "VGammaORTool::filterPhotonOrigins" <<
": size of photon candidates (" << photon_candidates.size() <<
") different from number of photon origins (" << photon_origins.size() <<
187 std::vector<TLorentzVector> photon_p4s;
188 for (
uint i = 0;
i < photon_candidates.size();
i++) {
189 const TLorentzVector p4 = photon_candidates[
i];
190 const int p_origin = photon_origins[
i];
194 photon_p4s.push_back(p4);
202 const std::vector<int>& lepton_origins)
const {
204 if (lepton_candidates.size() != lepton_origins.size()) {
206 "VGammaORTool::filterLeptonOrigins" <<
": size of lepton candidates (" << lepton_candidates.size() <<
") different from number of lepton origins (" << lepton_origins.size() <<
209 std::vector<TLorentzVector> lepton_p4s;
210 std::vector<TLorentzVector> leptons_not_vetoed_p4s;
212 for (
uint i = 0;
i < lepton_candidates.size();
i++) {
213 const TLorentzVector p4 = lepton_candidates[
i];
214 const int p_origin = lepton_origins[
i];
217 lepton_p4s.push_back(p4);
229 leptons_not_vetoed_p4s.push_back(p4);
235 for (
const auto&
l : leptons_not_vetoed_p4s) {
236 lepton_p4s.push_back(
l);
245 std::vector<const xAOD::TruthParticle*> tau_candidates;
246 std::vector<const xAOD::TruthParticle*> elmu_candidates;
247 for (
const auto *
p : truthParticles) {
254 bool childIsTau =
false;
255 bool hasChildren =
false;
257 for (
uint i = 0;
i <
p->nChildren();
i++) {
258 if (
p->child(
i) ==
nullptr)
continue;
261 if (
p->child(
i)->pdgId() ==
p->pdgId()) {
266 if (hasChildren && !childIsTau) tau_candidates.push_back(
p);
270 elmu_candidates.push_back(
p);
274 sort(tau_candidates.begin(), tau_candidates.end(),
276 return p1->pt() > p2->pt();
278 sort(elmu_candidates.begin(), elmu_candidates.end(),
280 return p1->pt() > p2->pt();
283 std::vector<const xAOD::TruthParticle*> lepton_candidates(tau_candidates);
284 lepton_candidates.insert(lepton_candidates.end(), elmu_candidates.begin(), elmu_candidates.end());
286 std::vector<TLorentzVector> lepton_p4s;
287 std::vector<int> lepton_origins;
289 for (
const auto&
p : lepton_candidates) {
290 const unsigned int origin = classifierParticleOriginAcc(*
p);
291 lepton_origins.push_back(origin);
292 lepton_p4s.push_back(
p->p4());
299 std::vector<TLorentzVector> photon_p4s;
300 std::vector<int> photon_origins;
301 for (
const auto *
p : truthParticles) {
308 const unsigned int origin = classifierParticleOriginAcc(*
p);
309 photon_origins.push_back(origin);
310 photon_p4s.push_back(
p->p4());
334 ATH_MSG_ERROR(
"photon_pT_cuts needs to be a non-empty list, when inOverlap is called, set as property or in constructor.");
351 float epsilon)
const {
357 std::map<float, float> dr_to_pt;
358 for (
const auto *
p : truthParticles) {
365 const float dRgamma =
photon.p4().DeltaR(
p->p4());
369 if (dr_to_pt.count(dRgamma) > 0) {
370 dr_to_pt[dRgamma] +=
p->pt();
372 dr_to_pt[dRgamma] =
p->pt();
378 for (
const auto& pair : dr_to_pt) {
379 sumPt += pair.second;
380 const float dRgamma = pair.first;
392 return epsilon * TMath::Power((1 - TMath::Cos(dR)) / (1 - TMath::Cos(dR0)), exponent);