CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalHaloAlgo Class Reference

#include <HcalHaloAlgo.h>

Public Member Functions

reco::HcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, const edm::EventSetup &TheSetup)
 
reco::HcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, const edm::EventSetup &TheSetup)
 
std::vector< reco::HaloClusterCandidateHCALGetHaloClusterCandidateHB (edm::Handle< EcalRecHitCollection > &ebrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
 
std::vector< reco::HaloClusterCandidateHCALGetHaloClusterCandidateHE (edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
 
float GetHBRecHitEnergyThreshold ()
 
float GetHERecHitEnergyThreshold ()
 
float GetPhiWedgeEnergyThreshold ()
 
int GetPhiWedgeNHitsThreshold ()
 
bool HBClusterShapeandTimeStudy (reco::HaloClusterCandidateHCAL hcand, bool ishlt)
 
 HcalHaloAlgo (edm::ConsumesCollector iC)
 
bool HEClusterShapeandTimeStudy (reco::HaloClusterCandidateHCAL hcand, bool ishlt)
 
void SetPhiWedgeEnergyThreshold (float SumE)
 
void SetPhiWedgeNHitsThreshold (int nhits)
 
void SetPhiWedgeThresholds (float SumE, int nhits)
 
void SetRecHitEnergyThresholds (float HB, float HE)
 

Private Member Functions

math::XYZPoint getPosition (const DetId &id, reco::Vertex::Point vtx)
 

Private Attributes

const CaloGeometrygeo_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeoToken_
 
float HBRecHitEnergyThreshold
 
float HERecHitEnergyThreshold
 
const HcalGeometryhgeo_
 
int NHitsThreshold
 
float SumEnergyThreshold
 

Detailed Description

Definition at line 41 of file HcalHaloAlgo.h.

Constructor & Destructor Documentation

◆ HcalHaloAlgo()

HcalHaloAlgo::HcalHaloAlgo ( edm::ConsumesCollector  iC)
explicit

Definition at line 24 of file HcalHaloAlgo.cc.

References HBRecHitEnergyThreshold, HERecHitEnergyThreshold, NHitsThreshold, and SumEnergyThreshold.

24  : geoToken_(iC.esConsumes()), geo_(nullptr), hgeo_(nullptr) {
27  SumEnergyThreshold = 0.;
28  NHitsThreshold = 0;
29 }
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
Definition: HcalHaloAlgo.h:102
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:96
const CaloGeometry * geo_
Definition: HcalHaloAlgo.h:103
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:95
const HcalGeometry * hgeo_
Definition: HcalHaloAlgo.h:104
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:99

Member Function Documentation

◆ Calculate() [1/2]

HcalHaloData HcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits,
edm::Handle< CaloTowerCollection > &  TheCaloTowers,
edm::Handle< EBRecHitCollection > &  TheEBRecHits,
edm::Handle< EERecHitCollection > &  TheEERecHits,
const edm::EventSetup TheSetup 
)

Definition at line 40 of file HcalHaloAlgo.cc.

References funct::abs(), CompareTime(), CompareTowers(), F(), geo_, geoToken_, edm::EventSetup::getData(), GetHaloClusterCandidateHB(), GetHaloClusterCandidateHE(), reco::HcalHaloData::GetPhiWedges(), reco::HcalHaloData::getProblematicStrips(), CaloGeometry::getSubdetectorGeometry(), HBRecHitEnergyThreshold, DetId::Hcal, HcalBarrel, HcalEndcap, HERecHitEnergyThreshold, hgeo_, mps_fire::i, hit::id, hcalRecHitTable_cff::ieta, l1tPhase2CaloJetEmulator_cfi::iEta, HcalDetId::ieta(), hcalRecHitTable_cff::iphi, dqmiolumiharvest::j, WZElectronSkims53X_cff::max, NHitsThreshold, reco::HcalHaloData::setHaloClusterCandidatesHB(), reco::HcalHaloData::setHaloClusterCandidatesHE(), reco::PhiWedge::SetPlusZOriginConfidence(), jetUpdater_cfi::sort, nano_mu_digi_cff::strip, SumEnergyThreshold, hcalRecHitTable_cff::time, and l1tHGCalTowerProducer_cfi::tower.

Referenced by Calculate(), and reco::HcalHaloDataProducer::produce().

45  {
46  HcalHaloData TheHcalHaloData;
47  // ieta overlap geometrically w/ HB
48  const int iEtaOverlap = 22;
49  const int nPhiMax = 73;
50  // Store Energy sum of rechits as a function of iPhi (iPhi goes from 1 to 72)
51  float SumE[nPhiMax];
52  // Store Number of rechits as a function of iPhi
53  int NumHits[nPhiMax];
54  // Store minimum time of rechit as a function of iPhi
55  float MinTimeHits[nPhiMax];
56  // Store maximum time of rechit as a function of iPhi
57  float MaxTimeHits[nPhiMax];
58  for (unsigned int i = 0; i < nPhiMax; i++) {
59  SumE[i] = 0;
60  NumHits[i] = 0;
61  MinTimeHits[i] = 0.;
62  MaxTimeHits[i] = 0.;
63  }
64 
65  for (const auto& hit : (*TheHBHERecHits)) {
66  HcalDetId id = HcalDetId(hit.id());
67  switch (id.subdet()) {
68  case HcalBarrel:
69  if (hit.energy() < HBRecHitEnergyThreshold)
70  continue;
71  break;
72  case HcalEndcap:
73  if (hit.energy() < HERecHitEnergyThreshold)
74  continue;
75  break;
76  default:
77  continue;
78  }
79 
80  int iEta = id.ieta();
81  int iPhi = id.iphi();
82  if (iPhi < nPhiMax && std::abs(iEta) <= iEtaOverlap) {
83  SumE[iPhi] += hit.energy();
84  NumHits[iPhi]++;
85 
86  float time = hit.time();
87  MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
88  MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
89  }
90  }
91 
92  for (int iPhi = 1; iPhi < nPhiMax; iPhi++) {
93  if (SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold) {
94  // Build PhiWedge and store to HcalHaloData if energy or #hits pass thresholds
95  PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
96 
97  // Loop over rechits again to calculate direction based on timing info
98  std::vector<const HBHERecHit*> Hits;
99  for (const auto& hit : (*TheHBHERecHits)) {
100  HcalDetId id = HcalDetId(hit.id());
101  if (id.iphi() != iPhi)
102  continue;
103  if (std::abs(id.ieta()) > iEtaOverlap)
104  continue; // has to overlap geometrically w/ HB
105  switch (id.subdet()) {
106  case HcalBarrel:
107  if (hit.energy() < HBRecHitEnergyThreshold)
108  continue;
109  break;
110  case HcalEndcap:
111  if (hit.energy() < HERecHitEnergyThreshold)
112  continue;
113  break;
114  default:
115  continue;
116  }
117  Hits.push_back(&(hit));
118  }
119 
120  std::sort(Hits.begin(), Hits.end(), CompareTime);
121  float MinusToPlus = 0.;
122  float PlusToMinus = 0.;
123  for (unsigned int i = 0; i < Hits.size(); i++) {
124  HcalDetId id_i = HcalDetId(Hits[i]->id());
125  int ieta_i = id_i.ieta();
126  for (unsigned int j = (i + 1); j < Hits.size(); j++) {
127  HcalDetId id_j = HcalDetId(Hits[j]->id());
128  int ieta_j = id_j.ieta();
129  if (ieta_i > ieta_j)
130  PlusToMinus += std::abs(ieta_i - ieta_j);
131  else
132  MinusToPlus += std::abs(ieta_i - ieta_j);
133  }
134  }
135  float PlusZOriginConfidence = (PlusToMinus + MinusToPlus) ? PlusToMinus / (PlusToMinus + MinusToPlus) : -1.;
136  wedge.SetPlusZOriginConfidence(PlusZOriginConfidence);
137  TheHcalHaloData.GetPhiWedges().push_back(wedge);
138  }
139  }
140 
141  // Don't use HF.
142  int maxAbsIEta = 29;
143 
144  std::map<int, float> iPhiHadEtMap;
145  std::vector<const CaloTower*> sortedCaloTowers;
146  for (const auto& tower : (*TheCaloTowers)) {
147  if (std::abs(tower.ieta()) > maxAbsIEta)
148  continue;
149 
150  int iPhi = tower.iphi();
151  if (!iPhiHadEtMap.count(iPhi))
152  iPhiHadEtMap[iPhi] = 0.0;
153  iPhiHadEtMap[iPhi] += tower.hadEt();
154 
155  if (tower.numProblematicHcalCells() > 0)
156  sortedCaloTowers.push_back(&(tower));
157  }
158 
159  // Sort towers such that lowest iphi and ieta are first, highest last, and towers
160  // with same iphi value are consecutive. Then we can do everything else in one loop.
161  std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(), CompareTowers);
162 
164 
165  int prevIEta = -99, prevIPhi = -99;
166  float prevHadEt = 0.;
167  float prevEmEt = 0.;
168  std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
169  bool wasContiguous = true;
170 
171  // Loop through and store a vector of pairs (problematicCells, DetId) for each contiguous strip we find
172  for (unsigned int i = 0; i < sortedCaloTowers.size(); i++) {
173  const CaloTower* tower = sortedCaloTowers[i];
174 
175  towerPair = std::make_pair((uint8_t)tower->numProblematicHcalCells(), tower->id());
176 
177  bool newIPhi = tower->iphi() != prevIPhi;
178  bool isContiguous = tower->ieta() == 1 ? tower->ieta() - 2 == prevIEta : tower->ieta() - 1 == prevIEta;
179 
180  isContiguous = isContiguous || (tower->ieta() == -maxAbsIEta);
181  if (newIPhi)
182  isContiguous = false;
183 
184  if (!wasContiguous && isContiguous) {
185  strip.cellTowerIds.push_back(prevPair);
186  strip.cellTowerIds.push_back(towerPair);
187  strip.hadEt += prevHadEt + tower->hadEt();
188  strip.emEt += prevEmEt + tower->emEt();
189  }
190 
191  if (wasContiguous && isContiguous) {
192  strip.cellTowerIds.push_back(towerPair);
193  strip.hadEt += tower->hadEt();
194  strip.emEt += tower->emEt();
195  }
196 
197  if ((wasContiguous && !isContiguous) || i == sortedCaloTowers.size() - 1) { //ended the strip, so flush it
198 
199  if (strip.cellTowerIds.size() > 3) {
200  int iPhi = strip.cellTowerIds.at(0).second.iphi();
201  int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
202  int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
203 
204  float energyRatio = 0.0;
205  if (iPhiHadEtMap.count(iPhiLower))
206  energyRatio += iPhiHadEtMap[iPhiLower];
207  if (iPhiHadEtMap.count(iPhiUpper))
208  energyRatio += iPhiHadEtMap[iPhiUpper];
209  iPhiHadEtMap[iPhi] = std::max(iPhiHadEtMap[iPhi], 0.001F);
210 
211  energyRatio /= iPhiHadEtMap[iPhi];
212  strip.energyRatio = energyRatio;
213 
214  TheHcalHaloData.getProblematicStrips().push_back(strip);
215  }
216  strip = HaloTowerStrip();
217  }
218 
219  wasContiguous = isContiguous;
220  prevPair = towerPair;
221  prevEmEt = tower->emEt();
222  prevIPhi = tower->iphi();
223  prevIEta = tower->ieta();
224  prevHadEt = tower->hadEt();
225  }
226 
227  geo_ = &TheSetup.getData(geoToken_);
228  hgeo_ = dynamic_cast<const HcalGeometry*>(geo_->getSubdetectorGeometry(DetId::Hcal, 1));
229 
230  //Halo cluster building:
231  //Various clusters are built, depending on the subdetector.
232  //In barrel, one looks for deposits narrow in phi.
233  //In endcaps, one looks for localized deposits (dr condition in EE where r =sqrt(dphi*dphi+deta*deta)
234  //E/H condition is also applied.
235  //The halo cluster building step targets a large efficiency (ideally >99%) for beam halo deposits.
236  //These clusters are used as input for the halo pattern finding methods in HcalHaloAlgo and for the CSC-calo matching methods in GlobalHaloAlgo.
237 
238  //Et threshold hardcoded for now. Might one to get it from config
239 
240  std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
241  haloclustercands_HB = GetHaloClusterCandidateHB(TheEBRecHits, TheHBHERecHits, 5);
242 
243  std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
244  haloclustercands_HE = GetHaloClusterCandidateHE(TheEERecHits, TheHBHERecHits, 10);
245 
246  TheHcalHaloData.setHaloClusterCandidatesHB(haloclustercands_HB);
247  TheHcalHaloData.setHaloClusterCandidatesHE(haloclustercands_HE);
248 
249  return TheHcalHaloData;
250 }
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
Definition: HcalHaloAlgo.h:102
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:96
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void setHaloClusterCandidatesHB(const std::vector< HaloClusterCandidateHCAL > &x)
Definition: HcalHaloData.h:59
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHE(edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
const CaloGeometry * geo_
Definition: HcalHaloAlgo.h:103
const std::vector< HaloTowerStrip > & getProblematicStrips() const
Definition: HcalHaloData.h:50
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
void setHaloClusterCandidatesHE(const std::vector< HaloClusterCandidateHCAL > &x)
Definition: HcalHaloData.h:60
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool CompareTime(const HBHERecHit *x, const HBHERecHit *y)
Definition: HcalHaloAlgo.cc:19
unsigned int id
HitsSoA::View Hits
Definition: HitsSoA.h:32
bool CompareTowers(const CaloTower *x, const CaloTower *y)
Definition: HcalHaloAlgo.cc:20
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:95
const HcalGeometry * hgeo_
Definition: HcalHaloAlgo.h:104
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:99
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:46
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHB(edm::Handle< EcalRecHitCollection > &ebrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)

◆ Calculate() [2/2]

HcalHaloData HcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits,
edm::Handle< EBRecHitCollection > &  TheEBRecHits,
edm::Handle< EERecHitCollection > &  TheEERecHits,
const edm::EventSetup TheSetup 
)

