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 20 of file HcalHaloAlgo.cc.

21 {
24  SumEnergyThreshold = 0.;
25  NHitsThreshold = 0;
26 }
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 33 of file HcalHaloAlgo.cc.

References funct::abs(), Abs(), CompareTime(), CompareTowers(), reco::HcalHaloData::GetPhiWedges(), reco::HcalHaloData::getProblematicStrips(), CaloTower::hadEt(), HcalBarrel, HcalEndcap, i, hit::id, CaloTower::id(), HcalDetId::ieta(), CaloTower::ieta(), CaloTower::iphi(), j, CaloTower::numProblematicHcalCells(), reco::PhiWedge::SetPlusZOriginConfidence(), python.multivaluedict::sort(), and cond::rpcobgas::time.

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

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

Definition at line 28 of file HcalHaloAlgo.cc.

28  {
30  return Calculate(TheCaloGeometry, TheHBHERecHits, TheCaloTowers);
31 }
reco::HcalHaloData Calculate(const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits, edm::Handle< CaloTowerCollection > &TheCaloTowers)
Definition: HcalHaloAlgo.cc:33
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

Definition at line 43 of file HcalHaloAlgo.h.

References HBRecHitEnergyThreshold, and HERecHitEnergyThreshold.

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

float HERecHitEnergyThreshold
Definition: HcalHaloAlgo.h:61
float HBRecHitEnergyThreshold
Definition: HcalHaloAlgo.h:60

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