CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HcalHaloAlgo Class Reference

#include <HcalHaloAlgo.h>

Public Member Functions

reco::HcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers)
 
reco::HcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits)
 
float GetHBRecHitEnergyThreshold ()
 
float GetHERecHitEnergyThreshold ()
 
float GetPhiWedgeEnergyThreshold ()
 
int GetPhiWedgeNHitsThreshold ()
 
 HcalHaloAlgo ()
 
void SetPhiWedgeEnergyThreshold (float SumE)
 
void SetPhiWedgeNHitsThreshold (int nhits)
 
void SetPhiWedgeThresholds (float SumE, int nhits)
 
void SetRecHitEnergyThresholds (float HB, float HE)
 
 ~HcalHaloAlgo ()
 

Private Attributes

float HBRecHitEnergyThreshold
 
float HERecHitEnergyThreshold
 
int NHitsThreshold
 
float SumEnergyThreshold
 

Detailed Description

Definition at line 30 of file HcalHaloAlgo.h.

Constructor & Destructor Documentation

HcalHaloAlgo::HcalHaloAlgo ( )

Definition at line 21 of file HcalHaloAlgo.cc.

22 {
25  SumEnergyThreshold = 0.;
26  NHitsThreshold = 0;
27 }
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:61
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:60
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:64
int NHitsThreshold
Definition: HcalHaloAlgo.h:65
HcalHaloAlgo::~HcalHaloAlgo ( )
inline

Definition at line 35 of file HcalHaloAlgo.h.

35 {}

Member Function Documentation

HcalHaloData HcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits,
edm::Handle< CaloTowerCollection > &  TheCaloTowers 
)

Definition at line 34 of file HcalHaloAlgo.cc.

References funct::abs(), Abs(), CompareTime(), CompareTowers(), CaloTower::emEt(), F(), reco::HcalHaloData::GetPhiWedges(), reco::HcalHaloData::getProblematicStrips(), CaloTower::hadEt(), HcalBarrel, HcalEndcap, i, hit::id, CaloTower::id(), HcalDetId::ieta(), CaloTower::ieta(), CaloTower::iphi(), j, bookConverter::max, CaloTower::numProblematicHcalCells(), and reco::PhiWedge::SetPlusZOriginConfidence().

Referenced by reco::HcalHaloDataProducer::produce().

