CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalSimRawData.cc
Go to the documentation of this file.
8 
9 #include <memory>
10 
11 #include <fstream> //used for debugging
12 #include <iostream>
13 #include <iomanip>
14 #include <cmath>
17 
18 using namespace std;
19 using namespace edm;
20 
21 const int EcalSimRawData::ttType[nEbTtEta] = {
22  0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1, //EE-
23  0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1//EE+
24 };
25 
26 const int EcalSimRawData::stripCh2Phi[nTtTypes][ttEdge][ttEdge] = {
27  //TT type 0:
28  /*ch-->*/
29  {{4,3,2,1,0}, /*strip*/
30  {0,1,2,3,4}, /*|*/
31  {4,3,2,1,0}, /*|*/
32  {0,1,2,3,4}, /*|*/
33  {4,3,2,1,0}},/*V*/
34  //TT type 1:
35  {{0,1,2,3,4},
36  {4,3,2,1,0},
37  {0,1,2,3,4},
38  {4,3,2,1,0},
39  {0,1,2,3,4}}
40 };
41 
42 const int EcalSimRawData::strip2Eta[nTtTypes][ttEdge] = {
43  {4,3,2,1,0}, //TT type 0
44  {0,1,2,3,4} //TT type 1
45 };
46 
48  //sets up parameters:
49  digiProducer_ = params.getParameter<string>("unsuppressedDigiProducer");
50  ebDigiCollection_ = params.getParameter<std::string>("EBdigiCollection");
51  eeDigiCollection_ = params.getParameter<std::string>("EEdigiCollection");
52  srDigiProducer_ = params.getParameter<string>("srProducer");
53  ebSrFlagCollection_ = params.getParameter<std::string>("EBSrFlagCollection");
54  eeSrFlagCollection_ = params.getParameter<std::string>("EESrFlagCollection");
55  tpDigiCollection_
56  = params.getParameter<std::string>("trigPrimDigiCollection");
57  tcpDigiCollection_ = params.getParameter<std::string>("tcpDigiCollection");
58  tpProducer_ = params.getParameter<string>("trigPrimProducer");
59  xtalVerbose_ = params.getUntrackedParameter<bool>("xtalVerbose", false);
60  tpVerbose_ = params.getUntrackedParameter<bool>("tpVerbose", false);
61  tcc2dcc_ = params.getUntrackedParameter<bool>("tcc2dccData", true);
62  srp2dcc_ = params.getUntrackedParameter<bool>("srp2dccData", true);
63  fe2dcc_ = params.getUntrackedParameter<bool>("fe2dccData", true);
64  fe2tcc_ = params.getUntrackedParameter<bool>("fe2tccData", true);
65  dccNum_ = params.getUntrackedParameter<int>("dccNum", -1);
66  tccNum_ = params.getUntrackedParameter<int>("tccNum", -1);
67  tccInDefaultVal_ = params.getUntrackedParameter<int>("tccInDefaultVal", 0xffff);
68  basename_ = params.getUntrackedParameter<std::string>("outputBaseName");
69 
70  iEvent = 0;
71 
72  string writeMode = params.getParameter<string>("writeMode");
73 
74  if(writeMode==string("littleEndian")){
75  writeMode_ = littleEndian;
76  } else if(writeMode==string("bigEndian")){
77  writeMode_ = bigEndian;
78  } else{
79  writeMode_ = ascii;
80  }
81 }
82 
83 void
85  const edm::EventSetup& es){
86  //Event counter:
87  ++iEvent;
88 
89  if(xtalVerbose_ | tpVerbose_){
90  cout << "======================================================================\n"
91  << " Event " << iEvent << "\n"
92  << "----------------------------------------------------------------------\n";
93  }
94 
95  if(fe2dcc_){
96  vector<uint16_t> adc[nEbEta][nEbPhi];
97  getEbDigi(event, adc);
98  genFeData(basename_, iEvent, adc);
99  }
100 
101  if(fe2tcc_){
102  int tcp[nTtEta][nTtPhi]={{0}};
103  getTp(event, tcpDigiCollection_, tcp);
104  genTccIn(basename_, iEvent, tcp);
105  }
106 
107  if(tcc2dcc_){
108  int tp[nTtEta][nTtPhi]={{0}};
109  getTp(event, tpDigiCollection_, tp);
110  genTccOut(basename_, iEvent, tp);
111  }
112 
113  //SR flags:
114  int ebSrf[nTtEta][nTtPhi];
115  int eeSrf[nEndcaps][nScX][nScY];
116 
117  if(srp2dcc_){
118  getSrfs(event, ebSrf, eeSrf);
119  genSrData(basename_, iEvent, ebSrf);
120  }
121 
122 }
123 
124 void EcalSimRawData::elec2GeomNum(int ittEta0, int ittPhi0, int strip1,
125  int ch1, int& iEta0, int& iPhi0) const{
126  assert(0<=ittEta0 && ittEta0<nEbTtEta);
127  assert(0<=ittPhi0 && ittPhi0<nTtPhi);
128  assert(1<=strip1&& strip1<=ttEdge);
129  assert(1<=ch1 && ch1<=ttEdge);
130  const int type = ttType[ittEta0];
131  iEta0 = ittEta0*ttEdge + strip2Eta[type][strip1-1];
132  iPhi0 = ittPhi0*ttEdge + stripCh2Phi[type][strip1-1][ch1-1];
133  assert(0<=iEta0 && iEta0<nEbEta);
134  assert(0<=iPhi0 && iPhi0<nEbPhi);
135 }
136 
137 void EcalSimRawData::fwrite(ofstream& f, uint16_t data,
138  int& iWord, bool hpar) const{
139 
140  if(hpar){
141  //set horizontal odd parity bit:
142  setHParity(data);
143  }
144 
145  switch(writeMode_){
146  case littleEndian:
147  {
148  char c = data & 0x00FF;
149  f.write(&c, sizeof(c));
150  c = (data >>8) & 0x00FF;
151  f.write(&c, sizeof(c));
152  }
153  break;
154  case bigEndian:
155  {
156  char c = (data >>8) & 0x00FF;
157  f.write(&c, sizeof(c));
158  c = data & 0x00FF;
159  f.write(&c, sizeof(c));
160  }
161  break;
162  case ascii:
163  f << ((iWord%8==0&&iWord!=0)?"\n":"")
164  << "0x" << setfill('0') << setw(4) << hex << data << "\t"
165  << dec << setfill(' ');
166  break;
167  }
168  ++iWord;
169 }
170 
171 string EcalSimRawData::getExt() const{
172  switch(writeMode_){
173  case littleEndian:
174  return ".le";
175  case bigEndian:
176  return ".be";
177  case ascii:
178  return ".txt";
179  default:
180  return".?";
181  }
182 }
183 
184 void EcalSimRawData::genFeData(string basename, int iEvent,
185  const vector<uint16_t> adcCount[nEbEta][nEbPhi]
186  ) const{
187  int smf = 0;
188  int gmf = 0;
189  int nPendingEvt = 0;
190  int monitorFlag = 0;
191  int chFrameLen = adcCount[0][0].size() + 1;
192 
193  int iWord = 0;
194 
195  for(int iZ0 = 0; iZ0<2; ++iZ0){
196  for(int iDccPhi0 = 0; iDccPhi0<nDccInPhi; ++iDccPhi0){
197  int iDcc1 = iDccPhi0 + iZ0*nDccInPhi + nDccEndcap + 1;
198 
199  if(dccNum_!=-1 && dccNum_!=iDcc1) continue;
200 
201  stringstream s;
202  s.str("");
203  const string& ext = getExt();
204  s << basename << "_fe2dcc" << setfill('0') << setw(2) << iDcc1
205  << setfill(' ') << ext;
206  ofstream f(s.str().c_str(), (iEvent==1?ios::ate:ios::app));
207 
208  if(f.fail()) return;
209 
210 
211  if(writeMode_==ascii){
212  f << (iEvent==1?"":"\n") << "[Event:" << iEvent << "]\n";
213  }
214 
215  for(int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0){
216  int iTtEta0 = iZ0*nTtSmEta + iTtEtaInSm0;
217  for(int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0){
218  //phi=0deg at middle of 1st barrel DCC:
219  int iTtPhi0 = -nTtPhisPerEbDcc/2 + iDccPhi0*nTtPhisPerEbDcc
220  + iTtPhiInSm0;
221  if(iTtPhi0<0) iTtPhi0 += nTtPhi;
222  for(int stripId1 = 1; stripId1 <= ttEdge; ++stripId1){
223  uint16_t stripHeader =
224  0xF << 11
225  | (nPendingEvt & 0x3F) << 5
226  | (gmf & 0x1) << 4
227  | (smf & 0x1) << 3
228  | (stripId1 & 0x7);
230  fwrite(f,stripHeader, iWord);
231 
232  for(int xtalId1 = 1; xtalId1 <= ttEdge; ++xtalId1){
233 
234  uint16_t crystalHeader =
235  1 <<14
236  | (chFrameLen & 0xFF) <<4
237  | (monitorFlag & 0x1) <<3
238  | (xtalId1 & 0x7);
239  // crystalHeader |=parity(crystalHeader) << 15;
240  fwrite(f, crystalHeader, iWord);
241 
242  int iEta0;
243  int iPhi0;
244  elec2GeomNum(iTtEta0, iTtPhi0, stripId1, xtalId1,
245  iEta0, iPhi0);
246  if(xtalVerbose_){
247  cout << dec
248  << "iDcc1 = " << iDcc1 << "\t"
249  << "iEbTtEta0 = " << iTtEta0 << "\t"
250  << "iEbTtPhi0 = " << iTtPhi0 << "\t"
251  << "stripId1 = " << stripId1 << "\t"
252  << "xtalId1 = " << xtalId1 << "\t"
253  << "iEta0 = " << iEta0 << "\t"
254  << "iPhi0 = " << iPhi0 << "\t"
255  << "adc[5] = 0x" << hex << adcCount[iEta0][iPhi0][5]
256  << dec << "\n";
257  }
258 
259 
260  const vector<uint16_t>& adc = adcCount[iEta0][iPhi0];
261  for(unsigned iSample=0; iSample < adc.size(); ++iSample){
262  uint16_t data = adc[iSample] & 0x3FFF;
263  // data |= parity(data);
264  fwrite(f, data, iWord);
265  } //next time sample
266  } //next crystal in strip
267  } //next strip in TT
268  } //next TT along phi
269  } //next TT along eta
270  } //next DCC
271  } //next half-barrel
272 }
273 
274 void EcalSimRawData::genSrData(string basename, int iEvent,
275  int srf[nEbTtEta][nTtPhi]) const{
276  for(int iZ0 = 0; iZ0<2; ++iZ0){
277  for(int iDccPhi0 = 0; iDccPhi0<nDccInPhi; ++iDccPhi0){
278  int iDcc1 = iDccPhi0 + iZ0*nDccInPhi + nDccEndcap + 1;
279  if(dccNum_!=-1 && dccNum_!=iDcc1) continue;
280  stringstream s;
281  s.str("");
282  s << basename << "_ab2dcc" << setfill('0') << setw(2) << iDcc1
283  << setfill(' ') << getExt();
284  ofstream f(s.str().c_str(), (iEvent==1?ios::ate:ios::app));
285 
286  if(f.fail()) throw cms::Exception(string("Cannot create/open file ")
287  + s.str() + ".");
288 
289  int iWord = 0;
290 
291  if(writeMode_==ascii){
292  f << (iEvent==1?"":"\n")<< "[Event:" << iEvent << "]\n";
293  }
294 
295  const uint16_t le1 = 0;
296  const uint16_t le0 = 0;
297  const uint16_t h1 = 1;
298  const uint16_t nFlags = 68;
299  uint16_t data = (h1 & 0x1)<< 14
300  | (le1 & 0x1) << 12
301  | (le0 & 0x1) << 11
302  | (nFlags & 0x7F);
303 
304  fwrite(f, data, iWord, true);
305 
306  int iFlag = 0;
307  data = 0;
308 
309  for(int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0){
310  // int iTtEbEta0 = iZ0*nTtSmEta + iTtEtaInSm0;
311  int iTtEta0 = nEeTtEta + iZ0*nTtSmEta + iTtEtaInSm0;
312  for(int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0){
313  //phi=0deg at middle of 1st barrel DCC:
314  int iTtPhi0 = -nTtPhisPerEbDcc/2 + iDccPhi0*nTtPhisPerEbDcc
315  + iTtPhiInSm0;
316  if(iTtPhi0<0) iTtPhi0 += nTtPhi;
317  //flags are packed by four:
318  //|15 |14 |13-12 |11 9|8 6|5 3|2 0|
319  //| P | 0 | X X | srf i+3| srf i+2| srf i+1| srf i |
320  //| | | | field 3 |field 2 | field 1| field 0|
321  const int field = iFlag%4;
322  //cout << "TtEta0: " << iTtEta0 << "\tTtPhi0: " << iTtPhi0 << "\n";
323  //cout << "#" << oct << (int)srf[iTtEta0][iTtPhi0] << "o ****> #" << oct << (srf[iTtEta0][iTtPhi0] << (field*3)) << "o\n" << dec;
324 
325  data |= srf[iTtEta0][iTtPhi0] << (field*3);
326 
327  if(field==3){
328  //cout << srf[iTtEta0][iTtPhi0] << "----> 0x" << hex << data << "\n";
329  fwrite(f, data, iWord, true);
330  data = 0;
331  }
332  ++iFlag;
333  } //next TT along phi
334  } //next TT along eta
335  } //next DCC
336  } //next half-barrel
337 }
338 
339 
340 void EcalSimRawData::genTccIn(string basename, int iEvent,
341  const int tcp[nTtEta][nTtPhi]) const{
342  for(int iZ0 = 0; iZ0<2; ++iZ0){
343  for(int iTccPhi0 = 0; iTccPhi0<nTccInPhi; ++iTccPhi0){
344  int iTcc1 = iTccPhi0 + iZ0*nTccInPhi + nTccEndcap + 1;
345 
346  if(tccNum_!=-1 && tccNum_!=iTcc1) continue;
347 
348  stringstream s;
349  s.str("");
350  const char* ext = ".txt"; //only ascii mode supported for TCP
351 
352  s << basename << "_tcc" << setfill('0') << setw(2) << iTcc1
353  << setfill(' ') << ext;
354  ofstream fe2tcc(s.str().c_str(), (iEvent==1?ios::ate:ios::app));
355 
356  if(fe2tcc.fail()) throw cms::Exception(string("Failed to create file ")
357  + s.str() + ".");
358 
359  int memPos = iEvent-1;
360  int iCh1 = 1;
361  for(int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0){
362  int iTtEta0 = (iZ0==0) ? 27 - iTtEtaInSm0 : 28 + iTtEtaInSm0;
363  for(int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0){
364  //phi=0deg at middle of 1st barrel DCC:
365  int iTtPhi0 = -nTtPhisPerEbTcc/2 + iTccPhi0*nTtPhisPerEbTcc
366  + iTtPhiInSm0;
367  iTtPhi0 += nTtPhisPerEbTcc*iTccPhi0;
368  if(iTtPhi0<0) iTtPhi0 += nTtPhi;
369  uint16_t tp_fe2tcc = (tcp[iTtEta0][iTtPhi0] & 0x7ff) ; //keep only Et (9:0) and FineGrain (10)
370 
371  if(tpVerbose_ && tp_fe2tcc!=0){
372  cout << dec
373  << "iTcc1 = " << iTcc1 << "\t"
374  << "iTtEta0 = " << iTtEta0 << "\t"
375  << "iTtPhi0 = " << iTtPhi0 << "\t"
376  << "iCh1 = " << iCh1 << "\t"
377  << "memPos = " << memPos << "\t"
378  << "tp = 0x" << setfill('0') << hex << setw(3)
379  << tp_fe2tcc
380  << dec << setfill(' ') << "\n";
381  }
382  fe2tcc << iCh1 << "\t"
383  << memPos << "\t"
384  << setfill('0') << hex
385  << "0x" << setw(4) << tp_fe2tcc << "\t"
386  << "0"
387  << dec << setfill(' ') << "\n";
388  ++iCh1;
389  } //next TT along phi
390  } //next TT along eta
391  fe2tcc << std::flush;
392  fe2tcc.close();
393  } //next TCC
394  } //next half-barrel
395 }
396 
397 
398 void EcalSimRawData::genTccOut(string basename, int iEvent,
399  const int tps[nTtEta][nTtPhi]) const{
400  int iDccWord = 0;
401 
402  for(int iZ0 = 0; iZ0<2; ++iZ0){
403  for(int iTccPhi0 = 0; iTccPhi0<nTccInPhi; ++iTccPhi0){
404  int iTcc1 = iTccPhi0 + iZ0*nTccInPhi + nTccEndcap + 1;
405 
406  if(tccNum_!=-1 && tccNum_!=iTcc1) continue;
407 
408  stringstream s;
409  s.str("");
410  const char* ext = ".txt"; //only ascii mode supported for TCP
411 
412  s << basename << "_tcc" << setfill('0') << setw(2) << iTcc1
413  << setfill(' ') << ext;
414 
415  s.str("");
416  s << basename << "_tcc2dcc" << setfill('0') << setw(2) << iTcc1
417  << setfill(' ') << getExt();
418  ofstream dccF(s.str().c_str(), (iEvent==1?ios::ate:ios::app));
419 
420  if(dccF.fail()){
421  cout << "Warning: failed to create or open file " << s.str() << ".\n";
422  return;
423  }
424 
425  const uint16_t h1 = 1;
426  const uint16_t le1 = 0;
427  const uint16_t le0 = 0;
428  const uint16_t nSamples = 1;
429  const uint16_t nTts = 68;
430  const uint16_t data = (h1 & 0x1) << 14
431  | (le1 & 0x1) << 12
432  | (le0 & 0x1) << 11
433  | (nSamples & 0xF) << 7
434  | (nTts & 0x7F);
435  dccF << (iEvent==1?"":"\n") << "[Event:" << iEvent << "]\n";
436  fwrite(dccF, data, iDccWord, false);
437 
438  int memPos = iEvent-1;
439  int iCh1 = 1;
440  for(int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0){
441  int iTtEta0 = nEeTtEta + iZ0*nTtSmEta + iTtEtaInSm0;
442  for(int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0){
443  //phi=0deg at middle of 1st barrel DCC:
444  int iTtPhi0 = -nTtPhisPerEbTcc/2 + iTccPhi0*nTtPhisPerEbTcc
445  + iTtPhiInSm0;
446  if(iTtPhi0<0) iTtPhi0 += nTtPhi;
447 
448  if(tpVerbose_){
449  cout << dec
450  << "iTcc1 = " << iTcc1 << "\t"
451  << "iTtEta0 = " << iTtEta0 << "\t"
452  << "iTtPhi0 = " << iTtPhi0 << "\t"
453  << "iCh1 = " << iCh1 << "\t"
454  << "memPos = " << memPos << "\t"
455  << "tp = 0x" << hex << tps[iTtEta0][iTtPhi0]
456  << dec << "\n";
457  }
458  fwrite(dccF, tps[iTtEta0][iTtPhi0], iDccWord, false);
459  ++iCh1;
460  } //next TT along phi
461  } //next TT along eta
462  } //next TCC
463  } //next half-barrel
464 }
465 
466 
467 void EcalSimRawData::setHParity(uint16_t& a) const{
468  const int odd = 1 <<15;
469  const int even = 0;
470  //parity bit of numbers from 0x0 to 0xF:
471  // 0 1 2 3 4 5 6 7 8 9 A B C D E F
472  const int p[16] = {even,odd,odd,even,odd,even,even,odd,odd,even,even,odd,even,odd,odd,even};
473  //inverts parity bit (LSB) of 'a' in case of even parity:
474  a ^= p[a&0xF] ^ p[(a>>4)&0xF] ^ p[(a>>8)&0xF] ^ p[a>>12&0xF] ^ odd;
475 }
476 
478  int ebSrf[nTtEta][nTtPhi],
479  int eeSrf[nEndcaps][nScX][nScY]) const{
480 
481  //EE
483  event.getByLabel(srDigiProducer_, eeSrFlagCollection_, hEeSrFlags);
484  for(size_t i=0; i < (nEndcaps*nScX*nScY); ((int*)eeSrf)[i++] = -1){};
485  if(hEeSrFlags.isValid()){
486  for(EESrFlagCollection::const_iterator it = hEeSrFlags->begin();
487  it != hEeSrFlags->end(); ++it){
488  const EESrFlag& flag = *it;
489  int iZ0 = flag.id().zside()>0?1:0;
490  int iX0 = flag.id().ix()-1;
491  int iY0 = flag.id().iy()-1;
492  assert(iZ0>=0 && iZ0<nEndcaps);
493  assert(iX0>=0 && iX0<nScX);
494  assert(iY0>=0 && iY0<nScY);
495  eeSrf[iZ0][iX0][iY0] = flag.value();
496  }
497  } else{
498  LogWarning("EcalSimRawData") << "EE SR flag not found ("
499  << "Product label: " << srDigiProducer_
500  << "Producet instance: "
501  << eeSrFlagCollection_ << ")";
502  }
503 
504  //EB
506  event.getByLabel(srDigiProducer_, ebSrFlagCollection_, hEbSrFlags);
507  for(size_t i=0; i<(nTtEta*nTtPhi); ((int*)ebSrf)[i++] = -1){};
508  if(hEbSrFlags.isValid()){
509  for(EBSrFlagCollection::const_iterator it = hEbSrFlags->begin();
510  it != hEbSrFlags->end(); ++it){
511 
512  const EBSrFlag& flag = *it;
513  int iEta = flag.id().ieta();
514  int iEta0 = iEta + nTtEta/2 - (iEta>=0?1:0); //0->55 from eta=-3 to eta=3
515  int iEbEta0 = iEta0 - nEeTtEta;//0->33 from eta=-1.48 to eta=1.48
516  int iPhi0 = flag.id().iphi() - 1;
517 
518  assert(iEbEta0>=0 && iEbEta0<nEbTtEta);
519  assert(iPhi0>=0 && iPhi0<nTtPhi);
520 
521  ebSrf[iEbEta0][iPhi0] = flag.value();
522  }
523  } else{
524  LogWarning("EcalSimRawData") << "EB SR flag not found ("
525  << "Product label: " << srDigiProducer_
526  << "Producet instance: "
527  << ebSrFlagCollection_ << ")";
528  }
529 }
530 
532  vector<uint16_t> adc[nEbEta][nEbPhi]) const{
533 
535  event.getByLabel(digiProducer_, ebDigiCollection_, hEbDigis);
536 
537  int nSamples = 0;
538  if(hEbDigis.isValid() && hEbDigis->size()>0){//there is at least one digi
539  nSamples = hEbDigis->begin()->size();//gets the sample count from 1st digi
540  }
541 
542 
543  const uint16_t suppressed = 0xFFFF;
544 
545  adc[0][0] = vector<uint16_t>(nSamples, suppressed);
546 
547  for(int iEbEta=0; iEbEta<nEbEta; ++iEbEta){
548  for(int iEbPhi=0; iEbPhi<nEbPhi; ++iEbPhi){
549  adc[iEbEta][iEbPhi] = adc[0][0];
550  }
551  }
552  if(hEbDigis.isValid()){
553  if(xtalVerbose_) cout << setfill('0');
554  for(EBDigiCollection::const_iterator it = hEbDigis->begin();
555  it != hEbDigis->end(); ++it){
556  const EBDataFrame& frame = *it;
557 
558  int iEta0 = iEta2cIndex((frame.id()).ieta());
559  int iPhi0 = iPhi2cIndex((frame.id()).iphi());
560 
561  // cout << "xtl indices conv: (" << frame.id().ieta() << ","
562  // << frame.id().iphi() << ") -> ("
563  // << iEta0 << "," << iPhi0 << ")\n";
564 
565  if(iEta0<0 || iEta0>=nEbEta){
566  cout << "iEta0 (= " << iEta0 << ") is out of range ("
567  << "[0," << nEbEta -1 << "])\n";
568  }
569  if(iPhi0<0 || iPhi0>=nEbPhi){
570  cout << "iPhi0 (= " << iPhi0 << ") is out of range ("
571  << "[0," << nEbPhi -1 << "])\n";
572  }
573 
574  if(xtalVerbose_){
575  cout << iEta0 << "\t" << iPhi0 << ":\t";
576  cout << hex;
577  }
578 
579  if(nSamples!=frame.size()){
580  throw cms::Exception("EcalSimRawData", "Found EB digis with different sample count! This is not supported by EcalSimRawData.");
581  }
582 
583  for(int iSample=0; iSample<nSamples; ++iSample){
584  const EcalMGPASample& sample = frame.sample(iSample);
585  uint16_t encodedAdc = sample.raw();
586  adc[iEta0][iPhi0][iSample] = encodedAdc;
587  if(xtalVerbose_){
588  cout << (iSample>0?" ":"") << "0x" << setw(4)
589  << encodedAdc;
590  }
591  }
592  if(xtalVerbose_) cout << "\n" << dec;
593  }
594  if(xtalVerbose_) cout << setfill(' ');
595  }
596 }
597 
598 
600  const std::string& collName,
601  int tcp[nTtEta][nTtPhi]) const{
603  event.getByLabel(tpProducer_, collName, hTpDigis);
604  if(hTpDigis.isValid() && hTpDigis->size()>0){
605  const EcalTrigPrimDigiCollection& tpDigis = *hTpDigis.product();
606 
607  // EcalSelectiveReadout::ttFlag_t ttf[nTtEta][nTtPhi];
608  for(int iTtEta0=0; iTtEta0 < nTtEta; ++iTtEta0){
609  for(int iTtPhi0=0; iTtPhi0 < nTtPhi; ++iTtPhi0){
610  tcp[iTtEta0][iTtPhi0] = tccInDefaultVal_ ;
611  }
612  }
613  if(tpVerbose_){
614  cout << setfill('0');
615  }
617  it != tpDigis.end(); ++it){
618  const EcalTriggerPrimitiveDigi& tp = *it;
619  int iTtEta0 = iTtEta2cIndex(tp.id().ieta());
620  int iTtPhi0 = iTtPhi2cIndex(tp.id().iphi());
621  if(iTtEta0<0 || iTtEta0>=nTtEta){
622  cout << "iTtEta0 (= " << iTtEta0 << ") is out of range ("
623  << "[0," << nEbTtEta -1 << "])\n";
624  }
625  if(iTtPhi0<0 || iTtPhi0>=nTtPhi){
626  cout << "iTtPhi0 (= " << iTtPhi0 << ") is out of range ("
627  << "[0," << nTtPhi -1 << "])\n";
628  }
629 
630  tcp[iTtEta0][iTtPhi0] = tp[tp.sampleOfInterest()].raw();
631 
632  if(tpVerbose_){
633  if(tcp[iTtEta0][iTtPhi0]!=0) //print non-zero values only
634  cout << collName << (collName.size()==0?"":" ")
635  << "TP(" << setw(2) << iTtEta0 << "," << iTtPhi0 << ") = "
636  << "0x" << setw(4)
637  << tcp[iTtEta0][iTtPhi0]
638  << "\tcmssw indices: "
639  << tp.id().ieta() << " " << tp.id().iphi() << "\n";
640  }
641  }//next TP
642  if(tpVerbose_) cout << setfill(' ');
643  }
644 }
int adc(sample_type sample)
get the ADC sample (12 bits)
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
int value() const
Definition: EcalSrFlag.h:44
key_type id() const
Definition: EBDataFrame.h:31
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
assert(m_qm.get())
std::vector< EESrFlag >::const_iterator const_iterator
virtual void analyze(const edm::Event &, const edm::EventSetup &)
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
void getTp(const edm::Event &event, const std::string &collName, int tp[nTtEta][nTtPhi]) const
uint16_t raw() const
get the raw word
std::string getExt() const
int size() const
Definition: EcalDataFrame.h:26
void setHParity(uint16_t &a) const
int ieta() const
get the tower ieta
int iEvent
Definition: GenABIO.cc:230
static const int strip2Eta[nTtTypes][ttEdge]
void genFeData(std::string basename, int iEvent, const std::vector< uint16_t > adcCount[nEbEta][nEbPhi]) const
int ix() const
Definition: EcalScDetId.h:71
void getSrfs(const edm::Event &event, int ebSrf[nTtEta][nTtPhi], int eeSrf[nEndcaps][nScX][nScY]) const
double f[11][100]
EcalSimRawData(const edm::ParameterSet &pset)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
constexpr size_t nSamples
int iy() const
Definition: EcalScDetId.h:77
void fwrite(std::ofstream &f, uint16_t data, int &iword, bool hpar=true) const
void genTccOut(std::string basename, int iEvent, const int tps[nTtEta][nTtPhi]) const
const_iterator end() const
int iphi() const
get the tower iphi
static const int nEndcaps
Definition: GenABIO.cc:126
void genSrData(std::string basename, int iEvent, int ttf[nEbTtEta][nTtPhi]) const
const EcalTrigTowerDetId & id() const
T const * product() const
Definition: Handle.h:81
const EcalScDetId & id() const
Definition: EESrFlag.h:37
void getEbDigi(const edm::Event &event, std::vector< uint16_t > adc[nEbEta][nEbPhi]) const
int zside() const
Definition: EcalScDetId.h:65
void genTccIn(std::string basename, int iEvent, const int tps[nTtEta][nTtPhi]) const
const EcalTrigTowerDetId & id() const
Definition: EBSrFlag.h:36
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:145
static const int stripCh2Phi[nTtTypes][ttEdge][ttEdge]
int sampleOfInterest() const
Gets the interesting sample.
void elec2GeomNum(int ittEta0, int ittPhi0, int strip1, int ch1, int &iEta0, int &iPhi0) const
const_iterator begin() const
static const int ttType[nEbTtEta]