36 return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers, TheEBRecHits, TheEERecHits, TheSetup);
47 const int iEtaOverlap = 22;
48 const int nPhiMax = 73;
54 float MinTimeHits[nPhiMax];
56 float MaxTimeHits[nPhiMax];
57 for (
unsigned int i = 0;
i < nPhiMax;
i++) {
64 for (
const auto&
hit : (*TheHBHERecHits)) {
66 switch (
id.subdet()) {
81 if (iPhi < nPhiMax &&
std::abs(iEta) <= iEtaOverlap) {
82 SumE[iPhi] +=
hit.energy();
86 MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
87 MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
91 for (
int iPhi = 1; iPhi < nPhiMax; iPhi++) {
94 PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
97 std::vector<const HBHERecHit*> Hits;
98 for (
const auto&
hit : (*TheHBHERecHits)) {
100 if (
id.
iphi() != iPhi)
104 switch (
id.subdet()) {
116 Hits.push_back(&(
hit));
120 float MinusToPlus = 0.;
121 float PlusToMinus = 0.;
122 for (
unsigned int i = 0;
i < Hits.size();
i++) {
124 int ieta_i = id_i.
ieta();
125 for (
unsigned int j = (
i + 1);
j < Hits.size();
j++) {
127 int ieta_j = id_j.
ieta();
129 PlusToMinus +=
std::abs(ieta_i - ieta_j);
131 MinusToPlus +=
std::abs(ieta_i - ieta_j);
134 float PlusZOriginConfidence = (PlusToMinus + MinusToPlus) ? PlusToMinus / (PlusToMinus + MinusToPlus) : -1.;
143 std::map<int, float> iPhiHadEtMap;
144 std::vector<const CaloTower*> sortedCaloTowers;
145 for (
const auto&
tower : (*TheCaloTowers)) {
149 int iPhi =
tower.iphi();
150 if (!iPhiHadEtMap.count(iPhi))
151 iPhiHadEtMap[iPhi] = 0.0;
152 iPhiHadEtMap[iPhi] +=
tower.hadEt();
154 if (
tower.numProblematicHcalCells() > 0)
155 sortedCaloTowers.push_back(&(
tower));
160 std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(),
CompareTowers);
164 int prevIEta = -99, prevIPhi = -99;
165 float prevHadEt = 0.;
167 std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
168 bool wasContiguous =
true;
171 for (
unsigned int i = 0;
i < sortedCaloTowers.size();
i++) {
176 bool newIPhi = tower->
iphi() != prevIPhi;
177 bool isContiguous = tower->
ieta() == 1 ? tower->
ieta() - 2 == prevIEta : tower->
ieta() - 1 == prevIEta;
179 isContiguous = isContiguous || (tower->
ieta() == -maxAbsIEta);
181 isContiguous =
false;
183 if (!wasContiguous && isContiguous) {
184 strip.cellTowerIds.push_back(prevPair);
185 strip.cellTowerIds.push_back(towerPair);
186 strip.hadEt += prevHadEt + tower->
hadEt();
187 strip.emEt += prevEmEt + tower->
emEt();
190 if (wasContiguous && isContiguous) {
191 strip.cellTowerIds.push_back(towerPair);
192 strip.hadEt += tower->
hadEt();
193 strip.emEt += tower->
emEt();
196 if ((wasContiguous && !isContiguous) ||
i == sortedCaloTowers.size() - 1) {
198 if (strip.cellTowerIds.size() > 3) {
199 int iPhi = strip.cellTowerIds.at(0).second.iphi();
200 int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
201 int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
203 float energyRatio = 0.0;
204 if (iPhiHadEtMap.count(iPhiLower))
205 energyRatio += iPhiHadEtMap[iPhiLower];
206 if (iPhiHadEtMap.count(iPhiUpper))
207 energyRatio += iPhiHadEtMap[iPhiUpper];
208 iPhiHadEtMap[iPhi] =
std::max(iPhiHadEtMap[iPhi], 0.001
F);
210 energyRatio /= iPhiHadEtMap[iPhi];
211 strip.energyRatio = energyRatio;
218 wasContiguous = isContiguous;
219 prevPair = towerPair;
220 prevEmEt = tower->
emEt();
221 prevIPhi = tower->
iphi();
222 prevIEta = tower->
ieta();
223 prevHadEt = tower->
hadEt();
241 std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
244 std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
250 return TheHcalHaloData;
256 float et_thresh_seedrh) {
257 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
261 for (
size_t ihit = 0; ihit < hbherechitcoll->
size(); ++ihit) {
264 const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
267 double rhet = rechit.
energy() *
sqrt(rhpos.perp2() / rhpos.mag2());
268 if (rhet < et_thresh_seedrh)
270 if (
std::abs(rhpos.z()) > zseparation_HBHE)
272 double eta = rhpos.eta();
273 double phi = rhpos.phi();
277 int nbtowerssameeta(0);
278 double timediscriminatorITBH(0), timediscriminatorOTBH(0);
279 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
283 for (
size_t jhit = 0; jhit < hbherechitcoll->
size(); ++jhit) {
284 const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
287 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
290 if (
std::abs(rhposj.z()) > zseparation_HBHE)
292 double etaj = rhposj.eta();
293 double phij = rhposj.phi();
294 double deta = eta - etaj;
309 etstrip_phiseedplus1 += rhetj;
311 etstrip_phiseedminus1 += rhetj;
324 double rhtj = rechitj.
time();
325 timediscriminatorITBH +=
327 (rhtj + 0.5 * (
sqrt(240. * 240. + rhposj.z() * rhposj.z()) -
std::abs(rhposj.z())) / c_cm_per_ns);
329 timediscriminatorOTBH +=
331 (rhtj - 0.5 * (25 - (
sqrt(330. * 330. + rhposj.z() * rhposj.z()) +
std::abs(rhposj.z())) / c_cm_per_ns));
337 if (etstrip_phiseedplus1 / etcluster > 0.2 && etstrip_phiseedminus1 / etcluster > 0.2)
342 for (
size_t jhit = 0; jhit < ecalrechitcoll->
size(); ++jhit) {
343 const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
345 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
348 double etaj = rhposj.eta();
349 double phij = rhposj.phi();
354 eoh += rhetj / etcluster;
380 TheHaloClusterCandsHB.push_back(clustercand);
383 return TheHaloClusterCandsHB;
389 float et_thresh_seedrh) {
390 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
394 for (
size_t ihit = 0; ihit < hbherechitcoll->
size(); ++ihit) {
397 const HBHERecHit& rechit = (*hbherechitcoll)[ihit];
400 double rhet = rechit.
energy() *
sqrt(rhpos.perp2() / rhpos.mag2());
401 if (rhet < et_thresh_seedrh)
403 if (
std::abs(rhpos.z()) < zseparation_HBHE)
405 double eta = rhpos.eta();
406 double phi = rhpos.phi();
407 double rhr =
sqrt(rhpos.perp2());
409 double etcluster(0), hdepth1(0);
411 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
415 for (
size_t jhit = 0; jhit < hbherechitcoll->
size(); ++jhit) {
416 const HBHERecHit& rechitj = (*hbherechitcoll)[jhit];
419 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
422 if (
std::abs(rhposj.z()) < zseparation_HBHE)
424 if (rhpos.z() * rhposj.z() < 0)
426 double phij = rhposj.phi();
430 double rhrj =
sqrt(rhposj.perp2());
438 etstrip_phiseedplus1 += rhetj;
440 etstrip_phiseedminus1 += rhetj;
451 if (etstrip_phiseedplus1 / etcluster > 0.1 && etstrip_phiseedminus1 / etcluster > 0.1)
456 for (
size_t jhit = 0; jhit < ecalrechitcoll->
size(); ++jhit) {
457 const EcalRecHit& rechitj = (*ecalrechitcoll)[jhit];
459 double rhetj = rechitj.
energy() *
sqrt(rhposj.perp2() / rhposj.mag2());
462 if (rhpos.z() * rhposj.z() < 0)
464 double etaj = rhposj.eta();
465 double phij = rhposj.phi();
470 eoh += rhetj / etcluster;
496 TheHaloClusterCandsHE.push_back(clustercand);
499 return TheHaloClusterCandsHE;
void setIsHaloFromPattern(bool x)
constexpr float energy() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
double getEtStripPhiSeedPlus1() const
float HERecHitEnergyThreshold
void setHaloClusterCandidatesHB(const std::vector< HaloClusterCandidateHCAL > &x)
HcalDetId id() const
get the id
Global3DPoint GlobalPoint
void setH1overH123(double x)
double getH1overH123() const
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHE(edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
const CaloGeometry * geo_
int getNbTowersInEta() const
double getTimeDiscriminatorOTBH() const
bool HBClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
void setSeedEta(double x)
void setEtStripPhiSeedPlus1(double x)
constexpr float time() const
double getEtStripPhiSeedMinus1() const
int ieta() const
get the cell ieta
void setHaloClusterCandidatesHE(const std::vector< HaloClusterCandidateHCAL > &x)
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Abs< T >::type abs(const T &t)
void SetPlusZOriginConfidence(float x)
void setNbTowersInEta(double x)
math::XYZPoint Point
point in the space
bool CompareTime(const HBHERecHit *x, const HBHERecHit *y)
GlobalPoint getPosition(const DetId &id) const
double getTimeDiscriminatorITBH() const
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)
CaloTowerDetId id() const
unsigned int numProblematicHcalCells() const
DetId 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_
void setTimeDiscriminatorOTBH(double x)
math::XYZPoint getPosition(const DetId &id, reco::Vertex::Point vtx)
const std::vector< HaloTowerStrip > & getProblematicStrips() const
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.
const std::vector< PhiWedge > & GetPhiWedges() const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
void setIsHaloFromPattern_HLT(bool x)
void setClusterSize(int x)
T const * product() const
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)