CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalNoiseInfoProducer.cc
Go to the documentation of this file.
2 
3 //
4 // HcalNoiseInfoProducer.cc
5 //
6 // description: Implementation of the producer for the HCAL noise information
7 //
8 // author: J.P. Chou, Brown
9 //
10 //
11 
23 
24 using namespace reco;
25 
26 //
27 // constructors and destructor
28 //
29 
31 {
32  // set the parameters
33  fillDigis_ = iConfig.getParameter<bool>("fillDigis");
34  fillRecHits_ = iConfig.getParameter<bool>("fillRecHits");
35  fillCaloTowers_ = iConfig.getParameter<bool>("fillCaloTowers");
36  fillTracks_ = iConfig.getParameter<bool>("fillTracks");
37 
38  maxProblemRBXs_ = iConfig.getParameter<int>("maxProblemRBXs");
39 
40  maxCaloTowerIEta_ = iConfig.getParameter<int>("maxCaloTowerIEta");
41  maxTrackEta_ = iConfig.getParameter<double>("maxTrackEta");
42  minTrackPt_ = iConfig.getParameter<double>("minTrackPt");
43 
44  digiCollName_ = iConfig.getParameter<std::string>("digiCollName");
45  recHitCollName_ = iConfig.getParameter<std::string>("recHitCollName");
46  caloTowerCollName_ = iConfig.getParameter<std::string>("caloTowerCollName");
47  trackCollName_ = iConfig.getParameter<std::string>("trackCollName");
48 
49  if (iConfig.existsAs<std::string>("jetCollName"))
50  {
51  jetCollName_ = iConfig.getParameter<std::string>("jetCollName");
52  maxNHF_ = iConfig.getParameter<double>("maxNHF");
53  maxjetindex_ = iConfig.getParameter<int>("maxjetindex");
54  jet_token_ = consumes<reco::PFJetCollection>(edm::InputTag(jetCollName_));
55  }
56 
57  minRecHitE_ = iConfig.getParameter<double>("minRecHitE");
58  minLowHitE_ = iConfig.getParameter<double>("minLowHitE");
59  minHighHitE_ = iConfig.getParameter<double>("minHighHitE");
60  if(iConfig.existsAs<double>("minR45HitE"))
61  minR45HitE_ = iConfig.getParameter<double>("minR45HitE");
62 
63  HcalAcceptSeverityLevel_ = iConfig.getParameter<uint32_t>("HcalAcceptSeverityLevel");
64  if (iConfig.exists("HcalRecHitFlagsToBeExcluded"))
65  HcalRecHitFlagsToBeExcluded_ = iConfig.getParameter<std::vector<int> >("HcalRecHitFlagsToBeExcluded");
66  else{
67  edm::LogWarning("MisConfiguration")<<"the module is missing the parameter HcalAcceptSeverityLevel. created empty.";
69  }
70 
71  // Digi threshold and time slices to use for HBHE and HF calibration digis
72  useCalibDigi_ = true;
73  if(iConfig.existsAs<double>("calibdigiHBHEthreshold") == false) useCalibDigi_ = false;
74  if(iConfig.existsAs<double>("calibdigiHFthreshold") == false) useCalibDigi_ = false;
75  if(iConfig.existsAs<std::vector<int> >("calibdigiHBHEtimeslices") == false) useCalibDigi_ = false;
76  if(iConfig.existsAs<std::vector<int> >("calibdigiHFtimeslices") == false) useCalibDigi_ = false;
77 
78  if(useCalibDigi_ == true)
79  {
80  calibdigiHBHEthreshold_ = iConfig.getParameter<double>("calibdigiHBHEthreshold");
81  calibdigiHBHEtimeslices_ = iConfig.getParameter<std::vector<int> >("calibdigiHBHEtimeslices");
82  calibdigiHFthreshold_ = iConfig.getParameter<double>("calibdigiHFthreshold");
83  calibdigiHFtimeslices_ = iConfig.getParameter<std::vector<int> >("calibdigiHFtimeslices");
84  }
85  else
86  {
88  calibdigiHBHEtimeslices_ = std::vector<int>();
90  calibdigiHFtimeslices_ = std::vector<int>();
91  }
92 
93  TS4TS5EnergyThreshold_ = iConfig.getParameter<double>("TS4TS5EnergyThreshold");
94 
95  std::vector<double> TS4TS5UpperThresholdTemp = iConfig.getParameter<std::vector<double> >("TS4TS5UpperThreshold");
96  std::vector<double> TS4TS5UpperCutTemp = iConfig.getParameter<std::vector<double> >("TS4TS5UpperCut");
97  std::vector<double> TS4TS5LowerThresholdTemp = iConfig.getParameter<std::vector<double> >("TS4TS5LowerThreshold");
98  std::vector<double> TS4TS5LowerCutTemp = iConfig.getParameter<std::vector<double> >("TS4TS5LowerCut");
99 
100  for(int i = 0; i < (int)TS4TS5UpperThresholdTemp.size() && i < (int)TS4TS5UpperCutTemp.size(); i++)
101  TS4TS5UpperCut_.push_back(std::pair<double, double>(TS4TS5UpperThresholdTemp[i], TS4TS5UpperCutTemp[i]));
102  sort(TS4TS5UpperCut_.begin(), TS4TS5UpperCut_.end());
103 
104  for(int i = 0; i < (int)TS4TS5LowerThresholdTemp.size() && i < (int)TS4TS5LowerCutTemp.size(); i++)
105  TS4TS5LowerCut_.push_back(std::pair<double, double>(TS4TS5LowerThresholdTemp[i], TS4TS5LowerCutTemp[i]));
106  sort(TS4TS5LowerCut_.begin(), TS4TS5LowerCut_.end());
107 
108  // if digis are filled, then rechits must also be filled
109  if(fillDigis_ && !fillRecHits_) {
110  fillRecHits_=true;
111  edm::LogWarning("HCalNoiseInfoProducer") << " forcing fillRecHits to be true if fillDigis is true.\n";
112  }
113 
114  const float adc2fCTemp[128]={-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,
115  13.5,15.,17.,19.,21.,23.,25.,27.,29.5,32.5,35.5,38.5,42.,46.,50.,54.5,59.5,
116  64.5,59.5,64.5,69.5,74.5,79.5,84.5,89.5,94.5,99.5,104.5,109.5,114.5,119.5,
117  124.5,129.5,137.,147.,157.,167.,177.,187.,197.,209.5,224.5,239.5,254.5,272.,
118  292.,312.,334.5,359.5,384.5,359.5,384.5,409.5,434.5,459.5,484.5,509.5,534.5,
119  559.5,584.5,609.5,634.5,659.5,684.5,709.5,747.,797.,847.,897.,947.,997.,
120  1047.,1109.5,1184.5,1259.5,1334.5,1422.,1522.,1622.,1734.5,1859.5,1984.5,
121  1859.5,1984.5,2109.5,2234.5,2359.5,2484.5,2609.5,2734.5,2859.5,2984.5,
122  3109.5,3234.5,3359.5,3484.5,3609.5,3797.,4047.,4297.,4547.,4797.,5047.,
123  5297.,5609.5,5984.5,6359.5,6734.5,7172.,7672.,8172.,8734.5,9359.5,9984.5};
124  for(int i = 0; i < 128; i++)
125  adc2fC[i] = adc2fCTemp[i];
126 
127  hbhedigi_token_ = consumes<HBHEDigiCollection>(edm::InputTag(digiCollName_));
128  hcalcalibdigi_token_ = consumes<HcalCalibDigiCollection>(edm::InputTag("hcalDigis"));
129  hbherechit_token_ = consumes<HBHERecHitCollection>(edm::InputTag(recHitCollName_));
130  calotower_token_ = consumes<CaloTowerCollection>(edm::InputTag(caloTowerCollName_));
131  track_token_ = consumes<reco::TrackCollection>(edm::InputTag(trackCollName_));
132 
133  // we produce a vector of HcalNoiseRBXs
134  produces<HcalNoiseRBXCollection>();
135  // we also produce a noise summary
136  produces<HcalNoiseSummary>();
137 }
138 
139 
141 {
142 }
143 
144 
145 //
146 // member functions
147 //
148 
149 // ------------ method called to produce the data ------------
150 void
152 {
153  // this is what we're going to actually write to the EDM
154  std::auto_ptr<HcalNoiseRBXCollection> result1(new HcalNoiseRBXCollection);
155  std::auto_ptr<HcalNoiseSummary> result2(new HcalNoiseSummary);
156 
157  // define an empty HcalNoiseRBXArray that we're going to fill
158  HcalNoiseRBXArray rbxarray;
159  HcalNoiseSummary &summary=*result2;
160 
161  // fill them with the various components
162  // digi assumes that rechit information is available
163  if(fillRecHits_) fillrechits(iEvent, iSetup, rbxarray, summary);
164  if(fillDigis_) filldigis(iEvent, iSetup, rbxarray, summary);
165  if(fillCaloTowers_) fillcalotwrs(iEvent, iSetup, rbxarray, summary);
166  if(fillTracks_) filltracks(iEvent, iSetup, summary);
167 
168  filljetinfo(iEvent, iSetup, summary);
169 
170  // Why is this here? Shouldn't it have been in the filldigis method? Any reason for TotalCalibCharge to be defined outside filldigis(...) ?-- Jeff, 7/2/12
171  //if(fillDigis_) summary.calibCharge_ = TotalCalibCharge;
172 
173  // select those RBXs which are interesting
174  // also look for the highest energy RBX
175  HcalNoiseRBXArray::iterator maxit=rbxarray.begin();
176  double maxenergy=-999;
177  bool maxwritten=false;
178  for(HcalNoiseRBXArray::iterator rit = rbxarray.begin(); rit!=rbxarray.end(); ++rit) {
179  HcalNoiseRBX &rbx=(*rit);
182 
183  // find the highest energy rbx
184  if(data.energy()>maxenergy) {
185  maxenergy=data.energy();
186  maxit=rit;
187  maxwritten=false;
188  }
189 
190  // find out if the rbx is problematic/noisy/etc.
191  bool writerbx = algo_.isProblematic(data) || !algo_.passLooseNoiseFilter(data) ||
193 
194  // fill variables in the summary object not filled elsewhere
195  fillOtherSummaryVariables(summary, data);
196 
197  if(writerbx) {
198  summary.nproblemRBXs_++;
199  if(summary.nproblemRBXs_<=maxProblemRBXs_) {
200  result1->push_back(rbx);
201  if(maxit==rit) maxwritten=true;
202  }
203  }
204  } // end loop over rbxs
205 
206  // if we still haven't written the maximum energy rbx, write it now
207  if(!maxwritten) {
208  HcalNoiseRBX &rbx=(*maxit);
209 
210  // add the RBX to the event
211  result1->push_back(rbx);
212  }
213 
214  // put the rbxcollection and summary into the EDM
215  iEvent.put(result1);
216  iEvent.put(result2);
217 
218  return;
219 }
220 
221 
222 // ------------ here we fill specific variables in the summary object not already accounted for earlier
223 void
225 {
226  // charge ratio
227  if(algo_.passRatioThreshold(data) && data.validRatio()) {
228  if(data.ratio()<summary.minE2Over10TS()) {
229  summary.mine2ts_ = data.e2ts();
230  summary.mine10ts_ = data.e10ts(); }
231  if(data.ratio()>summary.maxE2Over10TS()) {
232  summary.maxe2ts_ = data.e2ts();
233  summary.maxe10ts_ = data.e10ts();
234  }
235  }
236 
237  // ADC zeros
238  if(algo_.passZerosThreshold(data)) {
239  if(data.numZeros()>summary.maxZeros()) {
240  summary.maxzeros_ = data.numZeros();
241  }
242  }
243 
244  // hits count
245  if(data.numHPDHits() > summary.maxHPDHits()) {
246  summary.maxhpdhits_ = data.numHPDHits();
247  }
248  if(data.numRBXHits() > summary.maxRBXHits()) {
249  summary.maxrbxhits_ = data.numRBXHits();
250  }
251  if(data.numHPDNoOtherHits() > summary.maxHPDNoOtherHits()) {
252  summary.maxhpdhitsnoother_ = data.numHPDNoOtherHits();
253  }
254 
255  // TS4TS5
256  if(data.PassTS4TS5() == false)
257  summary.hasBadRBXTS4TS5_ = true;
258 
259  if(algo_.passLooseRBXRechitR45(data) == false)
260  summary.hasBadRBXRechitR45Loose_ = true;
261  if(algo_.passTightRBXRechitR45(data) == false)
262  summary.hasBadRBXRechitR45Tight_ = true;
263 
264  // hit timing
265  if(data.minLowEHitTime()<summary.min10GeVHitTime()) {
266  summary.min10_ = data.minLowEHitTime();
267  }
268  if(data.maxLowEHitTime()>summary.max10GeVHitTime()) {
269  summary.max10_ = data.maxLowEHitTime();
270  }
271  summary.rms10_ += data.lowEHitTimeSqrd();
272  summary.cnthit10_ += data.numLowEHits();
273  if(data.minHighEHitTime()<summary.min25GeVHitTime()) {
274  summary.min25_ = data.minHighEHitTime();
275  }
276  if(data.maxHighEHitTime()>summary.max25GeVHitTime()) {
277  summary.max25_ = data.maxHighEHitTime();
278  }
279  summary.rms25_ += data.highEHitTimeSqrd();
280  summary.cnthit25_ += data.numHighEHits();
281 
282  // EMF
283  if(algo_.passEMFThreshold(data)) {
284  if(summary.minHPDEMF() > data.HPDEMF()) {
285  summary.minhpdemf_ = data.HPDEMF();
286  }
287  if(summary.minRBXEMF() > data.RBXEMF()) {
288  summary.minrbxemf_ = data.RBXEMF();
289  }
290  }
291 
292  // summary flag
293  if(!algo_.passLooseRatio(data)) summary.filterstatus_ |= 0x1;
294  if(!algo_.passLooseHits(data)) summary.filterstatus_ |= 0x2;
295  if(!algo_.passLooseZeros(data)) summary.filterstatus_ |= 0x4;
296  if(!algo_.passLooseTiming(data)) summary.filterstatus_ |= 0x8;
297 
298  if(!algo_.passTightRatio(data)) summary.filterstatus_ |= 0x100;
299  if(!algo_.passTightHits(data)) summary.filterstatus_ |= 0x200;
300  if(!algo_.passTightZeros(data)) summary.filterstatus_ |= 0x400;
301  if(!algo_.passTightTiming(data)) summary.filterstatus_ |= 0x800;
302 
303  if(!algo_.passHighLevelNoiseFilter(data)) summary.filterstatus_ |= 0x10000;
304 
305  // summary refvectors
307  if(!algo_.passLooseNoiseFilter(data))
308  join(summary.loosenoisetwrs_, data.rbxTowers());
309  if(!algo_.passTightNoiseFilter(data))
310  join(summary.tightnoisetwrs_, data.rbxTowers());
312  join(summary.hlnoisetwrs_, data.rbxTowers());
313 
314  return;
315 }
316 
317 
318 // ------------ fill the array with digi information
319 void
321 {
322  // Some initialization
323  TotalCalibCharge = 0;
324 
325  // Starting with this version (updated by Jeff Temple on Dec. 6, 2012), the "TS45" names in the variables are mis-nomers. The actual time slices used are determined from the digiTimeSlices_ variable, which may not be limited to only time slices 4 and 5. For now, "TS45" name kept, because that is what is used in HcalNoiseSummary object (in GetCalibCountTS45, etc.). Likewise, the charge value in 'gt15' is now configurable, though the name remains the same. For HBHE, we track both the number of calibration channels (NcalibTS45) and the number of calibration channels above threshold (NcalibTS45gt15). For HF, we track only the number of channels above the given threshold in the given time window (NcalibHFgtX). Default for HF in 2012 is to use the full time sample with effectively no threshold (threshold=-999)
326  int NcalibTS45=0;
327  int NcalibTS45gt15=0;
328  int NcalibHFgtX=0;
329 
330  double chargecalibTS45=0;
331  double chargecalibgt15TS45=0;
332 
333  // get the conditions and channel quality
334  edm::ESHandle<HcalDbService> conditions;
335  iSetup.get<HcalDbRecord>().get(conditions);
337  iSetup.get<HcalChannelQualityRcd>().get("withTopo",qualhandle);
338  const HcalChannelQuality* myqual = qualhandle.product();
340  iSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
341  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
342 
343  // get the digis
345  // iEvent.getByLabel(digiCollName_, handle);
346  iEvent.getByToken(hbhedigi_token_, handle);
347 
348  if(!handle.isValid()) {
349  throw edm::Exception(edm::errors::ProductNotFound) << " could not find HBHEDigiCollection named " << digiCollName_ << "\n.";
350  return;
351  }
352 
353  // loop over all of the digi information
354  for(HBHEDigiCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
355  const HBHEDataFrame &digi=(*it);
356  HcalDetId cell = digi.id();
357  DetId detcell=(DetId)cell;
358 
359  // check on cells to be ignored and dropped
360  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
361  if(mySeverity->dropChannel(mydigistatus->getValue())) continue;
362  if(digi.zsMarkAndPass()) continue;
363  // Drop if exclude bit set
364  if ((mydigistatus->getValue() & (1 <<HcalChannelStatus::HcalCellExcludeFromHBHENoiseSummary))==1) continue;
365 
366  // get the calibrations and coder
367  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
368  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
369  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
370  HcalCoderDb coder (*channelCoder, *shape);
371 
372  // match the digi to an rbx and hpd
373  HcalNoiseRBX &rbx=(*array.findRBX(digi));
374  HcalNoiseHPD &hpd=(*array.findHPD(digi));
375 
376  // determine if the digi is one the highest energy hits in the HPD
377  // this works because the rechits are sorted by energy (see fillrechits() below)
378  bool isBig=false, isBig5=false, isRBX=false;
379  int counter=0;
382  rit!=rechits.end(); ++rit, ++counter) {
383  if((*rit)->id() == digi.id()) {
384  if(counter==0) isBig=isBig5=true; // digi is also the highest energy rechit
385  if(counter<5) isBig5=true; // digi is one of 5 highest energy rechits
386  isRBX=true;
387  }
388  }
389 
390  // loop over each of the digi's time slices
391  int totalzeros=0;
392  CaloSamples tool;
393  coder.adc2fC(digi,tool);
394  for(int ts=0; ts<tool.size(); ++ts) {
395 
396  // count zero's
397  if(digi[ts].adc()==0) {
398  ++hpd.totalZeros_;
399  ++totalzeros;
400  }
401 
402  // get the fC's
403  double corrfc = tool[ts]-calibrations.pedestal(digi[ts].capid());
404 
405  // fill the relevant digi arrays
406  if(isBig) hpd.bigCharge_[ts]+=corrfc;
407  if(isBig5) hpd.big5Charge_[ts]+=corrfc;
408  if(isRBX) rbx.allCharge_[ts]+=corrfc;
409  }
410 
411  // record the maximum number of zero's found
412  if(totalzeros>hpd.maxZeros_)
413  hpd.maxZeros_=totalzeros;
414  }
415 
416  // get the calibration digis
418  // iEvent.getByLabel("hcalDigis", hCalib);
419  iEvent.getByToken(hcalcalibdigi_token_, hCalib);
420 
421  // get total charge in calibration channels
422  if(hCalib.isValid() == true)
423  {
424  for(HcalCalibDigiCollection::const_iterator digi = hCalib->begin(); digi != hCalib->end(); digi++)
425  {
426  if(digi->id().hcalSubdet() == 0)
427  continue;
428 
429  /*
430  HcalCalibDetId cell = digi->id();
431  DetId detcell = (DetId)cell;
432 
433  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
434 
435  if(mySeverity->dropChannel(mydigistatus->getValue()))
436  continue;
437  if(digi->zsMarkAndPass())
438  continue;
439 
440  const HcalQIECoder *channelCoder = conditions->getHcalCoder(cell);
441  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
442  HcalCoderDb coder(*channelCoder, *shape);
443 
444  CaloSamples tool;
445  coder.adc2fC(*digi, tool);
446 
447  for(int i = 0; i < (int)digi->size(); i++)
448  TotalCalibCharge = TotalCalibCharge + tool[i];
449  */
450 
451  // Original code computes total calib charge over all digis. While I think it would be more useful to skip
452  // zs mark-and-pass channels, I keep this computation as is. Individual HBHE and HF variables do skip
453  // the m-p channels. -- Jeff Temple, 6 December 2012
454 
455  for(int i = 0; i < (int)digi->size(); i++)
456  TotalCalibCharge = TotalCalibCharge + adc2fC[digi->sample(i).adc()&0xff];
457 
458 
459  HcalCalibDetId myid=(HcalCalibDetId)digi->id();
461  continue; // ignore HOCrosstalk channels
462  if(digi->zsMarkAndPass()) continue; // skip "mark-and-pass" channels when computing charge in calib channels
463 
464 
465  if (digi->id().hcalSubdet()==HcalForward) // check HF
466  {
467  double sumChargeHF=0;
468  for (unsigned int i=0;i<calibdigiHFtimeslices_.size();++i)
469  {
470  // skip unphysical time slices
471  if (calibdigiHFtimeslices_[i]<0 || calibdigiHFtimeslices_[i]>digi->size())
472  continue;
473  sumChargeHF+=adc2fC[digi->sample(calibdigiHFtimeslices_[i]).adc()&0xff];
474  }
475  if (sumChargeHF>calibdigiHFthreshold_) ++NcalibHFgtX;
476  } // end of HF check
477  else if (digi->id().hcalSubdet()==HcalBarrel || digi->id().hcalSubdet()==HcalEndcap) // now check HBHE
478  {
479  double sumChargeHBHE=0;
480  for (unsigned int i=0;i<calibdigiHBHEtimeslices_.size();++i)
481  {
482  // skip unphysical time slices
483  if (calibdigiHBHEtimeslices_[i]<0 || calibdigiHBHEtimeslices_[i]>digi->size())
484  continue;
485  sumChargeHBHE+=adc2fC[digi->sample(calibdigiHBHEtimeslices_[i]).adc()&0xff];
486  }
487  ++NcalibTS45;
488  chargecalibTS45+=sumChargeHBHE;
489  if (sumChargeHBHE>calibdigiHBHEthreshold_)
490  {
491  ++NcalibTS45gt15;
492  chargecalibgt15TS45+=sumChargeHBHE;
493  }
494  } // end of HBHE check
495  } // loop on HcalCalibDigiCollection
496  } // if (hCalib.isValid()==true)
497 
498  summary.calibCharge_ = TotalCalibCharge;
499  summary.calibCountTS45_=NcalibTS45;
500  summary.calibCountgt15TS45_=NcalibTS45gt15;
501  summary.calibChargeTS45_=chargecalibTS45;
502  summary.calibChargegt15TS45_=chargecalibgt15TS45;
503  summary.calibCountHF_=NcalibHFgtX;
504 
505  return;
506 }
507 
508 // ------------ fill the array with rec hit information
509 void
511 {
512  // get the HCAL channel status map
514  iSetup.get<HcalChannelQualityRcd>().get( "withTopo", hcalChStatus );
515  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
516 
517  // get the severity level computer
518  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
519  iSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
520  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
521 
522  // get the calo geometry
524  iSetup.get<CaloGeometryRecord>().get(pG);
525  const CaloGeometry* geo = pG.product();
526 
527  // get the rechits
529  // iEvent.getByLabel(recHitCollName_, handle);
530  iEvent.getByToken(hbherechit_token_, handle);
531 
532  if(!handle.isValid()) {
534  << " could not find HBHERecHitCollection named " << recHitCollName_ << "\n.";
535  return;
536  }
537 
538  summary.rechitCount_ = 0;
539  summary.rechitCount15_ = 0;
540  summary.rechitEnergy_ = 0;
541  summary.rechitEnergy15_ = 0;
542 
543  summary.hitsInLaserRegion_=0;
544  summary.hitsInNonLaserRegion_=0;
545  summary.energyInLaserRegion_=0;
546  summary.energyInNonLaserRegion_=0;
547 
548 
549 
550  // loop over all of the rechit information
551  for(HBHERecHitCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
552  const HBHERecHit &rechit=(*it);
553 
554  // skip bad rechits (other than those flagged by the isolated noise, triangle, flat, and spike algorithms)
555  const DetId id = rechit.detid();
556  uint32_t recHitFlag = rechit.flags();
557  uint32_t isolbitset = (1 << HcalCaloFlagLabels::HBHEIsolatedNoise);
558  uint32_t flatbitset = (1 << HcalCaloFlagLabels::HBHEFlatNoise);
559  uint32_t spikebitset = (1 << HcalCaloFlagLabels::HBHESpikeNoise);
560  uint32_t trianglebitset = (1 << HcalCaloFlagLabels::HBHETriangleNoise);
561  uint32_t ts4ts5bitset = (1 << HcalCaloFlagLabels::HBHETS4TS5Noise);
562  uint32_t negativebitset = (1 << HcalCaloFlagLabels::HBHENegativeNoise);
563  for(unsigned int i=0; i<HcalRecHitFlagsToBeExcluded_.size(); i++) {
564  uint32_t bitset = (1 << HcalRecHitFlagsToBeExcluded_[i]);
565  recHitFlag = (recHitFlag & bitset) ? recHitFlag-bitset : recHitFlag;
566  }
567  const uint32_t dbStatusFlag = dbHcalChStatus->getValues(id)->getValue();
568 
569  // Ignore rechit if exclude bit set, regardless of severity of other bits
570  if ((dbStatusFlag & (1 <<HcalChannelStatus::HcalCellExcludeFromHBHENoiseSummary))==1) continue;
571 
572  int severityLevel = hcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
573  bool isRecovered = hcalSevLvlComputer->recoveredRecHit(id, recHitFlag);
574  if(severityLevel!=0 && !isRecovered && severityLevel>static_cast<int>(HcalAcceptSeverityLevel_)) continue;
575 
576  // do some rechit counting and energies
577  summary.rechitCount_ = summary.rechitCount_ + 1;
578  summary.rechitEnergy_ = summary.rechitEnergy_ + rechit.eraw();
579  if ((dbStatusFlag & (1 <<HcalChannelStatus::HcalBadLaserSignal))==1) // hit comes from a region where no laser calibration pulse is normally seen
580  {
581  ++summary.hitsInNonLaserRegion_;
582  summary.energyInNonLaserRegion_+=rechit.eraw();
583  }
584  else // hit comes from region where laser calibration pulse is seen
585  {
586  ++summary.hitsInLaserRegion_;
587  summary.energyInLaserRegion_+=rechit.eraw();
588  }
589 
590  if(rechit.eraw() > 1.5)
591  {
592  summary.rechitCount15_ = summary.rechitCount15_ + 1;
593  summary.rechitEnergy15_ = summary.rechitEnergy15_ + rechit.eraw();
594  }
595 
596  // if it was ID'd as isolated noise, update the summary object
597  if(rechit.flags() & isolbitset) {
598  summary.nisolnoise_++;
599  summary.isolnoisee_ += rechit.eraw();
600  GlobalPoint gp = geo->getPosition(rechit.id());
601  double et = rechit.eraw()*gp.perp()/gp.mag();
602  summary.isolnoiseet_ += et;
603  }
604 
605  if(rechit.flags() & flatbitset) {
606  summary.nflatnoise_++;
607  summary.flatnoisee_ += rechit.eraw();
608  GlobalPoint gp = geo->getPosition(rechit.id());
609  double et = rechit.eraw()*gp.perp()/gp.mag();
610  summary.flatnoiseet_ += et;
611  }
612 
613  if(rechit.flags() & spikebitset) {
614  summary.nspikenoise_++;
615  summary.spikenoisee_ += rechit.eraw();
616  GlobalPoint gp = geo->getPosition(rechit.id());
617  double et = rechit.eraw()*gp.perp()/gp.mag();
618  summary.spikenoiseet_ += et;
619  }
620 
621  if(rechit.flags() & trianglebitset) {
622  summary.ntrianglenoise_++;
623  summary.trianglenoisee_ += rechit.eraw();
624  GlobalPoint gp = geo->getPosition(rechit.id());
625  double et = rechit.eraw()*gp.perp()/gp.mag();
626  summary.trianglenoiseet_ += et;
627  }
628 
629  if(rechit.flags() & ts4ts5bitset) {
630  if ((dbStatusFlag & (1 <<HcalChannelStatus::HcalCellExcludeFromHBHENoiseSummaryR45))==0) // only add to TS4TS5 if the bit is not marked as "HcalCellExcludeFromHBHENoiseSummaryR45"
631  {
632  summary.nts4ts5noise_++;
633  summary.ts4ts5noisee_ += rechit.eraw();
634  GlobalPoint gp = geo->getPosition(rechit.id());
635  double et = rechit.eraw()*gp.perp()/gp.mag();
636  summary.ts4ts5noiseet_ += et;
637  }
638  }
639 
640  if(rechit.flags() & negativebitset) {
641  summary.nnegativenoise_++;
642  summary.negativenoisee_ += rechit.eraw();
643  GlobalPoint gp = geo->getPosition(rechit.id());
644  double et = rechit.eraw()*gp.perp()/gp.mag();
645  summary.negativenoiseet_ += et;
646  }
647 
648  // find the hpd that the rechit is in
649  HcalNoiseHPD& hpd=(*array.findHPD(rechit));
650 
651  // create a persistent reference to the rechit
652  edm::Ref<HBHERecHitCollection> myRef(handle, it-handle->begin());
653 
654  // store it in a place so that it remains sorted by energy
655  hpd.refrechitset_.insert(myRef);
656 
657  } // end loop over rechits
658 
659  // loop over all HPDs and transfer the information from refrechitset_ to rechits_;
660  for(HcalNoiseRBXArray::iterator rbxit=array.begin(); rbxit!=array.end(); ++rbxit) {
661  for(std::vector<HcalNoiseHPD>::iterator hpdit=rbxit->hpds_.begin(); hpdit!=rbxit->hpds_.end(); ++hpdit) {
662 
663  // loop over all of the entries in the set and add them to rechits_
665  it=hpdit->refrechitset_.begin(); it!=hpdit->refrechitset_.end(); ++it) {
666  hpdit->rechits_.push_back(*it);
667  }
668  }
669  }
670  // now the rechits in all the HPDs are sorted by energy!
671 
672  return;
673 }
674 
675 // ------------ fill the array with calo tower information
676 void
678 {
679  // get the calotowers
681  // iEvent.getByLabel(caloTowerCollName_, handle);
682  iEvent.getByToken(calotower_token_, handle);
683 
684  if(!handle.isValid()) {
686  << " could not find CaloTowerCollection named " << caloTowerCollName_ << "\n.";
687  return;
688  }
689 
690  summary.emenergy_ = summary.hadenergy_ = 0.0;
691 
692  // loop over all of the calotower information
693  for(CaloTowerCollection::const_iterator it = handle->begin(); it!=handle->end(); ++it) {
694  const CaloTower& twr=(*it);
695 
696  // create a persistent reference to the tower
697  edm::Ref<CaloTowerCollection> myRef(handle, it-handle->begin());
698 
699  // get all of the hpd's that are pointed to by the calotower
700  std::vector<std::vector<HcalNoiseHPD>::iterator> hpditervec;
701  array.findHPD(twr, hpditervec);
702 
703  // loop over the hpd's and add the reference to the RefVectors
704  for(std::vector<std::vector<HcalNoiseHPD>::iterator>::iterator it=hpditervec.begin();
705  it!=hpditervec.end(); ++it)
706  (*it)->calotowers_.push_back(myRef);
707 
708  // skip over anything with |ieta|>maxCaloTowerIEta
709  if(twr.ietaAbs()>maxCaloTowerIEta_) {
710  summary.emenergy_ += twr.emEnergy();
711  summary.hadenergy_ += twr.hadEnergy();
712  }
713  }
714 
715  return;
716 }
717 
718 // ------------ fill the summary info from jets
719 void
721 {
722  bool goodJetFoundInLowBVRegion = false; // checks whether a jet is in
723  // a low BV region, where false
724  // noise flagging rate is higher.
725  if (!jetCollName_.empty())
726  {
728  iEvent.getByToken(jet_token_, pfjet_h);
729 
730  if (pfjet_h.isValid())
731  {
732  int jetindex=0;
733  for(reco::PFJetCollection::const_iterator jet = pfjet_h->begin();
734  jet != pfjet_h->end(); ++jet)
735  {
736  if (jetindex>maxjetindex_) break; // only look at jets with
737  // indices up to maxjetindex_
738 
739  // Check whether jet is in low-BV region (0<eta<1.4, -1.8<phi<-1.4)
740  if (jet->eta()>0.0 && jet->eta()<1.4 &&
741  jet->phi()>-1.8 && jet->phi()<-1.4)
742  {
743  // Look for a good jet in low BV region;
744  // if found, we will keep event
745  if (maxNHF_<0.0 || jet->neutralHadronEnergyFraction()<maxNHF_)
746  {
747  goodJetFoundInLowBVRegion=true;
748  break;
749  }
750  }
751  ++jetindex;
752  }
753  }
754  }
755 
756  summary.goodJetFoundInLowBVRegion_ = goodJetFoundInLowBVRegion;
757 }
758 
759 // ------------ fill the summary with track information
760 void
762 {
764  // iEvent.getByLabel(trackCollName_, handle);
765  iEvent.getByToken(track_token_, handle);
766 
767  // don't throw exception, just return quietly
768  if(!handle.isValid()) {
769  // throw edm::Exception(edm::errors::ProductNotFound)
770  // << " could not find trackCollection named " << trackCollName_ << "\n.";
771  return;
772  }
773 
774  summary.trackenergy_=0.0;
775  for(reco::TrackCollection::const_iterator iTrack = handle->begin(); iTrack!=handle->end(); ++iTrack) {
776  reco::Track trk=*iTrack;
777  if(trk.pt()<minTrackPt_ || fabs(trk.eta())>maxTrackEta_) continue;
778 
779  summary.trackenergy_ += trk.p();
780  }
781 
782  return;
783 }
784 
785 //define this as a plug-in
int adc(sample_type sample)
get the ADC sample (12 bits)
double e10ts(void) const
Definition: HcalNoiseAlgo.h:23
double HPDEMF(void) const
Definition: HcalNoiseAlgo.h:38
double e2ts(void) const
Definition: HcalNoiseAlgo.h:22
double p() const
momentum vector magnitude
Definition: TrackBase.h:610
T getParameter(std::string const &) const
edm::RefVector< CaloTowerCollection > hlnoisetwrs_
int i
Definition: DBlmapReader.cc:9
double lowEHitTimeSqrd(void) const
Definition: HcalNoiseAlgo.h:31
std::vector< int > calibdigiHFtimeslices_
tuple array
Definition: mps_check.py:181
std::vector< HcalNoiseRBX > HcalNoiseRBXCollection
Definition: HcalNoiseRBX.h:26
std::vector< int > HcalRecHitFlagsToBeExcluded_
bool isProblematic(const CommonHcalNoiseRBXData &) const
algo_(conf.existsAs< bool >("Correct")?conf.getParameter< bool >("Correct"):true, conf.getParameter< double >("e9e25Cut"), conf.getParameter< double >("intercept2DCut"), conf.existsAs< bool >("intercept2DSlope")?conf.getParameter< double >("intercept2DSlope"):defaultSlope2D_, conf.getParameter< std::vector< double > >("e1e9Cut"), conf.getParameter< std::vector< double > >("eCOREe9Cut"), conf.getParameter< std::vector< double > >("eSeLCut"), hfvars_)
bool passTightRatio(const CommonHcalNoiseRBXData &) const
bool zsMarkAndPass() const
was ZS MarkAndPass?
Definition: HBHEDataFrame.h:30
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:186
bool passLooseRatio(const CommonHcalNoiseRBXData &) const
CalibDetType calibFlavor() const
get the flavor of this calibration detid
void fillrechits(edm::Event &, const edm::EventSetup &, HcalNoiseRBXArray &, HcalNoiseSummary &) const
bool passTightRBXRechitR45(const CommonHcalNoiseRBXData &) const
const DetId & detid() const
Definition: CaloRecHit.h:20
double maxHighEHitTime(void) const
Definition: HcalNoiseAlgo.h:34
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
bool passTightTiming(const CommonHcalNoiseRBXData &) const
double maxLowEHitTime(void) const
Definition: HcalNoiseAlgo.h:30
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int numLowEHits(void) const
Definition: HcalNoiseAlgo.h:32
virtual void produce(edm::Event &, const edm::EventSetup &) override
double ratio(void) const
Definition: HcalNoiseAlgo.h:21
std::vector< std::pair< double, double > > TS4TS5LowerCut_
HcalDetId id() const
get the id
Definition: HBHERecHit.h:23
std::set< edm::Ref< HBHERecHitCollection >, RefHBHERecHitEnergyComparison > refrechitset_
Definition: HcalNoiseHPD.h:145
std::vector< HBHEDataFrame >::const_iterator const_iterator
std::vector< float > bigCharge_
Definition: HcalNoiseHPD.h:137
float maxE2Over10TS(void) const
edm::RefVector< CaloTowerCollection > loosenoisetwrs_
bool exists(std::string const &parameterName) const
checks if a parameter exists
void fillcalotwrs(edm::Event &, const edm::EventSetup &, HcalNoiseRBXArray &, HcalNoiseSummary &) const
std::vector< float > big5Charge_
Definition: HcalNoiseHPD.h:138
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool passLooseRBXRechitR45(const CommonHcalNoiseRBXData &) const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
float min25GeVHitTime(void) const
bool passHighLevelNoiseFilter(const CommonHcalNoiseRBXData &) const
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
double RBXEMF(void) const
Definition: HcalNoiseAlgo.h:37
edm::RefVector< HBHERecHitCollection > rechits_
Definition: HcalNoiseHPD.h:141
edm::EDGetTokenT< reco::PFJetCollection > jet_token_
int numRBXHits(void) const
Definition: HcalNoiseAlgo.h:26
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
float min10GeVHitTime(void) const
HcalNoiseRBXArray::iterator findRBX(int rbxindex)
double highEHitTimeSqrd(void) const
Definition: HcalNoiseAlgo.h:35
int iEvent
Definition: GenABIO.cc:230
float minE2Over10TS(void) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
bool passLooseZeros(const CommonHcalNoiseRBXData &) const
double emEnergy() const
Definition: CaloTower.h:107
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
int maxRBXHits(void) const
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
Definition: HcalCoderDb.cc:60
bool passTightZeros(const CommonHcalNoiseRBXData &) const
void filljetinfo(edm::Event &, const edm::EventSetup &, HcalNoiseSummary &) const
double pt() const
track transverse momentum
Definition: TrackBase.h:616
bool recoveredRecHit(const DetId &myid, const uint32_t &myflag) const
uint32_t flags() const
Definition: CaloRecHit.h:21
int numHighEHits(void) const
Definition: HcalNoiseAlgo.h:36
edm::EDGetTokenT< HcalCalibDigiCollection > hcalcalibdigi_token_
tuple handle
Definition: patZpeak.py:22
bool passRatioThreshold(const CommonHcalNoiseRBXData &) const
std::vector< HcalNoiseHPD >::iterator findHPD(int hpdindex)
bool dropChannel(const uint32_t &mystatus) const
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
int numHPDNoOtherHits(void) const
Definition: HcalNoiseAlgo.h:27
int numZeros(void) const
Definition: HcalNoiseAlgo.h:28
edm::EDGetTokenT< HBHEDigiCollection > hbhedigi_token_
bool isValid() const
Definition: HandleBase.h:75
bool passZerosThreshold(const CommonHcalNoiseRBXData &) const
std::vector< std::pair< double, double > > TS4TS5UpperCut_
float minHPDEMF(void) const
bool passLooseNoiseFilter(const CommonHcalNoiseRBXData &) const
edm::RefVector< CaloTowerCollection > rbxTowers(void) const
Definition: HcalNoiseAlgo.h:40
double hadEnergy() const
Definition: CaloTower.h:108
std::vector< float > allCharge_
Definition: HcalNoiseRBX.h:115
edm::EDGetTokenT< reco::TrackCollection > track_token_
Definition: DetId.h:18
bool passLooseHits(const CommonHcalNoiseRBXData &) const
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
edm::EDGetTokenT< HBHERecHitCollection > hbherechit_token_
int size() const
get the size
Definition: CaloSamples.h:24
void filldigis(edm::Event &, const edm::EventSetup &, HcalNoiseRBXArray &, HcalNoiseSummary &)
int maxZeros(void) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
edm::RefVector< CaloTowerCollection > tightnoisetwrs_
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
double energy(void) const
Definition: HcalNoiseAlgo.h:20
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
Definition: Point3D.h:17
int ietaAbs() const
Definition: CaloTower.h:183
bool passLooseTiming(const CommonHcalNoiseRBXData &) const
bool passTightNoiseFilter(const CommonHcalNoiseRBXData &) const
int maxHPDNoOtherHits(void) const
double minHighEHitTime(void) const
Definition: HcalNoiseAlgo.h:33
static std::atomic< unsigned int > counter
double energyInNonLaserRegion_
float minRBXEMF(void) const
std::vector< int > calibdigiHBHEtimeslices_
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
float eraw() const
Definition: HBHERecHit.h:26
bool PassTS4TS5(void) const
Definition: HcalNoiseAlgo.h:39
uint32_t getValue() const
bool passEMFThreshold(const CommonHcalNoiseRBXData &) const
void filltracks(edm::Event &, const edm::EventSetup &, HcalNoiseSummary &) const
HcalNoiseInfoProducer(const edm::ParameterSet &)
void fillOtherSummaryVariables(HcalNoiseSummary &summary, const CommonHcalNoiseRBXData &data) const
int maxHPDHits(void) const
int numHPDHits(void) const
Definition: HcalNoiseAlgo.h:25
float max25GeVHitTime(void) const
float max10GeVHitTime(void) const
bool validRatio(void) const
Definition: HcalNoiseAlgo.h:24
bool passTightHits(const CommonHcalNoiseRBXData &) const
edm::EDGetTokenT< CaloTowerCollection > calotower_token_