23 HBRecHitEnergyThreshold = 0.;
24 HERecHitEnergyThreshold = 0.;
25 SumEnergyThreshold = 0.;
31 return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers);
43 float MinTimeHits[73];
45 float MaxTimeHits[73];
46 for(
unsigned int i = 0 ;
i < 73 ;
i++ )
57 switch (
id.subdet() )
60 if(
hit->energy() < HBRecHitEnergyThreshold )
continue;
63 if(
hit->energy() < HERecHitEnergyThreshold )
continue;
73 SumE[iPhi]+=
hit->energy();
76 float time =
hit->time();
77 MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
78 MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
82 for(
int iPhi = 1 ; iPhi < 73 ; iPhi++ )
84 if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold )
87 PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
90 std::vector<const HBHERecHit*> Hits;
95 if(
id.iphi() != iPhi )
continue;
97 switch (
id.subdet() )
100 if(
hit->energy() < HBRecHitEnergyThreshold )
continue;
103 if(
hit->energy() < HERecHitEnergyThreshold )
continue;
108 Hits.push_back(&(*
hit));
111 std::sort( Hits.begin() , Hits.end() ,
CompareTime);
112 float MinusToPlus = 0.;
113 float PlusToMinus = 0.;
114 for(
unsigned int i = 0 ;
i < Hits.size() ;
i++ )
117 int ieta_i = id_i.
ieta();
118 for(
unsigned int j = (
i+1) ;
j < Hits.size() ;
j++ )
121 int ieta_j = id_j.
ieta();
122 if( ieta_i > ieta_j ) PlusToMinus +=
TMath::Abs(ieta_i - ieta_j ) ;
123 else MinusToPlus +=
TMath::Abs(ieta_i - ieta_j);
126 float PlusZOriginConfidence = (PlusToMinus + MinusToPlus )? PlusToMinus / ( PlusToMinus + MinusToPlus ) : -1. ;
137 std::map<int, float> iPhiHadEtMap;
138 std::vector<const CaloTower*> sortedCaloTowers;
140 if(
abs(tower->ieta()) > maxAbsIEta)
continue;
142 int iPhi = tower->iphi();
143 if(!iPhiHadEtMap.count(iPhi)) iPhiHadEtMap[iPhi] = 0.0;
144 iPhiHadEtMap[iPhi] += tower->hadEt();
146 if(tower->numProblematicHcalCells() > 0) sortedCaloTowers.push_back(&(*tower));
153 std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(),
CompareTowers);
158 int prevIEta = -99, prevIPhi = -99;
159 float prevHadEt = 0.;
161 std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
162 bool wasContiguous =
true;
165 for(
unsigned int i = 0;
i < sortedCaloTowers.size();
i++) {
170 bool newIPhi = tower->
iphi() != prevIPhi;
171 bool isContiguous = tower->
ieta() == 1 ? tower->
ieta() - 2 == prevIEta : tower->
ieta() - 1 == prevIEta;
173 isContiguous = isContiguous || (tower->
ieta() == -maxAbsIEta);
174 if(newIPhi) isContiguous =
false;
176 if(!wasContiguous && isContiguous) {
177 strip.cellTowerIds.push_back(prevPair);
178 strip.cellTowerIds.push_back(towerPair);
179 strip.hadEt += prevHadEt + tower->
hadEt();
180 strip.emEt += prevEmEt + tower->
emEt();
183 if(wasContiguous && isContiguous) {
184 strip.cellTowerIds.push_back(towerPair);
185 strip.hadEt += tower->
hadEt();
186 strip.emEt += tower->
emEt();
189 if((wasContiguous && !isContiguous) ||
i == sortedCaloTowers.size()-1) {
191 if(strip.cellTowerIds.size() > 3) {
193 int iPhi = strip.cellTowerIds.at(0).second.iphi();
194 int iPhiLower = (iPhi == 1) ? 72 : iPhi - 1;
195 int iPhiUpper = (iPhi == 72) ? 1 : iPhi + 1;
197 float energyRatio = 0.0;
198 if(iPhiHadEtMap.count(iPhiLower)) energyRatio += iPhiHadEtMap[iPhiLower];
199 if(iPhiHadEtMap.count(iPhiUpper)) energyRatio += iPhiHadEtMap[iPhiUpper];
200 iPhiHadEtMap[iPhi] =
max(iPhiHadEtMap[iPhi], 0.001
F);
202 energyRatio /= iPhiHadEtMap[iPhi];
203 strip.energyRatio = energyRatio;
211 wasContiguous = isContiguous;
212 prevPair = towerPair;
213 prevEmEt = tower->
emEt();
214 prevIPhi = tower->
iphi();
215 prevIEta = tower->
ieta();
216 prevHadEt = tower->
hadEt();
219 return TheHcalHaloData;
std::vector< HBHERecHit >::const_iterator const_iterator
Helper class for the calculation of a top and a W boson mass estime.
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
void SetPlusZOriginConfidence(float x)
reco::HcalHaloData Calculate(const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers)
CaloTowerDetId id() const
unsigned int numProblematicHcalCells() const
bool CompareTowers(const CaloTower *x, const CaloTower *y)
const std::vector< HaloTowerStrip > & getProblematicStrips() const
bool CompareTime(const EcalRecHit *x, const EcalRecHit *y)
const std::vector< PhiWedge > & GetPhiWedges() const
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)