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});
33 ATH_MSG_ERROR(origin <<
" in both lepton origin and lepton veto origin, this is not correct.");
49 const std::vector<TLorentzVector>* leptons,
50 const std::vector<TLorentzVector>* photons,
51 const std::vector<int>* lepton_origins,
52 const std::vector<int>* photon_origins)
const {
53 std::vector<float> photon_pts;
56 return StatusCode::SUCCESS;
63 const std::vector<TLorentzVector>* leptons,
64 const std::vector<TLorentzVector>* photons,
65 const std::vector<int>* lepton_origins,
66 const std::vector<int>* photon_origins)
const {
67 std::map<float, std::vector<float> > photon_pt_map;
70 return StatusCode::SUCCESS;
77 const std::vector<TLorentzVector>* leptons,
78 const std::vector<TLorentzVector>* photons,
79 const std::vector<int>* lepton_origins,
80 const std::vector<int>* photon_origins)
const {
82 return StatusCode::SUCCESS;
90 const std::vector<float>& drCuts,
91 const std::vector<TLorentzVector>* leptons,
92 const std::vector<TLorentzVector>* photons,
93 const std::vector<int>* lepton_origins,
94 const std::vector<int>* photon_origins)
const {
95 std::vector<TLorentzVector> good_leptons;
96 std::vector<TLorentzVector> good_photons;
97 ANA_CHECK(
setInput(good_leptons,good_photons,leptons,photons,lepton_origins,photon_origins));
100 for (
const auto& drCut : drCuts) {
101 result[drCut] = std::vector<float>();
102 for (
const auto&
photon : good_photons) {
103 bool tooCloseToLepton =
false;
105 const float dr =
photon.DeltaR(good_leptons[i_lep]);
107 tooCloseToLepton =
true;
111 if (!tooCloseToLepton)
result[drCut].push_back(
photon.Pt());
117 return StatusCode::SUCCESS;
123 std::vector<TLorentzVector>& photons_out,
124 const std::vector<TLorentzVector>* lepton_p4s,
125 const std::vector<TLorentzVector>* photon_p4s,
126 const std::vector<int>* lepton_origins,
127 const std::vector<int>* photon_origins)
const {
133 if(lepton_p4s==0 || photon_p4s==0){
141 std::vector<TLorentzVector> muonsOut=
getLeptonP4s(*truthMuons);
142 std::vector<TLorentzVector> electronsOut=
getLeptonP4s(*truthElectrons);
143 leptons_out.insert(leptons_out.end(),muonsOut.begin(),muonsOut.end());
144 leptons_out.insert(leptons_out.end(),electronsOut.begin(),electronsOut.end());
147 if(lepton_origins!=0){
151 leptons_out = *lepton_p4s;
158 if(photon_origins!=0){
162 photons_out = *photon_p4s;
166 ATH_MSG_DEBUG(
"VGammaORTool::setInput" <<
": Found " << photons_out.size() <<
" photons.");
167 ATH_MSG_DEBUG(
"VGammaORTool::setInput" <<
": Found " << leptons_out.size() <<
" leptons.");
171 "VGammaORTool::setInput" <<
": Found " << leptons_out.size() <<
" leptons but expected " <<
m_n_leptons <<
".");
174 return StatusCode::SUCCESS;
180 const std::vector<int>& photon_origins)
const {
182 if (photon_candidates.size() != photon_origins.size()) {
184 "VGammaORTool::filterPhotonOrigins" <<
": size of photon candidates (" << photon_candidates.size() <<
") different from number of photon origins (" << photon_origins.size() <<
188 std::vector<TLorentzVector> photon_p4s;
189 for (
uint i = 0;
i < photon_candidates.size();
i++) {
190 const TLorentzVector p4 = photon_candidates[
i];
191 const int p_origin = photon_origins[
i];
195 photon_p4s.push_back(p4);
203 const std::vector<int>& lepton_origins)
const {
205 if (lepton_candidates.size() != lepton_origins.size()) {
207 "VGammaORTool::filterLeptonOrigins" <<
": size of lepton candidates (" << lepton_candidates.size() <<
") different from number of lepton origins (" << lepton_origins.size() <<
210 std::vector<TLorentzVector> lepton_p4s;
211 std::vector<TLorentzVector> leptons_not_vetoed_p4s;
213 for (
uint i = 0;
i < lepton_candidates.size();
i++) {
214 const TLorentzVector p4 = lepton_candidates[
i];
215 const int p_origin = lepton_origins[
i];
218 lepton_p4s.push_back(p4);
230 leptons_not_vetoed_p4s.push_back(p4);
236 for (
const auto&
l : leptons_not_vetoed_p4s) {
237 lepton_p4s.push_back(
l);
246 std::vector<const xAOD::TruthParticle*> tau_candidates;
247 std::vector<const xAOD::TruthParticle*> elmu_candidates;
248 for (
const auto *
p : truthParticles) {
255 bool childIsTau =
false;
256 bool hasChildren =
false;
258 for (
uint i = 0;
i <
p->nChildren();
i++) {
259 if (
p->child(
i) ==
nullptr)
continue;
262 if (
p->child(
i)->pdgId() ==
p->pdgId()) {
267 if (hasChildren && !childIsTau) tau_candidates.push_back(
p);
271 elmu_candidates.push_back(
p);
275 sort(tau_candidates.begin(), tau_candidates.end(),
277 return p1->pt() > p2->pt();
279 sort(elmu_candidates.begin(), elmu_candidates.end(),
281 return p1->pt() > p2->pt();
284 std::vector<const xAOD::TruthParticle*> lepton_candidates(tau_candidates);
285 lepton_candidates.insert(lepton_candidates.end(), elmu_candidates.begin(), elmu_candidates.end());
287 std::vector<TLorentzVector> lepton_p4s;
288 std::vector<int> lepton_origins;
290 for (
const auto&
p : lepton_candidates) {
291 const unsigned int origin = classifierParticleOriginAcc(*
p);
292 lepton_origins.push_back(origin);
293 lepton_p4s.push_back(
p->p4());
300 std::vector<TLorentzVector> photon_p4s;
301 std::vector<int> photon_origins;
302 for (
const auto *
p : truthParticles) {
309 const unsigned int origin = classifierParticleOriginAcc(*
p);
310 photon_origins.push_back(origin);
311 photon_p4s.push_back(
p->p4());
335 ATH_MSG_ERROR(
"photon_pT_cuts needs to be a non-empty list, when inOverlap is called, set as property or in constructor.");
352 float epsilon)
const {
358 std::map<float, float> dr_to_pt;
359 for (
const auto *
p : truthParticles) {
366 const float dRgamma =
photon.p4().DeltaR(
p->p4());
370 if (dr_to_pt.count(dRgamma) > 0) {
371 dr_to_pt[dRgamma] +=
p->pt();
373 dr_to_pt[dRgamma] =
p->pt();
379 for (
const auto& pair : dr_to_pt) {
380 sumPt += pair.second;
381 const float dRgamma = pair.first;
393 return epsilon * TMath::Power((1 - TMath::Cos(dR)) / (1 - TMath::Cos(dR0)), exponent);