35 {
36  HcalHaloData TheHcalHaloData;
37 
38  // Store Energy sum of rechits as a function of iPhi (iPhi goes from 1 to 72)
39  float SumE[73];
40  // Store Number of rechits as a function of iPhi
41  int NumHits[73];
42  // Store minimum time of rechit as a function of iPhi
43  float MinTimeHits[73];
44  // Store maximum time of rechit as a function of iPhi
45  float MaxTimeHits[73];
46  for(unsigned int i = 0 ; i < 73 ; i++ )
47  {
48  SumE[i] = 0;
49  NumHits[i]= 0;
50  MinTimeHits[i] = 0.;
51  MaxTimeHits[i] = 0.;
52  }
53 
54  for( HBHERecHitCollection::const_iterator hit = TheHBHERecHits->begin() ; hit != TheHBHERecHits->end() ; hit++ )
55  {
56  HcalDetId id = HcalDetId(hit->id());
57  switch ( id.subdet() )
58  {
59  case HcalBarrel:
60  if(hit->energy() < HBRecHitEnergyThreshold )continue;
61  break;
62  case HcalEndcap:
63  if(hit->energy() < HERecHitEnergyThreshold ) continue;
64  break;
65  default:
66  continue;
67  }
68 
69  int iEta = id.ieta();
70  int iPhi = id.iphi();
71  if(iPhi < 73 && TMath::Abs(iEta) < 23 )
72  {
73  SumE[iPhi]+= hit->energy();
74  NumHits[iPhi] ++;
75 
76  float time = hit->time();
77  MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
78  MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
79  }
80  }
81 
82  for( int iPhi = 1 ; iPhi < 73 ; iPhi++ )
83  {
84  if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold )
85  {
86  // Build PhiWedge and store to HcalHaloData if energy or #hits pass thresholds
87  PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
88 
89  // Loop over rechits again to calculate direction based on timing info
90  std::vector<const HBHERecHit*> Hits;
91  for( HBHERecHitCollection::const_iterator hit = TheHBHERecHits->begin() ; hit != TheHBHERecHits->end() ; hit++ )
92  {
93 
94  HcalDetId id = HcalDetId(hit->id());
95  if( id.iphi() != iPhi ) continue;
96  if( TMath::Abs(id.ieta() ) > 22 ) continue; // has to overlap geometrically w/ HB
97  switch ( id.subdet() )
98  {
99  case HcalBarrel:
100  if(hit->energy() < HBRecHitEnergyThreshold )continue;
101  break;
102  case HcalEndcap:
103  if(hit->energy() < HERecHitEnergyThreshold ) continue;
104  break;
105  default:
106  continue;
107  }
108  Hits.push_back(&(*hit));
109  }
110 
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++ )
115  {
116  HcalDetId id_i = HcalDetId(Hits[i]->id() );
117  int ieta_i = id_i.ieta();
118  for( unsigned int j = (i+1) ; j < Hits.size() ; j++ )
119  {
120  HcalDetId id_j = HcalDetId(Hits[j]->id() );
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);
124  }
125  }
126  float PlusZOriginConfidence = (PlusToMinus + MinusToPlus )? PlusToMinus / ( PlusToMinus + MinusToPlus ) : -1. ;
127  wedge.SetPlusZOriginConfidence( PlusZOriginConfidence );
128  TheHcalHaloData.GetPhiWedges().push_back( wedge );
129  }
130  }
131 
132 
133  // Don't use HF.
134  int maxAbsIEta = 29;
135 
136 
137  std::map<int, float> iPhiHadEtMap;
138  std::vector<const CaloTower*> sortedCaloTowers;
139  for(CaloTowerCollection::const_iterator tower = TheCaloTowers->begin(); tower != TheCaloTowers->end(); tower++) {
140  if(abs(tower->ieta()) > maxAbsIEta) continue;
141 
142  int iPhi = tower->iphi();
143  if(!iPhiHadEtMap.count(iPhi)) iPhiHadEtMap[iPhi] = 0.0;
144  iPhiHadEtMap[iPhi] += tower->hadEt();
145 
146  if(tower->numProblematicHcalCells() > 0) sortedCaloTowers.push_back(&(*tower));
147 
148  }
149 
150 
151  // Sort towers such that lowest iphi and ieta are first, highest last, and towers
152  // with same iphi value are consecutive. Then we can do everything else in one loop.
153  std::sort(sortedCaloTowers.begin(), sortedCaloTowers.end(), CompareTowers);
154 
155  HaloTowerStrip strip;
156 
157 
158  int prevIEta = -99, prevIPhi = -99;
159  float prevHadEt = 0.;
160  float prevEmEt = 0.;
161  std::pair<uint8_t, CaloTowerDetId> prevPair, towerPair;
162  bool wasContiguous = true;
163 
164  // Loop through and store a vector of pairs (problematicCells, DetId) for each contiguous strip we find
165  for(unsigned int i = 0; i < sortedCaloTowers.size(); i++) {
166  const CaloTower* tower = sortedCaloTowers[i];
167 
168  towerPair = std::make_pair((uint8_t)tower->numProblematicHcalCells(), tower->id());
169 
170  bool newIPhi = tower->iphi() != prevIPhi;
171  bool isContiguous = tower->ieta() == 1 ? tower->ieta() - 2 == prevIEta : tower->ieta() - 1 == prevIEta;
172 
173  isContiguous = isContiguous || (tower->ieta() == -maxAbsIEta);
174  if(newIPhi) isContiguous = false;
175 
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();
181  }
182 
183  if(wasContiguous && isContiguous) {
184  strip.cellTowerIds.push_back(towerPair);
185  strip.hadEt += tower->hadEt();
186  strip.emEt += tower->emEt();
187  }
188 
189  if((wasContiguous && !isContiguous) || i == sortedCaloTowers.size()-1) { //ended the strip, so flush it
190 
191  if(strip.cellTowerIds.size() > 3) {
192 
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;
196 
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.001F);
201 
202  energyRatio /= iPhiHadEtMap[iPhi];
203  strip.energyRatio = energyRatio;
204 
205  TheHcalHaloData.getProblematicStrips().push_back( strip );
206 
207  }
208  strip = HaloTowerStrip();
209  }
210 
211  wasContiguous = isContiguous;
212  prevPair = towerPair;
213  prevEmEt = tower->emEt();
214  prevIPhi = tower->iphi();
215  prevIEta = tower->ieta();
216  prevHadEt = tower->hadEt();
217  }
218 
219  return TheHcalHaloData;
220 
221 }
int i
Definition: DBlmapReader.cc:9
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:61
int ieta() const
Definition: CaloTower.h:182
double hadEt() const
Definition: CaloTower.h:113
std::vector< HBHERecHit >::const_iterator const_iterator
int iphi() const
Definition: CaloTower.h:184
T Abs(T a)
Definition: MathUtil.h:49
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
unsigned int id
CaloTowerDetId id() const
Definition: CaloTower.h:100
unsigned int numProblematicHcalCells() const
Definition: CaloTower.h:199
bool CompareTowers(const CaloTower *x, const CaloTower *y)
Definition: HcalHaloAlgo.cc:17
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:60
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:64
const std::vector< HaloTowerStrip > & getProblematicStrips() const
Definition: HcalHaloData.h:50
bool CompareTime(const EcalRecHit *x, const EcalRecHit *y)
Definition: EcalHaloAlgo.cc:15
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:46
int NHitsThreshold
Definition: HcalHaloAlgo.h:65
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
double emEt() const
Definition: CaloTower.h:112
HcalHaloData HcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< HBHERecHitCollection > &  TheHBHERecHits 
)