Definition at line 31 of file HcalHaloAlgo.cc.

References Calculate().

35  {
37  return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers, TheEBRecHits, TheEERecHits, TheSetup);
38 }
reco::HcalHaloData Calculate(const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, const edm::EventSetup &TheSetup)
Definition: HcalHaloAlgo.cc:40

◆ GetHaloClusterCandidateHB()

std::vector< HaloClusterCandidateHCAL > HcalHaloAlgo::GetHaloClusterCandidateHB ( edm::Handle< EcalRecHitCollection > &  ebrechitcoll,
edm::Handle< HBHERecHitCollection > &  hbherechitcoll,
float  et_thresh_seedrh 
)

Definition at line 252 of file HcalHaloAlgo.cc.

References funct::abs(), srCondWrite_cfg::deltaPhi, CaloRecHit::energy(), EcalRecHit::energy(), PVValHelper::eta, getPosition(), HBClusterShapeandTimeStudy(), HBHERecHit::id(), EcalRecHit::id(), phi, edm::RefVector< C, T, F >::push_back(), reco::HaloClusterCandidateHCAL::setBeamHaloRecHitsCandidates(), reco::HaloClusterCandidateHCAL::setClusterEt(), reco::HaloClusterCandidateHCAL::setEoverH(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedMinus1(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedPlus1(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern_HLT(), reco::HaloClusterCandidateHCAL::setNbTowersInEta(), reco::HaloClusterCandidateHCAL::setSeedEt(), reco::HaloClusterCandidateHCAL::setSeedEta(), reco::HaloClusterCandidateHCAL::setSeedPhi(), reco::HaloClusterCandidateHCAL::setSeedR(), reco::HaloClusterCandidateHCAL::setSeedTime(), reco::HaloClusterCandidateHCAL::setSeedZ(), reco::HaloClusterCandidateHCAL::setTimeDiscriminatorITBH(), reco::HaloClusterCandidateHCAL::setTimeDiscriminatorOTBH(), edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), CaloRecHit::time(), and L1BJetProducer_cff::vtx.

Referenced by Calculate().

255  {
256  std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
257 
258  reco::Vertex::Point vtx(0, 0, 0);
259 
260  for (size_t ihit = 0; ihit < hbherechitcoll->size(); ++ihit) {
261  HaloClusterCandidateHCAL clustercand;
262 
263  const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
264  math::XYZPoint rhpos = getPosition(rechit.id(), vtx);
265  //Et condition
266  double rhet = rechit.energy() * sqrt(rhpos.perp2() / rhpos.mag2());
267  if (rhet < et_thresh_seedrh)
268  continue;
269  if (std::abs(rhpos.z()) > zseparation_HBHE)
270  continue;
271  double eta = rhpos.eta();
272  double phi = rhpos.phi();
273 
274  bool isiso = true;
275  double etcluster(0);
276  int nbtowerssameeta(0);
277  double timediscriminatorITBH(0), timediscriminatorOTBH(0);
278  double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
279 
280  //Building the cluster
282  for (size_t jhit = 0; jhit < hbherechitcoll->size(); ++jhit) {
283  const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
284  HBHERecHitRef rhRef(hbherechitcoll, jhit);
285  math::XYZPoint rhposj = getPosition(rechitj.id(), vtx);
286  double rhetj = rechitj.energy() * sqrt(rhposj.perp2() / rhposj.mag2());
287  if (rhetj < 2)
288  continue;
289  if (std::abs(rhposj.z()) > zseparation_HBHE)
290  continue;
291  double etaj = rhposj.eta();
292  double phij = rhposj.phi();
293  double deta = eta - etaj;
294  double dphi = deltaPhi(phi, phij);
295  if (std::abs(deta) > 0.4)
296  continue; //This means +/-4 towers in eta
297  if (std::abs(dphi) > 0.2)
298  continue; //This means +/-2 towers in phi
299  if (std::abs(dphi) > 0.1 && std::abs(deta) < 0.2) {
300  isiso = false;
301  break;
302  } //The strip should be isolated
303  if (std::abs(dphi) > 0.1)
304  continue;
305  if (std::abs(dphi) < 0.05)
306  nbtowerssameeta++;
307  if (dphi > 0.05)
308  etstrip_phiseedplus1 += rhetj;
309  if (dphi < -0.05)
310  etstrip_phiseedminus1 += rhetj;
311 
312  etcluster += rhetj;
313  //Timing discriminator
314  //We assign a weight to the rechit defined as:
315  //Log10(Et)*f(T,R,Z)
316  //where f(T,R,Z) is the separation curve between halo-like and IP-like times.
317  //The time difference between a deposit from a outgoing IT halo and a deposit coming from a particle emitted at the IP is given by:
318  //dt= ( - sqrt(R^2+z^2) + |z| )/c
319  // For OT beam halo, the time difference is:
320  //dt= ( 25 + sqrt(R^2+z^2) + |z| )/c
321  //only consider the central part of HB as things get hard at large z.
322  //The best fitted value for R leads to 240 cm (IT) and 330 cm (OT)
323  double rhtj = rechitj.time();
324  timediscriminatorITBH +=
325  std::log10(rhetj) *
326  (rhtj + 0.5 * (sqrt(240. * 240. + rhposj.z() * rhposj.z()) - std::abs(rhposj.z())) / c_cm_per_ns);
327  if (std::abs(rhposj.z()) < 300)
328  timediscriminatorOTBH +=
329  std::log10(rhetj) *
330  (rhtj - 0.5 * (25 - (sqrt(330. * 330. + rhposj.z() * rhposj.z()) + std::abs(rhposj.z())) / c_cm_per_ns));
331  bhrhcandidates.push_back(rhRef);
332  }
333  //Isolation conditions
334  if (!isiso)
335  continue;
336  if (etstrip_phiseedplus1 / etcluster > 0.2 && etstrip_phiseedminus1 / etcluster > 0.2)
337  continue;
338 
339  //Calculate E/H
340  double eoh(0);
341  for (size_t jhit = 0; jhit < ecalrechitcoll->size(); ++jhit) {
342  const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
343  math::XYZPoint rhposj = getPosition(rechitj.id(), vtx);
344  double rhetj = rechitj.energy() * sqrt(rhposj.perp2() / rhposj.mag2());
345  if (rhetj < 2)
346  continue;
347  double etaj = rhposj.eta();
348  double phij = rhposj.phi();
349  if (std::abs(eta - etaj) > 0.2)
350  continue;
351  if (std::abs(deltaPhi(phi, phij)) > 0.2)
352  continue;
353  eoh += rhetj / etcluster;
354  }
355  //E/H condition
356  if (eoh > 0.1)
357  continue;
358 
359  clustercand.setClusterEt(etcluster);
360  clustercand.setSeedEt(rhet);
361  clustercand.setSeedEta(eta);
362  clustercand.setSeedPhi(phi);
363  clustercand.setSeedZ(rhpos.Z());
364  clustercand.setSeedR(sqrt(rhpos.perp2()));
365  clustercand.setSeedTime(rechit.time());
366  clustercand.setEoverH(eoh);
367  clustercand.setNbTowersInEta(nbtowerssameeta);
368  clustercand.setEtStripPhiSeedPlus1(etstrip_phiseedplus1);
369  clustercand.setEtStripPhiSeedMinus1(etstrip_phiseedminus1);
370  clustercand.setTimeDiscriminatorITBH(timediscriminatorITBH);
371  clustercand.setTimeDiscriminatorOTBH(timediscriminatorOTBH);
372  clustercand.setBeamHaloRecHitsCandidates(bhrhcandidates);
373 
374  bool isbeamhalofrompattern = HBClusterShapeandTimeStudy(clustercand, false);
375  clustercand.setIsHaloFromPattern(isbeamhalofrompattern);
376  bool isbeamhalofrompattern_hlt = HBClusterShapeandTimeStudy(clustercand, true);
377  clustercand.setIsHaloFromPattern_HLT(isbeamhalofrompattern_hlt);
378 
379  TheHaloClusterCandsHB.push_back(clustercand);
380  }
381 
382  return TheHaloClusterCandsHB;
383 }
size_type size() const
bool HBClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
constexpr float energy() const
Definition: CaloRecHit.h:29
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
DetId id() const
get the id
Definition: EcalRecHit.h:78
constexpr float time() const
Definition: CaloRecHit.h:31
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
void setBeamHaloRecHitsCandidates(edm::RefVector< HBHERecHitCollection > x)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
float energy() const
Definition: EcalRecHit.h:69

◆ GetHaloClusterCandidateHE()

std::vector< HaloClusterCandidateHCAL > HcalHaloAlgo::GetHaloClusterCandidateHE ( edm::Handle< EcalRecHitCollection > &  eerechitcoll,
edm::Handle< HBHERecHitCollection > &  hbherechitcoll,
float  et_thresh_seedrh 
)

Definition at line 385 of file HcalHaloAlgo.cc.

References funct::abs(), srCondWrite_cfg::deltaPhi, l1ctLayer1_cff::dr, CaloRecHit::energy(), EcalRecHit::energy(), PVValHelper::eta, getPosition(), HEClusterShapeandTimeStudy(), HBHERecHit::id(), EcalRecHit::id(), phi, edm::RefVector< C, T, F >::push_back(), reco::HaloClusterCandidateHCAL::setBeamHaloRecHitsCandidates(), reco::HaloClusterCandidateHCAL::setClusterEt(), reco::HaloClusterCandidateHCAL::setClusterSize(), reco::HaloClusterCandidateHCAL::setEoverH(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedMinus1(), reco::HaloClusterCandidateHCAL::setEtStripPhiSeedPlus1(), reco::HaloClusterCandidateHCAL::setH1overH123(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern(), reco::HaloClusterCandidateHCAL::setIsHaloFromPattern_HLT(), reco::HaloClusterCandidateHCAL::setSeedEt(), reco::HaloClusterCandidateHCAL::setSeedEta(), reco::HaloClusterCandidateHCAL::setSeedPhi(), reco::HaloClusterCandidateHCAL::setSeedR(), reco::HaloClusterCandidateHCAL::setSeedTime(), reco::HaloClusterCandidateHCAL::setSeedZ(), reco::HaloClusterCandidateHCAL::setTimeDiscriminator(), edm::SortedCollection< T, SORT >::size(), mathSSE::sqrt(), CaloRecHit::time(), and L1BJetProducer_cff::vtx.

Referenced by Calculate().

388  {
389  std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
390 
391  reco::Vertex::Point vtx(0, 0, 0);
392 
393  for (size_t ihit = 0; ihit < hbherechitcoll->size(); ++ihit) {
394  HaloClusterCandidateHCAL clustercand;
395 
396  const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
397  math::XYZPoint rhpos = getPosition(rechit.id(), vtx);
398  //Et condition
399  double rhet = rechit.energy() * sqrt(rhpos.perp2() / rhpos.mag2());
400  if (rhet < et_thresh_seedrh)
401  continue;
402  if (std::abs(rhpos.z()) < zseparation_HBHE)
403  continue;
404  double eta = rhpos.eta();
405  double phi = rhpos.phi();
406  double rhr = sqrt(rhpos.perp2());
407  bool isiso = true;
408  double etcluster(0), hdepth1(0);
409  int clustersize(0);
410  double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
411 
412  //Building the cluster
414  for (size_t jhit = 0; jhit < hbherechitcoll->size(); ++jhit) {
415  const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
416  HBHERecHitRef rhRef(hbherechitcoll, jhit);
417  math::XYZPoint rhposj = getPosition(rechitj.id(), vtx);
418  double rhetj = rechitj.energy() * sqrt(rhposj.perp2() / rhposj.mag2());
419  if (rhetj < 2)
420  continue;
421  if (std::abs(rhposj.z()) < zseparation_HBHE)
422  continue;
423  if (rhpos.z() * rhposj.z() < 0)
424  continue;
425  double phij = rhposj.phi();
426  double dphi = deltaPhi(phi, phij);
427  if (std::abs(dphi) > 0.4)
428  continue;
429  double rhrj = sqrt(rhposj.perp2());
430  if (std::abs(rhr - rhrj) > 50)
431  continue;
432  if (std::abs(dphi) > 0.2 || std::abs(rhr - rhrj) > 20) {
433  isiso = false;
434  break;
435  } //The deposit should be isolated
436  if (dphi > 0.05)
437  etstrip_phiseedplus1 += rhetj;
438  if (dphi < -0.05)
439  etstrip_phiseedminus1 += rhetj;
440  clustersize++;
441  etcluster += rhetj;
442  if (std::abs(rhposj.z()) < 405)
443  hdepth1 += rhetj;
444  //No timing condition for now in HE
445  bhrhcandidates.push_back(rhRef);
446  }
447  //Isolation conditions
448  if (!isiso)
449  continue;
450  if (etstrip_phiseedplus1 / etcluster > 0.1 && etstrip_phiseedminus1 / etcluster > 0.1)
451  continue;
452 
453  //Calculate E/H
454  double eoh(0);
455  for (size_t jhit = 0; jhit < ecalrechitcoll->size(); ++jhit) {
456  const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
457  math::XYZPoint rhposj = getPosition(rechitj.id(), vtx);
458  double rhetj = rechitj.energy() * sqrt(rhposj.perp2() / rhposj.mag2());
459  if (rhetj < 2)
460  continue;
461  if (rhpos.z() * rhposj.z() < 0)
462  continue;
463  double etaj = rhposj.eta();
464  double phij = rhposj.phi();
465  double dr = sqrt((eta - etaj) * (eta - etaj) + deltaPhi(phi, phij) * deltaPhi(phi, phij));
466  if (dr > 0.3)
467  continue;
468 
469  eoh += rhetj / etcluster;
470  }
471  //E/H condition
472  if (eoh > 0.1)
473  continue;
474 
475  clustercand.setClusterEt(etcluster);
476  clustercand.setSeedEt(rhet);
477  clustercand.setSeedEta(eta);
478  clustercand.setSeedPhi(phi);
479  clustercand.setSeedZ(rhpos.Z());
480  clustercand.setSeedR(sqrt(rhpos.perp2()));
481  clustercand.setSeedTime(rechit.time());
482  clustercand.setEoverH(eoh);
483  clustercand.setH1overH123(hdepth1 / etcluster);
484  clustercand.setClusterSize(clustersize);
485  clustercand.setEtStripPhiSeedPlus1(etstrip_phiseedplus1);
486  clustercand.setEtStripPhiSeedMinus1(etstrip_phiseedminus1);
487  clustercand.setTimeDiscriminator(0);
488  clustercand.setBeamHaloRecHitsCandidates(bhrhcandidates);
489 
490  bool isbeamhalofrompattern = HEClusterShapeandTimeStudy(clustercand, false);
491  clustercand.setIsHaloFromPattern(isbeamhalofrompattern);
492  bool isbeamhalofrompattern_hlt = HEClusterShapeandTimeStudy(clustercand, true);
493  clustercand.setIsHaloFromPattern_HLT(isbeamhalofrompattern_hlt);
494 
495  TheHaloClusterCandsHE.push_back(clustercand);
496  }
497 
498  return TheHaloClusterCandsHE;
499 }
size_type size() const
constexpr float energy() const
Definition: CaloRecHit.h:29
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
DetId id() const
get the id
Definition: EcalRecHit.h:78
constexpr float time() const
Definition: CaloRecHit.h:31
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
void setBeamHaloRecHitsCandidates(edm::RefVector< HBHERecHitCollection > x)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
float energy() const
Definition: EcalRecHit.h:69
bool HEClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)

◆ GetHBRecHitEnergyThreshold()

float HcalHaloAlgo::GetHBRecHitEnergyThreshold ( )
inline

Definition at line 75 of file HcalHaloAlgo.h.

References HBRecHitEnergyThreshold.

75 { return HBRecHitEnergyThreshold; }
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:95

◆ GetHERecHitEnergyThreshold()

float HcalHaloAlgo::GetHERecHitEnergyThreshold ( )
inline

Definition at line 76 of file HcalHaloAlgo.h.

References HERecHitEnergyThreshold.

76 { return HERecHitEnergyThreshold; }
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:96

◆ GetPhiWedgeEnergyThreshold()

float HcalHaloAlgo::GetPhiWedgeEnergyThreshold ( )
inline

Definition at line 79 of file HcalHaloAlgo.h.

References SumEnergyThreshold.

79 { return SumEnergyThreshold; }
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:99

◆ GetPhiWedgeNHitsThreshold()

int HcalHaloAlgo::GetPhiWedgeNHitsThreshold ( )
inline

Definition at line 80 of file HcalHaloAlgo.h.

References NHitsThreshold.

80 { return NHitsThreshold; }

◆ getPosition()

math::XYZPoint HcalHaloAlgo::getPosition ( const DetId id,
reco::Vertex::Point  vtx 
)
private

Definition at line 557 of file HcalHaloAlgo.cc.

References geo_, CaloGeometry::getPosition(), HcalGeometry::getPosition(), DetId::Hcal, hgeo_, and L1BJetProducer_cff::vtx.

Referenced by GetHaloClusterCandidateHB(), and GetHaloClusterCandidateHE().

557  {
558  const GlobalPoint pos = ((id.det() == DetId::Hcal) ? hgeo_->getPosition(id) : GlobalPoint(geo_->getPosition(id)));
559  math::XYZPoint posV(pos.x() - vtx.x(), pos.y() - vtx.y(), pos.z() - vtx.z());
560  return posV;
561 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const CaloGeometry * geo_
Definition: HcalHaloAlgo.h:103
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const HcalGeometry * hgeo_
Definition: HcalHaloAlgo.h:104
GlobalPoint getPosition(const DetId &id) const

◆ HBClusterShapeandTimeStudy()

bool HcalHaloAlgo::HBClusterShapeandTimeStudy ( reco::HaloClusterCandidateHCAL  hcand,
bool  ishlt 
)

Definition at line 501 of file HcalHaloAlgo.cc.

References reco::HaloClusterCandidateHCAL::getEtStripPhiSeedMinus1(), reco::HaloClusterCandidateHCAL::getEtStripPhiSeedPlus1(), reco::HaloClusterCandidateHCAL::getNbTowersInEta(), reco::HaloClusterCandidateHCAL::getSeedEt(), reco::HaloClusterCandidateHCAL::getTimeDiscriminatorITBH(), reco::HaloClusterCandidateHCAL::getTimeDiscriminatorOTBH(), and reco::HaloClusterCandidateHCAL::setIsHaloFromPattern().

Referenced by GetHaloClusterCandidateHB().

501  {
502  //Conditions on the central strip size in eta.
503  //For low size, extra conditions on seed et, isolation and cluster timing
504  //Here we target both IT and OT beam halo. Two separate discriminators were built for the two cases.
505 
506  if (hcand.getSeedEt() < 10)
507  return false;
508 
509  if (hcand.getNbTowersInEta() < 3)
510  return false;
511  //Isolation criteria for very short eta strips
512  if (hcand.getNbTowersInEta() == 3 && (hcand.getEtStripPhiSeedPlus1() > 0.1 || hcand.getEtStripPhiSeedMinus1() > 0.1))
513  return false;
514  if (hcand.getNbTowersInEta() <= 5 && (hcand.getEtStripPhiSeedPlus1() > 0.1 && hcand.getEtStripPhiSeedMinus1() > 0.1))
515  return false;
516 
517  //Timing conditions for short eta strips
518  if (hcand.getNbTowersInEta() == 3 && hcand.getTimeDiscriminatorITBH() >= 0.)
519  return false;
520  if (hcand.getNbTowersInEta() <= 6 && hcand.getTimeDiscriminatorITBH() >= 5. && hcand.getTimeDiscriminatorOTBH() < 0.)
521  return false;
522 
523  //For HLT, only use conditions without timing
524  if (ishlt && hcand.getNbTowersInEta() < 7)
525  return false;
526 
527  hcand.setIsHaloFromPattern(true);
528 
529  return true;
530 }

◆ HEClusterShapeandTimeStudy()

bool HcalHaloAlgo::HEClusterShapeandTimeStudy ( reco::HaloClusterCandidateHCAL  hcand,
bool  ishlt 
)

Definition at line 532 of file HcalHaloAlgo.cc.

References reco::HaloClusterCandidateHCAL::getH1overH123(), reco::HaloClusterCandidateHCAL::getSeedEt(), reco::HaloClusterCandidateHCAL::getSeedR(), and reco::HaloClusterCandidateHCAL::setIsHaloFromPattern().

Referenced by GetHaloClusterCandidateHE().

532  {
533  //Conditions on H1/H123 to spot halo interacting only in one HCAL layer.
534  //For R> about 170cm, HE has only one layer and this condition cannot be applied
535  //Note that for R>170 cm, the halo is in CSC acceptance and will most likely be spotted by the CSC-calo matching method
536  //A method to identify halos interacting in both H1 and H2/H3 at low R is still missing.
537 
538  if (hcand.getSeedEt() < 20)
539  return false;
540  if (hcand.getSeedR() > 170)
541  return false;
542 
543  if (hcand.getH1overH123() > 0.02 && hcand.getH1overH123() < 0.98)
544  return false;
545 
546  //This method is one of the ones with the highest fake rate: in JetHT dataset, it happens in around 0.1% of the cases that a low pt jet (pt= 20) leaves all of its energy in only one HCAL layer.
547  //At HLT, one only cares about large deposits from BH that would lead to a MET/SinglePhoton trigger to be fired.
548  //Rising the seed Et threshold at HLT has therefore little impact on the HLT performances but ensures that possible controversial events are still recorded.
549  if (ishlt && hcand.getSeedEt() < 50)
550  return false;
551 
552  hcand.setIsHaloFromPattern(true);
553 
554  return true;
555 }

◆ SetPhiWedgeEnergyThreshold()

void HcalHaloAlgo::SetPhiWedgeEnergyThreshold ( float  SumE)
inline

Definition at line 67 of file HcalHaloAlgo.h.

References SumEnergyThreshold.

67 { SumEnergyThreshold = SumE; }
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:99

◆ SetPhiWedgeNHitsThreshold()

void HcalHaloAlgo::SetPhiWedgeNHitsThreshold ( int  nhits)
inline

◆ SetPhiWedgeThresholds()

void HcalHaloAlgo::SetPhiWedgeThresholds ( float  SumE,
int  nhits 
)
inline

◆ SetRecHitEnergyThresholds()

void HcalHaloAlgo::SetRecHitEnergyThresholds ( float  HB,
float  HE 
)
inline

Definition at line 61 of file HcalHaloAlgo.h.

References HB, HBRecHitEnergyThreshold, HE, and HERecHitEnergyThreshold.

Referenced by reco::HcalHaloDataProducer::produce().

61  {
64  }
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:96
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:95

Member Data Documentation

◆ geo_

const CaloGeometry* HcalHaloAlgo::geo_
private

Definition at line 103 of file HcalHaloAlgo.h.

Referenced by Calculate(), and getPosition().

◆ geoToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> HcalHaloAlgo::geoToken_
private

Definition at line 102 of file HcalHaloAlgo.h.

Referenced by Calculate().

◆ HBRecHitEnergyThreshold

float HcalHaloAlgo::HBRecHitEnergyThreshold
private

◆ HERecHitEnergyThreshold

float HcalHaloAlgo::HERecHitEnergyThreshold
private

◆ hgeo_

const HcalGeometry* HcalHaloAlgo::hgeo_
private

Definition at line 104 of file HcalHaloAlgo.h.

Referenced by Calculate(), and getPosition().

◆ NHitsThreshold

int HcalHaloAlgo::NHitsThreshold
private

◆ SumEnergyThreshold

float HcalHaloAlgo::SumEnergyThreshold
private