21 return x->iphi() * 1000 +
x->ieta() < y->iphi() * 1000 + y->ieta();
37 return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers, TheEBRecHits, TheEERecHits, TheSetup);
48 const int iEtaOverlap = 22;
49 const int nPhiMax = 73;
55 float MinTimeHits[nPhiMax];
57 float MaxTimeHits[nPhiMax];
58 for (
unsigned int i = 0;
i < nPhiMax;
i++) {
65 for (
const auto&
hit : (*TheHBHERecHits)) {
67 switch (
id.subdet()) {
83 SumE[iPhi] +=
hit.energy();
87 MinTimeHits[iPhi] =
time < MinTimeHits[iPhi] ?
time : MinTimeHits[iPhi];
88 MaxTimeHits[iPhi] =
time > MaxTimeHits[iPhi] ?
time : MaxTimeHits[iPhi];
92 for (
int iPhi = 1; iPhi < nPhiMax; iPhi++) {
95 PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
98 std::vector<const HBHERecHit*> Hits;
99 for (
const auto&
hit : (*TheHBHERecHits)) {
101 if (
id.
iphi() != iPhi)
105 switch (
id.subdet()) {
117 Hits.push_back(&(
hit));
121 float MinusToPlus = 0.;
122 float PlusToMinus = 0.;
123 for (
unsigned int i = 0;
i < Hits.size();
i++) {
125 int ieta_i = id_i.
ieta();
126 for (
unsigned int j = (
i + 1);
j < Hits.size();
j++) {
128 int ieta_j = id_j.
ieta();
130 PlusToMinus +=
std::abs(ieta_i - ieta_j);
132 MinusToPlus +=
std::abs(ieta_i - ieta_j);
135 float PlusZOriginConfidence = (PlusToMinus + MinusToPlus) ? PlusToMinus / (PlusToMinus + MinusToPlus) : -1.;
144 std::map<int, float> iPhiHadEtMap;
145 std::vector<const CaloTower*> sortedCaloTowers;
146 for (
const auto&
tower : (*TheCaloTowers)) {
150 int iPhi =
tower.iphi();
151 if (!iPhiHadEtMap.count(iPhi))
152 iPhiHadEtMap[iPhi] = 0.0;
153 iPhiHadEtMap[iPhi] +=
tower.hadEt();
155 if (
tower.numProblematicHcalCells() > 0)
156 sortedCaloTowers.push_back(&(
tower));
165 int prevIEta = -99, prevIPhi = -99;
166 float prevHadEt = 0.;
168 std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
169 bool wasContiguous =
true;
172 for (
unsigned int i = 0;
i < sortedCaloTowers.size();
i++) {
175 towerPair = std::make_pair((uint8_t)
tower->numProblematicHcalCells(),
tower->id());
177 bool newIPhi =
tower->iphi() != prevIPhi;
178 bool isContiguous =
tower->ieta() == 1 ?
tower->ieta() - 2 == prevIEta :
tower->ieta() - 1 == prevIEta;
180 isContiguous = isContiguous || (
tower->ieta() == -maxAbsIEta);
182 isContiguous =
false;
184 if (!wasContiguous && isContiguous) {
185 strip.cellTowerIds.push_back(prevPair);
186 strip.cellTowerIds.push_back(towerPair);
191 if (wasContiguous && isContiguous) {
192 strip.cellTowerIds.push_back(towerPair);
197 if ((wasContiguous && !isContiguous) ||
i == sortedCaloTowers.size() - 1) {
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;
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.001
F);
211 energyRatio /= iPhiHadEtMap[iPhi];
212 strip.energyRatio = energyRatio;
219 wasContiguous = isContiguous;
220 prevPair = towerPair;
221 prevEmEt =
tower->emEt();
222 prevIPhi =
tower->iphi();
223 prevIEta =
tower->ieta();
224 prevHadEt =
tower->hadEt();
240 std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
243 std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
249 return TheHcalHaloData;
255 float et_thresh_seedrh) {
256 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
260 for (
size_t ihit = 0; ihit < hbherechitcoll->
size(); ++ihit) {
263 const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
266 double rhet = rechit.
energy() *
sqrt(rhpos.perp2() / rhpos.mag2());
267 if (rhet < et_thresh_seedrh)
269 if (
std::abs(rhpos.z()) > zseparation_HBHE)
271 double eta = rhpos.eta();
272 double phi = rhpos.phi();
276 int nbtowerssameeta(0);
277 double timediscriminatorITBH(0), timediscriminatorOTBH(0);
278 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
282 for (
size_t jhit = 0; jhit < hbherechitcoll->
size(); ++jhit) {
283 const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
286 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
289 if (
std::abs(rhposj.z()) > zseparation_HBHE)
291 double etaj = rhposj.eta();
292 double phij = rhposj.phi();
293 double deta =
eta - etaj;
308 etstrip_phiseedplus1 += rhetj;
310 etstrip_phiseedminus1 += rhetj;
323 double rhtj = rechitj.
time();
324 timediscriminatorITBH +=
326 (rhtj + 0.5 * (
sqrt(240. * 240. + rhposj.z() * rhposj.z()) -
std::abs(rhposj.z())) / c_cm_per_ns);
328 timediscriminatorOTBH +=
330 (rhtj - 0.5 * (25 - (
sqrt(330. * 330. + rhposj.z() * rhposj.z()) +
std::abs(rhposj.z())) / c_cm_per_ns));
336 if (etstrip_phiseedplus1 / etcluster > 0.2 && etstrip_phiseedminus1 / etcluster > 0.2)
341 for (
size_t jhit = 0; jhit < ecalrechitcoll->
size(); ++jhit) {
342 const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
344 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
347 double etaj = rhposj.eta();
348 double phij = rhposj.phi();
353 eoh += rhetj / etcluster;
379 TheHaloClusterCandsHB.push_back(clustercand);
382 return TheHaloClusterCandsHB;
388 float et_thresh_seedrh) {
389 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
393 for (
size_t ihit = 0; ihit < hbherechitcoll->
size(); ++ihit) {
396 const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
399 double rhet = rechit.
energy() *
sqrt(rhpos.perp2() / rhpos.mag2());
400 if (rhet < et_thresh_seedrh)
402 if (
std::abs(rhpos.z()) < zseparation_HBHE)
404 double eta = rhpos.eta();
405 double phi = rhpos.phi();
406 double rhr =
sqrt(rhpos.perp2());
408 double etcluster(0), hdepth1(0);
410 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
414 for (
size_t jhit = 0; jhit < hbherechitcoll->
size(); ++jhit) {
415 const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
418 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
421 if (
std::abs(rhposj.z()) < zseparation_HBHE)
423 if (rhpos.z() * rhposj.z() < 0)
425 double phij = rhposj.phi();
429 double rhrj =
sqrt(rhposj.perp2());
437 etstrip_phiseedplus1 += rhetj;
439 etstrip_phiseedminus1 += rhetj;
450 if (etstrip_phiseedplus1 / etcluster > 0.1 && etstrip_phiseedminus1 / etcluster > 0.1)
455 for (
size_t jhit = 0; jhit < ecalrechitcoll->
size(); ++jhit) {
456 const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
458 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
461 if (rhpos.z() * rhposj.z() < 0)
463 double etaj = rhposj.eta();
464 double phij = rhposj.phi();
469 eoh += rhetj / etcluster;
495 TheHaloClusterCandsHE.push_back(clustercand);
498 return TheHaloClusterCandsHE;
void setIsHaloFromPattern(bool x)
double getTimeDiscriminatorOTBH() const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken_
double getEtStripPhiSeedPlus1() const
float HERecHitEnergyThreshold
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
void setHaloClusterCandidatesHB(const std::vector< HaloClusterCandidateHCAL > &x)
double getH1overH123() const
Global3DPoint GlobalPoint
void setH1overH123(double x)
double getEtStripPhiSeedMinus1() const
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHE(edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
const CaloGeometry * geo_
bool HBClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
constexpr float energy() const
void setSeedEta(double x)
double getTimeDiscriminatorITBH() const
const std::vector< HaloTowerStrip > & getProblematicStrips() const
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
void setEtStripPhiSeedPlus1(double x)
constexpr int ieta() const
get the cell ieta
void setHaloClusterCandidatesHE(const std::vector< HaloClusterCandidateHCAL > &x)
Abs< T >::type abs(const T &t)
void SetPlusZOriginConfidence(float x)
void setNbTowersInEta(double x)
math::XYZPoint Point
point in the space
int getNbTowersInEta() const
bool CompareTime(const HBHERecHit *x, const HBHERecHit *y)
void setTimeDiscriminator(double x)
void setSeedTime(double x)
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)
constexpr HcalDetId id() const
get the id
void setEtStripPhiSeedMinus1(double x)
XYZPointD XYZPoint
point in space with cartesian internal representation
bool CompareTowers(const CaloTower *x, const CaloTower *y)
float HBRecHitEnergyThreshold
const HcalGeometry * hgeo_
DetId id() const
get the id
constexpr float time() const
void setTimeDiscriminatorOTBH(double x)
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
GlobalPoint getPosition(const DetId &id) const
HcalHaloAlgo(edm::ConsumesCollector iC)
void setBeamHaloRecHitsCandidates(edm::RefVector< HBHERecHitCollection > x)
void setSeedPhi(double x)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
void setIsHaloFromPattern_HLT(bool x)
void setClusterSize(int x)
const std::vector< PhiWedge > & GetPhiWedges() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
bool HEClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
void setTimeDiscriminatorITBH(double x)
void setClusterEt(double x)
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHB(edm::Handle< EcalRecHitCollection > &ebrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)