CMS 3D CMS Logo

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