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 {
8  // energy
9  energy_ = rbx.recHitEnergy(minRecHitE);
10 
11  // ratio
12  e2ts_ = rbx.allChargeHighest2TS();
13  e10ts_ = rbx.allChargeTotal();
14 
15  // TS4TS5
16  TS4TS5Decision_ = true;
17  if(energy_ > TS4TS5EnergyThreshold) // check filter
18  {
19  std::vector<float> AllCharge = rbx.allCharge();
20  double BaseCharge = AllCharge[4] + AllCharge[5];
21  if(BaseCharge < 1)
22  BaseCharge = 1;
23  double TS4TS5 = (AllCharge[4] - AllCharge[5]) / BaseCharge;
24 
25  if(CheckPassFilter(BaseCharge, TS4TS5, TS4TS5UpperCut, 1) == false)
26  TS4TS5Decision_ = false;
27  if(CheckPassFilter(BaseCharge, TS4TS5, TS4TS5LowerCut, -1) == false)
28  TS4TS5Decision_ = false;
29  }
30  else
31  TS4TS5Decision_ = true;
32 
33  // # of hits
34  numHPDHits_ = 0;
35  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
36  int nhpdhits=it1->numRecHits(minRecHitE);
37  if(numHPDHits_ < nhpdhits) numHPDHits_ = nhpdhits;
38  }
39  numRBXHits_ = rbx.numRecHits(minRecHitE);
41 
42  // # of ADC zeros
43  numZeros_ = rbx.totalZeros();
44 
45  // timing
50  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
51  edm::RefVector<HBHERecHitCollection> rechits=it1->recHits();
52  for(edm::RefVector<HBHERecHitCollection>::const_iterator it2=rechits.begin(); it2!=rechits.end(); ++it2) {
53  float energy=(*it2)->energy();
54  float time=(*it2)->time();
55  if(energy>=minLowHitE) {
58  lowEHitTimeSqrd_ += time*time;
59  ++numLowEHits_;
60  }
61  if(energy>=minHighHitE) {
64  highEHitTimeSqrd_ += time*time;
65  ++numHighEHits_;
66  }
67  }
68  }
69 
70  // emf
71  HPDEMF_ = 999.;
72  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
73  double eme=it1->caloTowerEmE();
74  double hade=it1->recHitEnergy(minRecHitE);
75  double emf=(eme+hade)==0 ? 999 : eme/(eme+hade);
76  if(HPDEMF_ > emf) emf = HPDEMF_;
77  }
78  double eme=rbx.caloTowerEmE();
79  RBXEMF_ = (eme+energy_)==0 ? 999 : eme/(eme+energy_);
80 
81  // calotowers
82  rbxtowers_.clear();
84  for(std::vector<reco::HcalNoiseHPD>::const_iterator it1=rbx.HPDsBegin(); it1!=rbx.HPDsEnd(); ++it1) {
85  join(rbxtowers_, it1->caloTowers());
86  }
87 
88  return;
89 }
90 
92 {
93  pMinERatio_ = iConfig.getParameter<double>("pMinERatio");
94  pMinEZeros_ = iConfig.getParameter<double>("pMinEZeros");
95  pMinEEMF_ = iConfig.getParameter<double>("pMinEEMF");
96 
97  minERatio_ = iConfig.getParameter<double>("minERatio");
98  minEZeros_ = iConfig.getParameter<double>("minEZeros");
99  minEEMF_ = iConfig.getParameter<double>("minEEMF");
100 
101  pMinE_ = iConfig.getParameter<double>("pMinE");
102  pMinRatio_ = iConfig.getParameter<double>("pMinRatio");
103  pMaxRatio_ = iConfig.getParameter<double>("pMaxRatio");
104  pMinHPDHits_ = iConfig.getParameter<int>("pMinHPDHits");
105  pMinRBXHits_ = iConfig.getParameter<int>("pMinRBXHits");
106  pMinHPDNoOtherHits_ = iConfig.getParameter<int>("pMinHPDNoOtherHits");
107  pMinZeros_ = iConfig.getParameter<int>("pMinZeros");
108  pMinLowEHitTime_ = iConfig.getParameter<double>("pMinLowEHitTime");
109  pMaxLowEHitTime_ = iConfig.getParameter<double>("pMaxLowEHitTime");
110  pMinHighEHitTime_ = iConfig.getParameter<double>("pMinHighEHitTime");
111  pMaxHighEHitTime_ = iConfig.getParameter<double>("pMaxHighEHitTime");
112  pMaxHPDEMF_ = iConfig.getParameter<double>("pMaxHPDEMF");
113  pMaxRBXEMF_ = iConfig.getParameter<double>("pMaxRBXEMF");
114 
115  lMinRatio_ = iConfig.getParameter<double>("lMinRatio");
116  lMaxRatio_ = iConfig.getParameter<double>("lMaxRatio");
117  lMinHPDHits_ = iConfig.getParameter<int>("lMinHPDHits");
118  lMinRBXHits_ = iConfig.getParameter<int>("lMinRBXHits");
119  lMinHPDNoOtherHits_ = iConfig.getParameter<int>("lMinHPDNoOtherHits");
120  lMinZeros_ = iConfig.getParameter<int>("lMinZeros");
121  lMinLowEHitTime_ = iConfig.getParameter<double>("lMinLowEHitTime");
122  lMaxLowEHitTime_ = iConfig.getParameter<double>("lMaxLowEHitTime");
123  lMinHighEHitTime_ = iConfig.getParameter<double>("lMinHighEHitTime");
124  lMaxHighEHitTime_ = iConfig.getParameter<double>("lMaxHighEHitTime");
125 
126  tMinRatio_ = iConfig.getParameter<double>("tMinRatio");
127  tMaxRatio_ = iConfig.getParameter<double>("tMaxRatio");
128  tMinHPDHits_ = iConfig.getParameter<int>("tMinHPDHits");
129  tMinRBXHits_ = iConfig.getParameter<int>("tMinRBXHits");
130  tMinHPDNoOtherHits_ = iConfig.getParameter<int>("tMinHPDNoOtherHits");
131  tMinZeros_ = iConfig.getParameter<int>("tMinZeros");
132  tMinLowEHitTime_ = iConfig.getParameter<double>("tMinLowEHitTime");
133  tMaxLowEHitTime_ = iConfig.getParameter<double>("tMaxLowEHitTime");
134  tMinHighEHitTime_ = iConfig.getParameter<double>("tMinHighEHitTime");
135  tMaxHighEHitTime_ = iConfig.getParameter<double>("tMaxHighEHitTime");
136 
137  hlMaxHPDEMF_ = iConfig.getParameter<double>("hlMaxHPDEMF");
138  hlMaxRBXEMF_ = iConfig.getParameter<double>("hlMaxRBXEMF");
139 }
140 
142 {
143  if(data.energy()>pMinE_) return true;
144  if(data.validRatio() && data.energy()>pMinERatio_ && data.ratio()<pMinRatio_) return true;
145  if(data.validRatio() && data.energy()>pMinERatio_ && data.ratio()>pMaxRatio_) return true;
146  if(data.numHPDHits()>=pMinHPDHits_) return true;
147  if(data.numRBXHits()>=pMinRBXHits_) return true;
148  if(data.numHPDNoOtherHits()>=pMinHPDNoOtherHits_) return true;
149  if(data.numZeros()>=pMinZeros_ && data.energy()>pMinEZeros_) return true;
150  if(data.minLowEHitTime()<pMinLowEHitTime_) return true;
151  if(data.maxLowEHitTime()>pMaxLowEHitTime_) return true;
152  if(data.minHighEHitTime()<pMinHighEHitTime_) return true;
153  if(data.maxHighEHitTime()>pMaxHighEHitTime_) return true;
154  if(data.HPDEMF()<pMaxHPDEMF_ && data.energy()>pMinEEMF_) return true;
155  if(data.RBXEMF()<pMaxRBXEMF_ && data.energy()>pMinEEMF_) return true; return false;
156 }
157 
158 
160 {
161  return (passLooseRatio(data) && passLooseHits(data) && passLooseZeros(data) && passLooseTiming(data));
162 }
163 
165 {
166  return (passTightRatio(data) && passTightHits(data) && passTightZeros(data) && passTightTiming(data));
167 }
168 
170 {
171  if(passEMFThreshold(data)) {
172  if(data.HPDEMF()<hlMaxHPDEMF_) return false;
173  if(data.RBXEMF()<hlMaxRBXEMF_) return false;
174  }
175  return true;
176 }
177 
179 {
180  if(passRatioThreshold(data)) {
181  if(data.validRatio() && data.ratio()<lMinRatio_) return false;
182  if(data.validRatio() && data.ratio()>lMaxRatio_) return false;
183  }
184  return true;
185 }
186 
188 {
189  if(data.numHPDHits()>=lMinHPDHits_) return false;
190  if(data.numRBXHits()>=lMinRBXHits_) return false;
191  if(data.numHPDNoOtherHits()>=lMinHPDNoOtherHits_) return false;
192  return true;
193 }
194 
196 {
197  if(passZerosThreshold(data)) {
198  if(data.numZeros()>=lMinZeros_) return false;
199  }
200  return true;
201 }
202 
204 {
205  if(data.minLowEHitTime()<lMinLowEHitTime_) return false;
206  if(data.maxLowEHitTime()>lMaxLowEHitTime_) return false;
207  if(data.minHighEHitTime()<lMinHighEHitTime_) return false;
208  if(data.maxHighEHitTime()>lMaxHighEHitTime_) return false;
209  return true;
210 }
211 
213 {
214  if(passRatioThreshold(data)) {
215  if(data.validRatio() && data.ratio()<tMinRatio_) return false;
216  if(data.validRatio() && data.ratio()>tMaxRatio_) return false;
217  }
218  return true;
219 }
220 
222 {
223  if(data.numHPDHits()>=tMinHPDHits_) return false;
224  if(data.numRBXHits()>=tMinRBXHits_) return false;
225  if(data.numHPDNoOtherHits()>=tMinHPDNoOtherHits_) return false;
226  return true;
227 }
228 
230 {
231  if(passZerosThreshold(data)) {
232  if(data.numZeros()>=tMinZeros_) return false;
233  }
234  return true;
235 }
236 
238 {
239  if(data.minLowEHitTime()<tMinLowEHitTime_) return false;
240  if(data.maxLowEHitTime()>tMaxLowEHitTime_) return false;
241  if(data.minHighEHitTime()<tMinHighEHitTime_) return false;
242  if(data.maxHighEHitTime()>tMaxHighEHitTime_) return false;
243  return true;
244 }
245 
247 {
248  return (data.energy()>minERatio_);
249 }
250 
252 {
253  return (data.energy()>minEZeros_);
254 }
255 
257 {
258  return (data.energy()>minEEMF_);
259 }
260 
262 {
263  // combines them first into a set to get rid of duplicates and then puts them into the first vector
264 
265  // sorts them first to get rid of duplicates, then puts them into another RefVector
266  twrrefset_t twrrefset;
268  twrrefset.insert(*it);
270  twrrefset.insert(*it);
271 
272  // clear the original refvector and put them back in
273  v1.clear();
274  for(twrrefset_t::const_iterator it=twrrefset.begin(); it!=twrrefset.end(); ++it) {
275  v1.push_back(*it);
276  }
277  return;
278 }
279 
280 bool CommonHcalNoiseRBXData::CheckPassFilter(double Charge, double Discriminant,
281  std::vector<std::pair<double, double> > &Cuts, int Side)
282 {
283  //
284  // Checks whether Discriminant value passes Cuts for the specified Charge. True if pulse is good.
285  //
286  // The "Cuts" pairs are assumed to be sorted in terms of size from small to large,
287  // where each "pair" = (Charge, Discriminant)
288  // "Side" is either positive or negative, which determines whether to discard the pulse if discriminant
289  // is greater or smaller than the cut value
290  //
291 
292  if(Cuts.size() == 0) // safety check that there are some cuts defined
293  return true;
294 
295  if(Charge <= Cuts[0].first) // too small to cut on
296  return true;
297 
298  int IndexLargerThanCharge = -1; // find the range it is falling in
299  for(int i = 1; i < (int)Cuts.size(); i++)
300  {
301  if(Cuts[i].first > Charge)
302  {
303  IndexLargerThanCharge = i;
304  break;
305  }
306  }
307 
308  double limit = 1000000;
309 
310  if(IndexLargerThanCharge == -1) // if charge is greater than the last entry, assume flat line
311  limit = Cuts[Cuts.size()-1].second;
312  else // otherwise, do a linear interpolation to find the cut position
313  {
314  double C1 = Cuts[IndexLargerThanCharge].first;
315  double C2 = Cuts[IndexLargerThanCharge-1].first;
316  double L1 = Cuts[IndexLargerThanCharge].second;
317  double L2 = Cuts[IndexLargerThanCharge-1].second;
318 
319  limit = (Charge - C1) / (C2 - C1) * (L2 - L1) + L1;
320  }
321 
322  if(Side > 0 && Discriminant > limit)
323  return false;
324  if(Side < 0 && Discriminant < limit)
325  return false;
326 
327  return true;
328 }
329 
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
bool isProblematic(const CommonHcalNoiseRBXData &) const
bool passTightRatio(const CommonHcalNoiseRBXData &) const
double pMaxHPDEMF_
double minLowEHitTime(void) const
Definition: HcalNoiseAlgo.h:29
float allChargeHighest2TS(unsigned int firstts=4) const
Definition: HcalNoiseRBX.cc:65
double hlMaxRBXEMF_
double pMinERatio_
bool passLooseRatio(const CommonHcalNoiseRBXData &) const
double maxHighEHitTime(void) const
Definition: HcalNoiseAlgo.h:34
bool passTightTiming(const CommonHcalNoiseRBXData &) const
double maxLowEHitTime(void) const
Definition: HcalNoiseAlgo.h:30
double pMinHighEHitTime_
std::vector< HcalNoiseHPD >::const_iterator HPDsBegin(void) const
Definition: HcalNoiseRBX.h:61
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
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:243
edm::RefVector< CaloTowerCollection > rbxtowers_
Definition: HcalNoiseAlgo.h:65
bool passHighLevelNoiseFilter(const CommonHcalNoiseRBXData &) const
double tMaxHighEHitTime_
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:238
double RBXEMF(void) const
Definition: HcalNoiseAlgo.h:37
double lMaxHighEHitTime_
double caloTowerEmE(void) const
int numRBXHits(void) const
Definition: HcalNoiseAlgo.h:26
double pMinEZeros_
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)
Definition: HcalNoiseAlgo.cc:3
std::set< edm::Ref< CaloTowerCollection >, twrrefcomp > twrrefset_t
bool passLooseZeros(const CommonHcalNoiseRBXData &) const
double tMinHighEHitTime_
double recHitEnergy(double theshold=1.5) const
Definition: HcalNoiseRBX.cc:99
float allChargeTotal(void) const
Definition: HcalNoiseRBX.cc:57
double pMaxHighEHitTime_
double lMinLowEHitTime_
bool passTightZeros(const CommonHcalNoiseRBXData &) const
double tMinLowEHitTime_
bool passRatioThreshold(const CommonHcalNoiseRBXData &) const
void operator()(edm::RefVector< CaloTowerCollection > &v1, const edm::RefVector< CaloTowerCollection > &v2) const
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:79
bool passZerosThreshold(const CommonHcalNoiseRBXData &) const
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:128
double pMaxRBXEMF_
double energy(void) const
Definition: HcalNoiseAlgo.h:20
bool passLooseTiming(const CommonHcalNoiseRBXData &) const
bool passTightNoiseFilter(const CommonHcalNoiseRBXData &) const
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:60
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