CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHaloAlgo.cc
Go to the documentation of this file.
2 
3 /*
4  [class]: HcalHaloAlgo
5  [authors]: R. Remington, The University of Florida
6  [description]: See HcalHaloAlgo.h
7  [date]: October 15, 2009
8 */
9 
10 using namespace std;
11 using namespace edm;
12 using namespace reco;
13 
14 #include <iomanip>
15 bool CompareTime(const HBHERecHit* x, const HBHERecHit* y ){ return x->time() < y->time() ;}
16 
18 {
19  HBRecHitEnergyThreshold = 0.;
20  HERecHitEnergyThreshold = 0.;
21  SumEnergyThreshold = 0.;
22  NHitsThreshold = 0;
23 }
24 
26 {
27  HcalHaloData TheHcalHaloData;
28 
29  // Store Energy sum of rechits as a function of iPhi (iPhi goes from 1 to 72)
30  float SumE[73];
31  // Store Number of rechits as a function of iPhi
32  int NumHits[73];
33  // Store minimum time of rechit as a function of iPhi
34  float MinTimeHits[73];
35  // Store maximum time of rechit as a function of iPhi
36  float MaxTimeHits[73];
37  for(unsigned int i = 0 ; i < 73 ; i++ )
38  {
39  SumE[i] = 0;
40  NumHits[i]= 0;
41  MinTimeHits[i] = 0.;
42  MaxTimeHits[i] = 0.;
43  }
44 
45  for( HBHERecHitCollection::const_iterator hit = TheHBHERecHits->begin() ; hit != TheHBHERecHits->end() ; hit++ )
46  {
47  HcalDetId id = HcalDetId(hit->id());
48  switch ( id.subdet() )
49  {
50  case HcalBarrel:
51  if(hit->energy() < HBRecHitEnergyThreshold )continue;
52  break;
53  case HcalEndcap:
54  if(hit->energy() < HERecHitEnergyThreshold ) continue;
55  break;
56  default:
57  continue;
58  }
59 
60  int iEta = id.ieta();
61  int iPhi = id.iphi();
62  if(iPhi < 73 && TMath::Abs(iEta) < 23 )
63  {
64  SumE[iPhi]+= hit->energy();
65  NumHits[iPhi] ++;
66 
67  float time = hit->time();
68  MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
69  MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
70  }
71  }
72 
73  for( int iPhi = 1 ; iPhi < 73 ; iPhi++ )
74  {
75  if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold )
76  {
77  // Build PhiWedge and store to HcalHaloData if energy or #hits pass thresholds
78  PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
79 
80  // Loop over rechits again to calculate direction based on timing info
81  std::vector<const HBHERecHit*> Hits;
82  for( HBHERecHitCollection::const_iterator hit = TheHBHERecHits->begin() ; hit != TheHBHERecHits->end() ; hit++ )
83  {
84 
85  HcalDetId id = HcalDetId(hit->id());
86  if( id.iphi() != iPhi ) continue;
87  if( TMath::Abs(id.ieta() ) > 22 ) continue; // has to overlap geometrically w/ HB
88  switch ( id.subdet() )
89  {
90  case HcalBarrel:
91  if(hit->energy() < HBRecHitEnergyThreshold )continue;
92  break;
93  case HcalEndcap:
94  if(hit->energy() < HERecHitEnergyThreshold ) continue;
95  break;
96  default:
97  continue;
98  }
99  Hits.push_back(&(*hit));
100  }
101 
102  std::sort( Hits.begin() , Hits.end() , CompareTime);
103  float MinusToPlus = 0.;
104  float PlusToMinus = 0.;
105  for( unsigned int i = 0 ; i < Hits.size() ; i++ )
106  {
107  HcalDetId id_i = HcalDetId(Hits[i]->id() );
108  int ieta_i = id_i.ieta();
109  for( unsigned int j = (i+1) ; j < Hits.size() ; j++ )
110  {
111  HcalDetId id_j = HcalDetId(Hits[j]->id() );
112  int ieta_j = id_j.ieta();
113  if( ieta_i > ieta_j ) PlusToMinus += TMath::Abs(ieta_i - ieta_j ) ;
114  else MinusToPlus += TMath::Abs(ieta_i - ieta_j);
115  }
116  }
117  float PlusZOriginConfidence = (PlusToMinus + MinusToPlus )? PlusToMinus / ( PlusToMinus + MinusToPlus ) : -1. ;
118  wedge.SetPlusZOriginConfidence( PlusZOriginConfidence );
119  TheHcalHaloData.GetPhiWedges().push_back( wedge );
120  }
121  }
122  return TheHcalHaloData;
123 
124 }
125 
126 
int i
Definition: DBlmapReader.cc:9
std::vector< HBHERecHit >::const_iterator const_iterator
float time() const
Definition: CaloRecHit.h:19
T Abs(T a)
Definition: MathUtil.h:49
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
int j
Definition: DBlmapReader.cc:9
void SetPlusZOriginConfidence(float x)
Definition: PhiWedge.h:67
reco::HcalHaloData Calculate(const CaloGeometry &TheCaloGeometry, edm::Handle< HBHERecHitCollection > &TheHBHERecHits)
Definition: HcalHaloAlgo.cc:25
unsigned int id
bool CompareTime(const EcalRecHit *x, const EcalRecHit *y)
Definition: EcalHaloAlgo.cc:15
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: HcalHaloData.h:21