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  minRecHitE_ = iConfig.getParameter<double>("minRecHitE");
50  minLowHitE_ = iConfig.getParameter<double>("minLowHitE");
51  minHighHitE_ = iConfig.getParameter<double>("minHighHitE");
52 
53  HcalAcceptSeverityLevel_ = iConfig.getParameter<uint32_t>("HcalAcceptSeverityLevel");
54  if (iConfig.exists("HcalRecHitFlagsToBeExcluded"))
55  HcalRecHitFlagsToBeExcluded_ = iConfig.getParameter<std::vector<int> >("HcalRecHitFlagsToBeExcluded");
56  else{
57  edm::LogWarning("MisConfiguration")<<"the module is missing the parameter HcalAcceptSeverityLevel. created empty.";
59  }
60 
61  // Digi threshold and time slices to use for HBHE and HF calibration digis
62  useCalibDigi_ = true;
63  if(iConfig.existsAs<double>("calibdigiHBHEthreshold") == false) useCalibDigi_ = false;
64  if(iConfig.existsAs<double>("calibdigiHFthreshold") == false) useCalibDigi_ = false;
65  if(iConfig.existsAs<std::vector<int> >("calibdigiHBHEtimeslices") == false) useCalibDigi_ = false;
66  if(iConfig.existsAs<std::vector<int> >("calibdigiHFtimeslices") == false) useCalibDigi_ = false;
67 
68  if(useCalibDigi_ == true)
69  {
70  calibdigiHBHEthreshold_ = iConfig.getParameter<double>("calibdigiHBHEthreshold");
71  calibdigiHBHEtimeslices_ = iConfig.getParameter<std::vector<int> >("calibdigiHBHEtimeslices");
72  calibdigiHFthreshold_ = iConfig.getParameter<double>("calibdigiHFthreshold");
73  calibdigiHFtimeslices_ = iConfig.getParameter<std::vector<int> >("calibdigiHFtimeslices");
74  }
75  else
76  {
78  calibdigiHBHEtimeslices_ = std::vector<int>();
80  calibdigiHFtimeslices_ = std::vector<int>();
81  }
82 
83  TS4TS5EnergyThreshold_ = iConfig.getParameter<double>("TS4TS5EnergyThreshold");
84 
85  std::vector<double> TS4TS5UpperThresholdTemp = iConfig.getParameter<std::vector<double> >("TS4TS5UpperThreshold");
86  std::vector<double> TS4TS5UpperCutTemp = iConfig.getParameter<std::vector<double> >("TS4TS5UpperCut");
87  std::vector<double> TS4TS5LowerThresholdTemp = iConfig.getParameter<std::vector<double> >("TS4TS5LowerThreshold");
88  std::vector<double> TS4TS5LowerCutTemp = iConfig.getParameter<std::vector<double> >("TS4TS5LowerCut");
89 
90  for(int i = 0; i < (int)TS4TS5UpperThresholdTemp.size() && i < (int)TS4TS5UpperCutTemp.size(); i++)
91  TS4TS5UpperCut_.push_back(std::pair<double, double>(TS4TS5UpperThresholdTemp[i], TS4TS5UpperCutTemp[i]));
92  sort(TS4TS5UpperCut_.begin(), TS4TS5UpperCut_.end());
93 
94  for(int i = 0; i < (int)TS4TS5LowerThresholdTemp.size() && i < (int)TS4TS5LowerCutTemp.size(); i++)
95  TS4TS5LowerCut_.push_back(std::pair<double, double>(TS4TS5LowerThresholdTemp[i], TS4TS5LowerCutTemp[i]));
96  sort(TS4TS5LowerCut_.begin(), TS4TS5LowerCut_.end());
97 
98  // if digis are filled, then rechits must also be filled
99  if(fillDigis_ && !fillRecHits_) {
100  fillRecHits_=true;
101  edm::LogWarning("HCalNoiseInfoProducer") << " forcing fillRecHits to be true if fillDigis is true.\n";
102  }
103 
104  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,
105  13.5,15.,17.,19.,21.,23.,25.,27.,29.5,32.5,35.5,38.5,42.,46.,50.,54.5,59.5,
106  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,
107  124.5,129.5,137.,147.,157.,167.,177.,187.,197.,209.5,224.5,239.5,254.5,272.,
108  292.,312.,334.5,359.5,384.5,359.5,384.5,409.5,434.5,459.5,484.5,509.5,534.5,
109  559.5,584.5,609.5,634.5,659.5,684.5,709.5,747.,797.,847.,897.,947.,997.,
110  1047.,1109.5,1184.5,1259.5,1334.5,1422.,1522.,1622.,1734.5,1859.5,1984.5,
111  1859.5,1984.5,2109.5,2234.5,2359.5,2484.5,2609.5,2734.5,2859.5,2984.5,
112  3109.5,3234.5,3359.5,3484.5,3609.5,3797.,4047.,4297.,4547.,4797.,5047.,
113  5297.,5609.5,5984.5,6359.5,6734.5,7172.,7672.,8172.,8734.5,9359.5,9984.5};
114  for(int i = 0; i < 128; i++)
115  adc2fC[i] = adc2fCTemp[i];
116 
117  hbhedigi_token_ = consumes<HBHEDigiCollection>(edm::InputTag(digiCollName_));
118  hcalcalibdigi_token_ = consumes<HcalCalibDigiCollection>(edm::InputTag("hcalDigis"));
119  hbherechit_token_ = consumes<HBHERecHitCollection>(edm::InputTag(recHitCollName_));
120  calotower_token_ = consumes<CaloTowerCollection>(edm::InputTag(caloTowerCollName_));
121  track_token_ = consumes<reco::TrackCollection>(edm::InputTag(trackCollName_));
122 
123  // we produce a vector of HcalNoiseRBXs
124  produces<HcalNoiseRBXCollection>();
125  // we also produce a noise summary
126  produces<HcalNoiseSummary>();
127 }
128 
129 
131 {
132 }
133 
134 
135 //
136 // member functions
137 //
138 
139 // ------------ method called to produce the data ------------
140 void
142 {
143  // this is what we're going to actually write to the EDM
144  std::auto_ptr<HcalNoiseRBXCollection> result1(new HcalNoiseRBXCollection);
145  std::auto_ptr<HcalNoiseSummary> result2(new HcalNoiseSummary);
146 
147  // define an empty HcalNoiseRBXArray that we're going to fill
148  HcalNoiseRBXArray rbxarray;
149  HcalNoiseSummary &summary=*result2;
150 
151  // fill them with the various components
152  // digi assumes that rechit information is available
153  if(fillRecHits_) fillrechits(iEvent, iSetup, rbxarray, summary);
154  if(fillDigis_) filldigis(iEvent, iSetup, rbxarray, summary);
155  if(fillCaloTowers_) fillcalotwrs(iEvent, iSetup, rbxarray, summary);
156  if(fillTracks_) filltracks(iEvent, iSetup, summary);
157 
158  // 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
159  //if(fillDigis_) summary.calibCharge_ = TotalCalibCharge;
160 
161  // select those RBXs which are interesting
162  // also look for the highest energy RBX
163  HcalNoiseRBXArray::iterator maxit=rbxarray.begin();
164  double maxenergy=-999;
165  bool maxwritten=false;
166  for(HcalNoiseRBXArray::iterator rit = rbxarray.begin(); rit!=rbxarray.end(); ++rit) {
167  HcalNoiseRBX &rbx=(*rit);
170 
171  // find the highest energy rbx
172  if(data.energy()>maxenergy) {
173  maxenergy=data.energy();
174  maxit=rit;
175  maxwritten=false;
176  }
177 
178  // find out if the rbx is problematic/noisy/etc.
179  bool writerbx = algo_.isProblematic(data) || !algo_.passLooseNoiseFilter(data) ||
181 
182  // fill variables in the summary object not filled elsewhere
183  fillOtherSummaryVariables(summary, data);
184 
185  if(writerbx) {
186  summary.nproblemRBXs_++;
187  if(summary.nproblemRBXs_<=maxProblemRBXs_) {
188  result1->push_back(rbx);
189  if(maxit==rit) maxwritten=true;
190  }
191  }
192  } // end loop over rbxs
193 
194  // if we still haven't written the maximum energy rbx, write it now
195  if(!maxwritten) {
196  HcalNoiseRBX &rbx=(*maxit);
197 
198  // add the RBX to the event
199  result1->push_back(rbx);
200  }
201 
202  // put the rbxcollection and summary into the EDM
203  iEvent.put(result1);
204  iEvent.put(result2);
205 
206  return;
207 }
208 
209 
210 // ------------ here we fill specific variables in the summary object not already accounted for earlier
211 void
213 {
214  // charge ratio
215  if(algo_.passRatioThreshold(data) && data.validRatio()) {
216  if(data.ratio()<summary.minE2Over10TS()) {
217  summary.mine2ts_ = data.e2ts();
218  summary.mine10ts_ = data.e10ts(); }
219  if(data.ratio()>summary.maxE2Over10TS()) {
220  summary.maxe2ts_ = data.e2ts();
221  summary.maxe10ts_ = data.e10ts();
222  }
223  }
224 
225  // ADC zeros
226  if(algo_.passZerosThreshold(data)) {
227  if(data.numZeros()>summary.maxZeros()) {
228  summary.maxzeros_ = data.numZeros();
229  }
230  }
231 
232  // hits count
233  if(data.numHPDHits() > summary.maxHPDHits()) {
234  summary.maxhpdhits_ = data.numHPDHits();
235  }
236  if(data.numRBXHits() > summary.maxRBXHits()) {
237  summary.maxrbxhits_ = data.numRBXHits();
238  }
239  if(data.numHPDNoOtherHits() > summary.maxHPDNoOtherHits()) {
240  summary.maxhpdhitsnoother_ = data.numHPDNoOtherHits();
241  }
242 
243  // TS4TS5
244  if(data.PassTS4TS5() == false)
245  summary.hasBadRBXTS4TS5_ = true;
246 
247  // hit timing
248  if(data.minLowEHitTime()<summary.min10GeVHitTime()) {
249  summary.min10_ = data.minLowEHitTime();
250  }
251  if(data.maxLowEHitTime()>summary.max10GeVHitTime()) {
252  summary.max10_ = data.maxLowEHitTime();
253  }
254  summary.rms10_ += data.lowEHitTimeSqrd();
255  summary.cnthit10_ += data.numLowEHits();
256  if(data.minHighEHitTime()<summary.min25GeVHitTime()) {
257  summary.min25_ = data.minHighEHitTime();
258  }
259  if(data.maxHighEHitTime()>summary.max25GeVHitTime()) {
260  summary.max25_ = data.maxHighEHitTime();
261  }
262  summary.rms25_ += data.highEHitTimeSqrd();
263  summary.cnthit25_ += data.numHighEHits();
264 
265  // EMF
266  if(algo_.passEMFThreshold(data)) {
267  if(summary.minHPDEMF() > data.HPDEMF()) {
268  summary.minhpdemf_ = data.HPDEMF();
269  }
270  if(summary.minRBXEMF() > data.RBXEMF()) {
271  summary.minrbxemf_ = data.RBXEMF();
272  }
273  }
274 
275  // summary flag
276  if(!algo_.passLooseRatio(data)) summary.filterstatus_ |= 0x1;
277  if(!algo_.passLooseHits(data)) summary.filterstatus_ |= 0x2;
278  if(!algo_.passLooseZeros(data)) summary.filterstatus_ |= 0x4;
279  if(!algo_.passLooseTiming(data)) summary.filterstatus_ |= 0x8;
280 
281  if(!algo_.passTightRatio(data)) summary.filterstatus_ |= 0x100;
282  if(!algo_.passTightHits(data)) summary.filterstatus_ |= 0x200;
283  if(!algo_.passTightZeros(data)) summary.filterstatus_ |= 0x400;
284  if(!algo_.passTightTiming(data)) summary.filterstatus_ |= 0x800;
285 
286  if(!algo_.passHighLevelNoiseFilter(data)) summary.filterstatus_ |= 0x10000;
287 
288  // summary refvectors
290  if(!algo_.passLooseNoiseFilter(data))
291  join(summary.loosenoisetwrs_, data.rbxTowers());
292  if(!algo_.passTightNoiseFilter(data))
293  join(summary.tightnoisetwrs_, data.rbxTowers());
295  join(summary.hlnoisetwrs_, data.rbxTowers());
296 
297  return;
298 }
299 
300 
301 // ------------ fill the array with digi information
302 void
304 {
305  // Some initialization
306  TotalCalibCharge = 0;
307 
308  // 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)
309  int NcalibTS45=0;
310  int NcalibTS45gt15=0;
311  int NcalibHFgtX=0;
312 
313  double chargecalibTS45=0;
314  double chargecalibgt15TS45=0;
315 
316  // get the conditions and channel quality
317  edm::ESHandle<HcalDbService> conditions;
318  iSetup.get<HcalDbRecord>().get(conditions);
320  iSetup.get<HcalChannelQualityRcd>().get(qualhandle);
321  const HcalChannelQuality* myqual = qualhandle.product();
323  iSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
324  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
325 
326  // get the digis
328  // iEvent.getByLabel(digiCollName_, handle);
329  iEvent.getByToken(hbhedigi_token_, handle);
330 
331  if(!handle.isValid()) {
332  throw edm::Exception(edm::errors::ProductNotFound) << " could not find HBHEDigiCollection named " << digiCollName_ << "\n.";
333  return;
334  }
335 
336  // loop over all of the digi information
337  for(HBHEDigiCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
338  const HBHEDataFrame &digi=(*it);
339  HcalDetId cell = digi.id();
340  DetId detcell=(DetId)cell;
341 
342  // check on cells to be ignored and dropped
343  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
344  if(mySeverity->dropChannel(mydigistatus->getValue())) continue;
345  if(digi.zsMarkAndPass()) continue;
346  // Drop if exclude bit set
347  if ((mydigistatus->getValue() & (1 <<HcalChannelStatus::HcalCellExcludeFromHBHENoiseSummary))==1) continue;
348 
349  // get the calibrations and coder
350  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
351  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
352  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
353  HcalCoderDb coder (*channelCoder, *shape);
354 
355  // match the digi to an rbx and hpd
356  HcalNoiseRBX &rbx=(*array.findRBX(digi));
357  HcalNoiseHPD &hpd=(*array.findHPD(digi));
358 
359  // determine if the digi is one the highest energy hits in the HPD
360  // this works because the rechits are sorted by energy (see fillrechits() below)
361  bool isBig=false, isBig5=false, isRBX=false;
362  int counter=0;
365  rit!=rechits.end(); ++rit, ++counter) {
366  if((*rit)->id() == digi.id()) {
367  if(counter==0) isBig=isBig5=true; // digi is also the highest energy rechit
368  if(counter<5) isBig5=true; // digi is one of 5 highest energy rechits
369  isRBX=true;
370  }
371  }
372 
373  // loop over each of the digi's time slices
374  int totalzeros=0;
375  CaloSamples tool;
376  coder.adc2fC(digi,tool);
377  for(int ts=0; ts<tool.size(); ++ts) {
378 
379  // count zero's
380  if(digi[ts].adc()==0) {
381  ++hpd.totalZeros_;
382  ++totalzeros;
383  }
384 
385  // get the fC's
386  double corrfc = tool[ts]-calibrations.pedestal(digi[ts].capid());
387 
388  // fill the relevant digi arrays
389  if(isBig) hpd.bigCharge_[ts]+=corrfc;
390  if(isBig5) hpd.big5Charge_[ts]+=corrfc;
391  if(isRBX) rbx.allCharge_[ts]+=corrfc;
392  }
393 
394  // record the maximum number of zero's found
395  if(totalzeros>hpd.maxZeros_)
396  hpd.maxZeros_=totalzeros;
397  }
398 
399  // get the calibration digis
401  // iEvent.getByLabel("hcalDigis", hCalib);
402  iEvent.getByToken(hcalcalibdigi_token_, hCalib);
403 
404  // get total charge in calibration channels
405  if(hCalib.isValid() == true)
406  {
407  for(HcalCalibDigiCollection::const_iterator digi = hCalib->begin(); digi != hCalib->end(); digi++)
408  {
409  if(digi->id().hcalSubdet() == 0)
410  continue;
411 
412  /*
413  HcalCalibDetId cell = digi->id();
414  DetId detcell = (DetId)cell;
415 
416  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
417 
418  if(mySeverity->dropChannel(mydigistatus->getValue()))
419  continue;
420  if(digi->zsMarkAndPass())
421  continue;
422 
423  const HcalQIECoder *channelCoder = conditions->getHcalCoder(cell);
424  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
425  HcalCoderDb coder(*channelCoder, *shape);
426 
427  CaloSamples tool;
428  coder.adc2fC(*digi, tool);
429 
430  for(int i = 0; i < (int)digi->size(); i++)
431  TotalCalibCharge = TotalCalibCharge + tool[i];
432  */
433 
434  // Original code computes total calib charge over all digis. While I think it would be more useful to skip
435  // zs mark-and-pass channels, I keep this computation as is. Individual HBHE and HF variables do skip
436  // the m-p channels. -- Jeff Temple, 6 December 2012
437 
438  for(int i = 0; i < (int)digi->size(); i++)
439  TotalCalibCharge = TotalCalibCharge + adc2fC[digi->sample(i).adc()&0xff];
440 
441 
442  HcalCalibDetId myid=(HcalCalibDetId)digi->id();
444  continue; // ignore HOCrosstalk channels
445  if(digi->zsMarkAndPass()) continue; // skip "mark-and-pass" channels when computing charge in calib channels
446 
447 
448  if (digi->id().hcalSubdet()==HcalForward) // check HF
449  {
450  double sumChargeHF=0;
451  for (unsigned int i=0;i<calibdigiHFtimeslices_.size();++i)
452  {
453  // skip unphysical time slices
454  if (calibdigiHFtimeslices_[i]<0 || calibdigiHFtimeslices_[i]>digi->size())
455  continue;
456  sumChargeHF+=adc2fC[digi->sample(calibdigiHFtimeslices_[i]).adc()&0xff];
457  }
458  if (sumChargeHF>calibdigiHFthreshold_) ++NcalibHFgtX;
459  } // end of HF check
460  else if (digi->id().hcalSubdet()==HcalBarrel || digi->id().hcalSubdet()==HcalEndcap) // now check HBHE
461  {
462  double sumChargeHBHE=0;
463  for (unsigned int i=0;i<calibdigiHBHEtimeslices_.size();++i)
464  {
465  // skip unphysical time slices
466  if (calibdigiHBHEtimeslices_[i]<0 || calibdigiHBHEtimeslices_[i]>digi->size())
467  continue;
468  sumChargeHBHE+=adc2fC[digi->sample(calibdigiHBHEtimeslices_[i]).adc()&0xff];
469  }
470  ++NcalibTS45;
471  chargecalibTS45+=sumChargeHBHE;
472  if (sumChargeHBHE>calibdigiHBHEthreshold_)
473  {
474  ++NcalibTS45gt15;
475  chargecalibgt15TS45+=sumChargeHBHE;
476  }
477  } // end of HBHE check
478  } // loop on HcalCalibDigiCollection
479  } // if (hCalib.isValid()==true)
480 
481  summary.calibCharge_ = TotalCalibCharge;
482  summary.calibCountTS45_=NcalibTS45;
483  summary.calibCountgt15TS45_=NcalibTS45gt15;
484  summary.calibChargeTS45_=chargecalibTS45;
485  summary.calibChargegt15TS45_=chargecalibgt15TS45;
486  summary.calibCountHF_=NcalibHFgtX;
487 
488  return;
489 }
490 
491 // ------------ fill the array with rec hit information
492 void
494 {
495  // get the HCAL channel status map
497  iSetup.get<HcalChannelQualityRcd>().get( hcalChStatus );
498  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
499 
500  // get the severity level computer
501  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
502  iSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
503  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
504 
505  // get the calo geometry
507  iSetup.get<CaloGeometryRecord>().get(pG);
508  const CaloGeometry* geo = pG.product();
509 
510  // get the rechits
512  // iEvent.getByLabel(recHitCollName_, handle);
513  iEvent.getByToken(hbherechit_token_, handle);
514 
515  if(!handle.isValid()) {
517  << " could not find HBHERecHitCollection named " << recHitCollName_ << "\n.";
518  return;
519  }
520 
521  summary.rechitCount_ = 0;
522  summary.rechitCount15_ = 0;
523  summary.rechitEnergy_ = 0;
524  summary.rechitEnergy15_ = 0;
525 
526  summary.hitsInLaserRegion_=0;
527  summary.hitsInNonLaserRegion_=0;
528  summary.energyInLaserRegion_=0;
529  summary.energyInNonLaserRegion_=0;
530 
531 
532 
533  // loop over all of the rechit information
534  for(HBHERecHitCollection::const_iterator it=handle->begin(); it!=handle->end(); ++it) {
535  const HBHERecHit &rechit=(*it);
536 
537  // skip bad rechits (other than those flagged by the isolated noise, triangle, flat, and spike algorithms)
538  const DetId id = rechit.detid();
539  uint32_t recHitFlag = rechit.flags();
540  uint32_t isolbitset = (1 << HcalCaloFlagLabels::HBHEIsolatedNoise);
541  uint32_t flatbitset = (1 << HcalCaloFlagLabels::HBHEFlatNoise);
542  uint32_t spikebitset = (1 << HcalCaloFlagLabels::HBHESpikeNoise);
543  uint32_t trianglebitset = (1 << HcalCaloFlagLabels::HBHETriangleNoise);
544  uint32_t ts4ts5bitset = (1 << HcalCaloFlagLabels::HBHETS4TS5Noise);
545  for(unsigned int i=0; i<HcalRecHitFlagsToBeExcluded_.size(); i++) {
546  uint32_t bitset = (1 << HcalRecHitFlagsToBeExcluded_[i]);
547  recHitFlag = (recHitFlag & bitset) ? recHitFlag-bitset : recHitFlag;
548  }
549  const uint32_t dbStatusFlag = dbHcalChStatus->getValues(id)->getValue();
550 
551  // Ignore rechit if exclude bit set, regardless of severity of other bits
552  if ((dbStatusFlag & (1 <<HcalChannelStatus::HcalCellExcludeFromHBHENoiseSummary))==1) continue;
553 
554  int severityLevel = hcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
555  bool isRecovered = hcalSevLvlComputer->recoveredRecHit(id, recHitFlag);
556  if(severityLevel!=0 && !isRecovered && severityLevel>static_cast<int>(HcalAcceptSeverityLevel_)) continue;
557 
558  // do some rechit counting and energies
559  summary.rechitCount_ = summary.rechitCount_ + 1;
560  summary.rechitEnergy_ = summary.rechitEnergy_ + rechit.energy();
561  if ((dbStatusFlag & (1 <<HcalChannelStatus::HcalBadLaserSignal))==1) // hit comes from a region where no laser calibration pulse is normally seen
562  {
563  ++summary.hitsInNonLaserRegion_;
564  summary.energyInNonLaserRegion_+=rechit.energy();
565  }
566  else // hit comes from region where laser calibration pulse is seen
567  {
568  ++summary.hitsInLaserRegion_;
569  summary.energyInLaserRegion_+=rechit.energy();
570  }
571 
572  if(rechit.energy() > 1.5)
573  {
574  summary.rechitCount15_ = summary.rechitCount15_ + 1;
575  summary.rechitEnergy15_ = summary.rechitEnergy15_ + rechit.energy();
576  }
577 
578  // if it was ID'd as isolated noise, update the summary object
579  if(rechit.flags() & isolbitset) {
580  summary.nisolnoise_++;
581  summary.isolnoisee_ += rechit.energy();
582  GlobalPoint gp = geo->getPosition(rechit.id());
583  double et = rechit.energy()*gp.perp()/gp.mag();
584  summary.isolnoiseet_ += et;
585  }
586 
587  if(rechit.flags() & flatbitset) {
588  summary.nflatnoise_++;
589  summary.flatnoisee_ += rechit.energy();
590  GlobalPoint gp = geo->getPosition(rechit.id());
591  double et = rechit.energy()*gp.perp()/gp.mag();
592  summary.flatnoiseet_ += et;
593  }
594 
595  if(rechit.flags() & spikebitset) {
596  summary.nspikenoise_++;
597  summary.spikenoisee_ += rechit.energy();
598  GlobalPoint gp = geo->getPosition(rechit.id());
599  double et = rechit.energy()*gp.perp()/gp.mag();
600  summary.spikenoiseet_ += et;
601  }
602 
603  if(rechit.flags() & trianglebitset) {
604  summary.ntrianglenoise_++;
605  summary.trianglenoisee_ += rechit.energy();
606  GlobalPoint gp = geo->getPosition(rechit.id());
607  double et = rechit.energy()*gp.perp()/gp.mag();
608  summary.trianglenoiseet_ += et;
609  }
610 
611  if(rechit.flags() & ts4ts5bitset) {
612  if ((dbStatusFlag & (1 <<HcalChannelStatus::HcalCellExcludeFromHBHENoiseSummaryR45))==0) // only add to TS4TS5 if the bit is not marked as "HcalCellExcludeFromHBHENoiseSummaryR45"
613  {
614  summary.nts4ts5noise_++;
615  summary.ts4ts5noisee_ += rechit.energy();
616  GlobalPoint gp = geo->getPosition(rechit.id());
617  double et = rechit.energy()*gp.perp()/gp.mag();
618  summary.ts4ts5noiseet_ += et;
619  }
620  }
621 
622  // find the hpd that the rechit is in
623  HcalNoiseHPD& hpd=(*array.findHPD(rechit));
624 
625  // create a persistent reference to the rechit
626  edm::Ref<HBHERecHitCollection> myRef(handle, it-handle->begin());
627 
628  // store it in a place so that it remains sorted by energy
629  hpd.refrechitset_.insert(myRef);
630 
631  } // end loop over rechits
632 
633  // loop over all HPDs and transfer the information from refrechitset_ to rechits_;
634  for(HcalNoiseRBXArray::iterator rbxit=array.begin(); rbxit!=array.end(); ++rbxit) {
635  for(std::vector<HcalNoiseHPD>::iterator hpdit=rbxit->hpds_.begin(); hpdit!=rbxit->hpds_.end(); ++hpdit) {
636 
637  // loop over all of the entries in the set and add them to rechits_
639  it=hpdit->refrechitset_.begin(); it!=hpdit->refrechitset_.end(); ++it) {
640  hpdit->rechits_.push_back(*it);
641  }
642  }
643  }
644  // now the rechits in all the HPDs are sorted by energy!
645 
646  return;
647 }
648 
649 // ------------ fill the array with calo tower information
650 void
652 {
653  // get the calotowers
655  // iEvent.getByLabel(caloTowerCollName_, handle);
656  iEvent.getByToken(calotower_token_, handle);
657 
658  if(!handle.isValid()) {
660  << " could not find CaloTowerCollection named " << caloTowerCollName_ << "\n.";
661  return;
662  }
663 
664  summary.emenergy_ = summary.hadenergy_ = 0.0;
665 
666  // loop over all of the calotower information
667  for(CaloTowerCollection::const_iterator it = handle->begin(); it!=handle->end(); ++it) {
668  const CaloTower& twr=(*it);
669 
670  // create a persistent reference to the tower
671  edm::Ref<CaloTowerCollection> myRef(handle, it-handle->begin());
672 
673  // get all of the hpd's that are pointed to by the calotower
674  std::vector<std::vector<HcalNoiseHPD>::iterator> hpditervec;
675  array.findHPD(twr, hpditervec);
676 
677  // loop over the hpd's and add the reference to the RefVectors
678  for(std::vector<std::vector<HcalNoiseHPD>::iterator>::iterator it=hpditervec.begin();
679  it!=hpditervec.end(); ++it)
680  (*it)->calotowers_.push_back(myRef);
681 
682  // skip over anything with |ieta|>maxCaloTowerIEta
683  if(twr.ietaAbs()>maxCaloTowerIEta_) {
684  summary.emenergy_ += twr.emEnergy();
685  summary.hadenergy_ += twr.hadEnergy();
686  }
687  }
688 
689  return;
690 }
691 
692 // ------------ fill the summary with track information
693 void
695 {
697  // iEvent.getByLabel(trackCollName_, handle);
698  iEvent.getByToken(track_token_, handle);
699 
700  // don't throw exception, just return quietly
701  if(!handle.isValid()) {
702  // throw edm::Exception(edm::errors::ProductNotFound)
703  // << " could not find trackCollection named " << trackCollName_ << "\n.";
704  return;
705  }
706 
707  summary.trackenergy_=0.0;
708  for(reco::TrackCollection::const_iterator iTrack = handle->begin(); iTrack!=handle->end(); ++iTrack) {
709  reco::Track trk=*iTrack;
710  if(trk.pt()<minTrackPt_ || fabs(trk.eta())>maxTrackEta_) continue;
711 
712  summary.trackenergy_ += trk.p();
713  }
714 
715  return;
716 }
717 
718 //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:127
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_
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:184
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
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:434
bool passTightTiming(const CommonHcalNoiseRBXData &) const
double maxLowEHitTime(void) const
Definition: HcalNoiseAlgo.h:30
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:142
std::vector< HBHEDataFrame >::const_iterator const_iterator
std::vector< float > bigCharge_
Definition: HcalNoiseHPD.h:134
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:135
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
float min25GeVHitTime(void) const
bool passHighLevelNoiseFilter(const CommonHcalNoiseRBXData &) const
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
double RBXEMF(void) const
Definition: HcalNoiseAlgo.h:37
edm::RefVector< HBHERecHitCollection > rechits_
Definition: HcalNoiseHPD.h:138
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:139
bool passLooseZeros(const CommonHcalNoiseRBXData &) const
double emEnergy() const
Definition: CaloTower.h:94
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
int maxRBXHits(void) const
float energy() const
Definition: CaloRecHit.h:17
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
Definition: HcalCoderDb.cc:44
bool passTightZeros(const CommonHcalNoiseRBXData &) const
double pt() const
track transverse momentum
Definition: TrackBase.h:129
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:76
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:95
std::vector< float > allCharge_
Definition: HcalNoiseRBX.h:113
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
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:55
T const * product() const
Definition: ESHandle.h:62
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:170
bool passLooseTiming(const CommonHcalNoiseRBXData &) const
bool passTightNoiseFilter(const CommonHcalNoiseRBXData &) const
int maxHPDNoOtherHits(void) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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
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_