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 &),
130  const HcalPFCuts *hcalCuts) const {
131  const HcalDetId hid(hit.detid());
132  const int hd = hid.depth(), he = hid.ieta(), hp = hid.iphi();
133  const int h1 = hd - 1;
134  double thresholdE = 0.;
135 
136  if (include_or_exclude == -1 and (he != ieta or hp != iphi))
137  return 0.;
138 
139  if (include_or_exclude == 1 and (he == ieta and hp == iphi))
140  return 0.;
141 
142  if ((hid.subdet() == HcalBarrel and (hd < 1 or hd > int(eThresHB_.size()))) or
143  (hid.subdet() == HcalEndcap and (hd < 1 or hd > int(eThresHE_.size()))))
144  edm::LogWarning("EgammaHcalIsolation")
145  << " hit in subdet " << hid.subdet() << " has an unaccounted for depth of " << hd << "!!";
146 
147  const bool right_depth = (depth == 0 or hd == depth);
148  if (!right_depth)
149  return 0.;
150 
151  bool goodHBe = hid.subdet() == HcalBarrel and hit.energy() > eThresHB_[h1];
152  bool goodHEe = hid.subdet() == HcalEndcap and hit.energy() > eThresHE_[h1];
153 
154  if (hcalCuts != nullptr) {
155  const HcalPFCut *cutValue = hcalCuts->getValues(hid.rawId());
156  thresholdE = cutValue->noiseThreshold();
157  goodHBe = hid.subdet() == HcalBarrel and hit.energy() > thresholdE;
158  goodHEe = hid.subdet() == HcalEndcap and hit.energy() > thresholdE;
159  }
160 
161  if (!(goodHBe or goodHEe))
162  return 0.;
163 
164  const auto phit = caloGeometry_.getGeometry(hit.detid())->repPos();
165  const float phitEta = phit.eta();
166 
168  auto const dR2 = deltaR2(pcluEta, pcluPhi, phitEta, phit.phi());
171  return 0.;
172  }
173 
174  DetId did = hcalTopology_.idFront(hid);
175  const uint32_t flag = hit.flags();
176  const uint32_t dbflag = hcalChStatus_.getValues(did)->getValue();
178  bool recovered = hcalSevLvlComputer_.recoveredRecHit(did, flag);
179 
180  const double het = hit.energy() * scaleToEt(phitEta);
181  const bool goodHB = goodHBe and (severity <= maxSeverityHB_ or recovered) and het > etThresHB_[h1];
182  const bool goodHE = goodHEe and (severity <= maxSeverityHE_ or recovered) and het > etThresHE_[h1];
183 
184  if (goodHB or goodHE)
185  return hit.energy() * scale(phitEta);
186 
187  return 0.;
188 }
189 
191  int depth,
192  int ieta,
193  int iphi,
194  int include_or_exclude,
195  double (*scale)(const double &),
196  const HcalPFCuts *hcalCuts) const {
197  double sum = 0.;
198  const float pcluEta = pclu.eta();
199  const float pcluPhi = pclu.phi();
200  for (const auto &hit : mhbhe_)
201  sum += goodHitEnergy(pcluEta, pcluPhi, hit, depth, ieta, iphi, include_or_exclude, scale, hcalCuts);
202 
203  return sum;
204 }
double scaleToEt(const double &eta)
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)
double goodHitEnergy(float pcluEta, float pcluPhi, const HBHERecHit &hit, int depth, int ieta, int iphi, int include_or_exclude, double(*scale)(const double &), const HcalPFCuts *hcalCuts) const
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)
const HcalChannelQuality & hcalChStatus_
const Item * getValues(DetId fId, bool throwOnFail=true) const
float noiseThreshold() const
Definition: HcalPFCut.h:16
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
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_
double getHcalSum(const GlobalPoint &pclu, int depth, int ieta, int iphi, int include_or_exclude, double(*scale)(const double &), const HcalPFCuts *hcalCuts) const
Log< level::Warning, false > LogWarning
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164