Definition at line 29 of file HcalHaloAlgo.cc.

29  {
31  return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers);
32 }
reco::HcalHaloData Calculate(const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers)
Definition: HcalHaloAlgo.cc:34
float HcalHaloAlgo::GetHBRecHitEnergyThreshold ( )
inline

Definition at line 51 of file HcalHaloAlgo.h.

References HBRecHitEnergyThreshold.

51 { return HBRecHitEnergyThreshold;}
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:60
float HcalHaloAlgo::GetHERecHitEnergyThreshold ( )
inline

Definition at line 52 of file HcalHaloAlgo.h.

References HERecHitEnergyThreshold.

52 { return HERecHitEnergyThreshold;}
float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:61
float HcalHaloAlgo::GetPhiWedgeEnergyThreshold ( )
inline

Definition at line 55 of file HcalHaloAlgo.h.

References SumEnergyThreshold.

55 { return SumEnergyThreshold;}
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:64
int HcalHaloAlgo::GetPhiWedgeNHitsThreshold ( )
inline

Definition at line 56 of file HcalHaloAlgo.h.

References NHitsThreshold.

56 { return NHitsThreshold;}
int NHitsThreshold
Definition: HcalHaloAlgo.h:65
void HcalHaloAlgo::SetPhiWedgeEnergyThreshold ( float  SumE)
inline

Definition at line 46 of file HcalHaloAlgo.h.

References SumEnergyThreshold.

46 { SumEnergyThreshold = SumE ;}
float SumEnergyThreshold
Definition: HcalHaloAlgo.h:64
void HcalHaloAlgo::SetPhiWedgeNHitsThreshold ( int  nhits)
inline

Definition at line 47 of file HcalHaloAlgo.h.

References nhits, and NHitsThreshold.

void HcalHaloAlgo::SetPhiWedgeThresholds ( float  SumE,
int  nhits 
)
inline

Definition at line 48 of file HcalHaloAlgo.h.

References nhits, NHitsThreshold, and SumEnergyThreshold.

Referenced by reco::HcalHaloDataProducer::produce().

void HcalHaloAlgo::SetRecHitEnergyThresholds ( float  HB,
float  HE 
)
inline

Member Data Documentation

float HcalHaloAlgo::HBRecHitEnergyThreshold
private

Definition at line 60 of file HcalHaloAlgo.h.

Referenced by GetHBRecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

float HcalHaloAlgo::HERecHitEnergyThreshold
private

Definition at line 61 of file HcalHaloAlgo.h.

Referenced by GetHERecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

int HcalHaloAlgo::NHitsThreshold
private
float HcalHaloAlgo::SumEnergyThreshold
private