CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EESelectiveReadoutTask.cc
Go to the documentation of this file.
1 /*
2  * \file EESelectiveReadoutTask.cc
3  *
4  * \author P. Gras
5  * \author E. Di Marco
6  *
7 */
8 
9 #include <iostream>
10 #include <fstream>
11 #include <vector>
12 #include <math.h>
13 #include <cassert>
14 
18 
20 
22 
27 
30 
32 
34 
37 
38 
40 
41  init_ = false;
42 
44 
45  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
46 
47  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
48 
49  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
50 
51  // parameters...
52  EEDigiCollection_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEDigiCollection"));
53  EESRFlagCollection_ = consumes<EESrFlagCollection>(ps.getParameter<edm::InputTag>("EESRFlagCollection"));
54  EcalTrigPrimDigiCollection_ = consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("EcalTrigPrimDigiCollection"));
55  FEDRawDataCollection_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("FEDRawDataCollection"));
56 
57  firstFIRSample_ = ps.getParameter<int>("ecalDccZs1stSample");
58 
59  useCondDb_ = ps.getParameter<bool>("configFromCondDB");
60  if(!useCondDb_) configFirWeights(ps.getParameter<std::vector<double> >("dccWeights"));
61 
62  // histograms...
63  EEDccEventSize_ = 0;
65 
66  for(int i=0; i<2; i++) {
67  EETowerSize_[i] = 0;
68  EETTFMismatch_[i] = 0;
76  EETTFlags_[i] = 0;
77  EECompleteZSMap_[i] = 0;
78  EECompleteZSCount_[i] = 0;
79  EEDroppedFRMap_[i] = 0;
80  EEDroppedFRCount_[i] = 0;
81  EEEventSize_[i] = 0;
86  }
87 
88  // initialize variable binning for DCC size...
89  float ZSthreshold = 0.608; // kBytes of 1 TT fully readout
90  float zeroBinSize = ZSthreshold / 20.;
91  for(int i=0; i<20; i++) ybins[i] = i*zeroBinSize;
92  for(int i=20; i<133; i++) ybins[i] = ZSthreshold * (i-19);
93  for(int i=0; i<=18; i++) xbins[i] = i+1;
94 
95 }
96 
98 
99 }
100 
102 
103  ievt_ = 0;
104 
105  if ( dqmStore_ ) {
106  dqmStore_->setCurrentFolder(prefixME_ + "/EESelectiveReadoutTask");
107  dqmStore_->rmdir(prefixME_ + "/EESelectiveReadoutTask");
108  }
109 
110 }
111 
113 
114  Numbers::initGeometry(c, false);
115 
116  if ( ! mergeRuns_ ) this->reset();
117 
118  for(int ix = 0; ix < 20; ix++ ) {
119  for(int iy = 0; iy < 20; iy++ ) {
120  for(int iz = 0; iz < 2; iz++) {
121  nEvtFullReadout[ix][iy][iz] = 0;
122  nEvtZS1Readout[ix][iy][iz] = 0;
123  nEvtZSReadout[ix][iy][iz] = 0;
124  nEvtCompleteReadoutIfZS[ix][iy][iz] = 0;
125  nEvtDroppedReadoutIfFR[ix][iy][iz] = 0;
126  nEvtRUForced[ix][iy][iz] = 0;
127  nEvtAnyReadout[ix][iy][iz] = 0;
128  }
129  }
130  }
131  for(int ix = 0; ix < 100; ix++ ) {
132  for(int iy = 0; iy < 100; iy++ ) {
133  for(int iz = 0; iz < 2; iz++) {
134  nEvtHighInterest[ix][iy][iz] = 0;
135  nEvtMediumInterest[ix][iy][iz] = 0;
136  nEvtLowInterest[ix][iy][iz] = 0;
137  nEvtAnyInterest[ix][iy][iz] = 0;
138  }
139  }
140  }
141 
142  //getting selective readout configuration
143  if(useCondDb_) {
145  c.get<EcalSRSettingsRcd>().get(hSr);
146  settings_ = hSr.product();
147  std::vector<double> wsFromDB;
148 
149  std::vector<std::vector<float> > dccs = settings_->dccNormalizedWeights_;
150  int nws = dccs.size();
151  if(nws == 1) {
152  for(std::vector<float>::const_iterator it = dccs[0].begin(); it != dccs[0].end(); it++) {
153  wsFromDB.push_back(*it);
154  }
155  }
156  else edm::LogWarning("EESelectiveReadoutTask") << "DCC weight set is not exactly 1.";
157 
158  configFirWeights(wsFromDB);
159  }
160 
161 }
162 
164 
165 }
166 
168 
169  if ( EETowerSize_[0] ) EETowerSize_[0]->Reset();
170  if ( EETowerSize_[1] ) EETowerSize_[1]->Reset();
171 
172  if ( EETTFMismatch_[0] ) EETTFMismatch_[0]->Reset();
173  if ( EETTFMismatch_[1] ) EETTFMismatch_[1]->Reset();
174 
176 
178 
181 
184 
187 
190 
193 
196 
199 
200  if ( EETTFlags_[0] ) EETTFlags_[0]->Reset();
201  if ( EETTFlags_[1] ) EETTFlags_[1]->Reset();
202 
203  if ( EECompleteZSMap_[0] ) EECompleteZSMap_[0]->Reset();
204  if ( EECompleteZSMap_[1] ) EECompleteZSMap_[1]->Reset();
205 
208 
209  if ( EEDroppedFRMap_[0] ) EEDroppedFRMap_[0]->Reset();
210  if ( EEDroppedFRMap_[1] ) EEDroppedFRMap_[1]->Reset();
211 
212  if ( EEDroppedFRCount_[0] ) EEDroppedFRCount_[0]->Reset();
213  if ( EEDroppedFRCount_[1] ) EEDroppedFRCount_[1]->Reset();
214 
215  if ( EEEventSize_[0] ) EEEventSize_[0]->Reset();
216  if ( EEEventSize_[1] ) EEEventSize_[1]->Reset();
217 
220 
223 
226 
229 
230 }
231 
233 
234  init_ = true;
235 
237 
238  if ( dqmStore_ ) {
239  dqmStore_->setCurrentFolder(prefixME_ + "/EESelectiveReadoutTask");
240 
241  name = "EESRT tower event size EE -";
242  EETowerSize_[0] = dqmStore_->bookProfile2D(name, name, 20, 0., 20., 20, 0., 20., 100, 0., 200., "s");
243  EETowerSize_[0]->setAxisTitle("jx", 1);
244  EETowerSize_[0]->setAxisTitle("jy", 2);
245 
246  name = "EESRT tower event size EE +";
247  EETowerSize_[1] = dqmStore_->bookProfile2D(name, name, 20, 0., 20., 20, 0., 20., 100, 0., 200., "s");
248  EETowerSize_[1]->setAxisTitle("jx", 1);
249  EETowerSize_[1]->setAxisTitle("jy", 2);
250 
251  name = "EESRT TT flag mismatch EE -";
252  EETTFMismatch_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
253  EETTFMismatch_[0]->setAxisTitle("jx", 1);
254  EETTFMismatch_[0]->setAxisTitle("jy", 2);
255 
256  name = "EESRT TT flag mismatch EE +";
257  EETTFMismatch_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
258  EETTFMismatch_[1]->setAxisTitle("jx", 1);
259  EETTFMismatch_[1]->setAxisTitle("jy", 2);
260 
261  name = "EESRT DCC event size";
262  EEDccEventSize_ = dqmStore_->bookProfile(name, name, 18, 1, 19, 100, 0., 200., "s");
263  EEDccEventSize_->setAxisTitle("event size (kB)", 2);
264  for (int i = 0; i < 18; i++) {
265  EEDccEventSize_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
266  }
267 
268  name = "EESRT event size vs DCC";
269  EEDccEventSizeMap_ = dqmStore_->book2D(name, name, 18, xbins, 132, ybins);
270  EEDccEventSizeMap_->setAxisTitle("event size (kB)", 2);
271  for (int i = 0; i < 18; i++) {
272  EEDccEventSizeMap_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
273  }
274 
275  name = "EESRT readout unit with SR forced EE -";
276  EEReadoutUnitForcedBitMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
280 
281  name = "EESRT readout unit with SR forced EE +";
282  EEReadoutUnitForcedBitMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
286 
287  name = "EESRT full readout SR Flags EE -";
288  EEFullReadoutSRFlagMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
291  EEFullReadoutSRFlagMap_[0]->setAxisTitle("rate", 3);
292 
293  name = "EESRT full readout SR Flags EE +";
294  EEFullReadoutSRFlagMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
297  EEFullReadoutSRFlagMap_[1]->setAxisTitle("rate", 3);
298 
299  name = "EESRT full readout SR Flags Number EE -";
300  EEFullReadoutSRFlagCount_[0] = dqmStore_->book1D(name, name, 200, 0., 200.);
301  EEFullReadoutSRFlagCount_[0]->setAxisTitle("Readout Units number", 1);
302 
303  name = "EESRT full readout SR Flags Number EE +";
304  EEFullReadoutSRFlagCount_[1] = dqmStore_->book1D(name, name, 200, 0., 200.);
305  EEFullReadoutSRFlagCount_[1]->setAxisTitle("Fully readout RU number", 1);
306 
307  name = "EESRT zero suppression 1 SR Flags EE -";
308  EEZeroSuppression1SRFlagMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
312 
313  name = "EESRT zero suppression 1 SR Flags EE +";
314  EEZeroSuppression1SRFlagMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
318 
319  name = "EESRT high interest TT Flags EE -";
320  EEHighInterestTriggerTowerFlagMap_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
324 
325  name = "EESRT high interest TT Flags EE +";
326  EEHighInterestTriggerTowerFlagMap_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
330 
331  name = "EESRT medium interest TT Flags EE -";
332  EEMediumInterestTriggerTowerFlagMap_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
336 
337  name = "EESRT medium interest TT Flags EE +";
338  EEMediumInterestTriggerTowerFlagMap_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
342 
343  name = "EESRT low interest TT Flags EE -";
344  EELowInterestTriggerTowerFlagMap_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
348 
349  name = "EESRT low interest TT Flags EE +";
350  EELowInterestTriggerTowerFlagMap_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
354 
355  name = "EESRT TT Flags EE -";
356  EETTFlags_[0] = dqmStore_->book1D(name, name, 8, 0., 8.);
357  EETTFlags_[0]->setAxisTitle("TT Flag value", 1);
358 
359  name = "EESRT TT Flags EE +";
360  EETTFlags_[1] = dqmStore_->book1D(name, name, 8, 0., 8.);
361  EETTFlags_[1]->setAxisTitle("TT Flag value", 1);
362 
363  name = "EESRT ZS Flagged Fully Readout EE -";
364  EECompleteZSMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
365  EECompleteZSMap_[0]->setAxisTitle("jphi", 1);
366  EECompleteZSMap_[0]->setAxisTitle("jeta", 2);
367  EECompleteZSMap_[0]->setAxisTitle("rate", 3);
368 
369  name = "EESRT ZS Flagged Fully Readout EE +";
370  EECompleteZSMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
371  EECompleteZSMap_[1]->setAxisTitle("jphi", 1);
372  EECompleteZSMap_[1]->setAxisTitle("jeta", 2);
373  EECompleteZSMap_[1]->setAxisTitle("rate", 3);
374 
375  name = "EESRT ZS Flagged Fully Readout Number EE -";
376  EECompleteZSCount_[0] = dqmStore_->book1D(name, name, 20, 0., 20.);
377  EECompleteZSCount_[0]->setAxisTitle("Readout Units number", 1);
378 
379  name = "EESRT ZS Flagged Fully Readout Number EE +";
380  EECompleteZSCount_[1] = dqmStore_->book1D(name, name, 20, 0., 20.);
381  EECompleteZSCount_[1]->setAxisTitle("Readout Units number", 1);
382 
383  name = "EESRT FR Flagged Dropped Readout EE -";
384  EEDroppedFRMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
385  EEDroppedFRMap_[0]->setAxisTitle("jphi", 1);
386  EEDroppedFRMap_[0]->setAxisTitle("jeta", 2);
387  EEDroppedFRMap_[0]->setAxisTitle("rate", 3);
388 
389  name = "EESRT FR Flagged Dropped Readout EE +";
390  EEDroppedFRMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
391  EEDroppedFRMap_[1]->setAxisTitle("jphi", 1);
392  EEDroppedFRMap_[1]->setAxisTitle("jeta", 2);
393  EEDroppedFRMap_[1]->setAxisTitle("rate", 3);
394 
395  name = "EESRT FR Flagged Dropped Readout Number EE -";
396  EEDroppedFRCount_[0] = dqmStore_->book1D(name, name, 20, 0., 20.);
397  EEDroppedFRCount_[0]->setAxisTitle("Readout Units number", 1);
398 
399  name = "EESRT FR Flagged Dropped Readout Number EE +";
400  EEDroppedFRCount_[1] = dqmStore_->book1D(name, name, 20, 0., 20.);
401  EEDroppedFRCount_[1]->setAxisTitle("Readout Units number", 1);
402 
403  name = "EESRT event size EE -";
404  EEEventSize_[0] = dqmStore_->book1D(name, name, 100, 0, 200);
405  EEEventSize_[0]->setAxisTitle("event size (kB)",1);
406 
407  name = "EESRT event size EE +";
408  EEEventSize_[1] = dqmStore_->book1D(name, name, 100, 0, 200);
409  EEEventSize_[1]->setAxisTitle("event size (kB)",1);
410 
411  name = "EESRT high interest payload EE -";
412  EEHighInterestPayload_[0] = dqmStore_->book1D(name, name, 100, 0, 200);
413  EEHighInterestPayload_[0]->setAxisTitle("event size (kB)",1);
414 
415  name = "EESRT high interest payload EE +";
416  EEHighInterestPayload_[1] = dqmStore_->book1D(name, name, 100, 0, 200);
417  EEHighInterestPayload_[1]->setAxisTitle("event size (kB)",1);
418 
419  name = "EESRT low interest payload EE -";
420  EELowInterestPayload_[0] = dqmStore_->book1D(name, name, 100, 0, 200);
421  EELowInterestPayload_[0]->setAxisTitle("event size (kB)",1);
422 
423  name = "EESRT low interest payload EE +";
424  EELowInterestPayload_[1] = dqmStore_->book1D(name, name, 100, 0, 200);
425  EELowInterestPayload_[1]->setAxisTitle("event size (kB)",1);
426 
427  name = "EESRT high interest ZS filter output EE -";
428  EEHighInterestZsFIR_[0] = dqmStore_->book1D(name, name, 60, -30, 30);
429  EEHighInterestZsFIR_[0]->setAxisTitle("ADC counts*4",1);
430 
431  name = "EESRT high interest ZS filter output EE +";
432  EEHighInterestZsFIR_[1] = dqmStore_->book1D(name, name, 60, -30, 30);
433  EEHighInterestZsFIR_[1]->setAxisTitle("ADC counts*4",1);
434 
435  name = "EESRT low interest ZS filter output EE -";
436  EELowInterestZsFIR_[0] = dqmStore_->book1D(name, name, 60, -30, 30);
437  EELowInterestZsFIR_[0]->setAxisTitle("ADC counts*4",1);
438 
439  name = "EESRT low interest ZS filter output EE +";
440  EELowInterestZsFIR_[1] = dqmStore_->book1D(name, name, 60, -30, 30);
441  EELowInterestZsFIR_[1]->setAxisTitle("ADC counts*4",1);
442 
443  }
444 
445 }
446 
448 
449  if ( ! init_ ) return;
450 
451  if ( dqmStore_ ) {
452  dqmStore_->setCurrentFolder(prefixME_ + "/EESelectiveReadoutTask");
453 
454  if ( EETowerSize_[0] ) dqmStore_->removeElement( EETowerSize_[0]->getName() );
455  EETowerSize_[0] = 0;
456 
457  if ( EETowerSize_[1] ) dqmStore_->removeElement( EETowerSize_[1]->getName() );
458  EETowerSize_[1] = 0;
459 
460  if ( EETTFMismatch_[0] ) dqmStore_->removeElement( EETTFMismatch_[0]->getName() );
461  EETTFMismatch_[0] = 0;
462 
463  if ( EETTFMismatch_[1] ) dqmStore_->removeElement( EETTFMismatch_[1]->getName() );
464  EETTFMismatch_[1] = 0;
465 
467  EEDccEventSize_ = 0;
468 
470  EEDccEventSizeMap_ = 0;
471 
474 
477 
480 
483 
486 
489 
492 
495 
498 
501 
504 
507 
508  if ( EETTFlags_[0] ) dqmStore_->removeElement( EETTFlags_[0]->getName() );
509  EETTFlags_[0] = 0;
510 
511  if ( EETTFlags_[1] ) dqmStore_->removeElement( EETTFlags_[1]->getName() );
512  EETTFlags_[1] = 0;
513 
514  if ( EECompleteZSMap_[0] ) dqmStore_->removeElement( EECompleteZSMap_[0]->getName() );
515  EECompleteZSMap_[0] = 0;
516 
517  if ( EECompleteZSMap_[1] ) dqmStore_->removeElement( EECompleteZSMap_[1]->getName() );
518  EECompleteZSMap_[1] = 0;
519 
520  if ( EECompleteZSCount_[0] ) dqmStore_->removeElement( EECompleteZSCount_[0]->getName() );
521  EECompleteZSCount_[0] = 0;
522 
523  if ( EECompleteZSCount_[1] ) dqmStore_->removeElement( EECompleteZSCount_[1]->getName() );
524  EECompleteZSCount_[1] = 0;
525 
526  if ( EEDroppedFRMap_[0] ) dqmStore_->removeElement( EEDroppedFRMap_[0]->getName() );
527  EEDroppedFRMap_[0] = 0;
528 
529  if ( EEDroppedFRMap_[1] ) dqmStore_->removeElement( EEDroppedFRMap_[1]->getName() );
530  EEDroppedFRMap_[1] = 0;
531 
532  if ( EEDroppedFRCount_[0] ) dqmStore_->removeElement( EEDroppedFRCount_[0]->getName() );
533  EEDroppedFRCount_[0] = 0;
534 
535  if ( EEDroppedFRCount_[1] ) dqmStore_->removeElement( EEDroppedFRCount_[1]->getName() );
536  EEDroppedFRCount_[1] = 0;
537 
538  if ( EEEventSize_[0] ) dqmStore_->removeElement( EEEventSize_[0]->getName() );
539  EEEventSize_[0] = 0;
540 
541  if ( EEEventSize_[1] ) dqmStore_->removeElement( EEEventSize_[1]->getName() );
542  EEEventSize_[1] = 0;
543 
545  EEHighInterestPayload_[0] = 0;
546 
548  EEHighInterestPayload_[1] = 0;
549 
551  EELowInterestPayload_[0] = 0;
552 
554  EELowInterestPayload_[1] = 0;
555 
557  EEHighInterestZsFIR_[0] = 0;
558 
560  EEHighInterestZsFIR_[1] = 0;
561 
563  EELowInterestZsFIR_[0] = 0;
564 
566  EELowInterestZsFIR_[1] = 0;
567 
568  }
569 
570  init_ = false;
571 
572 }
573 
575 
576  edm::LogInfo("EESelectiveReadoutTask") << "analyzed " << ievt_ << " events";
577 
578  if ( enableCleanup_ ) this->cleanup();
579 
580 }
581 
583 
584  if ( ! init_ ) this->setup();
585 
586  ievt_++;
587 
589  if ( e.getByToken(FEDRawDataCollection_, raw) ) {
590 
591  int EEFirstFED[2];
592  EEFirstFED[0] = 601; // EE-
593  EEFirstFED[1] = 646; // EE+
594  for(int zside=0; zside<2; zside++) {
595 
596  int firstFedOnSide=EEFirstFED[zside];
597 
598  for ( int iDcc = 0; iDcc < 9; ++iDcc ) {
599 
600  int ism = 0;
601  if ( zside == 0 ) ism = iDcc+1;
602  else ism = 10+iDcc;
603 
604  EEDccEventSize_->Fill( ism, ((double)raw->FEDData(firstFedOnSide+iDcc).size())/kByte );
605  EEDccEventSizeMap_->Fill( ism, ((double)raw->FEDData(firstFedOnSide+iDcc).size())/kByte );
606 
607  }
608  }
609 
610  } else {
611  edm::LogWarning("EESelectiveReadoutTask") << "FEDRawDataCollection not available";
612  }
613 
614  // Selective Readout Flags
615  int nFRO[2], nCompleteZS[2], nDroppedFRO[2];
616  nFRO[0] = nFRO[1] = 0;
617  nCompleteZS[0] = nCompleteZS[1] = 0;
618  nDroppedFRO[0] = nDroppedFRO[1] = 0;
620  if ( e.getByToken(EESRFlagCollection_,eeSrFlags) ) {
621 
622  // Data Volume
623  double aLowInterest[2];
624  double aHighInterest[2];
625  double aAnyInterest[2];
626 
627  aLowInterest[0]=0;
628  aHighInterest[0]=0;
629  aAnyInterest[0]=0;
630  aLowInterest[1]=0;
631  aHighInterest[1]=0;
632  aAnyInterest[1]=0;
633 
635  if ( e.getByToken(EEDigiCollection_ , eeDigis) ) {
636 
637  anaDigiInit();
638 
639  // channel status
640  edm::ESHandle<EcalChannelStatus> pChannelStatus;
641  c.get<EcalChannelStatusRcd>().get(pChannelStatus);
642  const EcalChannelStatus* chStatus = pChannelStatus.product();
643 
644  for (unsigned int digis=0; digis<eeDigis->size(); ++digis) {
645  EEDataFrame eedf = (*eeDigis)[digis];
646  EEDetId id = eedf.id();
648  chit = chStatus->getMap().find(id.rawId());
649  uint16_t statusCode = 0;
650  if( chit != chStatus->getMap().end() ) {
651  EcalChannelStatusCode ch_code = (*chit);
652  statusCode = ch_code.getStatusCode();
653  }
654  anaDigi(eedf, *eeSrFlags, statusCode);
655  }
656 
657  //low interest channels:
658  aLowInterest[0] = nEeLI_[0]*bytesPerCrystal/kByte;
659  EELowInterestPayload_[0]->Fill(aLowInterest[0]);
660  aLowInterest[1] = nEeLI_[1]*bytesPerCrystal/kByte;
661  EELowInterestPayload_[1]->Fill(aLowInterest[1]);
662 
663  //low interest channels:
664  aHighInterest[0] = nEeHI_[0]*bytesPerCrystal/kByte;
665  EEHighInterestPayload_[0]->Fill(aHighInterest[0]);
666  aHighInterest[1] = nEeHI_[1]*bytesPerCrystal/kByte;
667  EEHighInterestPayload_[1]->Fill(aHighInterest[1]);
668 
669  //any-interest channels:
670  aAnyInterest[0] = getEeEventSize(nEe_[0])/kByte;
671  EEEventSize_[0]->Fill(aAnyInterest[0]);
672  aAnyInterest[1] = getEeEventSize(nEe_[1])/kByte;
673  EEEventSize_[1]->Fill(aAnyInterest[1]);
674 
675  //event size by tower:
676  for(int ix = 0; ix < 20; ix++ ) {
677  for(int iy = 0; iy < 20; iy++ ) {
678  for(int iz = 0; iz < 2; iz++) {
679 
680  double towerSize = nCrySC[ix][iy][iz] * bytesPerCrystal;
681 
682  float xix = ix;
683  if ( iz == 0 ) xix = 19 - xix;
684  xix += 0.5;
685 
686  float xiy = iy+0.5;
687 
688  EETowerSize_[iz]->Fill(xix, xiy, towerSize);
689 
690  }
691  }
692  }
693 
694  } else {
695  edm::LogWarning("EESelectiveReadoutTask") << "EEDigiCollection not available";
696  }
697 
698  // initialize dcchs_ to mask disabled towers
699  std::map< int, std::vector<short> > towersStatus;
701 
702  if( e.getByToken(FEDRawDataCollection_, dcchs) ) {
703  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
704  if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
705  int ism = Numbers::iSM( *dcchItr, EcalEndcap );
706  towersStatus.insert(std::make_pair(ism, dcchItr->getFEStatus()));
707  }
708  }
709 
710  for ( EESrFlagCollection::const_iterator it = eeSrFlags->begin(); it != eeSrFlags->end(); ++it ) {
711 
712  EcalScDetId id = it->id();
713 
714  if ( Numbers::subDet( id ) != EcalEndcap ) continue;
715 
716  int ix = id.ix();
717  int iy = id.iy();
718  int iDcc = dccNumOfRU(id);
719  int ism = Numbers::iSM( id );
720  int isc = Numbers::iSC( id );
721 
722  int zside = id.zside();
723 
724  int iz = ( zside < 0 ) ? 0 : 1;
725 
726  if ( zside < 0 ) ix = 21 - ix;
727 
728  nEvtAnyReadout[ix-1][iy-1][iz]++;
729 
730  int flag = it->value() & ~EcalSrFlag::SRF_FORCED_MASK;
731 
732  int status=0;
733  if( towersStatus[ism].size() > 0 ) status = (towersStatus[ism])[isc];
734 
735  if(flag == EcalSrFlag::SRF_FULL) {
736  nEvtFullReadout[ix-1][iy-1][iz]++;
737  nFRO[iz]++;
738  if(nPerRu_[iDcc-1][isc] == 0) {
739  if(status != 1) nEvtDroppedReadoutIfFR[ix-1][iy-1][iz]++;
740  nDroppedFRO[iz]++;
741  }
742  }
743 
744  if(flag == EcalSrFlag::SRF_ZS1) nEvtZS1Readout[ix-1][iy-1][iz]++;
745 
746  if(it->value() & EcalSrFlag::SRF_FORCED_MASK) nEvtRUForced[ix-1][iy-1][iz]++;
747 
748  if(flag == EcalSrFlag::SRF_ZS1 || flag == EcalSrFlag::SRF_ZS2) {
749  nEvtZSReadout[ix-1][iy-1][iz]++;
750  if(nPerRu_[iDcc-1][isc] == getCrystalCount(iDcc,isc)) {
751  if(status != 1) nEvtCompleteReadoutIfZS[ix-1][iy-1][iz]++;
752  nCompleteZS[iz]++;
753  }
754  }
755 
756  }
757  } else {
758  edm::LogWarning("EESelectiveReadoutTask") << "EESRFlagCollection not available";
759  }
760 
761  for(int ix = 0; ix < 20; ix++ ) {
762  for(int iy = 0; iy < 20; iy++ ) {
763  for(int iz = 0; iz < 2; iz++) {
764 
765  if( nEvtAnyReadout[ix][iy][iz] ) {
766 
767  float xix = ix;
768  if ( iz == 0 ) xix = 19 - xix;
769  xix += 0.5;
770 
771  float xiy = iy+0.5;
772 
773  float fraction = float(nEvtFullReadout[ix][iy][iz]) / float(nEvtAnyReadout[ix][iy][iz]);
774  float error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
775 
776  TH2F *h2d = EEFullReadoutSRFlagMap_[iz]->getTH2F();
777 
778  int binx=0, biny=0;
779 
780  if( h2d ) {
781  binx = h2d->GetXaxis()->FindBin(xix);
782  biny = h2d->GetYaxis()->FindBin(xiy);
783  }
784 
785  EEFullReadoutSRFlagMap_[iz]->setBinContent(binx, biny, fraction);
786  EEFullReadoutSRFlagMap_[iz]->setBinError(binx, biny, error);
787 
788 
789  fraction = float(nEvtZS1Readout[ix][iy][iz]) / float(nEvtAnyReadout[ix][iy][iz]);
790  error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
791 
793 
794  if( h2d ) {
795  binx = h2d->GetXaxis()->FindBin(xix);
796  biny = h2d->GetYaxis()->FindBin(xiy);
797  }
798 
799  EEZeroSuppression1SRFlagMap_[iz]->setBinContent(binx, biny, fraction);
800  EEZeroSuppression1SRFlagMap_[iz]->setBinError(binx, biny, error);
801 
802 
803  fraction = float(nEvtRUForced[ix][iy][iz]) / float(nEvtAnyReadout[ix][iy][iz]);
804  error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
805 
806  h2d = EEReadoutUnitForcedBitMap_[iz]->getTH2F();
807 
808  if( h2d ) {
809  binx = h2d->GetXaxis()->FindBin(xix);
810  biny = h2d->GetYaxis()->FindBin(xiy);
811  }
812 
813  EEReadoutUnitForcedBitMap_[iz]->setBinContent(binx, biny, fraction);
814  EEReadoutUnitForcedBitMap_[iz]->setBinError(binx, biny, error);
815 
816  if( nEvtZSReadout[ix][iy][iz] ) {
817  fraction = float(nEvtCompleteReadoutIfZS[ix][iy][iz]) / float(nEvtZSReadout[ix][iy][iz]);
818  error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
819 
820  h2d = EECompleteZSMap_[iz]->getTH2F();
821 
822  if( h2d ) {
823  binx = h2d->GetXaxis()->FindBin(xix);
824  biny = h2d->GetYaxis()->FindBin(xiy);
825  }
826 
827  EECompleteZSMap_[iz]->setBinContent(binx, biny, fraction);
828  EECompleteZSMap_[iz]->setBinError(binx, biny, error);
829  }
830 
831  if( nEvtFullReadout[ix][iy][iz] ) {
832  fraction = float(nEvtDroppedReadoutIfFR[ix][iy][iz]) / float(nEvtFullReadout[ix][iy][iz]);
833  error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
834 
835  h2d = EEDroppedFRMap_[iz]->getTH2F();
836 
837  if( h2d ) {
838  binx = h2d->GetXaxis()->FindBin(xix);
839  biny = h2d->GetYaxis()->FindBin(xiy);
840  }
841 
842  EEDroppedFRMap_[iz]->setBinContent(binx, biny, fraction);
843  EEDroppedFRMap_[iz]->setBinError(binx, biny, error);
844  }
845 
846  }
847 
848  }
849  }
850  }
851 
852  for(int iz = 0; iz < 2; iz++) {
853  EEFullReadoutSRFlagCount_[iz]->Fill( nFRO[iz] );
854  EECompleteZSCount_[iz]->Fill( nCompleteZS[iz] );
855  EEDroppedFRCount_[iz]->Fill( nDroppedFRO[iz] );
856  }
857 
859  if ( e.getByToken(EcalTrigPrimDigiCollection_, TPCollection) ) {
860 
861  // Trigger Primitives
863  for ( TPdigi = TPCollection->begin(); TPdigi != TPCollection->end(); ++TPdigi ) {
864 
865  if ( Numbers::subDet( TPdigi->id() ) != EcalEndcap ) continue;
866 
867  int ismt = Numbers::iSM( TPdigi->id() );
868  int zside = TPdigi->id().zside();
869  int iz = ( zside < 0 ) ? 0 : 1;
870 
871  EETTFlags_[iz]->Fill( TPdigi->ttFlag() );
872 
873  std::vector<DetId>* crystals = Numbers::crystals( TPdigi->id() );
874 
875  for ( unsigned int i=0; i<crystals->size(); i++ ) {
876 
877  EEDetId id = (*crystals)[i];
878 
879  int ix = id.ix();
880  int iy = id.iy();
881  int ism = Numbers::iSM( id );
882  int itcc = Numbers::iTCC( ism, EcalEndcap, ix, iy );
883  int itt = Numbers::iTT( ism, EcalEndcap, ix, iy );
884 
885  if ( ismt >= 1 && ismt <= 9 ) ix = 101 - ix;
886 
887  nEvtAnyInterest[ix-1][iy-1][iz]++;
888 
889  if ( (TPdigi->ttFlag() & 0x3) == 0 ) nEvtLowInterest[ix-1][iy-1][iz]++;
890 
891  if ( (TPdigi->ttFlag() & 0x3) == 1 ) nEvtMediumInterest[ix-1][iy-1][iz]++;
892 
893  if ( (TPdigi->ttFlag() & 0x3) == 3 ) nEvtHighInterest[ix-1][iy-1][iz]++;
894 
895  float xix = ix-0.5;
896  if ( iz == 0 ) xix = 100 - xix;
897  float xiy = iy-0.5;
898 
899  if ( ((TPdigi->ttFlag() & 0x3) == 1 || (TPdigi->ttFlag() & 0x3) == 3)
900  && nCryTT[itcc-1][itt-1] != (int)crystals->size() ) EETTFMismatch_[iz]->Fill(xix, xiy);
901 
902  }
903 
904  }
905  } else {
906  edm::LogWarning("EESelectiveReadoutTask") << "EcalTrigPrimDigiCollection not available";
907  }
908 
909  for(int ix = 0; ix < 100; ix++ ) {
910  for(int iy = 0; iy < 100; iy++ ) {
911  for(int iz = 0; iz < 2; iz++) {
912 
913  if( nEvtAnyInterest[ix][iy][iz] ) {
914 
915  float xix = ix;
916  if ( iz == 0 ) xix = 99 - xix;
917  xix += 0.5;
918 
919  float xiy = iy+0.5;
920 
921  float fraction = float(nEvtHighInterest[ix][iy][iz]) / float(nEvtAnyInterest[ix][iy][iz]);
922  float error = sqrt(fraction*(1-fraction)/float(nEvtAnyInterest[ix][iy][iz]));
923 
924  TH2F *h2d = EEHighInterestTriggerTowerFlagMap_[iz]->getTH2F();
925 
926  int binx=0, biny=0;
927 
928  if( h2d ) {
929  binx = h2d->GetXaxis()->FindBin(xix);
930  biny = h2d->GetYaxis()->FindBin(xiy);
931  }
932 
933  EEHighInterestTriggerTowerFlagMap_[iz]->setBinContent(binx, biny, fraction);
934  EEHighInterestTriggerTowerFlagMap_[iz]->setBinError(binx, biny, error);
935 
936 
937  fraction = float(nEvtMediumInterest[ix][iy][iz]) / float(nEvtAnyInterest[ix][iy][iz]);
938  error = sqrt(fraction*(1-fraction)/float(nEvtAnyInterest[ix][iy][iz]));
939 
941 
942  if( h2d ) {
943  binx = h2d->GetXaxis()->FindBin(xix);
944  biny = h2d->GetYaxis()->FindBin(xiy);
945  }
946 
947  EEMediumInterestTriggerTowerFlagMap_[iz]->setBinContent(binx, biny, fraction);
948  EEMediumInterestTriggerTowerFlagMap_[iz]->setBinError(binx, biny, error);
949 
950 
951  fraction = float(nEvtLowInterest[ix][iy][iz]) / float(nEvtAnyInterest[ix][iy][iz]);
952  error = sqrt(fraction*(1-fraction)/float(nEvtAnyInterest[ix][iy][iz]));
953 
955 
956  if( h2d ) {
957  binx = h2d->GetXaxis()->FindBin(xix);
958  biny = h2d->GetYaxis()->FindBin(xiy);
959  }
960 
961  EELowInterestTriggerTowerFlagMap_[iz]->setBinContent(binx, biny, fraction);
962  EELowInterestTriggerTowerFlagMap_[iz]->setBinError(binx, biny, error);
963 
964  }
965 
966  }
967  }
968  }
969 
970 }
971 
972 void EESelectiveReadoutTask::anaDigi(const EEDataFrame& frame, const EESrFlagCollection& srFlagColl, uint16_t statusCode){
973 
974  EEDetId id = frame.id();
975  int ism = Numbers::iSM( id );
976 
977  bool endcap = (id.subdetId()==EcalEndcap);
978 
979  if(endcap) {
980  if ( ism >= 1 && ism <= 9 ) {
981  ++nEe_[0];
982  } else {
983  ++nEe_[1];
984  }
985 
986  int ix = id.ix();
987  int iy = id.iy();
988 
989  int iX0 = iXY2cIndex(ix);
990  int iY0 = iXY2cIndex(iy);
991  int iZ0 = id.zside()>0?1:0;
992 
993  if(!eeRuActive_[iZ0][iX0/scEdge][iY0/scEdge]){
994  ++nRuPerDcc_[dccNum(id)];
995  eeRuActive_[iZ0][iX0/scEdge][iY0/scEdge] = true;
996  }
997 
999 
1000  if(srf == srFlagColl.end()){
1001  return;
1002  }
1003 
1004  int ttix = srf->id().ix();
1005  int ttiy = srf->id().iy();
1006 
1007  int zside = srf->id().zside();
1008 
1009  int ttiz = ( zside < 0 ) ? 0 : 1;
1010 
1011  nCrySC[ttix-1][ttiy-1][ttiz]++;
1012 
1013  int itcc = Numbers::iTCC( ism, EcalEndcap, ix, iy );
1014  int itt = Numbers::iTT( ism, EcalEndcap, ix, iy );
1015  nCryTT[itcc-1][itt-1]++;
1016 
1017  bool highInterest = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK)
1019 
1020  int dccZsFIRval = dccZsFIR(frame, firWeights_, firstFIRSample_, 0);
1021 
1022  if ( ism >= 1 && ism <= 9 ) {
1023  if(highInterest) {
1024  ++nEeHI_[0];
1025  // if(statusCode != 9) EEHighInterestZsFIR_[0]->Fill( dccZsFIRval );
1026  EEHighInterestZsFIR_[0]->Fill( dccZsFIRval );
1027  } else{ //low interest
1028  ++nEeLI_[0];
1029  // if(statusCode != 9) EELowInterestZsFIR_[0]->Fill( dccZsFIRval );
1030  EELowInterestZsFIR_[0]->Fill( dccZsFIRval );
1031  }
1032  } else {
1033  if(highInterest) {
1034  ++nEeHI_[1];
1035  EEHighInterestZsFIR_[1]->Fill( dccZsFIRval );
1036  } else{ //low interest
1037  ++nEeLI_[1];
1038  EELowInterestZsFIR_[1]->Fill( dccZsFIRval );
1039  }
1040  }
1041  int isc = Numbers::iSC( ism, EcalEndcap, ix, iy );
1042  ++nPerDcc_[dccNum(id)-1];
1043  ++nPerRu_[dccNum(id)-1][isc];
1044  }
1045 
1046 }
1047 
1049  nEe_[0] = 0;
1050  nEeLI_[0] = 0;
1051  nEeHI_[0] = 0;
1052  nEe_[1] = 0;
1053  nEeLI_[1] = 0;
1054  nEeHI_[1] = 0;
1055  bzero(nPerDcc_, sizeof(nPerDcc_));
1056  bzero(nRuPerDcc_, sizeof(nRuPerDcc_));
1057  bzero(eeRuActive_, sizeof(eeRuActive_));
1058 
1059  for(int idcc=0; idcc<nECALDcc; idcc++) {
1060  for(int isc=0; isc<nDccChs; isc++) {
1061  nPerRu_[idcc][isc] = 0;
1062  }
1063  }
1064 
1065  for(int iz = 0; iz<2; iz++) {
1066  for(int ix = 0; ix < 20; ix++ ) {
1067  for(int iy = 0; iy < 20; iy++ ) {
1068  nCrySC[ix][iy][iz] = 0;
1069  }
1070  }
1071  }
1072 
1073  for (int itcc = 0; itcc < 108; itcc++) {
1074  for (int itt = 0; itt < 41; itt++) nCryTT[itcc][itt] = 0;
1075  }
1076 
1077 }
1078 
1079 const EcalScDetId
1081  if (xtalId.ix() > 40 && xtalId.ix() < 61 &&
1082  xtalId.iy() > 40 && xtalId.iy() < 61) {
1083  // crystal belongs to an inner partial supercrystal
1084  return Numbers::getEcalScDetId(xtalId);
1085  } else {
1086  return EcalScDetId((xtalId.ix()-1)/5+1, (xtalId.iy()-1)/5+1, xtalId.zside());
1087  }
1088 }
1089 
1090 unsigned EESelectiveReadoutTask::dccNum(const DetId& xtalId) const {
1091  int j;
1092  int k;
1093 
1094  if ( xtalId.det()!=DetId::Ecal ) {
1095  throw cms::Exception("EESelectiveReadoutTask") << "Crystal does not belong to ECAL";
1096  }
1097 
1098  int iDet = 0;
1099 
1100  if(xtalId.subdetId()==EcalEndcap){
1101  EEDetId eeDetId(xtalId);
1102  j = iXY2cIndex(eeDetId.ix());
1103  k = iXY2cIndex(eeDetId.iy());
1104  int zside = eeDetId.zside();
1105  if ( zside < 0 ) iDet = 0;
1106  else iDet = 2;
1107  } else {
1108  throw cms::Exception("EESelectiveReadoutTask") << "Not ECAL endcap.";
1109  }
1110  int iDcc0 = dccIndex(iDet,j,k);
1111  assert(iDcc0>=0 && iDcc0<nECALDcc);
1112  return iDcc0+1;
1113 }
1114 
1116  int j;
1117  int k;
1118 
1119  if ( scId.det()!=DetId::Ecal ) {
1120  throw cms::Exception("EESelectiveReadoutTask") << "SuperCrystal does not belong to ECAL";
1121  }
1122 
1123  int iDet = 0;
1124 
1125  if(scId.subdetId()==EcalEndcap){
1126  j = scId.ix()-1;
1127  k = scId.iy()-1;
1128  int zside = scId.zside();
1129  if ( zside < 0 ) iDet = 0;
1130  else iDet = 2;
1131  } else {
1132  throw cms::Exception("EESelectiveReadoutTask") << "Not ECAL endcap.";
1133  }
1134  int iDcc0 = 0;
1135  int iPhi = dccPhiIndexOfRU(j,k);
1136  if(iPhi<0) iDcc0 = -1;
1137  else iDcc0 = iPhi+iDet/2*45;
1138  assert(iDcc0>=0 && iDcc0<nECALDcc);
1139  return iDcc0+1;
1140 }
1141 
1142 double EESelectiveReadoutTask::getEeEventSize(double nReadXtals) const {
1143  double ruHeaderPayload = 0.;
1144  const int firstEbDcc0 = nEEDcc/2;
1145  for ( int iDcc0 = 0; iDcc0 < nECALDcc; ++iDcc0 ) {
1146  //skip barrel:
1147  if(iDcc0 == firstEbDcc0) iDcc0 += nEBDcc;
1148  ruHeaderPayload += nRuPerDcc_[iDcc0]*8.;
1149  }
1150  return getDccOverhead(EE)*nEEDcc +
1151  nReadXtals*bytesPerCrystal +
1152  ruHeaderPayload;
1153 }
1154 
1156  char flag=endcapDccMap[i+j*20];
1157  return (flag==' ')?-1:(flag-'0');
1158 }
1159 
1160 int EESelectiveReadoutTask::dccIndex(int iDet, int i, int j) const {
1161  int iPhi = dccPhiIndex(i, j);
1162  if(iPhi<0) return -1;
1163  //34 DCCs in barrel and 8 in EE-=>in EE+ DCC numbering starts at 45,
1164  //iDet/2 is 0 for EE- and 1 for EE+:
1165  return iPhi+iDet/2*45;
1166 }
1167 
1168 //This implementation assumes that int is coded on at least 28-bits,
1169 //which in pratice should be always true.
1170 int
1172  const std::vector<int>& firWeights,
1173  int firstFIRSample,
1174  bool* saturated){
1175  const int nFIRTaps = 6;
1176  //FIR filter weights:
1177  const std::vector<int>& w = firWeights;
1178 
1179  //accumulator used to compute weighted sum of samples
1180  int acc = 0;
1181  bool gain12saturated = false;
1182  const int gain12 = 0x01;
1183 
1184  int iWeight = 0;
1185  for(int i = -1; i < nFIRTaps - 1; ++i, ++iWeight){
1186  int iSample(firstFIRSample + i);
1187  if(iSample>=0 && iSample < frame.size()){
1188  EcalMGPASample sample(frame[iSample]);
1189  if(sample.gainId()!=gain12) gain12saturated = true;
1190  LogTrace("DccFir") << (iSample>=firstFIRSample?"+":"") << sample.adc()
1191  << "*(" << w[iWeight] << ")";
1192  acc+=sample.adc()*w[iWeight];
1193  } else{
1194  edm::LogWarning("DccFir") << __FILE__ << ":" << __LINE__ <<
1195  ": Not enough samples in data frame or 'ecalDccZs1stSample' module "
1196  "parameter is not valid...";
1197  }
1198  }
1199  LogTrace("DccFir") << "\n";
1200  //discards the 8 LSBs
1201  //(shift operator cannot be used on negative numbers because
1202  // the result depends on compilator implementation)
1203  acc = (acc>=0)?(acc >> 8):-(-acc >> 8);
1204  //ZS passed if weighted sum acc above ZS threshold or if
1205  //one sample has a lower gain than gain 12 (that is gain 12 output
1206  //is saturated)
1207 
1208  LogTrace("DccFir") << "acc: " << acc << "\n"
1209  << "saturated: " << (gain12saturated?"yes":"no") << "\n";
1210 
1211  if(saturated){
1212  *saturated = gain12saturated;
1213  }
1214 
1215  return gain12saturated?std::numeric_limits<int>::max():acc;
1216 }
1217 
1218 std::vector<int>
1219 EESelectiveReadoutTask::getFIRWeights(const std::vector<double>&
1220  normalizedWeights){
1221  const int nFIRTaps = 6;
1222  std::vector<int> firWeights(nFIRTaps, 0); //default weight: 0;
1223  const static int maxWeight = 0xEFF; //weights coded on 11+1 signed bits
1224  for(unsigned i=0; i < std::min((size_t)nFIRTaps,normalizedWeights.size()); ++i){
1225  firWeights[i] = lround(normalizedWeights[i] * (1<<10));
1226  if(std::abs(firWeights[i])>maxWeight){//overflow
1227  firWeights[i] = firWeights[i]<0?-maxWeight:maxWeight;
1228  }
1229  }
1230  return firWeights;
1231 }
1232 
1233 void
1234 EESelectiveReadoutTask::configFirWeights(const std::vector<double>& weightsForZsFIR){
1235  bool notNormalized = false;
1236  bool notInt = false;
1237  for(unsigned i=0; i < weightsForZsFIR.size(); ++i){
1238  if(weightsForZsFIR[i] > 1.) notNormalized = true;
1239  if((int)weightsForZsFIR[i]!=weightsForZsFIR[i]) notInt = true;
1240  }
1241  if(notInt && notNormalized){
1242  throw cms::Exception("InvalidParameter")
1243  << "weigtsForZsFIR paramater values are not valid: they "
1244  << "must either be integer and uses the hardware representation "
1245  << "of the weights or less or equal than 1 and used the normalized "
1246  << "representation.";
1247  }
1248  edm::LogInfo log("DccFir");
1249  if(notNormalized){
1250  firWeights_ = std::vector<int>(weightsForZsFIR.size());
1251  for(unsigned i = 0; i< weightsForZsFIR.size(); ++i){
1252  firWeights_[i] = (int)weightsForZsFIR[i];
1253  }
1254  } else{
1255  firWeights_ = getFIRWeights(weightsForZsFIR);
1256  }
1257 
1258  log << "Input weights for FIR: ";
1259  for(unsigned i = 0; i < weightsForZsFIR.size(); ++i){
1260  log << weightsForZsFIR[i] << "\t";
1261  }
1262 
1263  double s2 = 0.;
1264  log << "\nActual FIR weights: ";
1265  for(unsigned i = 0; i < firWeights_.size(); ++i){
1266  log << firWeights_[i] << "\t";
1267  s2 += firWeights_[i]*firWeights_[i];
1268  }
1269 
1270  s2 = sqrt(s2);
1271  log << "\nNormalized FIR weights after hw representation rounding: ";
1272  for(unsigned i = 0; i < firWeights_.size(); ++i){
1273  log << firWeights_[i] / (double)(1<<10) << "\t";
1274  }
1275 
1276  log <<"\nFirst FIR sample: " << firstFIRSample_;
1277 }
1278 
1279 int EESelectiveReadoutTask::getCrystalCount(int iDcc, int iDccCh) {
1280  if(iDcc<1 || iDcc>54) {
1281  // invalid DCC
1282  return 0;
1283  } else if (10 <= iDcc && iDcc <= 45) {
1284  // EB
1285  return 25;
1286  } else {
1287  // EE
1288  int iDccPhi;
1289  if(iDcc < 10) {
1290  iDccPhi = iDcc;
1291  } else {
1292  iDccPhi = iDcc - 45;
1293  }
1294  switch(iDccPhi*100+iDccCh){
1295  case 110:
1296  case 232:
1297  case 312:
1298  case 412:
1299  case 532:
1300  case 610:
1301  case 830:
1302  case 806:
1303  //inner partials at 12, 3, and 9 o'clock
1304  return 20;
1305  case 134:
1306  case 634:
1307  case 827:
1308  case 803:
1309  return 10;
1310  case 330:
1311  case 430:
1312  return 20;
1313  case 203:
1314  case 503:
1315  case 721:
1316  case 921:
1317  return 21;
1318  default:
1319  return 25;
1320  }
1321  }
1322 }
int nEvtFullReadout[20][20][2]
To store the events with full readout.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:223
int i
Definition: DBlmapReader.cc:9
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void setBinContent(int binx, double content)
set content of bin (1-D)
int ix() const
Definition: EEDetId.h:76
MonitorElement * EEFullReadoutSRFlagCount_[2]
EESelectiveReadoutTask(const edm::ParameterSet &ps)
Constructor.
MonitorElement * EEReadoutUnitForcedBitMap_[2]
double getDccOverhead(subdet_t subdet) const
MonitorElement * EELowInterestZsFIR_[2]
MonitorElement * EEDroppedFRCount_[2]
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void configFirWeights(const std::vector< double > &weightsForZsFIR)
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
MonitorElement * EETowerSize_[2]
edm::EDGetTokenT< EESrFlagCollection > EESRFlagCollection_
static const int SRF_ZS2
Definition: EcalSrFlag.h:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const self & getMap() const
Some &quot;id&quot; conversions.
static const int SRF_FORCED_MASK
Definition: EcalSrFlag.h:29
static const int nECALDcc
Constants.
int nEvtZSReadout[20][20][2]
To store the events with ZS1 or ZS2 readout.
std::vector< EcalDCCHeaderBlock >::const_iterator const_iterator
int getCrystalCount(int iDcc, int iDccCh)
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::vector< std::vector< float > > dccNormalizedWeights_
MonitorElement * EEZeroSuppression1SRFlagMap_[2]
MonitorElement * EEHighInterestZsFIR_[2]
int nEvtAnyInterest[100][100][2]
To store the events with any interest.
int nEvtDroppedReadoutIfFR[20][20][2]
To store the events with 0 channels readout when FR is requested.
int gainId() const
get the gainId (2 bits)
static const int nDccChs
maximum number of RUs read by a DCC
virtual ~EESelectiveReadoutTask()
Destructor.
MonitorElement * EECompleteZSMap_[2]
int nEvtCompleteReadoutIfZS[20][20][2]
To store the events with complete readout when ZS is requested.
static const char endcapDccMap[401]
int size() const
Definition: EcalDataFrame.h:26
MonitorElement * EETTFMismatch_[2]
int nPerRu_[nECALDcc][nDccChs]
MonitorElement * EEEventSize_[2]
tuple s2
Definition: indexGen.py:106
void Fill(long long x)
int nEvtLowInterest[100][100][2]
To store the events with low interest TT.
int dccIndex(int iDet, int i, int j) const
static std::vector< DetId > * crystals(const EcalTrigTowerDetId &id)
Definition: Numbers.cc:582
MonitorElement * EEHighInterestPayload_[2]
MonitorElement * EEHighInterestTriggerTowerFlagMap_[2]
uint16_t getStatusCode() const
double getEeEventSize(double nReadXtals) const
static unsigned iTCC(const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2)
Definition: Numbers.cc:531
const T & max(const T &a, const T &b)
int ix() const
Definition: EcalScDetId.h:71
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
static unsigned iSC(const EcalScDetId &id)
Definition: Numbers.cc:434
T sqrt(T t)
Definition: SSEVec.h:48
void removeElement(const std::string &name)
Definition: DQMStore.cc:2772
int zside() const
Definition: EEDetId.h:70
static const int SRF_FULL
Definition: EcalSrFlag.h:24
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
MonitorElement * EEDccEventSizeMap_
int iy() const
Definition: EEDetId.h:82
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1186
bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge]
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcalTrigPrimDigiCollection_
void anaDigi(const EEDataFrame &frame, const EESrFlagCollection &srFlagColl, uint16_t statusCode)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define LogTrace(id)
int iy() const
Definition: EcalScDetId.h:77
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
static const int SRF_ZS1
Definition: EcalSrFlag.h:18
key_type id() const
Definition: EEDataFrame.h:28
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
int nEvtRUForced[20][20][2]
To store the events with RU forced.
int k[5][pyjets_maxn]
edm::EDGetTokenT< FEDRawDataCollection > FEDRawDataCollection_
const_iterator end() const
MonitorElement * EETTFlags_[2]
Definition: DetId.h:18
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:47
int dccPhiIndexOfRU(int i, int j) const
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: ESHandle.h:62
int zside() const
Definition: EcalScDetId.h:65
unsigned dccNum(const DetId &xtalId) const
int nEvtMediumInterest[100][100][2]
To store the events with medium interest TT.
void beginJob(void)
BeginJob.
int nEvtZS1Readout[20][20][2]
To store the events with ZS1 readout.
int nEvtHighInterest[100][100][2]
To store the events with high interest TT.
int nCrySC[20][20][2]
To store the readout crystals / SC.
const EcalSRSettings * settings_
unsigned dccNumOfRU(const EcalScDetId &scId) const
std::vector< int > firWeights_
iterator find(key_type k)
#define begin
Definition: vmac.h:30
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:243
MonitorElement * EECompleteZSCount_[2]
const_iterator find(uint32_t rawId) const
MonitorElement * EEDroppedFRMap_[2]
const_iterator end() const
static std::vector< int > getFIRWeights(const std::vector< double > &normalizedWeights)
static const EcalScDetId getEcalScDetId(const EEDetId &id)
Definition: Numbers.cc:676
T w() const
int nEvtAnyReadout[20][20][2]
To store the events with any readout.
MonitorElement * EELowInterestPayload_[2]
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:142
edm::EDGetTokenT< EEDigiCollection > EEDigiCollection_
const EcalScDetId readOutUnitOf(const EEDetId &xtalId) const
tuple status
Definition: ntuplemaker.py:245
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
MonitorElement * EELowInterestTriggerTowerFlagMap_[2]
static const int scEdge
Number of crystals along a supercrystal edge.
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
int dccPhiIndex(int i, int j) const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
static const int bytesPerCrystal
Number of bytes per crystal.
MonitorElement * EEMediumInterestTriggerTowerFlagMap_[2]
tuple size
Write out results.
static int dccZsFIR(const EcalDataFrame &frame, const std::vector< int > &firWeights, int firstFIRSample, bool *saturated=0)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
static unsigned iTT(const unsigned ism, const EcalSubdetector subdet, const unsigned i1, const unsigned i2)
Definition: Numbers.cc:482
Definition: Run.h:41
int adc() const
get the ADC sample (12 bits)
MonitorElement * EEFullReadoutSRFlagMap_[2]
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:1330