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
EcalHaloAlgo Class Reference

#include <EcalHaloAlgo.h>

Public Member Functions

reco::EcalHaloData Calculate (const CaloGeometry &TheCaloGeometry, edm::Handle< reco::PhotonCollection > &ThePhotons, edm::Handle< reco::SuperClusterCollection > &TheSuperClusters, edm::Handle< EBRecHitCollection > &TheEBRecHits, edm::Handle< EERecHitCollection > &TheEERecHits, edm::Handle< ESRecHitCollection > &TheESRecHits)
 
 EcalHaloAlgo ()
 
float GetAngleCut ()
 
float GetEBRecHitEnergyThreshold ()
 
float GetEERecHitEnergyThreshold ()
 
float GetESRecHitEnergyThreshold ()
 
float GetPhiWedgeEnergyThreshold ()
 
int GetPhiWedgeNHitsThreshold ()
 
float GetRoundnessCut ()
 
void SetAngleCut (float a=4.)
 
void SetPhiWedgeEnergyThreshold (float SumE)
 
void SetPhiWedgeNHitsThreshold (int nhits)
 
void SetPhiWedgeThresholds (float SumE, int nhits)
 
void SetRecHitEnergyThresholds (float EB, float EE, float ES)
 
void SetRoundnessCut (float r=100.)
 
 ~EcalHaloAlgo ()
 

Private Attributes

float AngleCut
 
float EBRecHitEnergyThreshold
 
float EERecHitEnergyThreshold
 
float ESRecHitEnergyThreshold
 
int NHitsThreshold
 
float RoundnessCut
 
float SumEnergyThreshold
 

Detailed Description

Definition at line 42 of file EcalHaloAlgo.h.

Constructor & Destructor Documentation

EcalHaloAlgo::EcalHaloAlgo ( )

Definition at line 17 of file EcalHaloAlgo.cc.

18 {
19  RoundnessCut = 0 ;
20  AngleCut = 0 ;
24  SumEnergyThreshold = 0.;
25  NHitsThreshold =0;
26 }
float ESRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:89
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:92
float EERecHitEnergyThreshold
Definition: EcalHaloAlgo.h:88
float EBRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:87
float AngleCut
Definition: EcalHaloAlgo.h:84
int NHitsThreshold
Definition: EcalHaloAlgo.h:93
float RoundnessCut
Definition: EcalHaloAlgo.h:82
EcalHaloAlgo::~EcalHaloAlgo ( )
inline

Definition at line 48 of file EcalHaloAlgo.h.

48 {}

Member Function Documentation

EcalHaloData EcalHaloAlgo::Calculate ( const CaloGeometry TheCaloGeometry,
edm::Handle< reco::PhotonCollection > &  ThePhotons,
edm::Handle< reco::SuperClusterCollection > &  TheSuperClusters,
edm::Handle< EBRecHitCollection > &  TheEBRecHits,
edm::Handle< EERecHitCollection > &  TheEERecHits,
edm::Handle< ESRecHitCollection > &  TheESRecHits 
)

Definition at line 28 of file EcalHaloAlgo.cc.

References funct::abs(), Abs(), angle(), CompareTime(), DetId::Ecal, reco::EcalHaloData::GetPhiWedges(), reco::EcalHaloData::GetShowerShapesAngle(), reco::EcalHaloData::GetShowerShapesRoundness(), CaloGeometry::getSubdetectorGeometry(), reco::EcalHaloData::GetSuperClusters(), i, hit::id, EBDetId::ieta(), edm::helper::Filler< Map >::insert(), EBDetId::iphi(), edm::HandleBase::isValid(), j, edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), DetId::rawId(), reco::PhiWedge::SetPlusZOriginConfidence(), python.multivaluedict::sort(), and cond::rpcobgas::time.

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

