ATLAS Offline Software
OverlapRemovalIndices.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 // $Id: OverlapRemovalIndices.cxx 661110 2015-04-17 00:03:39Z morrisj $
7 #include "TopEvent/EventTools.h"
8 
9 #include <list>
10 
11 namespace top {
13  }
14 
16  }
17 
19  const xAOD::MuonContainer* mu,
20  const xAOD::JetContainer* jet,
21  const xAOD::JetContainer* ljet,
22  std::vector<unsigned int>& OUT_el,
23  std::vector<unsigned int>& OUT_mu,
24  std::vector<unsigned int>& OUT_jet,
25  std::vector<unsigned int>& OUT_ljet,
26  const bool isLoose) {
27  std::string passTopCuts("");
28  if (!isLoose) {
29  passTopCuts = "passPreORSelection";
30  }
31  if (isLoose) {
32  passTopCuts = "passPreORSelectionLoose";
33  }
34 
35 
36  // Work internally with std::list
37  // What passed the pre-overlap removal selection?
38  std::vector<unsigned int> IN_el, IN_mu, IN_jet, IN_ljet;
39  std::list<unsigned int> l_el, l_mu, l_jet, l_ljet;
40  unsigned int index_el(0), index_mu(0), index_jet(0), index_ljet(0);
41 
42  if (el) {
43  for (auto x : *el) {
44  if (x->auxdataConst< char >(passTopCuts) == 1) {
45  IN_el.push_back(index_el);
46  l_el.push_back(index_el);
47  }
48  ++index_el;
49  }
50  }
51 
52  if (mu) {
53  for (auto x : *mu) {
54  if (x->auxdataConst< char >(passTopCuts) == 1) {
55  IN_mu.push_back(index_mu);
56  l_mu.push_back(index_mu);
57  }
58  ++index_mu;
59  }
60  }
61 
62  if (jet) {
63  for (auto x : *jet) {
64  if (x->auxdataConst< char >(passTopCuts) == 1) {
65  IN_jet.push_back(index_jet);
66  l_jet.push_back(index_jet);
67  }
68  ++index_jet;
69  }
70  }
71 
72  if (ljet) {
73  for (auto x : *ljet) {
74  if (x->auxdataConst< char >(passTopCuts) == 1) {
75  IN_ljet.push_back(index_ljet);
76  l_ljet.push_back(index_ljet);
77  }
78  ++index_ljet;
79  }
80  }
81 
82  // Jets and Muons - remove muon with dR < 0.4
83  for (auto j : IN_jet) {
84  for (auto m : IN_mu) {
85  if (top::deltaR(*(jet->at(j)), *(mu->at(m))) < 0.4) {
86  l_mu.remove(m);
87  }
88  }
89  }
90 
91  // Jets and Electrons - remove single closest jet with dR < 0.2
92  for (auto e : IN_el) {
93  double closestdr = 100.;
94  int closestJetIndex = -1;
95  for (auto j : IN_jet) {
96  const double ejetdr = top::deltaR(*(jet->at(j)), *(el->at(e)));
97 
98  if (ejetdr < 0.2 && ejetdr < closestdr) {
99  closestdr = ejetdr;
100  closestJetIndex = j;
101  }
102  }
103 
104  if (closestJetIndex > -1) l_jet.remove(closestJetIndex);
105  }
106 
107  // Electrons and Jets - remove electrons with dR < 0.4
108  for (auto j : l_jet) {
109  for (auto e : IN_el) {
110  if (top::deltaR(*(el->at(e)), *(jet->at(j))) < 0.4) {
111  l_el.remove(e);
112  }
113  }
114  }
115 
116  // Save what's left of the std::lists into the OUT vectors;
117  OUT_el.clear();
118  OUT_mu.clear();
119  OUT_jet.clear();
120  OUT_ljet.clear();
121 
122  for (auto i : l_el) {
123  OUT_el.push_back(i);
124  }
125  for (auto i : l_mu) {
126  OUT_mu.push_back(i);
127  }
128  for (auto i : l_jet) {
129  OUT_jet.push_back(i);
130  }
131  for (auto i : l_ljet) {
132  OUT_ljet.push_back(i);
133  }
134  }
135 
138  const xAOD::MuonContainer* mu,
139  const xAOD::TauJetContainer* /*tau*/,
140  const xAOD::JetContainer* jet,
141  const xAOD::JetContainer* ljet,
142  std::vector<unsigned int>& /*goodPhotons*/,
143  std::vector<unsigned int>& goodElectrons,
144  std::vector<unsigned int>& goodMuons,
145  std::vector<unsigned int>& /*goodTaus*/,
146  std::vector<unsigned int>& goodJets,
147  std::vector<unsigned int>& goodLargeRJets,
148  const bool isLoose) {
149  overlapremoval(el, mu, jet, ljet, goodElectrons, goodMuons, goodJets, goodLargeRJets, isLoose);
150  }
151 
152  void OverlapRemovalIndices::print(std::ostream& os) const {
153  os << "OverlapRemovalIndices\n";
154  os << " (1) remove muon within dR < 0.4 of any jet\n";
155  os << " (2) remove single jet closest to an electron (within dR < 0.2)\n";
156  os << " (3) remove electron with dR < 0.4 of jet\n";
157  }
158 }
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
top::OverlapRemovalIndices::print
virtual void print(std::ostream &) const
Print something useful to the screen.
Definition: OverlapRemovalIndices.cxx:152
OverlapRemovalIndices.h
top::deltaR
double deltaR(const xAOD::IParticle &p1, const xAOD::IParticle &p2)
Calculate the delta-r distance between two particles (e.g.
Definition: EventTools.cxx:21
x
#define x
top::OverlapRemovalIndices::overlapremoval
virtual void overlapremoval(const xAOD::ElectronContainer *el, const xAOD::MuonContainer *mu, const xAOD::JetContainer *jet, const xAOD::JetContainer *ljet, std::vector< unsigned int > &OUT_el, std::vector< unsigned int > &OUT_mu, std::vector< unsigned int > &OUT_jet, std::vector< unsigned int > &OUT_ljet, const bool isLooseEvent)
Perform our "standard" overlap removal.
Definition: OverlapRemovalIndices.cxx:18
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
top::OverlapRemovalIndices::~OverlapRemovalIndices
virtual ~OverlapRemovalIndices()
Doesn't do anything.
Definition: OverlapRemovalIndices.cxx:15
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:92
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
top::OverlapRemovalIndices::OverlapRemovalIndices
OverlapRemovalIndices()
Doesn't do anything.
Definition: OverlapRemovalIndices.cxx:12