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,
36 ATH_MSG_ERROR(origin <<
" in both lepton origin and lepton veto origin, this is not correct.");
52 const std::vector<TLorentzVector>* leptons,
53 const std::vector<TLorentzVector>* photons,
54 const std::vector<int>* lepton_origins,
55 const std::vector<int>* photon_origins)
const {
56 std::vector<float> photon_pts;
59 return StatusCode::SUCCESS;
66 const std::vector<TLorentzVector>* leptons,
67 const std::vector<TLorentzVector>* photons,
68 const std::vector<int>* lepton_origins,
69 const std::vector<int>* photon_origins)
const {
70 std::map<float, std::vector<float> > photon_pt_map;
73 return StatusCode::SUCCESS;
80 const std::vector<TLorentzVector>* leptons,
81 const std::vector<TLorentzVector>* photons,
82 const std::vector<int>* lepton_origins,
83 const std::vector<int>* photon_origins)
const {
85 return StatusCode::SUCCESS;
93 const std::vector<float>& drCuts,
94 const std::vector<TLorentzVector>* leptons,
95 const std::vector<TLorentzVector>* photons,
96 const std::vector<int>* lepton_origins,
97 const std::vector<int>* photon_origins)
const {
99 std::vector<TLorentzVector> good_leptons;
100 std::vector<TLorentzVector> good_photons;
101 ANA_CHECK(
setInput(good_leptons,good_photons,leptons,photons,lepton_origins,photon_origins));
104 for (
const auto& drCut : drCuts) {
105 result[drCut] = std::vector<float>();
106 for (
const auto&
photon : good_photons) {
107 bool tooCloseToLepton =
false;
109 const float dr =
photon.DeltaR(good_leptons[i_lep]);
111 tooCloseToLepton =
true;
115 if (!tooCloseToLepton) {
123 return StatusCode::SUCCESS;
129 std::vector<TLorentzVector>& photons_out,
130 const std::vector<TLorentzVector>* lepton_p4s,
131 const std::vector<TLorentzVector>* photon_p4s,
132 const std::vector<int>* lepton_origins,
133 const std::vector<int>* photon_origins)
const {
139 if(lepton_p4s==0 || photon_p4s==0){
149 if(lepton_origins!=0){
153 leptons_out = *lepton_p4s;
160 if(photon_origins!=0){
164 photons_out = *photon_p4s;
168 ATH_MSG_DEBUG(
"VGammaORTool::setInput" <<
": Found " << photons_out.size() <<
" photons.");
169 ATH_MSG_DEBUG(
"VGammaORTool::setInput" <<
": Found " << leptons_out.size() <<
" leptons.");
173 "VGammaORTool::setInput" <<
": Found " << leptons_out.size() <<
" leptons but expected " <<
m_n_leptons <<
".");
176 return StatusCode::SUCCESS;
182 const std::vector<int>& photon_origins)
const {
184 if (photon_candidates.size() != photon_origins.size()) {
186 "VGammaORTool::filterPhotonOrigins" <<
": size of photon candidates (" << photon_candidates.size() <<
") different from number of photon origins (" << photon_origins.size() <<
190 std::vector<TLorentzVector> photon_p4s;
191 for (
uint i = 0;
i < photon_candidates.size();
i++) {
192 const TLorentzVector p4 = photon_candidates[
i];
193 const int p_origin = photon_origins[
i];
197 photon_p4s.push_back(p4);
205 const std::vector<int>& lepton_origins)
const {
207 if (lepton_candidates.size() != lepton_origins.size()) {
209 "VGammaORTool::filterLeptonOrigins" <<
": size of lepton candidates (" << lepton_candidates.size() <<
") different from number of lepton origins (" << lepton_origins.size() <<
212 std::vector<TLorentzVector> lepton_p4s;
213 std::vector<TLorentzVector> leptons_not_vetoed_p4s;
215 for (
uint i = 0;
i < lepton_candidates.size();
i++) {
216 const TLorentzVector p4 = lepton_candidates[
i];
217 const int p_origin = lepton_origins[
i];
220 lepton_p4s.push_back(p4);
232 leptons_not_vetoed_p4s.push_back(p4);
238 for (
const auto&
l : leptons_not_vetoed_p4s) {
239 lepton_p4s.push_back(
l);
250 std::vector<const xAOD::TruthParticle*> tau_candidates;
251 std::vector<const xAOD::TruthParticle*> elmu_candidates;
252 for (
const auto *
p : truthParticles) {
262 if (std::abs(
p->pdgId()) == 15) {
263 bool childIsTau =
false;
264 bool hasChildren =
false;
266 for (
uint i = 0;
i <
p->nChildren();
i++) {
267 if (
p->child(
i) ==
nullptr)
continue;
270 if (
p->child(
i)->pdgId() ==
p->pdgId()) {
275 if (hasChildren && !childIsTau) {
276 tau_candidates.push_back(
p);
281 elmu_candidates.push_back(
p);
285 sort(tau_candidates.begin(), tau_candidates.end(),
287 return p1->pt() > p2->pt();
289 sort(elmu_candidates.begin(), elmu_candidates.end(),
291 return p1->pt() > p2->pt();
294 std::vector<const xAOD::TruthParticle*> lepton_candidates(tau_candidates);
295 lepton_candidates.insert(lepton_candidates.end(), elmu_candidates.begin(), elmu_candidates.end());
297 std::vector<TLorentzVector> lepton_p4s;
298 std::vector<int> lepton_origins;
300 for (
const auto&
p : lepton_candidates) {
301 const unsigned int origin = classifierParticleOriginAcc(*
p);
302 lepton_origins.push_back(origin);
303 lepton_p4s.push_back(
p->p4());
310 std::vector<TLorentzVector> photon_p4s;
311 std::vector<int> photon_origins;
312 for (
const auto *
p : truthParticles) {
324 const unsigned int origin = classifierParticleOriginAcc(*
p);
325 photon_origins.push_back(origin);
326 photon_p4s.push_back(
p->p4());
339 if(abs(
parent->pdgId())==15){
352 ATH_MSG_ERROR(
"photon_pT_cuts needs to be a non-empty list, when inOverlap is called, set as property or in constructor.");
369 float epsilon)
const {
375 std::map<float, float> dr_to_pt;
376 for (
const auto *
p : truthParticles) {
386 const float dRgamma =
photon.p4().DeltaR(
p->p4());
390 if (dr_to_pt.count(dRgamma) > 0) {
391 dr_to_pt[dRgamma] +=
p->pt();
393 dr_to_pt[dRgamma] =
p->pt();
399 for (
const auto& pair : dr_to_pt) {
400 sumPt += pair.second;
401 const float dRgamma = pair.first;
413 return epsilon * TMath::Power((1 - TMath::Cos(dR)) / (1 - TMath::Cos(dR0)), exponent);