29 {
30  EcalHaloData TheEcalHaloData;
31 
32  // Store energy sum of rechits as a function of iPhi (iphi goes from 1 to 72)
33  float SumE[361];
34  // Store number of rechits as a function of iPhi
35  int NumHits[361];
36  // Store minimum time of rechit as a function of iPhi
37  float MinTimeHits[361];
38  // Store maximum time of rechit as a function of iPhi
39  float MaxTimeHits[361];
40 
41  // initialize
42  for(int i = 0 ; i < 361 ; i++ )
43  {
44  SumE[i] = 0.;
45  NumHits[i] = 0 ;
46  MinTimeHits[i] = 9999.;
47  MaxTimeHits[i] = -9999.;
48  }
49 
50  // Loop over EB RecHits
51  for(EBRecHitCollection::const_iterator hit = TheEBRecHits->begin() ; hit != TheEBRecHits->end() ; hit++ )
52  {
53  // Arbitrary threshold to kill noise (needs to be optimized with data)
54  if (hit->energy() < EBRecHitEnergyThreshold ) continue;
55 
56  // Get Det Id of the rechit
57  DetId id = DetId(hit->id());
58  const CaloSubdetectorGeometry* TheSubGeometry = 0;
59  const CaloCellGeometry* cell = 0 ;
60 
61  // Get EB geometry
62  TheSubGeometry = TheCaloGeometry.getSubdetectorGeometry(DetId::Ecal, 1);
63  EBDetId EcalID(id.rawId());
64  if( TheSubGeometry )
65  cell = TheSubGeometry->getGeometry(id);
66 
67  if(cell)
68  {
69  // GlobalPoint globalpos = cell->getPosition();
70  // float r = TMath::Sqrt ( globalpos.y()*globalpos.y() + globalpos.x()*globalpos.x());
71  int iPhi = EcalID.iphi();
72 
73  if( iPhi < 361 ) // just to be safe
74  {
75  //iPhi = (iPhi-1)/5 +1; // convert ecal iphi to phiwedge iphi (e.g. there are 5 crystal per phi wedge, as in calotowers )
76  SumE[iPhi] += hit->energy();
77  NumHits[iPhi] ++;
78 
79  float time = hit->time();
80  MinTimeHits[iPhi] = time < MinTimeHits[iPhi] ? time : MinTimeHits[iPhi];
81  MaxTimeHits[iPhi] = time > MaxTimeHits[iPhi] ? time : MaxTimeHits[iPhi];
82  }
83  }
84  }
85 
86  //for( int iPhi = 1 ; iPhi < 73; iPhi++ )
87  for( int iPhi = 1 ; iPhi < 361; iPhi++ )
88  {
89  if( SumE[iPhi] >= SumEnergyThreshold && NumHits[iPhi] > NHitsThreshold )
90  {
91  // Build PhiWedge and store to EcalHaloData if energy or #hits pass thresholds
92  PhiWedge wedge(SumE[iPhi], iPhi, NumHits[iPhi], MinTimeHits[iPhi], MaxTimeHits[iPhi]);
93 
94  // Loop over rechits again to calculate direction based on timing info
95 
96  // Loop over EB RecHits
97  std::vector<const EcalRecHit*> Hits;
98  for(EBRecHitCollection::const_iterator hit = TheEBRecHits->begin() ; hit != TheEBRecHits->end() ; hit++ )
99  {
100  if (hit->energy() < EBRecHitEnergyThreshold ) continue;
101 
102  // Get Det Id of the rechit
103  DetId id = DetId(hit->id());
104  EBDetId EcalID(id.rawId());
105  int Hit_iPhi = EcalID.iphi();
106  //Hit_iPhi = (Hit_iPhi-1)/5 +1; // convert ecal iphi to phiwedge iphi
107  if( Hit_iPhi != iPhi ) continue;
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  DetId id_i = DetId(Hits[i]->id());
117  EBDetId EcalID_i(id_i.rawId());
118  int ieta_i = EcalID_i.ieta();
119  for( unsigned int j = (i+1) ; j < Hits.size() ; j++ )
120  {
121  DetId id_j = DetId(Hits[j]->id() );
122  EBDetId EcalID_j(id_j.rawId());
123  int ieta_j = EcalID_j.ieta();
124  if( ieta_i > ieta_j ) PlusToMinus += TMath::Abs(ieta_j - ieta_i );
125  else MinusToPlus += TMath::Abs(ieta_j -ieta_i) ;
126  }
127  }
128 
129  float PlusZOriginConfidence = (PlusToMinus+MinusToPlus) ? PlusToMinus / (PlusToMinus+MinusToPlus) : -1.;
130  wedge.SetPlusZOriginConfidence(PlusZOriginConfidence);
131  TheEcalHaloData.GetPhiWedges().push_back(wedge);
132  }
133  }
134 
135  std::vector<float> vShowerShapes_Roundness;
136  std::vector<float> vShowerShapes_Angle ;
137  for(reco::SuperClusterCollection::const_iterator cluster = TheSuperClusters->begin() ; cluster != TheSuperClusters->end() ; cluster++ )
138  {
139  if( abs(cluster->eta()) <= 1.48 )
140  {
141  vector<float> shapes = EcalClusterTools::roundnessBarrelSuperClusters( *cluster, (*TheEBRecHits.product()));
142  float roundness = shapes[0];
143  float angle = shapes[1];
144 
145  // Check if supercluster belongs to photon and passes the cuts on roundness and angle, if so store the reference to it
146  if( (roundness >=0 && roundness < GetRoundnessCut()) && angle >= 0 && angle < GetAngleCut() )
147  {
148  edm::Ref<SuperClusterCollection> TheClusterRef( TheSuperClusters, cluster - TheSuperClusters->begin());
149  bool BelongsToPhoton = false;
150  if( ThePhotons.isValid() )
151  {
152  for(reco::PhotonCollection::const_iterator iPhoton = ThePhotons->begin() ; iPhoton != ThePhotons->end() ; iPhoton++ )
153  {
154  if(iPhoton->isEB())
155  if ( TheClusterRef == iPhoton->superCluster() )
156  {
157  BelongsToPhoton = true;
158  break;
159  }
160  }
161  }
162  //Only store refs to suspicious EB SuperClusters which belong to Photons
163  //Showershape variables are more discriminating for these cases
164  if( BelongsToPhoton )
165  {
166  TheEcalHaloData.GetSuperClusters().push_back( TheClusterRef ) ;
167  }
168  }
169  vShowerShapes_Roundness.push_back(shapes[0]);
170  vShowerShapes_Angle.push_back(shapes[1]);
171  }
172  else
173  {
174  vShowerShapes_Roundness.push_back(-1.);
175  vShowerShapes_Angle.push_back(-1.);
176  }
177  }
178 
179  edm::ValueMap<float>::Filler TheRoundnessFiller( TheEcalHaloData.GetShowerShapesRoundness() );
180  TheRoundnessFiller.insert( TheSuperClusters, vShowerShapes_Roundness.begin(), vShowerShapes_Roundness.end() );
181  TheRoundnessFiller.fill();
182 
183  edm::ValueMap<float>::Filler TheAngleFiller( TheEcalHaloData.GetShowerShapesAngle() );
184  TheAngleFiller.insert( TheSuperClusters, vShowerShapes_Angle.begin() , vShowerShapes_Angle.end() );
185  TheAngleFiller.fill();
186 
187  return TheEcalHaloData;
188 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
edm::ValueMap< float > & GetShowerShapesRoundness()
Definition: EcalHaloData.h:41
const std::vector< PhiWedge > & GetPhiWedges() const
Definition: EcalHaloData.h:32
edm::RefVector< reco::SuperClusterCollection > & GetSuperClusters()
Definition: EcalHaloData.h:36
edm::ValueMap< float > & GetShowerShapesAngle()
Definition: EcalHaloData.h:44
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
std::vector< EcalRecHit >::const_iterator const_iterator
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:92
float GetRoundnessCut()
Definition: EcalHaloAlgo.h:65
T Abs(T a)
Definition: MathUtil.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
bool isValid() const
Definition: HandleBase.h:76
float GetAngleCut()
Definition: EcalHaloAlgo.h:67
unsigned int id
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
float EBRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:87
int NHitsThreshold
Definition: EcalHaloAlgo.h:93
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
bool CompareTime(const EcalRecHit *x, const EcalRecHit *y)
Definition: EcalHaloAlgo.cc:15
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
float EcalHaloAlgo::GetAngleCut ( )
inline

Definition at line 67 of file EcalHaloAlgo.h.

References AngleCut.

67 {return AngleCut ;}
float AngleCut
Definition: EcalHaloAlgo.h:84
float EcalHaloAlgo::GetEBRecHitEnergyThreshold ( )
inline

Definition at line 70 of file EcalHaloAlgo.h.

References EBRecHitEnergyThreshold.

70 { return EBRecHitEnergyThreshold;}
float EBRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:87
float EcalHaloAlgo::GetEERecHitEnergyThreshold ( )
inline

Definition at line 71 of file EcalHaloAlgo.h.

References EERecHitEnergyThreshold.

71 { return EERecHitEnergyThreshold;}
float EERecHitEnergyThreshold
Definition: EcalHaloAlgo.h:88
float EcalHaloAlgo::GetESRecHitEnergyThreshold ( )
inline

Definition at line 72 of file EcalHaloAlgo.h.

References ESRecHitEnergyThreshold.

72 { return ESRecHitEnergyThreshold;}
float ESRecHitEnergyThreshold
Definition: EcalHaloAlgo.h:89
float EcalHaloAlgo::GetPhiWedgeEnergyThreshold ( )
inline

Definition at line 75 of file EcalHaloAlgo.h.

References SumEnergyThreshold.

75 { return SumEnergyThreshold;}
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:92
int EcalHaloAlgo::GetPhiWedgeNHitsThreshold ( )
inline

Definition at line 76 of file EcalHaloAlgo.h.

References NHitsThreshold.

76 { return NHitsThreshold;}
int NHitsThreshold
Definition: EcalHaloAlgo.h:93
float EcalHaloAlgo::GetRoundnessCut ( )
inline

Definition at line 65 of file EcalHaloAlgo.h.

References RoundnessCut.

65 {return RoundnessCut ;}
float RoundnessCut
Definition: EcalHaloAlgo.h:82
void EcalHaloAlgo::SetAngleCut ( float  a = 4.)
inline

Definition at line 55 of file EcalHaloAlgo.h.

References a, and AngleCut.

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

55 { AngleCut =a;}
double a
Definition: hdecay.h:121
float AngleCut
Definition: EcalHaloAlgo.h:84
void EcalHaloAlgo::SetPhiWedgeEnergyThreshold ( float  SumE)
inline

Definition at line 60 of file EcalHaloAlgo.h.

References SumEnergyThreshold.

60 { SumEnergyThreshold = SumE ;}
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:92
void EcalHaloAlgo::SetPhiWedgeNHitsThreshold ( int  nhits)
inline

Definition at line 61 of file EcalHaloAlgo.h.

References NHitsThreshold.

61 { NHitsThreshold = nhits ; }
int NHitsThreshold
Definition: EcalHaloAlgo.h:93
void EcalHaloAlgo::SetPhiWedgeThresholds ( float  SumE,
int  nhits 
)
inline

Definition at line 62 of file EcalHaloAlgo.h.

References NHitsThreshold, and SumEnergyThreshold.

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

62 { SumEnergyThreshold = SumE ; NHitsThreshold = nhits ;}
float SumEnergyThreshold
Definition: EcalHaloAlgo.h:92
int NHitsThreshold
Definition: EcalHaloAlgo.h:93
void EcalHaloAlgo::SetRecHitEnergyThresholds ( float  EB,
float  EE,
float  ES 
)
inline
void EcalHaloAlgo::SetRoundnessCut ( float  r = 100.)
inline

Definition at line 53 of file EcalHaloAlgo.h.

References alignCSCRings::r, and RoundnessCut.

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

53 { RoundnessCut=r; }
float RoundnessCut
Definition: EcalHaloAlgo.h:82

Member Data Documentation

float EcalHaloAlgo::AngleCut
private

Definition at line 84 of file EcalHaloAlgo.h.

Referenced by GetAngleCut(), and SetAngleCut().

float EcalHaloAlgo::EBRecHitEnergyThreshold
private

Definition at line 87 of file EcalHaloAlgo.h.

Referenced by GetEBRecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

float EcalHaloAlgo::EERecHitEnergyThreshold
private

Definition at line 88 of file EcalHaloAlgo.h.

Referenced by GetEERecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

float EcalHaloAlgo::ESRecHitEnergyThreshold
private

Definition at line 89 of file EcalHaloAlgo.h.

Referenced by GetESRecHitEnergyThreshold(), and SetRecHitEnergyThresholds().

int EcalHaloAlgo::NHitsThreshold
private
float EcalHaloAlgo::RoundnessCut
private

Definition at line 82 of file EcalHaloAlgo.h.

Referenced by GetRoundnessCut(), and SetRoundnessCut().

float EcalHaloAlgo::SumEnergyThreshold
private