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