28 HBRecHitEnergyThreshold = 0.;
29 HERecHitEnergyThreshold = 0.;
30 SumEnergyThreshold = 0.;
38 return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers,TheEBRecHits,TheEERecHits,TheSetup);
51 float MinTimeHits[73];
53 float MaxTimeHits[73];
54 for(
unsigned int i = 0 ;
i < 73 ;
i++ )
65 switch (
id.subdet() )
68 if(
hit->energy() < HBRecHitEnergyThreshold )
continue;
71 if(
hit->energy() < HERecHitEnergyThreshold )
continue;
81 SumE[iPhi]+=
hit->energy();
84 float time =
hit->time();
85 MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
86 MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
90 for(
int iPhi = 1 ; iPhi < 73 ; iPhi++ )
92 if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold )
95 PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
98 std::vector<const HBHERecHit*> Hits;
103 if(
id.iphi() != iPhi )
continue;
105 switch (
id.subdet() )
108 if(
hit->energy() < HBRecHitEnergyThreshold )
continue;
111 if(
hit->energy() < HERecHitEnergyThreshold )
continue;
116 Hits.push_back(&(*
hit));
119 std::sort( Hits.begin() , Hits.end() ,
CompareTime);
120 float MinusToPlus = 0.;
121 float PlusToMinus = 0.;
122 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++ )
129 int ieta_j = id_j.
ieta();
130 if( ieta_i > ieta_j ) PlusToMinus +=
TMath::Abs(ieta_i - ieta_j ) ;
131 else MinusToPlus +=
TMath::Abs(ieta_i - ieta_j);
134 float PlusZOriginConfidence = (PlusToMinus + MinusToPlus )? PlusToMinus / ( PlusToMinus + MinusToPlus ) : -1. ;
145 std::map<int, float> iPhiHadEtMap;
146 std::vector<const CaloTower*> sortedCaloTowers;
148 if(
abs(tower->ieta()) > maxAbsIEta)
continue;
150 int iPhi = tower->iphi();
151 if(!iPhiHadEtMap.count(iPhi)) iPhiHadEtMap[iPhi] = 0.0;
152 iPhiHadEtMap[iPhi] += tower->hadEt();
154 if(tower->numProblematicHcalCells() > 0) sortedCaloTowers.push_back(&(*tower));
161 std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(),
CompareTowers);
166 int prevIEta = -99, prevIPhi = -99;
167 float prevHadEt = 0.;
169 std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
170 bool wasContiguous =
true;
173 for(
unsigned int i = 0;
i < sortedCaloTowers.size();
i++) {
178 bool newIPhi = tower->
iphi() != prevIPhi;
179 bool isContiguous = tower->
ieta() == 1 ? tower->
ieta() - 2 == prevIEta : tower->
ieta() - 1 == prevIEta;
181 isContiguous = isContiguous || (tower->
ieta() == -maxAbsIEta);
182 if(newIPhi) isContiguous =
false;
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();
191 if(wasContiguous && isContiguous) {
192 strip.cellTowerIds.push_back(towerPair);
193 strip.hadEt += tower->
hadEt();
194 strip.emEt += tower->
emEt();
197 if((wasContiguous && !isContiguous) ||
i == sortedCaloTowers.size()-1) {
199 if(strip.cellTowerIds.size() > 3) {
201 int iPhi = strip.cellTowerIds.at(0).second.iphi();
202 int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
203 int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
205 float energyRatio = 0.0;
206 if(iPhiHadEtMap.count(iPhiLower)) energyRatio += iPhiHadEtMap[iPhiLower];
207 if(iPhiHadEtMap.count(iPhiUpper)) energyRatio += iPhiHadEtMap[iPhiUpper];
208 iPhiHadEtMap[iPhi] =
max(iPhiHadEtMap[iPhi], 0.001
F);
210 energyRatio /= iPhiHadEtMap[iPhi];
211 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();
242 std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
243 haloclustercands_HB= GetHaloClusterCandidateHB(TheEBRecHits , TheHBHERecHits, 5);
245 std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
246 haloclustercands_HE= GetHaloClusterCandidateHE(TheEERecHits , TheHBHERecHits, 10);
252 return TheHcalHaloData;
265 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
269 for(
size_t ihit = 0; ihit<hbherechitcoll->size(); ++ ihit){
272 const HBHERecHit & rechit = (*hbherechitcoll)[ ihit ];
275 double rhet = rechit.
energy()*
sqrt(rhpos.perp2()/rhpos.mag2());
276 if(rhet<et_thresh_seedrh)
continue;
277 if(
std::abs(rhpos.z())>zseparation_HBHE)
continue;
278 double eta = rhpos.eta();
279 double phi = rhpos.phi();
283 int nbtowerssameeta(0);
284 double timediscriminatorITBH(0),timediscriminatorOTBH(0);
285 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
289 for(
size_t jhit = 0; jhit<hbherechitcoll->size(); ++ jhit){
290 const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
293 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
294 if(rhetj<2)
continue;
295 if(
std::abs(rhposj.z())>zseparation_HBHE)
continue;
296 double etaj = rhposj.eta();
297 double phij = rhposj.phi();
298 double deta = eta - etaj;
304 if(
std::abs(dphi)<0.05) nbtowerssameeta++;
305 if(dphi>0.05) etstrip_phiseedplus1+=rhetj;
306 if(dphi<-0.05) etstrip_phiseedminus1+=rhetj;
319 double rhtj = rechitj.
time();
320 timediscriminatorITBH+= std::log10( rhetj )* ( rhtj +0.5*(
sqrt(240.*240.+rhposj.z()*rhposj.z()) -
std::abs(rhposj.z()))/c_cm_per_ns);
321 if(
std::abs(rhposj.z())<300) timediscriminatorOTBH+= std::log10( rhetj )* ( rhtj -0.5*(25-(
sqrt(330.*330.+rhposj.z()*rhposj.z()) +
std::abs(rhposj.z()))/c_cm_per_ns) );
326 if(etstrip_phiseedplus1/etcluster>0.2&& etstrip_phiseedminus1/etcluster>0.2)
continue;
330 for(
size_t jhit = 0; jhit<ecalrechitcoll->size(); ++ jhit){
331 const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
333 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
334 if(rhetj<2)
continue;
335 double etaj = rhposj.eta();
336 double phij = rhposj.phi();
337 if(
std::abs(eta-etaj)>0.2)
continue;
339 eoh+=rhetj/etcluster;
342 if(eoh>0.1)
continue;
360 bool isbeamhalofrompattern = HBClusterShapeandTimeStudy(clustercand,
false);
362 bool isbeamhalofrompattern_hlt = HBClusterShapeandTimeStudy(clustercand,
true);
366 TheHaloClusterCandsHB.push_back(clustercand);
369 return TheHaloClusterCandsHB;
375 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
379 for(
size_t ihit = 0; ihit<hbherechitcoll->size(); ++ ihit){
382 const HBHERecHit & rechit = (*hbherechitcoll)[ ihit ];
385 double rhet = rechit.
energy()*
sqrt(rhpos.perp2()/rhpos.mag2());
386 if(rhet<et_thresh_seedrh)
continue;
387 if(
std::abs(rhpos.z())<zseparation_HBHE)
continue;
388 double eta = rhpos.eta();
389 double phi = rhpos.phi();
390 double rhr =
sqrt(rhpos.perp2());
392 double etcluster(0),hdepth1(0);
394 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
398 for(
size_t jhit = 0; jhit<hbherechitcoll->size(); ++ jhit){
399 const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
402 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
403 if(rhetj<2)
continue;
404 if(
std::abs(rhposj.z())<zseparation_HBHE)
continue;
405 if(rhpos.z()*rhposj.z()<0)
continue;
406 double phij = rhposj.phi();
409 double rhrj =
sqrt(rhposj.perp2());
410 if(
std::abs( rhr-rhrj )>50)
continue;
412 if(dphi>0.05) etstrip_phiseedplus1+=rhetj;
413 if(dphi<-0.05) etstrip_phiseedminus1+=rhetj;
416 if(
std::abs( rhposj.z())<405 )hdepth1+=rhetj;
422 if(etstrip_phiseedplus1/etcluster>0.1&& etstrip_phiseedminus1/etcluster>0.1)
continue;
426 for(
size_t jhit = 0; jhit<ecalrechitcoll->size(); ++ jhit){
427 const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
429 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
430 if(rhetj<2)
continue;
431 if(rhpos.z()*rhposj.z()<0)
continue;
432 double etaj = rhposj.eta();
433 double phij = rhposj.phi();
437 eoh+=rhetj/etcluster;
440 if(eoh>0.1)
continue;
458 bool isbeamhalofrompattern = HEClusterShapeandTimeStudy(clustercand,
false);
460 bool isbeamhalofrompattern_hlt = HEClusterShapeandTimeStudy(clustercand,
true);
464 TheHaloClusterCandsHE.push_back(clustercand);
467 return TheHaloClusterCandsHE;
505 if(hcand.
getSeedR()>170)
return false;
512 if(ishlt && hcand.
getSeedEt()<50)
return false;
void setIsHaloFromPattern(bool x)
double getEtStripPhiSeedPlus1() const
void setHaloClusterCandidatesHB(const std::vector< HaloClusterCandidateHCAL > &x)
HcalDetId id() const
get the id
void setH1overH123(double x)
std::vector< HBHERecHit >::const_iterator const_iterator
double getH1overH123() const
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHE(edm::Handle< EcalRecHitCollection > &eerechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)
int getNbTowersInEta() const
double getTimeDiscriminatorOTBH() const
bool HBClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
Helper class for the calculation of a top and a W boson mass estime.
void setSeedEta(double x)
void setEtStripPhiSeedPlus1(double x)
double getEtStripPhiSeedMinus1() const
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
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)
T const * product() const
Geom::Phi< T > phi() const
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.
bool CompareTime(const EcalRecHit *x, const EcalRecHit *y)
const std::vector< PhiWedge > & GetPhiWedges() const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
void setIsHaloFromPattern_HLT(bool x)
void setClusterSize(int x)
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)