33 return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers,TheEBRecHits,TheEERecHits,TheSetup);
46 float MinTimeHits[73];
48 float MaxTimeHits[73];
49 for(
unsigned int i = 0 ;
i < 73 ;
i++ )
60 switch (
id.subdet() )
76 SumE[iPhi]+=
hit->energy();
80 MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
81 MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
85 for(
int iPhi = 1 ; iPhi < 73 ; iPhi++ )
90 PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
93 std::vector<const HBHERecHit*> Hits;
98 if(
id.iphi() != iPhi )
continue;
100 switch (
id.subdet() )
111 Hits.push_back(&(*
hit));
114 std::sort( Hits.begin() , Hits.end() ,
CompareTime);
115 float MinusToPlus = 0.;
116 float PlusToMinus = 0.;
117 for(
unsigned int i = 0 ;
i < Hits.size() ;
i++ )
120 int ieta_i = id_i.
ieta();
121 for(
unsigned int j = (
i+1) ; j < Hits.size() ; j++ )
124 int ieta_j = id_j.
ieta();
125 if( ieta_i > ieta_j ) PlusToMinus +=
TMath::Abs(ieta_i - ieta_j ) ;
126 else MinusToPlus +=
TMath::Abs(ieta_i - ieta_j);
129 float PlusZOriginConfidence = (PlusToMinus + MinusToPlus )? PlusToMinus / ( PlusToMinus + MinusToPlus ) : -1. ;
140 std::map<int, float> iPhiHadEtMap;
141 std::vector<const CaloTower*> sortedCaloTowers;
143 if(
std::abs(tower->ieta()) > maxAbsIEta)
continue;
145 int iPhi = tower->iphi();
146 if(!iPhiHadEtMap.count(iPhi)) iPhiHadEtMap[iPhi] = 0.0;
147 iPhiHadEtMap[iPhi] += tower->hadEt();
149 if(tower->numProblematicHcalCells() > 0) sortedCaloTowers.push_back(&(*tower));
156 std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(),
CompareTowers);
161 int prevIEta = -99, prevIPhi = -99;
162 float prevHadEt = 0.;
164 std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
165 bool wasContiguous =
true;
168 for(
unsigned int i = 0;
i < sortedCaloTowers.size();
i++) {
173 bool newIPhi = tower->
iphi() != prevIPhi;
174 bool isContiguous = tower->
ieta() == 1 ? tower->
ieta() - 2 == prevIEta : tower->
ieta() - 1 == prevIEta;
176 isContiguous = isContiguous || (tower->
ieta() == -maxAbsIEta);
177 if(newIPhi) isContiguous =
false;
179 if(!wasContiguous && isContiguous) {
180 strip.cellTowerIds.push_back(prevPair);
181 strip.cellTowerIds.push_back(towerPair);
182 strip.hadEt += prevHadEt + tower->
hadEt();
183 strip.emEt += prevEmEt + tower->
emEt();
186 if(wasContiguous && isContiguous) {
187 strip.cellTowerIds.push_back(towerPair);
188 strip.hadEt += tower->
hadEt();
189 strip.emEt += tower->
emEt();
192 if((wasContiguous && !isContiguous) ||
i == sortedCaloTowers.size()-1) {
194 if(strip.cellTowerIds.size() > 3) {
196 int iPhi = strip.cellTowerIds.at(0).second.iphi();
197 int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
198 int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
200 float energyRatio = 0.0;
201 if(iPhiHadEtMap.count(iPhiLower)) energyRatio += iPhiHadEtMap[iPhiLower];
202 if(iPhiHadEtMap.count(iPhiUpper)) energyRatio += iPhiHadEtMap[iPhiUpper];
203 iPhiHadEtMap[iPhi] =
std::max(iPhiHadEtMap[iPhi], 0.001
F);
205 energyRatio /= iPhiHadEtMap[iPhi];
206 strip.energyRatio = energyRatio;
214 wasContiguous = isContiguous;
215 prevPair = towerPair;
216 prevEmEt = tower->
emEt();
217 prevIPhi = tower->
iphi();
218 prevIEta = tower->
ieta();
219 prevHadEt = tower->
hadEt();
237 std::vector<HaloClusterCandidateHCAL> haloclustercands_HB;
240 std::vector<HaloClusterCandidateHCAL> haloclustercands_HE;
247 return TheHcalHaloData;
260 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHB;
264 for(
size_t ihit = 0; ihit<hbherechitcoll->
size(); ++ ihit){
267 const HBHERecHit & rechit = (*hbherechitcoll)[ ihit ];
270 double rhet = rechit.
energy()*
sqrt(rhpos.perp2()/rhpos.mag2());
271 if(rhet<et_thresh_seedrh)
continue;
272 if(
std::abs(rhpos.z())>zseparation_HBHE)
continue;
273 double eta = rhpos.eta();
274 double phi = rhpos.phi();
278 int nbtowerssameeta(0);
279 double timediscriminatorITBH(0),timediscriminatorOTBH(0);
280 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
284 for(
size_t jhit = 0; jhit<hbherechitcoll->
size(); ++ jhit){
285 const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
288 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
289 if(rhetj<2)
continue;
290 if(
std::abs(rhposj.z())>zseparation_HBHE)
continue;
291 double etaj = rhposj.eta();
292 double phij = rhposj.phi();
293 double deta = eta - etaj;
299 if(
std::abs(dphi)<0.05) nbtowerssameeta++;
300 if(dphi>0.05) etstrip_phiseedplus1+=rhetj;
301 if(dphi<-0.05) etstrip_phiseedminus1+=rhetj;
314 double rhtj = rechitj.
time();
315 timediscriminatorITBH+= std::log10( rhetj )* ( rhtj +0.5*(
sqrt(240.*240.+rhposj.z()*rhposj.z()) -
std::abs(rhposj.z()))/c_cm_per_ns);
316 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) );
321 if(etstrip_phiseedplus1/etcluster>0.2&& etstrip_phiseedminus1/etcluster>0.2)
continue;
325 for(
size_t jhit = 0; jhit<ecalrechitcoll->
size(); ++ jhit){
326 const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
328 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
329 if(rhetj<2)
continue;
330 double etaj = rhposj.eta();
331 double phij = rhposj.phi();
332 if(
std::abs(eta-etaj)>0.2)
continue;
334 eoh+=rhetj/etcluster;
337 if(eoh>0.1)
continue;
361 TheHaloClusterCandsHB.push_back(clustercand);
364 return TheHaloClusterCandsHB;
370 std::vector<HaloClusterCandidateHCAL> TheHaloClusterCandsHE;
374 for(
size_t ihit = 0; ihit<hbherechitcoll->
size(); ++ ihit){
377 const HBHERecHit & rechit = (*hbherechitcoll)[ ihit ];
380 double rhet = rechit.
energy()*
sqrt(rhpos.perp2()/rhpos.mag2());
381 if(rhet<et_thresh_seedrh)
continue;
382 if(
std::abs(rhpos.z())<zseparation_HBHE)
continue;
383 double eta = rhpos.eta();
384 double phi = rhpos.phi();
385 double rhr =
sqrt(rhpos.perp2());
387 double etcluster(0),hdepth1(0);
389 double etstrip_phiseedplus1(0), etstrip_phiseedminus1(0);
393 for(
size_t jhit = 0; jhit<hbherechitcoll->
size(); ++ jhit){
394 const HBHERecHit & rechitj = (*hbherechitcoll)[ jhit ];
397 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
398 if(rhetj<2)
continue;
399 if(
std::abs(rhposj.z())<zseparation_HBHE)
continue;
400 if(rhpos.z()*rhposj.z()<0)
continue;
401 double phij = rhposj.phi();
404 double rhrj =
sqrt(rhposj.perp2());
405 if(
std::abs( rhr-rhrj )>50)
continue;
407 if(dphi>0.05) etstrip_phiseedplus1+=rhetj;
408 if(dphi<-0.05) etstrip_phiseedminus1+=rhetj;
411 if(
std::abs( rhposj.z())<405 )hdepth1+=rhetj;
417 if(etstrip_phiseedplus1/etcluster>0.1&& etstrip_phiseedminus1/etcluster>0.1)
continue;
421 for(
size_t jhit = 0; jhit<ecalrechitcoll->
size(); ++ jhit){
422 const EcalRecHit & rechitj = (*ecalrechitcoll)[ jhit ];
424 double rhetj = rechitj.
energy()*
sqrt(rhposj.perp2()/rhposj.mag2());
425 if(rhetj<2)
continue;
426 if(rhpos.z()*rhposj.z()<0)
continue;
427 double etaj = rhposj.eta();
428 double phij = rhposj.phi();
432 eoh+=rhetj/etcluster;
435 if(eoh>0.1)
continue;
459 TheHaloClusterCandsHE.push_back(clustercand);
462 return TheHaloClusterCandsHE;
500 if(hcand.
getSeedR()>170)
return false;
507 if(ishlt && hcand.
getSeedEt()<50)
return false;
void setIsHaloFromPattern(bool x)
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)
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)
const CaloGeometry * geo_
int getNbTowersInEta() const
double getTimeDiscriminatorOTBH() const
bool HBClusterShapeandTimeStudy(reco::HaloClusterCandidateHCAL hcand, bool ishlt)
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
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
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)
const_iterator end() const
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)
const_iterator begin() const
std::vector< reco::HaloClusterCandidateHCAL > GetHaloClusterCandidateHB(edm::Handle< EcalRecHitCollection > &ebrechitcoll, edm::Handle< HBHERecHitCollection > &hbherechitcoll, float et_thresh_seedrh)