CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTriggerPrimitiveAlgo.cc
Go to the documentation of this file.
3 
4 #include <iostream>
12 
13 using namespace std;
14 
15 HcalTriggerPrimitiveAlgo::HcalTriggerPrimitiveAlgo( bool pf, const std::vector<double>& w, int latency,
16  uint32_t FG_threshold1, uint32_t FG_threshold2, uint32_t ZS_threshold,
17  int numberOfSamples, int numberOfPresamples,
18  int numberOfSamplesHF, int numberOfPresamplesHF,
19  uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold)
20  : incoder_(0), outcoder_(0),
21  theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
22  FG_threshold1_(FG_threshold1), FG_threshold2_(FG_threshold2), ZS_threshold_(ZS_threshold),
23  numberOfSamples_(numberOfSamples),
24  numberOfPresamples_(numberOfPresamples),
25  numberOfSamplesHF_(numberOfSamplesHF),
26  numberOfPresamplesHF_(numberOfPresamplesHF),
27  minSignalThreshold_(minSignalThreshold),
28  PMT_NoiseThreshold_(PMT_NoiseThreshold),
29  peak_finder_algorithm_(2)
30 {
31  //No peak finding setting (for Fastsim)
32  if (!peakfind_){
33  numberOfSamples_ = 1;
35  numberOfSamplesHF_ = 1;
37  }
38  // Switch to integer for comparisons - remove compiler warning
40 }
41 
42 
44 }
45 
47  {
48  int GCTeta = 0;
49 
50  if (eta == 29 || eta == 30 || eta == 31)
51  {
52  GCTeta = 18;
53  }
54  else if (eta == 32 || eta == 33 || eta == 34)
55  {
56  GCTeta = 19;
57  }
58  else if (eta == 35 || eta == 36 || eta == 37)
59  {
60  GCTeta = 20;
61  }
62  else if (eta == 38 || eta == 39 || eta == 40 || eta == 41)
63  {
64  GCTeta = 21;
65  }
66  else if (eta == -29 || eta == -30 || eta == -31)
67  {
68  GCTeta = 3;
69  }
70  else if (eta == -32 || eta == -33 || eta == -34)
71  {
72  GCTeta = 2;
73  }
74  else if (eta == -35 || eta == -36 || eta == -37)
75  {
76  GCTeta = 1;
77  }
78  else if (eta == -38 || eta == -39 || eta == -40 || eta == -41)
79  {
80  GCTeta = 0;
81  }
82  return GCTeta;
83  }
84 
86  {
87 
88  int GCTphi = 0;
89 
90  if (phi == 1 || phi == 71)
91  {
92  GCTphi = 0;
93  }
94  else if (phi == 3 || phi == 5)
95  {
96  GCTphi = 1;
97  }
98  else if (phi == 7 || phi == 9)
99  {
100  GCTphi = 2;
101  }
102  else if (phi == 11 || phi == 13)
103  {
104  GCTphi = 3;
105  }
106  else if (phi == 15 || phi == 17)
107  {
108  GCTphi = 4;
109  }
110  else if (phi == 19 || phi == 21)
111  {
112  GCTphi = 5;
113  }
114  else if (phi == 23 || phi == 25)
115  {
116  GCTphi = 6;
117  }
118  else if (phi == 27 || phi == 29)
119  {
120  GCTphi = 7;
121  }
122  else if (phi == 31 || phi == 33)
123  {
124  GCTphi = 8;
125  }
126  else if (phi == 35 || phi == 37)
127  {
128  GCTphi = 9;
129  }
130  else if (phi == 39 || phi == 41)
131  {
132  GCTphi = 10;
133  }
134  else if (phi == 43 || phi == 45)
135  {
136  GCTphi = 11;
137  }
138  else if (phi == 47 || phi == 49)
139  {
140  GCTphi = 12;
141  }
142  else if (phi == 51 || phi == 53)
143  {
144  GCTphi = 13;
145  }
146  else if (phi == 55 || phi == 57)
147  {
148  GCTphi = 14;
149  }
150  else if (phi == 59 || phi == 61)
151  {
152  GCTphi = 15;
153  }
154  else if (phi == 63 || phi == 65)
155  {
156  GCTphi = 16;
157  }
158  else if (phi == 67 || phi == 69)
159  {
160  GCTphi = 17;
161  }
162  return GCTphi;
163  }
164 
165 int converttoTPGeta(int& GCTeta)
166 {
167  int TPGeta = 0;
168 
169  if (GCTeta == 0)
170  {
171  TPGeta = -32;
172  }
173  if (GCTeta == 1)
174  {
175  TPGeta = -31;
176  }
177  if (GCTeta == 2)
178  {
179  TPGeta = -30;
180  }
181  if (GCTeta == 3)
182  {
183  TPGeta = -29;
184  }
185  if (GCTeta == 18)
186  {
187  TPGeta = 29;
188  }
189  if (GCTeta == 19)
190  {
191  TPGeta = 30;
192  }
193  if (GCTeta == 20)
194  {
195  TPGeta = 31;
196  }
197  if (GCTeta == 21)
198  {
199  TPGeta = 32;
200  }
201 
202  return TPGeta;
203 }
204 
205 int converttoTPGphi(int& GCTphi)
206 {
207  int TPGphi = 0;
208 
209  if (GCTphi == 0)
210  {
211  TPGphi = 1;
212  }
213  if (GCTphi == 1)
214  {
215  TPGphi = 5;
216  }
217  if (GCTphi == 2)
218  {
219  TPGphi = 9;
220  }
221  if (GCTphi == 3)
222  {
223  TPGphi = 13;
224  }
225  if (GCTphi == 4)
226  {
227  TPGphi = 17;
228  }
229  if (GCTphi == 5)
230  {
231  TPGphi = 21;
232  }
233  if (GCTphi == 6)
234  {
235  TPGphi = 25;
236  }
237  if (GCTphi == 7)
238  {
239  TPGphi = 29;
240  }
241  if (GCTphi == 8)
242  {
243  TPGphi = 33;
244  }
245  if (GCTphi == 9)
246  {
247  TPGphi = 37;
248  }
249  if (GCTphi == 10)
250  {
251  TPGphi = 41;
252  }
253  if (GCTphi == 11)
254  {
255  TPGphi = 45;
256  }
257  if (GCTphi == 12)
258  {
259  TPGphi = 49;
260  }
261  if (GCTphi == 13)
262  {
263  TPGphi = 53;
264  }
265  if (GCTphi == 14)
266  {
267  TPGphi = 57;
268  }
269  if (GCTphi == 15)
270  {
271  TPGphi = 61;
272  }
273  if (GCTphi == 16)
274  {
275  TPGphi = 65;
276  }
277  if (GCTphi == 17)
278  {
279  TPGphi = 69;
280  }
281 return TPGphi;
282 }
283 
284 int converttoGCTetaFromTPG(int& etaTPG)
285 {
286  int neweta = 0;
287 
288  if (etaTPG == -32)
289  {
290  neweta = 0;
291  }
292  if (etaTPG == -31)
293  {
294  neweta = 1;
295  }
296  if (etaTPG == -30)
297  {
298  neweta = 2;
299  }
300  if (etaTPG == -29)
301  {
302  neweta = 3;
303  }
304 
305  if (etaTPG == 29)
306  {
307  neweta = 18;
308  }
309  if (etaTPG == 30)
310  {
311  neweta = 19;
312  }
313  if (etaTPG == 31)
314  {
315  neweta = 20;
316  }
317  if (etaTPG == 32)
318  {
319  neweta = 21;
320  }
321  return neweta;
322 }
323 
324 int converttoGCTphiFromTPG(int& phiTPG)
325 {
326  int newphi = 0;
327 
328  if (phiTPG == 1)
329  {
330  newphi = 0;
331  }
332  else if (phiTPG == 5 )
333  {
334  newphi = 1;
335  }
336  else if (phiTPG == 9)
337  {
338  newphi = 2;
339  }
340  else if (phiTPG == 13)
341  {
342  newphi = 3;
343  }
344  else if (phiTPG == 17)
345  {
346  newphi = 4;
347  }
348  else if (phiTPG == 21)
349  {
350  newphi = 5;
351  }
352  else if (phiTPG == 25)
353  {
354  newphi = 6;
355  }
356  else if (phiTPG == 29)
357  {
358  newphi = 7;
359  }
360  else if (phiTPG == 33)
361  {
362  newphi = 8;
363  }
364  else if (phiTPG == 37)
365  {
366  newphi = 9;
367  }
368  else if (phiTPG == 41)
369  {
370  newphi = 10;
371  }
372  else if (phiTPG == 45)
373  {
374  newphi = 11;
375  }
376  else if (phiTPG == 49)
377  {
378  newphi = 12;
379  }
380  else if (phiTPG == 53)
381  {
382  newphi = 13;
383  }
384  else if (phiTPG == 57)
385  {
386  newphi = 14;
387  }
388  else if (phiTPG == 61)
389  {
390  newphi = 15;
391  }
392  else if (phiTPG == 65)
393  {
394  newphi = 16;
395  }
396  else if (phiTPG == 69)
397  {
398  newphi = 17;
399  }
400  return newphi;
401 }
403  const HcalTPGCompressor* outcoder,
404  const HBHEDigiCollection& hbheDigis,
405  const HFDigiCollection& hfDigis,
407  const HcalTrigTowerGeometry* trigTowerGeometry,
408  float rctlsb) {
409  theTrigTowerGeometry = trigTowerGeometry;
410 
411  incoder_=dynamic_cast<const HcaluLUTTPGCoder*>(incoder);
412  outcoder_=outcoder;
413 
414  theSumMap.clear();
415  theTowerMapFGSum.clear();
416  HF_Veto.clear();
417  fgMap_.clear();
418 
419  // do the HB/HE digis
420  for(HBHEDigiCollection::const_iterator hbheItr = hbheDigis.begin();
421  hbheItr != hbheDigis.end(); ++hbheItr) {
422  addSignal(*hbheItr);
423  }
424 
425  // and the HF digis
426  for(HFDigiCollection::const_iterator hfItr = hfDigis.begin();
427  hfItr != hfDigis.end(); ++hfItr) {
428  addSignal(*hfItr);
429 
430  }
431 
432  int phiBin = 18;
433  int etaBin = 22;
434  int thresholds = 2;
435 
436  int fiberQIEThresh[phiBin][etaBin][thresholds];
437  int FGBit[18][22];
438 
439  for (int i = 0; i < phiBin; i++)
440  {
441  for (int j = 0; j < etaBin; j++)
442  {
443  FGBit[i][j] = 0;
444  for (int k = 0; k < thresholds; k++)
445  {
446  fiberQIEThresh[i][j][k] = 0;
447  }
448  }
449  }
450 
451  for(HFDigiCollection::const_iterator hfdigi = hfDigis.begin(); hfdigi != hfDigis.end(); hfdigi++)
452  {
453  HcalDetId hcalid = HcalDetId(hfdigi->id()) ;
454 
455  int ieta = hcalid.ieta();
456  int iphi = hcalid.iphi();
457  int presample = hfdigi->presamples();
458 
459  double qieval = hfdigi->sample(presample).adc();
460 
461  int GCTeta = converttoGCTeta(ieta);
462  int GCTphi = converttoGCTphi(iphi);
463 
464  if (qieval > FG_threshold1_ )
465  {
466  fiberQIEThresh[GCTphi][GCTeta][0]++;
467  }
468  if (qieval > FG_threshold2_)
469  {
470  fiberQIEThresh[GCTphi][GCTeta][1]++;
471  }
472  }
473 
474  // Calculate the final FG bit
475  for (int i = 0; i < phiBin; i++)
476  {
477  for (int j = 0; j < etaBin; j++)
478  {
479  if (fiberQIEThresh[i][j][0] > 0 && j < 4)
480  {
481  FGBit[i][0] = 1;
482  FGBit[i][2] = 1;
483  }
484  if (fiberQIEThresh[i][j][0] > 0 && j > 17)
485  {
486  FGBit[i][19] = 1;
487  FGBit[i][21] = 1;
488  }
489  if (fiberQIEThresh[i][j][1] > 0 && j < 4)
490  {
491  FGBit[i][1] = 1;
492  FGBit[i][3] = 1;
493  }
494  if (fiberQIEThresh[i][j][1] > 0 && j > 17)
495  {
496  FGBit[i][18] = 1;
497  FGBit[i][20] = 1;
498  }
499  }
500  }
501 
502 
503  for(SumMap::iterator mapItr = theSumMap.begin(); mapItr != theSumMap.end(); ++mapItr) {
504  result.push_back(HcalTriggerPrimitiveDigi(mapItr->first));
505  HcalTrigTowerDetId detId(mapItr->second.id());
506  if(detId.ietaAbs() >= theTrigTowerGeometry->firstHFTower())
507  {
508  int ietaTow = detId.ieta();
509  int iphiTow = detId.iphi();
510  analyzeHF(ietaTow, iphiTow, FGBit, mapItr->second, result.back(), rctlsb);
511  }
512  else{ analyze(mapItr->second, result.back()); }
513  }
514  return;
515 }
516 
517 
519  //Hack for 300_pre10, should be removed.
520  if (frame.id().depth()==5) return;
521 
522  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(frame.id());
523  assert(ids.size() == 1 || ids.size() == 2);
524  IntegerCaloSamples samples1(ids[0], int(frame.size()));
525 
526  samples1.setPresamples(frame.presamples());
527  incoder_->adc2Linear(frame, samples1);
528 
529  std::vector<bool> msb;
530  incoder_->lookupMSB(frame, msb);
531 
532  if(ids.size() == 2) {
533  // make a second trigprim for the other one, and split the energy
534  IntegerCaloSamples samples2(ids[1], samples1.size());
535  for(int i = 0; i < samples1.size(); ++i) {
536  samples1[i] = uint32_t(samples1[i]*0.5);
537  samples2[i] = samples1[i];
538  }
539  samples2.setPresamples(frame.presamples());
540  addSignal(samples2);
541  addFG(ids[1], msb);
542  }
543  addSignal(samples1);
544  addFG(ids[0], msb);
545 }
546 
547 
549 
550  if(frame.id().depth() == 1 || frame.id().depth() == 2) {
551  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(frame.id());
552  assert(ids.size() == 1);
553  IntegerCaloSamples samples(ids[0], frame.size());
554  samples.setPresamples(frame.presamples());
555  incoder_->adc2Linear(frame, samples);
556 
557  // Don't add to final collection yet
558  // HF PMT veto sum is calculated in analyzerHF()
559  IntegerCaloSamples zero_samples(ids[0], frame.size());
560  zero_samples.setPresamples(frame.presamples());
561  addSignal(zero_samples);
562 
563  // Mask off depths: fgid is the same for both depths
564  uint32_t fgid = (frame.id().maskDepth());
565 
566  if ( theTowerMapFGSum.find(ids[0]) == theTowerMapFGSum.end() ) {
567  SumFGContainer sumFG;
568  theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer >(ids[0], sumFG));
569  }
570 
571  SumFGContainer& sumFG = theTowerMapFGSum[ids[0]];
572  SumFGContainer::iterator sumFGItr;
573  for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
574  if (sumFGItr->id() == fgid) break;
575  }
576  // If find
577  if (sumFGItr != sumFG.end()) {
578  for (int i=0; i<samples.size(); ++i) (*sumFGItr)[i] += samples[i];
579  }
580  else {
581  //Copy samples (change to fgid)
582  IntegerCaloSamples sumFGSamples(DetId(fgid), samples.size());
583  sumFGSamples.setPresamples(samples.presamples());
584  for (int i=0; i<samples.size(); ++i) sumFGSamples[i] = samples[i];
585  sumFG.push_back(sumFGSamples);
586  }
587 
588  // set veto to true if Long or Short less than threshold
589  if (HF_Veto.find(fgid) == HF_Veto.end()) {
590  vector<bool> vetoBits(samples.size(), false);
591  HF_Veto[fgid] = vetoBits;
592  }
593  for (int i=0; i<samples.size(); ++i)
594  if (samples[i] < minSignalThreshold_)
595  HF_Veto[fgid][i] = true;
596  }
597 }
598 
599 
601  HcalTrigTowerDetId id(samples.id());
602  SumMap::iterator itr = theSumMap.find(id);
603  if(itr == theSumMap.end()) {
604  theSumMap.insert(std::make_pair(id, samples));
605  }
606  else {
607  // wish CaloSamples had a +=
608  for(int i = 0; i < samples.size(); ++i) {
609  (itr->second)[i] += samples[i];
610  }
611  }
612 }
613 
614 
616  int shrink = weights_.size() - 1;
617  std::vector<bool>& msb = fgMap_[samples.id()];
618  IntegerCaloSamples sum(samples.id(), samples.size());
619 
620  //slide algo window
621  for(int ibin = 0; ibin < int(samples.size())- shrink; ++ibin) {
622  int algosumvalue = 0;
623  for(unsigned int i = 0; i < weights_.size(); i++) {
624  //add up value * scale factor
625  algosumvalue += int(samples[ibin+i] * weights_[i]);
626  }
627  if (algosumvalue<0) sum[ibin]=0; // low-side
628  //high-side
629  //else if (algosumvalue>0x3FF) sum[ibin]=0x3FF;
630  else sum[ibin] = algosumvalue; //assign value to sum[]
631  }
632 
633  // Align digis and TP
634  int dgPresamples=samples.presamples();
635  int tpPresamples=numberOfPresamples_;
636  int shift = dgPresamples - tpPresamples;
637  int dgSamples=samples.size();
638  int tpSamples=numberOfSamples_;
639  if(peakfind_){
640  if((shift<shrink) || (shift + tpSamples + shrink > dgSamples - (peak_finder_algorithm_ - 1) ) ){
641  edm::LogInfo("HcalTriggerPrimitiveAlgo::analyze") <<
642  "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
643  shift=shrink;
644  tpPresamples=dgPresamples-shrink;
645  tpSamples=dgSamples-(peak_finder_algorithm_-1)-shrink-shift;
646  }
647  }
648 
649  std::vector<bool> finegrain(tpSamples,false);
650 
651  IntegerCaloSamples output(samples.id(), tpSamples);
652  output.setPresamples(tpPresamples);
653 
654  for (int ibin = 0; ibin < tpSamples; ++ibin) {
655  // ibin - index for output TP
656  // idx - index for samples + shift
657  int idx = ibin + shift;
658 
659  //Peak finding
660  if (peakfind_) {
661  bool isPeak = false;
662  switch (peak_finder_algorithm_) {
663  case 1 :
664  isPeak = (samples[idx] > samples[idx-1] && samples[idx] >= samples[idx+1] && samples[idx] > theThreshold);
665  break;
666  case 2:
667  isPeak = (sum[idx] > sum[idx-1] && sum[idx] >= sum[idx+1] && sum[idx] > theThreshold);
668  break;
669  default:
670  break;
671  }
672 
673  if (isPeak){
674  output[ibin] = std::min<unsigned int>(sum[idx],0x3FF);
675  finegrain[ibin] = msb[idx];
676  }
677  // Not a peak
678  else output[ibin] = 0;
679  }
680  else { // No peak finding, just output running sum
681  output[ibin] = std::min<unsigned int>(sum[idx],0x3FF);
682  finegrain[ibin] = msb[idx];
683  }
684 
685  // Only Pegged for 1-TS algo.
686  if (peak_finder_algorithm_ == 1) {
687  if (samples[idx] >= 0x3FF)
688  output[ibin] = 0x3FF;
689  }
690  }
691  outcoder_->compress(output, finegrain, result);
692 }
693 
694 
695 void HcalTriggerPrimitiveAlgo::analyzeHF(int ieta, int iphi, int (&FGBit)[18][22], IntegerCaloSamples & samples, HcalTriggerPrimitiveDigi & result, float rctlsb) {
696  HcalTrigTowerDetId detId(samples.id());
697 
698  // Align digis and TP
699  int dgPresamples=samples.presamples();
700  int tpPresamples=numberOfPresamplesHF_;
701  int shift = dgPresamples - tpPresamples;
702  int dgSamples=samples.size();
703  int tpSamples=numberOfSamplesHF_;
704  if(shift<0 || shift+tpSamples>dgSamples){
705  edm::LogInfo("HcalTriggerPrimitiveAlgo::analyzeHF") <<
706  "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
707  tpPresamples=dgPresamples;
708  shift=0;
709  tpSamples=dgSamples;
710  }
711 
712  std::vector<bool> finegrain(tpSamples, false);
713 
714  int ietaGCT = converttoGCTetaFromTPG(ieta);
715  int iphiGCT = converttoGCTphiFromTPG(iphi);
716 
717  for (int index = 0; index < tpSamples; ++index)
718  {
719  finegrain[index] = FGBit[iphiGCT][ietaGCT];
720  }
721 
722  TowerMapFGSum::const_iterator tower2fg = theTowerMapFGSum.find(detId);
723  assert(tower2fg != theTowerMapFGSum.end());
724 
725  const SumFGContainer& sumFG = tower2fg->second;
726  // Loop over all L+S pairs that mapped from samples.id()
727  // Note: 1 samples.id() = 6 x (L+S) without noZS
728  for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
729  const std::vector<bool>& veto = HF_Veto[sumFGItr->id().rawId()];
730  for (int ibin = 0; ibin < tpSamples; ++ibin) {
731  int idx = ibin + shift;
732  // if not vetod, add L+S to total sum and calculate FG
733  bool vetoed = idx<int(veto.size()) && veto[idx];
734  if (!(vetoed && (*sumFGItr)[idx] > PMT_NoiseThreshold_)) {
735  samples[idx] += (*sumFGItr)[idx];
736  }
737  }
738  }
739 
740  IntegerCaloSamples output(samples.id(), tpSamples);
741  output.setPresamples(tpPresamples);
742 
743  for (int ibin = 0; ibin < tpSamples; ++ibin) {
744  int idx = ibin + shift;
745  output[ibin] = samples[idx] / (rctlsb == 0.25 ? 4 : 8);
746  if (output[ibin] > 0x3FF) output[ibin] = 0x3FF;
747  }
748  outcoder_->compress(output, finegrain, result);
749 }
750 
752  for (HcalTrigPrimDigiCollection::iterator tp = result.begin(); tp != result.end(); ++tp){
753  bool ZS = true;
754  for (int i=0; i<tp->size(); ++i) {
755  if (tp->sample(i).compressedEt() > ZS_threshold_I_) {
756  ZS=false;
757  break;
758  }
759  }
760  if (ZS) tp->setZSInfo(false,true);
761  else tp->setZSInfo(true,false);
762  }
763 }
764 
766  const HcalElectronicsMap *emap,
768  ){
769  std::set<uint32_t> FrontEndErrors;
770 
772  const FEDRawData& raw = rawraw->FEDData(i);
773  if (raw.size()<12) continue;
774  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
775  if(!dccHeader) continue;
776  HcalHTRData htr;
777  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
778  if (!dccHeader->getSpigotPresent(spigot)) continue;
779  dccHeader->getSpigotData(spigot,htr,raw.size());
780  int dccid = dccHeader->getSourceId();
781  int errWord = htr.getErrorsWord() & 0x1FFFF;
782  bool HTRError = (!htr.check() || htr.isHistogramEvent() || (errWord & 0x800)!=0);
783 
784  if(HTRError) {
785  bool valid =false;
786  for(int fchan=0; fchan<3 && !valid; fchan++) {
787  for(int fib=0; fib<9 && !valid; fib++) {
788  HcalElectronicsId eid(fchan,fib,spigot,dccid-FEDNumbering::MINHCALFEDID);
789  eid.setHTR(htr.readoutVMECrateId(),htr.htrSlot(),htr.htrTopBottom());
790  DetId detId = emap->lookup(eid);
791  if(detId.null()) continue;
792  HcalSubdetector subdet=(HcalSubdetector(detId.subdetId()));
793  if (detId.det()!=4||
794  (subdet!=HcalBarrel && subdet!=HcalEndcap &&
795  subdet!=HcalForward )) continue;
796  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(detId);
797  for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
798  FrontEndErrors.insert(triggerId->rawId());
799  }
800  //valid = true;
801  }
802  }
803  }
804  }
805  }
806 
807  // Loop over TP collection
808  // Set TP to zero if there is FE Format Error
809  HcalTriggerPrimitiveSample zeroSample(0);
810  for (HcalTrigPrimDigiCollection::iterator tp = result.begin(); tp != result.end(); ++tp){
811  if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
812  for (int i=0; i<tp->size(); ++i) tp->setSample(i, zeroSample);
813  }
814  }
815 }
816 
817 void HcalTriggerPrimitiveAlgo::addFG(const HcalTrigTowerDetId& id, std::vector<bool>& msb){
818  FGbitMap::iterator itr = fgMap_.find(id);
819  if (itr != fgMap_.end()){
820  std::vector<bool>& _msb = itr->second;
821  for (size_t i=0; i<msb.size(); ++i)
822  _msb[i] = _msb[i] || msb[i];
823  }
824  else fgMap_[id] = msb;
825 }
826 
828  if (algo <=0 && algo>2)
829  throw cms::Exception("ERROR: Only algo 1 & 2 are supported.") << std::endl;
831 }
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual RecHits
int i
Definition: DBlmapReader.cc:9
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
int presamples() const
access presample information
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:62
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
const double w
Definition: UKUtility.cc:23
int converttoGCTetaFromTPG(int &etaTPG)
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
Definition: HcalHTRData.cc:342
void analyzeHF(int ieta, int iphi, int(&FGBit)[18][22], IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, float rctlsb)
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
assert(m_qm.get())
std::vector< HBHEDataFrame >::const_iterator const_iterator
void push_back(T const &t)
const HcalTPGCompressor * outcoder_
void setPresamples(int pre)
set presample information
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb)
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
int ieta() const
get the tower ieta
uint32_t maskDepth() const
get the tower depth
Definition: HcalDetId.h:57
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, uint32_t FG_threshold1, uint32_t FG_threshold2, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, int numberOfSamplesHF, int numberOfPresamplesHF, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
int converttoTPGeta(int &GCTeta)
int converttoGCTphiFromTPG(int &phiTPG)
std::vector< IntegerCaloSamples > SumFGContainer
int size() const
get the size
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
Definition: HcalHTRData.cc:338
int depth() const
get the tower depth
Definition: HcalDetId.h:55
const HcalTrigTowerGeometry * theTrigTowerGeometry
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int converttoGCTphi(int &phi)
tuple result
Definition: query.py:137
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
HcalSubdetector
Definition: HcalAssistant.h:31
int j
Definition: DBlmapReader.cc:9
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
std::vector< double > weights_
int converttoTPGphi(int &GCTphi)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HBHEDataFrame.h:28
void runZS(HcalTrigPrimDigiCollection &tp)
std::vector< HcalTriggerPrimitiveDigi >::iterator iterator
const_iterator end() const
int getSourceId() const
Definition: HcalDCCHeader.h:32
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
Definition: DetId.h:18
void setHTR(int crate, int slot, int tb)
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
unsigned int getErrorsWord() const
Get the errors word.
Definition: HcalHTRData.h:157
bool null() const
is this a null id ?
Definition: DetId.h:45
Geom::Phi< T > phi() const
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
Definition: HcalHTRData.cc:346
const HcaluLUTTPGCoder * incoder_
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
int converttoGCTeta(int &eta)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
static unsigned int const shift
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HFDataFrame.h:28
const HcalDetId & id() const
Definition: HFDataFrame.h:22
DetId id() const
get the (generic) id
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
Readout chain identification for Hcal.
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:385
const_iterator begin() const
const_reference back() const