CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalCleaningAlgo.cc
Go to the documentation of this file.
1 /* Implementation of class EcalCleaningAlgo
2  \author Stefano Argiro
3  \version $Id: EcalCleaningAlgo.cc,v 1.9 2011/05/17 12:07:23 argiro Exp $
4  \date 20 Dec 2010
5 */
6 
7 
12 
14 
16 
17  cThreshold_barrel_ = p.getParameter<double>("cThreshold_barrel");;
18  cThreshold_endcap_ = p.getParameter<double>("cThreshold_endcap");;
19  e4e1_a_barrel_ = p.getParameter<double>("e4e1_a_barrel");
20  e4e1_b_barrel_ = p.getParameter<double>("e4e1_b_barrel");
21  e4e1_a_endcap_ = p.getParameter<double>("e4e1_a_endcap");
22  e4e1_b_endcap_ = p.getParameter<double>("e4e1_b_endcap");
23  e4e1Treshold_barrel_ = p.getParameter<double>("e4e1Threshold_barrel");
24  e4e1Treshold_endcap_ = p.getParameter<double>("e4e1Threshold_endcap");
25 
26  cThreshold_double_ = p.getParameter<double>("cThreshold_double");
27 
28  ignoreOutOfTimeThresh_ =p.getParameter<double>("ignoreOutOfTimeThresh");
29  tightenCrack_e1_single_ =p.getParameter<double>("tightenCrack_e1_single");
30  tightenCrack_e4e1_single_=p.getParameter<double>("tightenCrack_e4e1_single");
31  tightenCrack_e1_double_ =p.getParameter<double>("tightenCrack_e1_double");
32  tightenCrack_e6e2_double_=p.getParameter<double>("tightenCrack_e6e2_double");
33  e6e2thresh_= p.getParameter<double>("e6e2thresh");
34 
35 
36 
37 }
38 
39 
40 
41 
71  const EcalRecHitCollection& rhs){
72 
73 
74  float a=0,b=0,e4e1thresh=0,ethresh=0;
75 
76 
77  if( id.subdetId() == EcalBarrel) {
78  a= e4e1_a_barrel_;
79  b= e4e1_b_barrel_;
80  ethresh=cThreshold_barrel_;
81 
82  }
83  else if( id.subdetId() == EcalEndcap){
84  a= e4e1_a_endcap_;
86  ethresh=cThreshold_endcap_;
87  }
88 
89 
90 
91  // for energies below threshold, we don't apply e4e1 cut
92  float energy = recHitE(id,rhs,false);
93 
94  if (energy< ethresh) return EcalRecHit::kGood;
95  if (isNearCrack(id) && energy < ethresh*tightenCrack_e1_single_)
96  return EcalRecHit::kGood;
97 
98 
99  float e4e1value = e4e1(id,rhs);
100  e4e1thresh = a* log10(energy) + b;
101 
102  // near cracks the cut is tighter by a factor
103  if (isNearCrack(id)) {
104  e4e1thresh/=tightenCrack_e4e1_single_;
105  }
106 
107  // identify spike
108  if (e4e1value < e4e1thresh) return EcalRecHit::kWeird;
109 
110 
111 
112  // now for double spikes
113 
114  // no checking for double spikes in EE
115  if( id.subdetId() == EcalEndcap) return EcalRecHit::kGood;
116 
117  float e6e2value = e6e2(id,rhs);
118  float e6e2thresh = e6e2thresh_ ;
120  return EcalRecHit::kGood;
121 
122  if (energy < cThreshold_double_) return EcalRecHit::kGood;
123 
124  // near cracks the cut is tighter by a factor
125  if (id.subdetId() == EcalBarrel && isNearCrack(id))
126  e6e2thresh/=tightenCrack_e6e2_double_;
127 
128  // identify double spike
129  if (e6e2value < e6e2thresh) return EcalRecHit::kDiWeird;
130 
131  return EcalRecHit::kGood;
132 
133 }
134 
135 
136 
137 
138 
139 
140 float EcalCleaningAlgo::e4e1(const DetId& id,
141  const EcalRecHitCollection& rhs){
142 
143 
144  float s4 = 0;
145  float e1 = recHitE( id, rhs, false );
146 
147 
148  if ( e1 == 0 ) return 0;
149  const std::vector<DetId>& neighs = neighbours(id);
150  for (size_t i=0; i<neighs.size(); ++i)
151  // avoid hits out of time when making s4
152  s4+=recHitE(neighs[i],rhs, true);
153 
154  return s4 / e1;
155 
156 
157 }
158 
159 
160 
161 
162 float EcalCleaningAlgo::e6e2(const DetId& id,
163  const EcalRecHitCollection& rhs){
164 
165  float s4_1 = 0;
166  float s4_2 = 0;
167  float e1 = recHitE( id, rhs , false );
168 
169 
170  float maxene=0;
171  DetId maxid;
172 
173  if ( e1 == 0 ) return 0;
174 
175  const std::vector<DetId>& neighs = neighbours(id);
176 
177  // find the most energetic neighbour ignoring time info
178  for (size_t i=0; i<neighs.size(); ++i){
179  float ene = recHitE(neighs[i],rhs,false);
180  if (ene>maxene) {
181  maxene=ene;
182  maxid = neighs[i];
183  }
184  }
185 
186  float e2=maxene;
187 
188  s4_1 = e4e1(id,rhs)* e1;
189  s4_2 = e4e1(maxid,rhs)* e2;
190 
191  return (s4_1 + s4_2) / (e1+e2) -1. ;
192 
193 }
194 
195 
196 
197 
199  const EcalRecHitCollection &recHits,
200  bool useTimingInfo )
201 {
202  if ( id.rawId() == 0 ) return 0;
203 
204 
206  if ( id.subdetId() == EcalEndcap) threshold = e4e1Treshold_endcap_;
207 
208  EcalRecHitCollection::const_iterator it = recHits.find( id );
209  if ( it != recHits.end() ){
210  float ene= (*it).energy();
211 
212  // ignore out of time in EB when making e4e1 if so configured
213  if (useTimingInfo){
214 
215  if (id.subdetId()==EcalBarrel &&
216  it->checkFlag(EcalRecHit::kOutOfTime)
217  && ene>ignoreOutOfTimeThresh_) return 0;
218  }
219 
220  // ignore hits below threshold
221  if (ene < threshold) return 0;
222 
223  // else return the energy of this hit
224  return ene;
225  }
226  return 0;
227 }
228 
230 const std::vector<DetId> EcalCleaningAlgo::neighbours(const DetId& id){
231 
232  std::vector<DetId> ret;
233 
234  if ( id.subdetId() == EcalBarrel) {
235 
236  ret.push_back( EBDetId::offsetBy( id, 1, 0 ));
237  ret.push_back( EBDetId::offsetBy( id, -1, 0 ));
238  ret.push_back( EBDetId::offsetBy( id, 0, 1 ));
239  ret.push_back( EBDetId::offsetBy( id, 0,-1 ));
240  }
241  // nobody understands what polymorphism is for, sgrunt !
242  else if (id.subdetId() == EcalEndcap) {
243  ret.push_back( EEDetId::offsetBy( id, 1, 0 ));
244  ret.push_back( EEDetId::offsetBy( id, -1, 0 ));
245  ret.push_back( EEDetId::offsetBy( id, 0, 1 ));
246  ret.push_back( EEDetId::offsetBy( id, 0,-1 ));
247 
248  }
249 
250 
251  return ret;
252 
253 }
254 
255 
257 
258  if (id.subdetId() == EcalEndcap) {
260  } else {
261  return EBDetId::isNextToBoundary(id);
262  }
263 }
264 
265 
266 
269  //changing the collection on place
270  for (rh=rhs.begin(); rh!=rhs.end(); ++rh){
271  EcalRecHit::Flags state=checkTopology(rh->id(),rhs);
272  if (state!=EcalRecHit::kGood) {
273  rh->unsetFlag(EcalRecHit::kGood);
274  rh->setFlag(state);
275  }
276  }
277 }
278 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
const std::vector< DetId > neighbours(const DetId &id)
return the id of the 4 neighbours in the swiss cross
EcalCleaningAlgo(const edm::ParameterSet &p)
float tightenCrack_e4e1_single_
float recHitE(const DetId id, const EcalRecHitCollection &recHits, bool useTimingInfo)
float ignoreOutOfTimeThresh_
ignore kOutOfTime above threshold when calculating e4e1
std::vector< EcalRecHit >::const_iterator const_iterator
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:490
EcalRecHit::Flags checkTopology(const DetId &id, const EcalRecHitCollection &rhs)
float e4e1(const DetId &id, const EcalRecHitCollection &rhs)
yet another function to calculate swiss cross
static bool isNextToBoundary(EBDetId id)
Definition: EBDetId.cc:171
bool isNearCrack(const DetId &detid)
in EB, check if we are near a crack
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:391
float tightenCrack_e6e2_double_
EBDetId offsetBy(int nrStepsEta, int nrStepsPhi) const
Definition: EBDetId.cc:111
std::vector< EcalRecHit >::iterator iterator
const_iterator end() const
Definition: DetId.h:20
double b
Definition: hdecay.h:120
char state
Definition: procUtils.cc:75
iterator find(key_type k)
double a
Definition: hdecay.h:121
void setFlags(EcalRecHitCollection &rhs)
const_iterator begin() const
float e6e2(const DetId &id, const EcalRecHitCollection &rhs)