CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalNoiseAlgo.cc
Go to the documentation of this file.
2 
4  double minLowHitE, double minHighHitE, double TS4TS5EnergyThreshold,
5  std::vector<std::pair<double, double> > &TS4TS5UpperCut,
6  std::vector<std::pair<double, double> > &TS4TS5LowerCut,
7  double minRBXRechitR45E)
8  :r45Count_(0)
9  ,r45Fraction_(0)
10  ,r45EnergyFraction_(0)
11 {
12  // energy
13  energy_ = rbx.recHitEnergy(minRecHitE);
14 
15  // ratio
16  e2ts_ = rbx.allChargeHighest2TS();
17  e10ts_ = rbx.allChargeTotal();
18 
19  // TS4TS5
20  TS4TS5Decision_ = true;
21  if(energy_ > TS4TS5EnergyThreshold) // check filter
22  {
23  std::vector<float> AllCharge = rbx.allCharge();
24  double BaseCharge = AllCharge[4] + AllCharge[5];
25  if(BaseCharge < 1)
26  BaseCharge = 1;
27  double TS4TS5 = (AllCharge[4] - AllCharge[5]) / BaseCharge;
28 
29  if(CheckPassFilter(BaseCharge, TS4TS5, TS4TS5UpperCut, 1) == false)
30  TS4TS5Decision_ = false;
31  if(CheckPassFilter(BaseCharge, TS4TS5, TS4TS5LowerCut, -1) == false)
32  TS4TS5Decision_ = false;
33  }
34  else
35  TS4TS5Decision_ = true;
36 
37  // Rechit-wide R45
38  int rbxHitCount = rbx.numRecHits(minRBXRechitR45E);
39  if(rbxHitCount > 0)
40  {
41  r45Count_ = rbx.numRecHitsFailR45(minRBXRechitR45E);
42  r45Fraction_ = r45Count_ / rbxHitCount;
43  r45EnergyFraction_ = rbx.recHitEnergyFailR45(minRBXRechitR45E) / rbx.recHitEnergy(minRBXRechitR45E);
44  }
45 
46  // # of hits
47  numHPDHits_ = 0;
48  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
49  int nhpdhits=it1->numRecHits(minRecHitE);
50  if(numHPDHits_ < nhpdhits) numHPDHits_ = nhpdhits;
51  }
52  numRBXHits_ = rbx.numRecHits(minRecHitE);
54 
55  // # of ADC zeros
56  numZeros_ = rbx.totalZeros();
57 
58  // timing
63  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
65  for(edm::RefVector<HBHERecHitCollection>::const_iterator it2=rechits.begin(); it2!=rechits.end(); ++it2) {
66  float energy=(*it2)->energy();
67  float time=(*it2)->time();
68  if(energy>=minLowHitE) {
71  lowEHitTimeSqrd_ += time*time;
72  ++numLowEHits_;
73  }
74  if(energy>=minHighHitE) {
77  highEHitTimeSqrd_ += time*time;
78  ++numHighEHits_;
79  }
80  }
81  }
82 
83  // emf
84  HPDEMF_ = 999.;
85  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
86  double eme=it1->caloTowerEmE();
87  double hade=it1->recHitEnergy(minRecHitE);
88  double emf=(eme+hade)==0 ? 999 : eme/(eme+hade);
89  if(HPDEMF_ > emf) emf = HPDEMF_;
90  }
91  double eme=rbx.caloTowerEmE();
92  RBXEMF_ = (eme+energy_)==0 ? 999 : eme/(eme+energy_);
93 
94  // calotowers
95  rbxtowers_.clear();
97  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
98  join(rbxtowers_, it1->caloTowers());
99  }
100 
101  return;
102 }
103 
105 {
106  pMinERatio_ = iConfig.getParameter<double>("pMinERatio");
107  pMinEZeros_ = iConfig.getParameter<double>("pMinEZeros");
108  pMinEEMF_ = iConfig.getParameter<double>("pMinEEMF");
109 
110  minERatio_ = iConfig.getParameter<double>("minERatio");
111  minEZeros_ = iConfig.getParameter<double>("minEZeros");
112  minEEMF_ = iConfig.getParameter<double>("minEEMF");
113 
114  pMinE_ = iConfig.getParameter<double>("pMinE");
115  pMinRatio_ = iConfig.getParameter<double>("pMinRatio");
116  pMaxRatio_ = iConfig.getParameter<double>("pMaxRatio");
117  pMinHPDHits_ = iConfig.getParameter<int>("pMinHPDHits");
118  pMinRBXHits_ = iConfig.getParameter<int>("pMinRBXHits");
119  pMinHPDNoOtherHits_ = iConfig.getParameter<int>("pMinHPDNoOtherHits");
120  pMinZeros_ = iConfig.getParameter<int>("pMinZeros");
121  pMinLowEHitTime_ = iConfig.getParameter<double>("pMinLowEHitTime");
122  pMaxLowEHitTime_ = iConfig.getParameter<double>("pMaxLowEHitTime");
123  pMinHighEHitTime_ = iConfig.getParameter<double>("pMinHighEHitTime");
124  pMaxHighEHitTime_ = iConfig.getParameter<double>("pMaxHighEHitTime");
125  pMaxHPDEMF_ = iConfig.getParameter<double>("pMaxHPDEMF");
126  pMaxRBXEMF_ = iConfig.getParameter<double>("pMaxRBXEMF");
127 
128  if(iConfig.existsAs<int>("pMinRBXRechitR45Count"))
129  pMinRBXRechitR45Count_ = iConfig.getParameter<int>("pMinRBXRechitR45Count");
130  else
132  if(iConfig.existsAs<double>("pMinRBXRechitR45Fraction"))
133  pMinRBXRechitR45Fraction_ = iConfig.getParameter<double>("pMinRBXRechitR45Fraction");
134  else
136  if(iConfig.existsAs<double>("pMinRechitR45EnergyFraction"))
137  pMinRBXRechitR45EnergyFraction_ = iConfig.getParameter<double>("pMinRBXRechitR45EnergyFraction");
138  else
140 
141  lMinRatio_ = iConfig.getParameter<double>("lMinRatio");
142  lMaxRatio_ = iConfig.getParameter<double>("lMaxRatio");
143  lMinHPDHits_ = iConfig.getParameter<int>("lMinHPDHits");
144  lMinRBXHits_ = iConfig.getParameter<int>("lMinRBXHits");
145  lMinHPDNoOtherHits_ = iConfig.getParameter<int>("lMinHPDNoOtherHits");
146  lMinZeros_ = iConfig.getParameter<int>("lMinZeros");
147  lMinLowEHitTime_ = iConfig.getParameter<double>("lMinLowEHitTime");
148  lMaxLowEHitTime_ = iConfig.getParameter<double>("lMaxLowEHitTime");
149  lMinHighEHitTime_ = iConfig.getParameter<double>("lMinHighEHitTime");
150  lMaxHighEHitTime_ = iConfig.getParameter<double>("lMaxHighEHitTime");
151 
152  if(iConfig.existsAs<std::vector<double> >("lRBXRecHitR45Cuts"))
153  lMinRBXRechitR45Cuts_ = iConfig.getParameter<std::vector<double> >("lRBXRecHitR45Cuts");
154  else
155  {
156  double defaultCut[4] = {-999, -999, -999, -999};
157  lMinRBXRechitR45Cuts_ = std::vector<double>(defaultCut, defaultCut + 4);
158  }
159 
160  tMinRatio_ = iConfig.getParameter<double>("tMinRatio");
161  tMaxRatio_ = iConfig.getParameter<double>("tMaxRatio");
162  tMinHPDHits_ = iConfig.getParameter<int>("tMinHPDHits");
163  tMinRBXHits_ = iConfig.getParameter<int>("tMinRBXHits");
164  tMinHPDNoOtherHits_ = iConfig.getParameter<int>("tMinHPDNoOtherHits");
165  tMinZeros_ = iConfig.getParameter<int>("tMinZeros");
166  tMinLowEHitTime_ = iConfig.getParameter<double>("tMinLowEHitTime");
167  tMaxLowEHitTime_ = iConfig.getParameter<double>("tMaxLowEHitTime");
168  tMinHighEHitTime_ = iConfig.getParameter<double>("tMinHighEHitTime");
169  tMaxHighEHitTime_ = iConfig.getParameter<double>("tMaxHighEHitTime");
170 
171  if(iConfig.existsAs<std::vector<double> >("tRBXRecHitR45Cuts"))
172  tMinRBXRechitR45Cuts_ = iConfig.getParameter<std::vector<double> >("tRBXRecHitR45Cuts");
173  else
174  {
175  double defaultCut[4] = {-999, -999, -999, -999};
176  tMinRBXRechitR45Cuts_ = std::vector<double>(defaultCut, defaultCut + 4);
177  }
178 
179  hlMaxHPDEMF_ = iConfig.getParameter<double>("hlMaxHPDEMF");
180  hlMaxRBXEMF_ = iConfig.getParameter<double>("hlMaxRBXEMF");
181 }
182 
184 {
185  if(data.energy()>pMinE_) return true;
186  if(data.validRatio() && data.energy()>pMinERatio_ && data.ratio()<pMinRatio_) return true;
187  if(data.validRatio() && data.energy()>pMinERatio_ && data.ratio()>pMaxRatio_) return true;
188  if(data.numHPDHits()>=pMinHPDHits_) return true;
189  if(data.numRBXHits()>=pMinRBXHits_) return true;
190  if(data.numHPDNoOtherHits()>=pMinHPDNoOtherHits_) return true;
191  if(data.numZeros()>=pMinZeros_ && data.energy()>pMinEZeros_) return true;
192  if(data.minLowEHitTime()<pMinLowEHitTime_) return true;
193  if(data.maxLowEHitTime()>pMaxLowEHitTime_) return true;
194  if(data.minHighEHitTime()<pMinHighEHitTime_) return true;
195  if(data.maxHighEHitTime()>pMaxHighEHitTime_) return true;
196  if(data.HPDEMF()<pMaxHPDEMF_ && data.energy()>pMinEEMF_) return true;
197  if(data.RBXEMF()<pMaxRBXEMF_ && data.energy()>pMinEEMF_) return true;
198  if(data.r45Count() >= pMinRBXRechitR45Count_) return true;
199  if(data.r45Fraction() >= pMinRBXRechitR45Fraction_) return true;
200  if(data.r45EnergyFraction() >= pMinRBXRechitR45EnergyFraction_) return true;
201 
202  return false;
203 }
204 
205 
207 {
208  return (passLooseRatio(data) && passLooseHits(data) && passLooseZeros(data) && passLooseTiming(data) && passLooseRBXRechitR45(data));
209 }
210 
212 {
213  return (passTightRatio(data) && passTightHits(data) && passTightZeros(data) && passTightTiming(data) && passTightRBXRechitR45(data));
214 }
215 
217 {
218  if(passEMFThreshold(data)) {
219  if(data.HPDEMF()<hlMaxHPDEMF_) return false;
220  if(data.RBXEMF()<hlMaxRBXEMF_) return false;
221  }
222  return true;
223 }
224 
226 {
227  if(passRatioThreshold(data)) {
228  if(data.validRatio() && data.ratio()<lMinRatio_) return false;
229  if(data.validRatio() && data.ratio()>lMaxRatio_) return false;
230  }
231  return true;
232 }
233 
235 {
236  if(data.numHPDHits()>=lMinHPDHits_) return false;
237  if(data.numRBXHits()>=lMinRBXHits_) return false;
238  if(data.numHPDNoOtherHits()>=lMinHPDNoOtherHits_) return false;
239  return true;
240 }
241 
243 {
244  if(passZerosThreshold(data)) {
245  if(data.numZeros()>=lMinZeros_) return false;
246  }
247  return true;
248 }
249 
251 {
252  if(data.minLowEHitTime()<lMinLowEHitTime_) return false;
253  if(data.maxLowEHitTime()>lMaxLowEHitTime_) return false;
254  if(data.minHighEHitTime()<lMinHighEHitTime_) return false;
255  if(data.maxHighEHitTime()>lMaxHighEHitTime_) return false;
256  return true;
257 }
258 
260 {
261  int Count = data.r45Count();
262  double Fraction = data.r45Fraction();
263  double EnergyFraction = data.r45EnergyFraction();
264 
265  for(int i = 0; i + 3 < (int)lMinRBXRechitR45Cuts_.size(); i = i + 4)
266  {
267  double Value = Count * lMinRBXRechitR45Cuts_[i] + Fraction * lMinRBXRechitR45Cuts_[i+1] + EnergyFraction * lMinRBXRechitR45Cuts_[i+2] + lMinRBXRechitR45Cuts_[i+3];
268  if(Value > 0)
269  return false;
270  }
271 
272  return true;
273 }
274 
276 {
277  if(passRatioThreshold(data)) {
278  if(data.validRatio() && data.ratio()<tMinRatio_) return false;
279  if(data.validRatio() && data.ratio()>tMaxRatio_) return false;
280  }
281  return true;
282 }
283 
285 {
286  if(data.numHPDHits()>=tMinHPDHits_) return false;
287  if(data.numRBXHits()>=tMinRBXHits_) return false;
288  if(data.numHPDNoOtherHits()>=tMinHPDNoOtherHits_) return false;
289  return true;
290 }
291 
293 {
294  if(passZerosThreshold(data)) {
295  if(data.numZeros()>=tMinZeros_) return false;
296  }
297  return true;
298 }
299 
301 {
302  if(data.minLowEHitTime()<tMinLowEHitTime_) return false;
303  if(data.maxLowEHitTime()>tMaxLowEHitTime_) return false;
304  if(data.minHighEHitTime()<tMinHighEHitTime_) return false;
305  if(data.maxHighEHitTime()>tMaxHighEHitTime_) return false;
306  return true;
307 }
308 
310 {
311  int Count = data.r45Count();
312  double Fraction = data.r45Fraction();
313  double EnergyFraction = data.r45EnergyFraction();
314 
315  for(int i = 0; i + 3 < (int)tMinRBXRechitR45Cuts_.size(); i = i + 4)
316  {
317  double Value = Count * tMinRBXRechitR45Cuts_[i] + Fraction * tMinRBXRechitR45Cuts_[i+1] + EnergyFraction * tMinRBXRechitR45Cuts_[i+2] + tMinRBXRechitR45Cuts_[i+3];
318  if(Value > 0)
319  return false;
320  }
321 
322  return true;
323 }
324 
326 {
327  return (data.energy()>minERatio_);
328 }
329 
331 {
332  return (data.energy()>minEZeros_);
333 }
334 
336 {
337  return (data.energy()>minEEMF_);
338 }
339 
341 {
342  // combines them first into a set to get rid of duplicates and then puts them into the first vector
343 
344  // sorts them first to get rid of duplicates, then puts them into another RefVector
345  twrrefset_t twrrefset;
347  twrrefset.insert(*it);
349  twrrefset.insert(*it);
350 
351  // clear the original refvector and put them back in
352  v1.clear();
353  for(twrrefset_t::const_iterator it=twrrefset.begin(); it!=twrrefset.end(); ++it) {
354  v1.push_back(*it);
355  }
356  return;
357 }
358 
359 bool CommonHcalNoiseRBXData::CheckPassFilter(double Charge, double Discriminant,
360  std::vector<std::pair<double, double> > &Cuts, int Side)
361 {
362  //
363  // Checks whether Discriminant value passes Cuts for the specified Charge. True if pulse is good.
364  //
365  // The "Cuts" pairs are assumed to be sorted in terms of size from small to large,
366  // where each "pair" = (Charge, Discriminant)
367  // "Side" is either positive or negative, which determines whether to discard the pulse if discriminant
368  // is greater or smaller than the cut value
369  //
370 
371  if(Cuts.size() == 0) // safety check that there are some cuts defined
372  return true;
373 
374  if(Charge <= Cuts[0].first) // too small to cut on
375  return true;
376 
377  int IndexLargerThanCharge = -1; // find the range it is falling in
378  for(int i = 1; i < (int)Cuts.size(); i++)
379  {
380  if(Cuts[i].first > Charge)
381  {
382  IndexLargerThanCharge = i;
383  break;
384  }
385  }
386 
387  double limit = 1000000;
388 
389  if(IndexLargerThanCharge == -1) // if charge is greater than the last entry, assume flat line
390  limit = Cuts[Cuts.size()-1].second;
391  else // otherwise, do a linear interpolation to find the cut position
392  {
393  double C1 = Cuts[IndexLargerThanCharge].first;
394  double C2 = Cuts[IndexLargerThanCharge-1].first;
395  double L1 = Cuts[IndexLargerThanCharge].second;
396  double L2 = Cuts[IndexLargerThanCharge-1].second;
397 
398  limit = (Charge - C1) / (C2 - C1) * (L2 - L1) + L1;
399  }
400 
401  if(Side > 0 && Discriminant > limit)
402  return false;
403  if(Side < 0 && Discriminant < limit)
404  return false;
405 
406  return true;
407 }
408 
bool CheckPassFilter(double Charge, double Discriminant, std::vector< std::pair< double, double > > &Cuts, int Side)
double HPDEMF(void) const
Definition: HcalNoiseAlgo.h:38
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
int numRecHitsFailR45(double threshold=1.5) const
bool isProblematic(const CommonHcalNoiseRBXData &) const
bool passTightRatio(const CommonHcalNoiseRBXData &) const
double pMaxHPDEMF_
double minLowEHitTime(void) const
Definition: HcalNoiseAlgo.h:29
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
float allChargeHighest2TS(unsigned int firstts=4) const
Definition: HcalNoiseRBX.cc:65
double hlMaxRBXEMF_
double pMinERatio_
bool passLooseRatio(const CommonHcalNoiseRBXData &) const
bool passTightRBXRechitR45(const CommonHcalNoiseRBXData &) const
double maxHighEHitTime(void) const
Definition: HcalNoiseAlgo.h:34
bool passTightTiming(const CommonHcalNoiseRBXData &) const
double maxLowEHitTime(void) const
Definition: HcalNoiseAlgo.h:30
int pMinRBXRechitR45Count_
double pMinHighEHitTime_
std::vector< HcalNoiseHPD >::const_iterator HPDsBegin(void) const
Definition: HcalNoiseRBX.h:61
std::vector< double > lMinRBXRechitR45Cuts_
double r45EnergyFraction(void) const
Definition: HcalNoiseAlgo.h:43
double ratio(void) const
Definition: HcalNoiseAlgo.h:21
int numRecHits(double threshold=1.5) const
std::vector< HcalNoiseHPD >::const_iterator HPDsEnd(void) const
Definition: HcalNoiseRBX.h:62
bool passLooseRBXRechitR45(const CommonHcalNoiseRBXData &) const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
edm::RefVector< CaloTowerCollection > rbxtowers_
Definition: HcalNoiseAlgo.h:68
bool passHighLevelNoiseFilter(const CommonHcalNoiseRBXData &) const
double tMaxHighEHitTime_
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
double RBXEMF(void) const
Definition: HcalNoiseAlgo.h:37
double lMaxHighEHitTime_
double caloTowerEmE(void) const
int numRBXHits(void) const
Definition: HcalNoiseAlgo.h:26
double pMinEZeros_
std::set< edm::Ref< CaloTowerCollection >, twrrefcomp > twrrefset_t
CommonHcalNoiseRBXData(const reco::HcalNoiseRBX &rbx, double minRecHitE, double minLowHitE, double minHighHitE, double TS4TS5EnergyThreshold, std::vector< std::pair< double, double > > &TS4TS5UpperCut, std::vector< std::pair< double, double > > &TS4TS5LowerCut, double MinRBXRechitR45E)
Definition: HcalNoiseAlgo.cc:3
bool passLooseZeros(const CommonHcalNoiseRBXData &) const
double pMinRBXRechitR45EnergyFraction_
double tMinHighEHitTime_
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
float allChargeTotal(void) const
Definition: HcalNoiseRBX.cc:57
double pMaxHighEHitTime_
std::vector< double > tMinRBXRechitR45Cuts_
double lMinLowEHitTime_
bool passTightZeros(const CommonHcalNoiseRBXData &) const
double pMinRBXRechitR45Fraction_
double tMinLowEHitTime_
bool passRatioThreshold(const CommonHcalNoiseRBXData &) const
void operator()(edm::RefVector< CaloTowerCollection > &v1, const edm::RefVector< CaloTowerCollection > &v2) const
reco::JetExtendedAssociation::JetExtendedData Value
int numHPDNoOtherHits(void) const
Definition: HcalNoiseAlgo.h:27
int numZeros(void) const
Definition: HcalNoiseAlgo.h:28
double pMaxLowEHitTime_
double pMinLowEHitTime_
bool passZerosThreshold(const CommonHcalNoiseRBXData &) const
int r45Count(void) const
Definition: HcalNoiseAlgo.h:41
bool passLooseNoiseFilter(const CommonHcalNoiseRBXData &) const
HcalNoiseAlgo(const edm::ParameterSet &iConfig)
bool passLooseHits(const CommonHcalNoiseRBXData &) const
int totalZeros(void) const
Definition: HcalNoiseRBX.cc:82
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
void clear()
Clear the vector.
Definition: RefVector.h:133
double recHitEnergyFailR45(double threshold=1.5) const
double pMaxRBXEMF_
double energy(void) const
Definition: HcalNoiseAlgo.h:20
bool passLooseTiming(const CommonHcalNoiseRBXData &) const
bool passTightNoiseFilter(const CommonHcalNoiseRBXData &) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double minHighEHitTime(void) const
Definition: HcalNoiseAlgo.h:33
double lMaxLowEHitTime_
double lMinHighEHitTime_
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
bool passEMFThreshold(const CommonHcalNoiseRBXData &) const
const std::vector< float > allCharge(void) const
Definition: HcalNoiseRBX.cc:52
int numHPDHits(void) const
Definition: HcalNoiseAlgo.h:25
double tMaxLowEHitTime_
bool validRatio(void) const
Definition: HcalNoiseAlgo.h:24
double hlMaxHPDEMF_
bool passTightHits(const CommonHcalNoiseRBXData &) const
double r45Fraction(void) const
Definition: HcalNoiseAlgo.h:42