CMS 3D CMS Logo

EgammaHcalIsolation.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaHcalIsolation.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 //ROOT includes
9 #include <Math/VectorUtil.h>
10 
11 //CMSSW includes
20 
21 double scaleToE(const double &eta) { return 1.; }
22 double scaleToEt(const double &eta) { return std::sin(2. * std::atan(std::exp(-eta))); }
23 
24 EgammaHcalIsolation::EgammaHcalIsolation(InclusionRule extIncRule,
25  double extRadius,
26  InclusionRule intIncRule,
27  double intRadius,
28  const arrayHB &eThresHB,
29  const arrayHB &etThresHB,
30  int maxSeverityHB,
31  const arrayHE &eThresHE,
32  const arrayHE &etThresHE,
33  int maxSeverityHE,
34  const HBHERecHitCollection &mhbhe,
35  edm::ESHandle<CaloGeometry> caloGeometry,
36  edm::ESHandle<HcalTopology> hcalTopology,
40  : extIncRule_(extIncRule),
41  extRadius_(extRadius * extRadius),
42  intIncRule_(intIncRule),
43  intRadius_(intRadius * intRadius),
44  maxSeverityHB_(maxSeverityHB),
45  maxSeverityHE_(maxSeverityHE),
46  mhbhe_(mhbhe),
47  caloGeometry_(*caloGeometry.product()),
48  hcalTopology_(*hcalTopology.product()),
49  hcalChStatus_(*hcalChStatus.product()),
50  hcalSevLvlComputer_(*hcalSevLvlComputer.product()),
51  towerMap_(*towerMap.product()) {
52  eThresHB_ = eThresHB;
53  etThresHB_ = etThresHB;
54  eThresHE_ = eThresHE;
55  etThresHE_ = etThresHE;
56 
57  // make some adjustments for the BC rules
58  if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::withinConeAroundCluster) {
59  extRadius_ = 0.;
60  intRadius_ = 0.;
61  } else if (extIncRule_ == InclusionRule::withinConeAroundCluster and
62  intIncRule_ == InclusionRule::isBehindClusterSeed) {
63  intRadius_ = 0.;
64  } else if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::isBehindClusterSeed) {
65  edm::LogWarning("EgammaHcalIsolation")
66  << " external and internal rechit inclusion rules can't both be isBehindClusterSeed."
67  << " Setting both to withinConeAroundCluster!";
68  extIncRule_ = InclusionRule::withinConeAroundCluster;
69  intIncRule_ = InclusionRule::withinConeAroundCluster;
70  }
71 }
72 
73 EgammaHcalIsolation::EgammaHcalIsolation(InclusionRule extIncRule,
74  double extRadius,
75  InclusionRule intIncRule,
76  double intRadius,
77  const arrayHB &eThresHB,
78  const arrayHB &etThresHB,
79  int maxSeverityHB,
80  const arrayHE &eThresHE,
81  const arrayHE &etThresHE,
82  int maxSeverityHE,
83  const HBHERecHitCollection &mhbhe,
84  const CaloGeometry &caloGeometry,
85  const HcalTopology &hcalTopology,
86  const HcalChannelQuality &hcalChStatus,
87  const HcalSeverityLevelComputer &hcalSevLvlComputer,
88  const CaloTowerConstituentsMap &towerMap)
89  : extIncRule_(extIncRule),
90  extRadius_(extRadius * extRadius),
91  intIncRule_(intIncRule),
92  intRadius_(intRadius * intRadius),
93  maxSeverityHB_(maxSeverityHB),
94  maxSeverityHE_(maxSeverityHE),
95  mhbhe_(mhbhe),
96  caloGeometry_(caloGeometry),
97  hcalTopology_(hcalTopology),
98  hcalChStatus_(hcalChStatus),
99  hcalSevLvlComputer_(hcalSevLvlComputer),
100  towerMap_(towerMap) {
101  eThresHB_ = eThresHB;
102  etThresHB_ = etThresHB;
103  eThresHE_ = eThresHE;
104  etThresHE_ = etThresHE;
105 
106  // make some adjustments for the BC rules
107  if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::withinConeAroundCluster) {
108  extRadius_ = 0.;
109  intRadius_ = 0.;
110  } else if (extIncRule_ == InclusionRule::withinConeAroundCluster and
111  intIncRule_ == InclusionRule::isBehindClusterSeed) {
112  intRadius_ = 0.;
113  } else if (extIncRule_ == InclusionRule::isBehindClusterSeed and intIncRule_ == InclusionRule::isBehindClusterSeed) {
114  edm::LogWarning("EgammaHcalIsolation")
115  << " external and internal rechit inclusion rules can't both be isBehindClusterSeed."
116  << " Setting both to withinConeAroundCluster!";
117  extIncRule_ = InclusionRule::withinConeAroundCluster;
118  intIncRule_ = InclusionRule::withinConeAroundCluster;
119  }
120 }
121 
123  float pcluPhi,
124  const HBHERecHit &hit,
125  int depth,
126  int ieta,
127  int iphi,
128  int include_or_exclude,
129  double (*scale)(const double &)) const {
130  const HcalDetId hid(hit.detid());
131  const int hd = hid.depth(), he = hid.ieta(), hp = hid.iphi();
132  const int h1 = hd - 1;
133 
134  if (include_or_exclude == -1 and (he != ieta or hp != iphi))
135  return 0.;
136 
137  if (include_or_exclude == 1 and (he == ieta and hp == iphi))
138  return 0.;
139 
140  if ((hid.subdet() == HcalBarrel and (hd < 1 or hd > int(eThresHB_.size()))) or
141  (hid.subdet() == HcalEndcap and (hd < 1 or hd > int(eThresHE_.size()))))
142  edm::LogWarning("EgammaHcalIsolation")
143  << " hit in subdet " << hid.subdet() << " has an unaccounted for depth of " << hd << "!!";
144 
145  const bool right_depth = (depth == 0 or hd == depth);
146  if (!right_depth)
147  return 0.;
148 
149  const bool goodHBe = hid.subdet() == HcalBarrel and hit.energy() > eThresHB_[h1];
150  const bool goodHEe = hid.subdet() == HcalEndcap and hit.energy() > eThresHE_[h1];
151  if (!(goodHBe or goodHEe))
152  return 0.;
153 
154  const auto phit = caloGeometry_.getGeometry(hit.detid())->repPos();
155  const float phitEta = phit.eta();
156 
158  auto const dR2 = deltaR2(pcluEta, pcluPhi, phitEta, phit.phi());
161  return 0.;
162  }
163 
164  DetId did = hcalTopology_.idFront(hid);
165  const uint32_t flag = hit.flags();
166  const uint32_t dbflag = hcalChStatus_.getValues(did)->getValue();
168  bool recovered = hcalSevLvlComputer_.recoveredRecHit(did, flag);
169 
170  const double het = hit.energy() * scaleToEt(phitEta);
171  const bool goodHB = goodHBe and (severity <= maxSeverityHB_ or recovered) and het > etThresHB_[h1];
172  const bool goodHE = goodHEe and (severity <= maxSeverityHE_ or recovered) and het > etThresHE_[h1];
173 
174  if (goodHB or goodHE)
175  return hit.energy() * scale(phitEta);
176 
177  return 0.;
178 }
179 
181  int depth,
182  int ieta,
183  int iphi,
184  int include_or_exclude,
185  double (*scale)(const double &)) const {
186  double sum = 0.;
187  const float pcluEta = pclu.eta();
188  const float pcluPhi = pclu.phi();
189  for (const auto &hit : mhbhe_)
190  sum += goodHitEnergy(pcluEta, pcluPhi, hit, depth, ieta, iphi, include_or_exclude, scale);
191 
192  return sum;
193 }
double scaleToEt(const double &eta)
double getHcalSum(const GlobalPoint &pclu, int depth, int ieta, int iphi, int include_or_exclude, double(*scale)(const double &)) const
const CaloGeometry & caloGeometry_
EgammaHcalIsolation(InclusionRule extIncRule, double extRadius, InclusionRule intIncRule, double intRadius, const arrayHB &eThresHB, const arrayHB &etThresHB, int maxSeverityHB, const arrayHE &eThresHE, const arrayHE &etThresHE, int maxSeverityHE, const HBHERecHitCollection &mhbhe, edm::ESHandle< CaloGeometry > caloGeometry, edm::ESHandle< HcalTopology > hcalTopology, edm::ESHandle< HcalChannelQuality > hcalChStatus, edm::ESHandle< HcalSeverityLevelComputer > hcalSevLvlComputer, edm::ESHandle< CaloTowerConstituentsMap > towerMap)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
bool recoveredRecHit(const DetId &myid, const uint32_t &myflag) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
double scaleToE(const double &eta)
double goodHitEnergy(float pcluEta, float pcluPhi, const HBHERecHit &hit, int depth, int ieta, int iphi, int include_or_exclude, double(*scale)(const double &)) const
const HcalChannelQuality & hcalChStatus_
const Item * getValues(DetId fId, bool throwOnFail=true) const
const HBHERecHitCollection & mhbhe_
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:60
uint32_t getValue() const
Definition: DetId.h:17
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
const HcalTopology & hcalTopology_
const HcalSeverityLevelComputer & hcalSevLvlComputer_
Log< level::Warning, false > LogWarning
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164