CMS 3D CMS Logo

EcalSelectiveReadoutSuppressor.cc
Go to the documentation of this file.
6 
8 
9 // Geometry
15 
17 
18 //exceptions:
20 
21 #include <cmath>
22 #include <iostream>
23 #include <limits>
24 #include <memory>
25 
26 using namespace boost;
27 using namespace std;
28 
30 
32  const EcalSRSettings* settings)
33  : ttThresOnCompressedEt_(false), ievt_(0) {
34  firstFIRSample = settings->ecalDccZs1stSample_[0];
35  weights = settings->dccNormalizedWeights_[0];
36  symetricZS = settings->symetricZS_[0];
37  actions_ = settings->actions_;
38 
39  int defTtf = params.getParameter<int>("defaultTtf");
40  if (defTtf < 0 || defTtf > 7) {
41  throw cms::Exception("InvalidParameter") << "Value of EcalSelectiveReadoutProducer module parameter defaultTtf, "
42  << defaultTtf_ << ", is out of the valid range 0..7\n";
43  } else {
45  }
46 
47  //online configuration has only 4 actions flags, the 4 'forced' flags being the same with the force
48  //bit set to 1. Extends the actions vector for case of online-type configuration:
49  if (actions_.size() == 4) {
50  for (int i = 0; i < 4; ++i) {
51  actions_.push_back(actions_[i] | 0x4);
52  }
53  }
54 
55  bool actionValid = actions_.size() == 8;
56  for (size_t i = 0; i < actions_.size(); ++i) {
57  if (actions_[i] < 0 || actions_[i] > 7)
58  actionValid = false;
59  }
60 
61  if (!actionValid) {
62  throw cms::Exception("InvalidParameter")
63  << "EcalSelectiveReadoutProducer module parameter 'actions' is "
64  "not valid. It must be a vector of 8 integer values comprised between 0 and 7\n";
65  }
66 
67  double adcToGeV = settings->ebDccAdcToGeV_;
68  thrUnit[BARREL] = adcToGeV / 4.; //unit=1/4th ADC count
69 
70  adcToGeV = settings->eeDccAdcToGeV_;
71  thrUnit[ENDCAP] = adcToGeV / 4.; //unit=1/4th ADC count
72  ecalSelectiveReadout = std::make_unique<EcalSelectiveReadout>(settings->deltaEta_[0], settings->deltaPhi_[0]);
73  const int eb = 0;
74  const int ee = 1;
76  settings->srpLowInterestChannelZS_[ee],
77  settings->srpHighInterestChannelZS_[eb],
78  settings->srpHighInterestChannelZS_[ee]);
79  trigPrimBypass_ = params.getParameter<bool>("trigPrimBypass");
80  trigPrimBypassMode_ = params.getParameter<int>("trigPrimBypassMode");
81  trigPrimBypassWithPeakFinder_ = params.getParameter<bool>("trigPrimBypassWithPeakFinder");
82  trigPrimBypassLTH_ = params.getParameter<double>("trigPrimBypassLTH");
83  trigPrimBypassHTH_ = params.getParameter<double>("trigPrimBypassHTH");
84  if (trigPrimBypass_) {
85  edm::LogWarning("Digitization") << "Beware a simplified trigger primitive "
86  "computation is used for the ECAL selective readout";
87  if (trigPrimBypassMode_ != 0 && trigPrimBypassMode_ != 1) {
88  throw cms::Exception("InvalidParameter")
89  << "Invalid value for EcalSelectiveReadoutProducer parameter 'trigPrimBypassMode_'."
90  " Valid values are 0 and 1.\n";
91  }
93  }
94 }
95 
98  ecalSelectiveReadout->setTriggerMap(map);
99 }
100 
102  ecalSelectiveReadout->setElecMap(map);
103 }
104 
106 #ifndef ECALSELECTIVEREADOUT_NOGEOM
107  ecalSelectiveReadout->setGeometry(caloGeometry);
108 #endif
109 }
110 
112  double endcapLowInterest,
113  double barrelHighInterest,
114  double endcapHighInterest) {
115  //center, neighbour and single RUs are grouped into a single
116  //'high interest' group
117  int lowInterestThr[2]; //index for BARREL/ENDCAP
118  // int lowInterestSrFlag[2];
119  int highInterestThr[2];
120  // int highInterestSrFlag[2];
121 
122  lowInterestThr[BARREL] = internalThreshold(barrelLowInterest, BARREL);
123  // lowInterestSrFlag[BARREL] = thr2Srf(lowInterestThr[BARREL],
124  // EcalSrFlag::SRF_ZS1);
125 
126  highInterestThr[BARREL] = internalThreshold(barrelHighInterest, BARREL);
127  // highInterestSrFlag[BARREL] = thr2Srf(highInterestThr[BARREL],
128  // EcalSrFlag::SRF_ZS2);
129 
130  lowInterestThr[ENDCAP] = internalThreshold(endcapLowInterest, ENDCAP);
131  //lowInterestSrFlag[ENDCAP] = thr2Srf(lowInterestThr[ENDCAP],
132  // EcalSrFlag::SRF_ZS1);
133 
134  highInterestThr[ENDCAP] = internalThreshold(endcapHighInterest, ENDCAP);
135  // highInterestSrFlag[ENDCAP] = thr2Srf(highInterestThr[ENDCAP],
136  // EcalSrFlag::SRF_ZS2);
137 
138  const int FORCED_MASK = EcalSelectiveReadout::FORCED_MASK;
139 
140  for (int iSubDet = 0; iSubDet < 2; ++iSubDet) {
141  //low interest
142  //zsThreshold[iSubDet][0] = lowInterestThr[iSubDet];
143  //srFlags[iSubDet][0] = lowInterestSrFlag[iSubDet];
144  //srFlags[iSubDet][0 + FORCED_MASK] = FORCED_MASK | lowInterestSrFlag[iSubDet];
145 
146  //single->high interest
147  //zsThreshold[iSubDet][1] = highInterestThr[iSubDet];
148  //srFlags[iSubDet][1] = highInterestSrFlag[iSubDet];
149  //srFlags[iSubDet][1 + FORCED_MASK] = FORCED_MASK | highInterestSrFlag[iSubDet];
150 
151  //neighbour->high interest
152  //zsThreshold[iSubDet][2] = highInterestThr[iSubDet];
153  //srFlags[iSubDet][2] = highInterestSrFlag[iSubDet];
154  //srFlags[iSubDet][2 + FORCED_MASK] = FORCED_MASK | highInterestSrFlag[iSubDet];
155 
156  //center->high interest
157  //zsThreshold[iSubDet][3] = highInterestThr[iSubDet];
158  //srFlags[iSubDet][3] = highInterestSrFlag[iSubDet];
159  //srFlags[iSubDet][3 + FORCED_MASK] = FORCED_MASK | highInterestSrFlag[iSubDet];
160  for (size_t i = 0; i < 8; ++i) {
161  srFlags[iSubDet][i] = actions_[i];
162  if ((actions_[i] & ~FORCED_MASK) == 0)
163  zsThreshold[iSubDet][i] = numeric_limits<int>::max();
164  else if ((actions_[i] & ~FORCED_MASK) == 1)
165  zsThreshold[iSubDet][i] = lowInterestThr[iSubDet];
166  else if ((actions_[i] & ~FORCED_MASK) == 2)
167  zsThreshold[iSubDet][i] = highInterestThr[iSubDet];
168  else
169  zsThreshold[iSubDet][i] = numeric_limits<int>::min();
170  }
171 
172  // for(size_t i = 0; i < 8; ++i){
173  // cout << "zsThreshold[" << iSubDet << "][" << i << "] = " << zsThreshold[iSubDet][i] << endl;
174  // }
175  }
176 }
177 
178 // int EcalSelectiveReadoutSuppressor::thr2Srf(int thr, int zsFlag) const{
179 // if(thr==numeric_limits<int>::max()){
180 // return EcalSrFlag::SRF_SUPPRESS;
181 // }
182 // if(thr==numeric_limits<int>::min()){
183 // return EcalSrFlag::SRF_FULL;
184 // }
185 // return zsFlag;
186 // }
187 
188 int EcalSelectiveReadoutSuppressor::internalThreshold(double thresholdInGeV, int iSubDet) const {
189  double thr_ = thresholdInGeV / thrUnit[iSubDet];
190  //treating over- and underflows, threshold is coded on 11+1 signed bits
191  //an underflow threshold is considered here as if NoRO DCC switch is on
192  //an overflow threshold is considered here as if ForcedRO DCC switch in on
193  //Beware that conparison must be done on a double type, because conversion
194  //cast to an int of a double higher than MAX_INT is undefined.
195  int thr;
196  if (thr_ >= 0x7FF + .5) {
197  thr = numeric_limits<int>::max();
198  } else if (thr_ <= -0x7FF - .5) {
199  thr = numeric_limits<int>::min();
200  } else {
201  thr = lround(thr_);
202  }
203  return thr;
204 }
205 
206 //This implementation assumes that int is coded on at least 28-bits,
207 //which in pratice should be always true.
209  //FIR filter weights:
210  const vector<int>& w = getFIRWeigths();
211 
212  //accumulator used to compute weighted sum of samples
213  int acc = 0;
214  bool gain12saturated = false;
215  const int gain12 = 0x01;
216  const int lastFIRSample = firstFIRSample + nFIRTaps - 1;
217  //LogDebug("DccFir") << "DCC FIR operation: ";
218  int iWeight = 0;
219  for (int iSample = firstFIRSample - 1; iSample < lastFIRSample; ++iSample, ++iWeight) {
220  if (iSample >= 0 && iSample < (int)frame.size()) {
221  EcalMGPASample sample(frame[iSample]);
222  if (sample.gainId() != gain12)
223  gain12saturated = true;
224  //LogTrace("DccFir") << (iSample>=firstFIRSample?"+":"") << sample.adc()
225  // << "*(" << w[iWeight] << ")";
226  acc += sample.adc() * w[iWeight];
227  } else {
228  edm::LogWarning("DccFir") << __FILE__ << ":" << __LINE__
229  << ": Not enough samples in data frame or 'ecalDccZs1stSample' module "
230  "parameter is not valid...";
231  }
232  }
233 
234  if (symetricZS) { //cut on absolute value
235  if (acc < 0)
236  acc = -acc;
237  }
238 
239  //LogTrace("DccFir") << "\n";
240  //discards the 8 LSBs
241  //(result of shift operator on negative numbers depends on compiler
242  //implementation, therefore the value is offset to make sure it is positive
243  //before performing the bit shift).
244  acc = ((acc + (1 << 30)) >> 8) - (1 << (30 - 8));
245 
246  //ZS passed if weigthed sum acc above ZS threshold or if
247  //one sample has a lower gain than gain 12 (that is gain 12 output
248  //is saturated)
249 
250  const bool result = (acc >= thr) || gain12saturated;
251 
252  //LogTrace("DccFir") << "acc: " << acc << "\n"
253  // << "threshold: " << thr << " ("
254  // << thr*thrUnit[((EcalDataFrame&)frame).id().subdetId()==EcalBarrel?0:1]
255  // << "GeV)\n"
256  // << "saturated: " << (gain12saturated?"yes":"no") << "\n"
257  // << "ZS passed: " << (result?"yes":"no")
258  // << (symetricZS?" (symetric cut)":"") << "\n";
259 
260  return result;
261 }
262 
264  const EcalTrigPrimDigiCollection& trigPrims,
267  EBDigiCollection selectedBarrelDigis;
268  EEDigiCollection selectedEndcapDigis;
269 
270  run(eventSetup, trigPrims, barrelDigis, endcapDigis, &selectedBarrelDigis, &selectedEndcapDigis, nullptr, nullptr);
271 
272  //replaces the input with the suppressed version
273  barrelDigis.swap(selectedBarrelDigis);
274  endcapDigis.swap(selectedEndcapDigis);
275 }
276 
278  const EcalTrigPrimDigiCollection& trigPrims,
281  EBDigiCollection* selectedBarrelDigis,
282  EEDigiCollection* selectedEndcapDigis,
283  EBSrFlagCollection* ebSrFlags,
284  EESrFlagCollection* eeSrFlags) {
285  ++ievt_;
286  if (!trigPrimBypass_ || ttThresOnCompressedEt_) { //uses output of TPG emulator
287  setTtFlags(trigPrims);
288  } else { //debug mode, run w/o TP digis
289  setTtFlags(eventSetup, barrelDigis, endcapDigis);
290  }
291 
292  ecalSelectiveReadout->runSelectiveReadout0(ttFlags);
293 
294  if (selectedBarrelDigis) {
295  selectedBarrelDigis->reserve(barrelDigis.size() / 20);
296 
297  // do barrel first
298  for (EBDigiCollection::const_iterator digiItr = barrelDigis.begin(); digiItr != barrelDigis.end(); ++digiItr) {
299  int interestLevel = ecalSelectiveReadout->getCrystalInterest(EBDigiCollection::DetId(digiItr->id())) &
300  ~EcalSelectiveReadout::FORCED_MASK;
301  if (accept(*digiItr, zsThreshold[BARREL][interestLevel])) {
302  selectedBarrelDigis->push_back(digiItr->id(), digiItr->begin());
303  }
304  }
305  }
306 
307  // and endcaps
308  if (selectedEndcapDigis) {
309  selectedEndcapDigis->reserve(endcapDigis.size() / 20);
310  for (EEDigiCollection::const_iterator digiItr = endcapDigis.begin(); digiItr != endcapDigis.end(); ++digiItr) {
311  int interestLevel = ecalSelectiveReadout->getCrystalInterest(EEDigiCollection::DetId(digiItr->id())) &
312  ~EcalSelectiveReadout::FORCED_MASK;
313  if (accept(*digiItr, zsThreshold[ENDCAP][interestLevel])) {
314  selectedEndcapDigis->push_back(digiItr->id(), digiItr->begin());
315  }
316  }
317  }
318 
319  if (ievt_ <= 10) {
320  int neb = (selectedBarrelDigis ? selectedBarrelDigis->size() : 0);
321  if (selectedEndcapDigis)
322  LogDebug("EcalSelectiveReadout")
323  // << __FILE__ << ":" << __LINE__ << ": "
324  << "Number of EB digis passing the SR: " << neb << " / " << barrelDigis.size() << "\n";
325  if (selectedEndcapDigis)
326  LogDebug("EcalSelectiveReadout")
327  // << __FILE__ << ":" << __LINE__ << ": "
328  << "\nNumber of EE digis passing the SR: " << selectedEndcapDigis->size() << " / " << endcapDigis.size()
329  << "\n";
330  }
331 
332  if (ebSrFlags)
333  ebSrFlags->reserve(34 * 72);
334  if (eeSrFlags)
335  eeSrFlags->reserve(624);
336  //SR flags:
337  for (int iZ = -1; iZ <= 1; iZ += 2) { //-1=>EE-, EB-, +1=>EE+, EB+
338  //barrel:
339  for (unsigned iEta = 1; iEta <= nBarrelTriggerTowersInEta / 2; ++iEta) {
340  for (unsigned iPhi = 1; iPhi <= nTriggerTowersInPhi; ++iPhi) {
341  const EcalTrigTowerDetId id(iZ, EcalBarrel, iEta, iPhi);
342  EcalSelectiveReadout::towerInterest_t interest = ecalSelectiveReadout->getTowerInterest(id);
343  if (interest < 0) {
344  throw cms::Exception("EcalSelectiveReadout") << __FILE__ << ":" << __LINE__ << ": "
345  << "unknown SR flag. for "
346  << " TT " << id << ". Most probably a bug.";
347  }
348  int flag;
349  // if(interest==EcalSelectiveReadout::FORCED_RO){
350  // flag = EcalSrFlag::SRF_FORCED_MASK | EcalSrFlag::SRF_FULL;
351  //} else{
352  flag = srFlags[BARREL][interest];
353  //}
354  if (ebSrFlags)
355  ebSrFlags->push_back(EBSrFlag(id, flag));
356  } //next iPhi
357  } //next barrel iEta
358 
359  //endcap:
360  EcalScDetId id;
361  for (int iX = 1; iX <= 20; ++iX) {
362  for (int iY = 1; iY <= 20; ++iY) {
363  if (EcalScDetId::validDetId(iX, iY, iZ))
364  id = EcalScDetId(iX, iY, iZ);
365  else
366  continue;
367 
368  EcalSelectiveReadout::towerInterest_t interest = ecalSelectiveReadout->getSuperCrystalInterest(id);
369 
370  if (interest >= 0) { //negative no SC at (iX,iY) coordinates
371  int flag;
372  // if(interest==EcalSelectiveReadout::FORCED_RO){
373  // flag = EcalSrFlag::SRF_FORCED_MASK | EcalSrFlag::SRF_FULL;
374  //} else{
375  flag = srFlags[ENDCAP][interest];
376  //}
377  if (eeSrFlags)
378  eeSrFlags->push_back(EESrFlag(id, flag));
379  } else if (iX < 9 || iX > 12 || iY < 9 || iY > 12) { //not an inner partial SC
380  edm::LogError("EcalSelectiveReadout") << __FILE__ << ":" << __LINE__ << ": "
381  << "negative interest in EE for SC " << id << "\n";
382  }
383  } //next iY
384  } //next iX
385  }
386 }
387 
389  for (size_t iEta0 = 0; iEta0 < nTriggerTowersInEta; ++iEta0) {
390  for (size_t iPhi0 = 0; iPhi0 < nTriggerTowersInPhi; ++iPhi0) {
391  ttFlags[iEta0][iPhi0] = defaultTtf_;
392  }
393  }
394  for (EcalTrigPrimDigiCollection::const_iterator trigPrim = trigPrims.begin(); trigPrim != trigPrims.end();
395  ++trigPrim) {
396  int iEta = trigPrim->id().ieta();
397  unsigned int iEta0;
398  if (iEta < 0) { //z- half ECAL: transforming ranges -28;-1 => 0;27
399  iEta0 = iEta + nTriggerTowersInEta / 2;
400  } else { //z+ halfECAL: transforming ranges 1;28 => 28;55
401  iEta0 = iEta + nTriggerTowersInEta / 2 - 1;
402  }
403 
404  unsigned int iPhi0 = trigPrim->id().iphi() - 1;
405 
406  if (!ttThresOnCompressedEt_) {
407  ttFlags[iEta0][iPhi0] = (EcalSelectiveReadout::ttFlag_t)trigPrim->ttFlag();
408  } else {
409  int compressedEt = trigPrim->compressedEt();
410  if (compressedEt < trigPrimBypassLTH_) {
412  } else if (compressedEt < trigPrimBypassHTH_) {
414  } else {
416  }
417  }
418  }
419 }
420 
422  if (firWeights.empty()) {
423  firWeights = vector<int>(nFIRTaps, 0); //default weight: 0;
424  const static int maxWeight = 0xEFF; //weights coded on 11+1 signed bits
425  for (unsigned i = 0; i < min((size_t)nFIRTaps, weights.size()); ++i) {
426  firWeights[i] = lround(weights[i] * (1 << 10));
427  if (abs(firWeights[i]) > maxWeight) { //overflow
428  firWeights[i] = firWeights[i] < 0 ? -maxWeight : maxWeight;
429  }
430  }
431  }
432  return firWeights;
433 }
434 
436  const EBDigiCollection& ebDigis,
437  const EEDigiCollection& eeDigis) {
438  double trigPrim[nTriggerTowersInEta][nTriggerTowersInPhi];
439 
440  //ecal geometry:
441  // static const CaloSubdetectorGeometry* eeGeometry = 0;
442  // static const CaloSubdetectorGeometry* ebGeometry = 0;
443  const CaloSubdetectorGeometry* eeGeometry = nullptr;
444  const CaloSubdetectorGeometry* ebGeometry = nullptr;
445  // if(eeGeometry==0 || ebGeometry==0){
446  edm::ESHandle<CaloGeometry> geoHandle;
447  es.get<CaloGeometryRecord>().get(geoHandle);
448  eeGeometry = (*geoHandle).getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
449  ebGeometry = (*geoHandle).getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
450  // }
451 
452  //init trigPrim array:
453  bzero(trigPrim, sizeof(trigPrim));
454 
455  for (EBDigiCollection::const_iterator it = ebDigis.begin(); it != ebDigis.end(); ++it) {
456  EBDataFrame frame(*it);
458  // edm:::LogDebug("TT") << __FILE__ << ":" << __LINE__ << ": "
459  // << ((EBDetId&)frame.id()).ieta()
460  // << "," << ((EBDetId&)frame.id()).iphi()
461  // << " -> " << ttId.ieta() << "," << ttId.iphi() << "\n";
462  const int iTTEta0 = iTTEta2cIndex(ttId.ieta());
463  const int iTTPhi0 = iTTPhi2cIndex(ttId.iphi());
464  double theta = ebGeometry->getGeometry(frame.id())->getPosition().theta();
465  double e = frame2Energy(frame);
466  if (!trigPrimBypassWithPeakFinder_ || ((frame2Energy(frame, -1) < e) && (frame2Energy(frame, 1) < e))) {
467  trigPrim[iTTEta0][iTTPhi0] += e * sin(theta);
468  }
469  }
470 
471  for (EEDigiCollection::const_iterator it = eeDigis.begin(); it != eeDigis.end(); ++it) {
472  EEDataFrame frame(*it);
474  const int iTTEta0 = iTTEta2cIndex(ttId.ieta());
475  const int iTTPhi0 = iTTPhi2cIndex(ttId.iphi());
476  // cout << __FILE__ << ":" << __LINE__ << ": EE xtal->TT "
477  // << ((EEDetId&)frame.id()).ix()
478  // << "," << ((EEDetId&)frame.id()).iy()
479  // << " -> " << ttId.ieta() << "," << ttId.iphi() << "\n";
480  double theta = eeGeometry->getGeometry(frame.id())->getPosition().theta();
481  double e = frame2Energy(frame);
482  if (!trigPrimBypassWithPeakFinder_ || ((frame2Energy(frame, -1) < e) && (frame2Energy(frame, 1) < e))) {
483  trigPrim[iTTEta0][iTTPhi0] += e * sin(theta);
484  }
485  }
486 
487  //dealing with pseudo-TT in two inner EE eta-ring:
488  int innerTTEtas[] = {0, 1, 54, 55};
489  for (unsigned iRing = 0; iRing < sizeof(innerTTEtas) / sizeof(innerTTEtas[0]); ++iRing) {
490  int iTTEta0 = innerTTEtas[iRing];
491  //this detector eta-section is divided in only 36 phi bins
492  //For this eta regions,
493  //current tower eta numbering scheme is inconsistent. For geometry
494  //version 133:
495  //- TT are numbered from 0 to 72 for 36 bins
496  //- some TT have an even index, some an odd index
497  //For geometry version 125, there are 72 phi bins.
498  //The code below should handle both geometry definition.
499  //If there are 72 input trigger primitives for each inner eta-ring,
500  //then the average of the trigger primitive of the two pseudo-TT of
501  //a pair (nEta, nEta+1) is taken as Et of both pseudo TTs.
502  //If there are only 36 input TTs for each inner eta ring, then half
503  //of the present primitive of a pseudo TT pair is used as Et of both
504  //pseudo TTs.
505 
506  for (unsigned iTTPhi0 = 0; iTTPhi0 < nTriggerTowersInPhi - 1; iTTPhi0 += 2) {
507  double et = .5 * (trigPrim[iTTEta0][iTTPhi0] + trigPrim[iTTEta0][iTTPhi0 + 1]);
508  //divides the TT into 2 phi bins in order to match with 72 phi-bins SRP
509  //scheme or average the Et on the two pseudo TTs if the TT is already
510  //divided into two trigger primitives.
511  trigPrim[iTTEta0][iTTPhi0] = et;
512  trigPrim[iTTEta0][iTTPhi0 + 1] = et;
513  }
514  }
515 
516  for (unsigned iTTEta0 = 0; iTTEta0 < nTriggerTowersInEta; ++iTTEta0) {
517  for (unsigned iTTPhi0 = 0; iTTPhi0 < nTriggerTowersInPhi; ++iTTPhi0) {
518  if (trigPrim[iTTEta0][iTTPhi0] > trigPrimBypassHTH_) {
520  } else if (trigPrim[iTTEta0][iTTPhi0] > trigPrimBypassLTH_) {
522  } else {
524  }
525 
526  // cout /*LogDebug("TT")*/
527  // << "ttFlags[" << iTTEta0 << "][" << iTTPhi0 << "] = "
528  // << ttFlags[iTTEta0][iTTPhi0] << "\n";
529  }
530  }
531 }
532 
533 template <class T>
535  //we have to start by 0 in order to handle offset=-1
536  //(however Fenix FIR has AFAK only 5 taps)
537  double weights[] = {0., -1 / 3., -1 / 3., -1 / 3., 0., 1.};
538 
539  double adc2GeV = 0.;
540  if (typeid(frame) == typeid(EBDataFrame)) {
541  adc2GeV = 0.035;
542  } else if (typeid(frame) == typeid(EEDataFrame)) {
543  adc2GeV = 0.060;
544  } else { //T is an invalid type!
545  //TODO: replace message by a cms exception
546  cerr << "Severe error. " << __FILE__ << ":" << __LINE__ << ": "
547  << "this is a bug. Please report it.\n";
548  }
549 
550  double acc = 0;
551 
552  const int n = min<int>(frame.size(), sizeof(weights) / sizeof(weights[0]));
553 
554  double gainInv[] = {12., 1., 6., 12.};
555 
556  //cout << __PRETTY_FUNCTION__ << ": ";
557  for (int i = offset; i < n; ++i) {
558  int iframe = i + offset;
559  if (iframe >= 0 && iframe < frame.size()) {
560  acc += weights[i] * frame[iframe].adc() * gainInv[frame[iframe].gainId()] * adc2GeV;
561  //cout << (iframe>offset?"+":"")
562  // << frame[iframe].adc() << "*" << gainInv[frame[iframe].gainId()]
563  // << "*" << adc2GeV << "*(" << weights[i] << ")";
564  }
565  }
566  //cout << "\n";
567  return acc;
568 }
569 
570 void EcalSelectiveReadoutSuppressor::printTTFlags(ostream& os, int iEvent, bool withHeader) const {
571  const char tccFlagMarker[] = {'?', '.', 'S', '?', 'C', 'E', 'E', 'E', 'E'};
574 
575  if (withHeader) {
576  os << "# TCC flag map\n#\n"
577  "# +-->Phi "
578  << tccFlagMarker[1 + 0]
579  << ": 000 (low interest)\n"
580  "# | "
581  << tccFlagMarker[1 + 1]
582  << ": 001 (mid interest)\n"
583  "# | "
584  << tccFlagMarker[1 + 2]
585  << ": 010 (not valid)\n"
586  "# V Eta "
587  << tccFlagMarker[1 + 3]
588  << ": 011 (high interest)\n"
589  "# "
590  << tccFlagMarker[1 + 4] << ": 1xx forced readout (Hw error)\n";
591  }
592 
593  if (iEvent >= 0) {
594  os << "#\n#Event " << iEvent << "\n";
595  }
596 
597  for (int iEta = 0; iEta < nEta; ++iEta) {
598  for (int iPhi = 0; iPhi < nPhi; ++iPhi) {
599  os << tccFlagMarker[ttFlags[iEta][iPhi] + 1];
600  }
601  os << "\n";
602  }
603 }
EcalSelectiveReadoutSuppressor::nTriggerTowersInPhi
const static size_t nTriggerTowersInPhi
Definition: EcalSelectiveReadoutSuppressor.h:207
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
EcalSRSettings::srpLowInterestChannelZS_
std::vector< float > srpLowInterestChannelZS_
Definition: EcalSRSettings.h:119
mps_fire.i
i
Definition: mps_fire.py:428
EcalSelectiveReadoutSuppressor::initCellThresholds
void initCellThresholds(double barrelLowInterest, double endcapLowInterest, double barrelHighInterest, double endcapHighInterest)
helpers for constructors
Definition: EcalSelectiveReadoutSuppressor.cc:111
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
EcalSelectiveReadoutSuppressor::setGeometry
void setGeometry(const CaloGeometry *caloGeometry)
Definition: EcalSelectiveReadoutSuppressor.cc:105
EcalSelectiveReadoutSuppressor::trigPrimBypassHTH_
double trigPrimBypassHTH_
Definition: EcalSelectiveReadoutSuppressor.h:290
ESHandle.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
EcalSelectiveReadoutSuppressor::defaultTtf_
EcalSelectiveReadout::ttFlag_t defaultTtf_
Definition: EcalSelectiveReadoutSuppressor.h:302
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
HLT_FULL_cff.nEta
nEta
Definition: HLT_FULL_cff.py:6585
mtdUncalibratedRecHits_cfi.barrelDigis
barrelDigis
Definition: mtdUncalibratedRecHits_cfi.py:33
EcalSelectiveReadout::TTF_LOW_INTEREST
Definition: EcalSelectiveReadout.h:83
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
min
T min(T a, T b)
Definition: MathUtil.h:58
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EBDetId
Definition: EBDetId.h:17
ecaldqm::ttId
unsigned ttId(DetId const &, EcalElectronicsMapping const *)
Definition: EcalDQMCommonUtils.cc:99
EBDataFrame
Definition: EBDataFrame.h:11
EcalSelectiveReadout::TTF_MID_INTEREST
Definition: EcalSelectiveReadout.h:84
EcalScDetId::validDetId
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
EcalSelectiveReadoutSuppressor::frame2Energy
double frame2Energy(const T &frame, int timeOffset=0) const
Definition: EcalSelectiveReadoutSuppressor.cc:534
edm::SortedCollection
Definition: SortedCollection.h:49
EcalSelectiveReadoutSuppressor::BARREL
Definition: EcalSelectiveReadoutSuppressor.h:25
EcalSelectiveReadoutSuppressor::ievt_
int ievt_
Definition: EcalSelectiveReadoutSuppressor.h:306
EcalSelectiveReadout::towerInterest_t
towerInterest_t
Definition: EcalSelectiveReadout.h:69
EcalSRSettings::actions_
std::vector< int > actions_
Definition: EcalSRSettings.h:166
EcalSelectiveReadoutSuppressor::getFIRWeigths
std::vector< int > getFIRWeigths()
Definition: EcalSelectiveReadoutSuppressor.cc:421
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalSelectiveReadoutSuppressor::trigPrimBypassWithPeakFinder_
bool trigPrimBypassWithPeakFinder_
Definition: EcalSelectiveReadoutSuppressor.h:280
boost
Definition: CLHEP.h:16
EcalSelectiveReadoutSuppressor::setTtFlags
void setTtFlags(const edm::EventSetup &eventSetup, const EBDigiCollection &ebDigis, const EEDigiCollection &eeDigis)
Definition: EcalSelectiveReadoutSuppressor.cc:435
EcalSelectiveReadout
Definition: EcalSelectiveReadout.h:62
edm::SortedCollection::push_back
void push_back(T const &t)
Definition: SortedCollection.h:188
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CollectionTags_cfi.EESrFlag
EESrFlag
Definition: CollectionTags_cfi.py:26
EcalSelectiveReadoutSuppressor::ecalSelectiveReadout
std::unique_ptr< EcalSelectiveReadout > ecalSelectiveReadout
Definition: EcalSelectiveReadoutSuppressor.h:211
EcalSelectiveReadoutSuppressor::trigPrimBypass_
bool trigPrimBypass_
Definition: EcalSelectiveReadoutSuppressor.h:257
EcalSelectiveReadoutSuppressor::ENDCAP
Definition: EcalSelectiveReadoutSuppressor.h:25
EcalBarrel
Definition: EcalSubdetector.h:10
EcalSelectiveReadoutSuppressor::trigPrimBypassMode_
int trigPrimBypassMode_
Definition: EcalSelectiveReadoutSuppressor.h:264
EcalSelectiveReadoutSuppressor::accept
bool accept(const edm::DataFrame &frame, int thr)
Definition: EcalSelectiveReadoutSuppressor.cc:208
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
EcalSelectiveReadoutSuppressor::nTriggerTowersInEta
const static size_t nTriggerTowersInEta
Definition: EcalSelectiveReadoutSuppressor.h:203
EcalSRSettings::deltaEta_
std::vector< int > deltaEta_
Definition: EcalSRSettings.h:56
CaloGeometry
Definition: CaloGeometry.h:21
EEDigiCollection::push_back
void push_back(const Digi &digi)
Definition: EcalDigiCollections.h:77
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
EcalSelectiveReadoutSuppressor::theTriggerMap
const EcalTrigTowerConstituentsMap * theTriggerMap
Definition: EcalSelectiveReadoutSuppressor.h:213
w
const double w
Definition: UKUtility.cc:23
EcalSelectiveReadoutSuppressor::setTriggerMap
void setTriggerMap(const EcalTrigTowerConstituentsMap *map)
Definition: EcalSelectiveReadoutSuppressor.cc:96
EcalScDetId
Definition: EcalScDetId.h:24
EcalSelectiveReadoutSuppressor::ttFlags
EcalSelectiveReadout::ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]
Definition: EcalSelectiveReadoutSuppressor.h:217
EcalSelectiveReadoutSuppressor::printTTFlags
void printTTFlags(std::ostream &os, int iEvent=-1, bool withHeader=true) const
Definition: EcalSelectiveReadoutSuppressor.cc:570
edm::ESHandle< CaloGeometry >
EcalSelectiveReadout::FORCED_MASK
static const int FORCED_MASK
Definition: EcalSelectiveReadout.h:64
EcalSelectiveReadoutSuppressor::zsThreshold
int zsThreshold[2][8]
Definition: EcalSelectiveReadoutSuppressor.h:247
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
EBDigiCollection::push_back
void push_back(const Digi &digi)
Definition: EcalDigiCollections.h:64
CollectionTags_cfi.EBSrFlag
EBSrFlag
Definition: CollectionTags_cfi.py:25
edm::DataFrameContainer::reserve
void reserve(size_t isize)
Definition: DataFrameContainer.h:86
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
EcalSRSettings::symetricZS_
std::vector< int > symetricZS_
Definition: EcalSRSettings.h:109
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
EcalTrigTowerConstituentsMap
Definition: EcalTrigTowerConstituentsMap.h:19
EcalSelectiveReadout::TTF_HIGH_INTEREST
Definition: EcalSelectiveReadout.h:86
CaloSubdetectorGeometry.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
EcalSelectiveReadout.h
EcalSelectiveReadout::nTriggerTowersInEta
const static size_t nTriggerTowersInEta
Definition: EcalSelectiveReadout.h:140
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
EcalSelectiveReadoutSuppressor::trigPrimBypassLTH_
double trigPrimBypassLTH_
Definition: EcalSelectiveReadoutSuppressor.h:285
EcalSelectiveReadoutSuppressor::firstFIRSample
int firstFIRSample
Definition: EcalSelectiveReadoutSuppressor.h:222
EBDigiCollection
Definition: EcalDigiCollections.h:56
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalSelectiveReadoutSuppressor.h
EEDigiCollection
Definition: EcalDigiCollections.h:69
HLT_FULL_cff.nPhi
nPhi
Definition: HLT_FULL_cff.py:6586
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
EcalSelectiveReadoutSuppressor::firWeights
std::vector< int > firWeights
Definition: EcalSelectiveReadoutSuppressor.h:226
EcalSelectiveReadoutSuppressor::iTTEta2cIndex
int iTTEta2cIndex(int iEta) const
Definition: EcalSelectiveReadoutSuppressor.h:156
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
EBDataFrame.h
edm::EventSetup
Definition: EventSetup.h:58
EcalSRSettings::deltaPhi_
std::vector< int > deltaPhi_
Definition: EcalSRSettings.h:69
EcalSelectiveReadoutSuppressor::nBarrelTriggerTowersInEta
const static size_t nBarrelTriggerTowersInEta
Definition: EcalSelectiveReadoutSuppressor.h:199
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
DetId::Ecal
Definition: DetId.h:27
EcalSelectiveReadoutSuppressor::iTTPhi2cIndex
int iTTPhi2cIndex(int iPhi) const
Definition: EcalSelectiveReadoutSuppressor.h:163
get
#define get
EcalSRSettings::ebDccAdcToGeV_
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
Definition: EcalSRSettings.h:81
EcalSelectiveReadoutSuppressor::EcalSelectiveReadoutSuppressor
EcalSelectiveReadoutSuppressor(const edm::ParameterSet &params, const EcalSRSettings *settings)
Definition: EcalSelectiveReadoutSuppressor.cc:31
EcalSelectiveReadoutSuppressor::srFlags
int srFlags[2][8]
Definition: EcalSelectiveReadoutSuppressor.h:298
EcalMGPASample
Definition: EcalMGPASample.h:22
EcalTrigTowerConstituentsMap::towerOf
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
Definition: EcalTrigTowerConstituentsMap.cc:11
EEDataFrame.h
edm::DataFrame
Definition: DataFrame.h:15
EcalSelectiveReadoutSuppressor::ttThresOnCompressedEt_
bool ttThresOnCompressedEt_
Definition: EcalSelectiveReadoutSuppressor.h:275
EcalSRSettings
Definition: EcalSRSettings.h:27
CaloCellGeometry.h
EcalSRSettings::dccNormalizedWeights_
std::vector< std::vector< float > > dccNormalizedWeights_
Definition: EcalSRSettings.h:97
std
Definition: JetResolutionObject.h:76
EcalSelectiveReadoutSuppressor::nFIRTaps
static const int nFIRTaps
Definition: EcalSelectiveReadoutSuppressor.h:231
EcalSelectiveReadoutSuppressor::thrUnit
double thrUnit[2]
Definition: EcalSelectiveReadoutSuppressor.h:253
tccFlagMarker
const char tccFlagMarker[]
Definition: GenABIO.cc:164
EcalSRSettings::ecalDccZs1stSample_
std::vector< int > ecalDccZs1stSample_
Definition: EcalSRSettings.h:78
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
T
long double T
Definition: Basic3DVectorLD.h:48
edm::SortedCollection::reserve
void reserve(size_type n)
Definition: SortedCollection.h:225
EcalSRSettings::eeDccAdcToGeV_
float eeDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EE.
Definition: EcalSRSettings.h:83
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
EcalSelectiveReadoutSuppressor::setElecMap
void setElecMap(const EcalElectronicsMapping *map)
Definition: EcalSelectiveReadoutSuppressor.cc:101
Exception
Definition: hltDiff.cc:245
CaloGeometry.h
EcalSelectiveReadoutSuppressor::weights
std::vector< float > weights
Definition: EcalSelectiveReadoutSuppressor.h:235
EcalSelectiveReadoutSuppressor::run
void run(const edm::EventSetup &eventSetup, const EcalTrigPrimDigiCollection &trigPrims, EBDigiCollection &barrelDigis, EEDigiCollection &endcapDigis)
Definition: EcalSelectiveReadoutSuppressor.cc:263
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
EcalSelectiveReadout::ttFlag_t
ttFlag_t
Definition: EcalSelectiveReadout.h:81
Exception.h
EcalSRSettings::srpHighInterestChannelZS_
std::vector< float > srpHighInterestChannelZS_
Definition: EcalSRSettings.h:129
L1TowerCalibrationProducer_cfi.iEta
iEta
Definition: L1TowerCalibrationProducer_cfi.py:60
EcalSelectiveReadoutSuppressor::actions_
std::vector< int > actions_
Definition: EcalSelectiveReadoutSuppressor.h:269
mps_fire.result
result
Definition: mps_fire.py:311
EcalSelectiveReadoutSuppressor::internalThreshold
int internalThreshold(double thresholdInGeV, int iSubDet) const
Definition: EcalSelectiveReadoutSuppressor.cc:188
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
genParticles_cff.map
map
Definition: genParticles_cff.py:11
mtdUncalibratedRecHits_cfi.endcapDigis
endcapDigis
Definition: mtdUncalibratedRecHits_cfi.py:34
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
EEDataFrame
Definition: EEDataFrame.h:12
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
GlobalPoint.h
SimL1EmulatorDM_cff.eeDigis
eeDigis
Definition: SimL1EmulatorDM_cff.py:18
EcalSelectiveReadout::nTriggerTowersInPhi
const static size_t nTriggerTowersInPhi
Definition: EcalSelectiveReadout.h:143
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
EcalSelectiveReadoutSuppressor::symetricZS
bool symetricZS
Definition: EcalSelectiveReadoutSuppressor.h:239
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37