CMS 3D CMS Logo

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