CMS 3D CMS Logo

IsoDeposit.cc
Go to the documentation of this file.
4 
5 #include <sstream>
6 
7 using namespace reco;
8 
9 IsoDeposit::IsoDeposit(const Direction& candDirection) : theDirection(candDirection), theCandTag(0.) {
11  theVeto.dR = 0.;
12 }
13 
14 IsoDeposit::IsoDeposit(double eta, double phi) : theDirection(Direction(eta, phi)), theCandTag(0.) {
16  theVeto.dR = 0.;
17 }
18 
19 void IsoDeposit::addDeposit(double dr, double value) {
20  Distance relDir = {float(dr), 0.f};
21  theDeposits.insert(std::make_pair(relDir, value));
22 }
23 
24 void IsoDeposit::addDeposit(const Direction& depDir, double deposit) {
25  Distance relDir = depDir - theDirection;
26  theDeposits.insert(std::make_pair(relDir, deposit));
27 }
28 
29 double IsoDeposit::depositWithin(double coneSize, const Vetos& vetos, bool skipDepositVeto) const {
30  return depositAndCountWithin(coneSize, vetos, -1e+36, skipDepositVeto).first;
31 }
32 
33 double IsoDeposit::depositWithin(Direction dir, double coneSize, const Vetos& vetos, bool skipDepositVeto) const {
34  return depositAndCountWithin(dir, coneSize, vetos, -1e+36, skipDepositVeto).first;
35 }
36 
37 std::pair<double, int> IsoDeposit::depositAndCountWithin(double coneSize,
38  const Vetos& vetos,
39  double threshold,
40  bool skipDepositVeto) const {
41  double result = 0;
42  int count = 0;
43 
44  Vetos allVetos = vetos;
45  typedef Vetos::const_iterator IV;
46  if (!skipDepositVeto)
47  allVetos.push_back(theVeto);
48  IV ivEnd = allVetos.end();
49 
50  Distance maxDistance = {float(coneSize), 999.f};
51  typedef DepositsMultimap::const_iterator IM;
52  IM imLoc = theDeposits.upper_bound(maxDistance);
53  for (IM im = theDeposits.begin(); im != imLoc; ++im) {
54  bool vetoed = false;
55  for (IV iv = allVetos.begin(); iv < ivEnd; ++iv) {
56  Direction dirDep = theDirection + im->first;
57  if (dirDep.deltaR(iv->vetoDir) < iv->dR)
58  vetoed = true;
59  }
60  if (!vetoed && im->second > threshold) {
61  result += im->second;
62  count++;
63  }
64  }
65  return std::pair<double, int>(result, count);
66 }
67 
68 std::pair<double, int> IsoDeposit::depositAndCountWithin(
69  Direction dir, double coneSize, const Vetos& vetos, double threshold, bool skipDepositVeto) const {
70  double result = 0;
71  int count = 0;
72 
73  Vetos allVetos = vetos;
74  typedef Vetos::const_iterator IV;
75  if (!skipDepositVeto)
76  allVetos.push_back(theVeto);
77  IV ivEnd = allVetos.end();
78 
79  typedef DepositsMultimap::const_iterator IM;
80  for (IM im = theDeposits.begin(); im != theDeposits.end(); ++im) {
81  bool vetoed = false;
82  Direction dirDep = theDirection + im->first;
83  Distance newDist = dirDep - dir;
84  if (newDist.deltaR > coneSize)
85  continue;
86  for (IV iv = allVetos.begin(); iv < ivEnd; ++iv) {
87  if (dirDep.deltaR(iv->vetoDir) < iv->dR)
88  vetoed = true;
89  }
90  if (!vetoed && im->second > threshold) {
91  result += im->second;
92  count++;
93  }
94  }
95  return std::pair<double, int>(result, count);
96 }
97 
98 std::pair<double, int> IsoDeposit::depositAndCountWithin(double coneSize,
99  const AbsVetos& vetos,
100  bool skipDepositVeto) const {
101  using namespace reco::isodeposit;
102  double result = 0;
103  int count = 0;
104  typedef AbsVetos::const_iterator IV;
105 
106  IV ivEnd = vetos.end();
107 
108  Distance maxDistance = {float(coneSize), 999.f};
109  typedef DepositsMultimap::const_iterator IM;
110  IM imLoc = theDeposits.upper_bound(maxDistance);
111  for (IM im = theDeposits.begin(); im != imLoc; ++im) {
112  bool vetoed = false;
113  Direction dirDep = theDirection + im->first;
114  for (IV iv = vetos.begin(); iv < ivEnd; ++iv) {
115  if ((*iv)->veto(dirDep.eta(), dirDep.phi(), im->second)) {
116  vetoed = true;
117  break;
118  }
119  }
120  if (!vetoed) {
121  if (skipDepositVeto || (dirDep.deltaR(theVeto.vetoDir) > theVeto.dR)) {
122  result += im->second;
123  count++;
124  }
125  }
126  }
127  return std::pair<double, int>(result, count);
128 }
129 
130 double IsoDeposit::depositWithin(double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
131  return depositAndCountWithin(coneSize, vetos, skipDepositVeto).first;
132 }
133 
134 double IsoDeposit::countWithin(double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
135  return algoWithin<CountAlgo>(coneSize, vetos, skipDepositVeto);
136 }
137 double IsoDeposit::sumWithin(double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
138  return algoWithin<SumAlgo>(coneSize, vetos, skipDepositVeto);
139 }
140 double IsoDeposit::sumWithin(const Direction& dir, double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
141  return algoWithin<SumAlgo>(dir, coneSize, vetos, skipDepositVeto);
142 }
143 double IsoDeposit::sum2Within(double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
144  return algoWithin<Sum2Algo>(coneSize, vetos, skipDepositVeto);
145 }
146 double IsoDeposit::maxWithin(double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
147  return algoWithin<MaxAlgo>(coneSize, vetos, skipDepositVeto);
148 }
149 
150 double IsoDeposit::nearestDR(double coneSize, const AbsVetos& vetos, bool skipDepositVeto) const {
151  using namespace reco::isodeposit;
152  double result = coneSize;
153  typedef AbsVetos::const_iterator IV;
154 
155  IV ivEnd = vetos.end();
156 
157  Distance maxDistance = {float(coneSize), 999.f};
158  typedef DepositsMultimap::const_iterator IM;
159  IM imLoc = theDeposits.upper_bound(maxDistance);
160  for (IM im = theDeposits.begin(); im != imLoc; ++im) {
161  bool vetoed = false;
162  Direction dirDep = theDirection + im->first;
163  for (IV iv = vetos.begin(); iv < ivEnd; ++iv) {
164  if ((*iv)->veto(dirDep.eta(), dirDep.phi(), im->second)) {
165  vetoed = true;
166  break;
167  }
168  }
169  if (!vetoed) {
170  if (skipDepositVeto || (dirDep.deltaR(theVeto.vetoDir) > theVeto.dR)) {
171  result = (dirDep.deltaR(theVeto.vetoDir) < result) ? dirDep.deltaR(theVeto.vetoDir) : result;
172  }
173  }
174  }
175  return result;
176 }
177 
179  std::ostringstream str;
180  str << "Direction : " << theDirection.print() << std::endl;
181  str << "Veto: (" << theVeto.vetoDir.eta() << ", " << theVeto.vetoDir.phi() << " dR=" << theVeto.dR << ")"
182  << std::endl;
183  typedef DepositsMultimap::const_iterator IM;
184  IM imEnd = theDeposits.end();
185  for (IM im = theDeposits.begin(); im != imEnd; ++im) {
186  str << "(dR=" << im->first.deltaR << ", alpha=" << im->first.relativeAngle << ", Pt=" << im->second << "),";
187  }
188  str << std::endl;
189 
190  return str.str();
191 }
reco::IsoDeposit::Veto::dR
float dR
Definition: IsoDeposit.h:61
reco::isodeposit::Direction::print
std::string print() const
Definition: IsoDepositDirection.h:66
reco::IsoDeposit::nearestDR
double nearestDR(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:150
IsoDepositVetos.h
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
reco::IsoDeposit::addDeposit
void addDeposit(double dr, double deposit)
Add deposit (ie. transverse energy or pT)
Definition: IsoDeposit.cc:19
reco::IsoDeposit::depositAndCountWithin
std::pair< double, int > depositAndCountWithin(double coneSize, const Vetos &vetos=Vetos(), double threshold=-1e+36, bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:37
particleFlowClusterHGC_cfi.maxDistance
maxDistance
Definition: particleFlowClusterHGC_cfi.py:23
reco::isodeposit::Direction::eta
double eta() const
Definition: IsoDepositDirection.h:34
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::IsoDeposit::sum2Within
double sum2Within(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:143
reco::IsoDeposit::countWithin
double countWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:134
reco::IsoDeposit::IsoDeposit
IsoDeposit(double eta=0, double phi=0)
Constructor.
Definition: IsoDeposit.cc:14
reco::IsoDeposit::theDirection
Direction theDirection
direcion of deposit (center of isolation cone)
Definition: IsoDeposit.h:293
reco::isodeposit
Definition: IsoDeposit.h:31
reco::IsoDeposit::Veto::vetoDir
Direction vetoDir
Definition: IsoDeposit.h:60
PVValHelper::eta
Definition: PVValidationHelpers.h:69
reco::IsoDeposit::AbsVetos
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:53
str
#define str(s)
Definition: TestProcessor.cc:51
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
IsoDeposit.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::isodeposit::Direction::deltaR
double deltaR(const Direction &dir2) const
Definition: IsoDepositDirection.h:47
HLT_FULL_cff.coneSize
coneSize
Definition: HLT_FULL_cff.py:50911
reco::isodeposit::Direction::Distance::deltaR
float deltaR
Definition: IsoDepositDirection.h:22
reco::IsoDeposit::sumWithin
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
value
Definition: value.py:1
reco::IsoDeposit::theDeposits
DepositsMultimap theDeposits
the deposits identifed by relative position to center of cone and deposit value
Definition: IsoDeposit.h:303
reco::IsoDeposit::depositWithin
double depositWithin(double coneSize, const Vetos &vetos=Vetos(), bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:29
reco::IsoDeposit::maxWithin
double maxWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:146
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
reco::IsoDeposit::theVeto
Veto theVeto
area to be excluded in computaion of depositWithin
Definition: IsoDeposit.h:296
mps_fire.result
result
Definition: mps_fire.py:311
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
reco::IsoDeposit::Vetos
std::vector< Veto > Vetos
Definition: IsoDeposit.h:65
boostedElectronIsolation_cff.vetos
vetos
Definition: boostedElectronIsolation_cff.py:79
reco::IsoDeposit::print
std::string print() const
Definition: IsoDeposit.cc:178
reco::isodeposit::Direction::phi
double phi() const
Definition: IsoDepositDirection.h:35
reco::isodeposit::Direction::Distance
Definition: IsoDepositDirection.h:21
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37