CMS 3D CMS Logo

EcalTrigPrimESProducer.cc
Go to the documentation of this file.
1 // user include files
3 
4 #include <TMath.h>
5 #include <fstream>
6 #include <iostream>
7 #include <sstream>
8 
10 
11 //
12 // input stream from a gz file
13 //
14 
15 struct GzInputStream {
16  gzFile gzf;
17  char buffer[256];
18  std::istringstream iss;
19  bool eof;
20  GzInputStream(const char *file) : eof(false) {
21  gzf = gzopen(file, "rb");
22  if (gzf == Z_NULL) {
23  eof = true;
24  edm::LogWarning("EcalTPG") << "Database file " << file << " not found!!!";
25  } else
26  readLine();
27  }
28  void readLine() {
29  char *res = gzgets(gzf, buffer, 256);
30  eof = (res == Z_NULL);
31  if (!eof) {
32  iss.clear();
33  iss.str(buffer);
34  const auto content = iss.str();
35  std::size_t found = content.find("COMMENT");
36  if (found != std::string::npos) {
37  iss.str("");
38  }
39  }
40  }
41  ~GzInputStream() { gzclose(gzf); }
42  explicit operator bool() const { return ((eof == true) ? false : !iss.fail()); }
43 };
44 
45 template <typename T>
47  while ((bool)gis && !(gis.iss >> var)) {
48  gis.readLine();
49  }
50  return gis;
51 }
52 
53 //
54 // constructors and destructor
55 //
56 
58  : dbFilename_(iConfig.getUntrackedParameter<std::string>("DatabaseFile", "")),
59  flagPrint_(iConfig.getParameter<bool>("WriteInFile")) {
60  // the following line is needed to tell the framework what
61  // data is being produced
81  // now do what ever other initialization is needed
82  //init TPmode
83  tpMode_ = std::vector<uint32_t>(18, 0);
84 }
85 
87 
88 //
89 // member functions
90 //
91 
92 // ------------ method called to produce the data ------------
93 
94 std::unique_ptr<EcalTPGPedestals> EcalTrigPrimESProducer::producePedestals(const EcalTPGPedestalsRcd &iRecord) {
95  auto prod = std::make_unique<EcalTPGPedestals>();
96  parseTextFile();
97  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
98  for (it = mapXtal_.begin(); it != mapXtal_.end(); it++) {
100  item.mean_x12 = (it->second)[0];
101  item.mean_x6 = (it->second)[3];
102  item.mean_x1 = (it->second)[6];
103  prod->setValue(it->first, item);
104  }
105  return prod;
106 }
107 
108 std::unique_ptr<EcalTPGLinearizationConst> EcalTrigPrimESProducer::produceLinearizationConst(
109  const EcalTPGLinearizationConstRcd &iRecord) {
110  auto prod = std::make_unique<EcalTPGLinearizationConst>();
111  parseTextFile();
112  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
113  for (it = mapXtal_.begin(); it != mapXtal_.end(); it++) {
115  item.mult_x12 = (it->second)[1];
116  item.mult_x6 = (it->second)[4];
117  item.mult_x1 = (it->second)[7];
118  item.shift_x12 = (it->second)[2];
119  item.shift_x6 = (it->second)[5];
120  item.shift_x1 = (it->second)[8];
121  prod->setValue(it->first, item);
122  }
123  return prod;
124 }
125 
126 std::unique_ptr<EcalTPGSlidingWindow> EcalTrigPrimESProducer::produceSlidingWindow(
127  const EcalTPGSlidingWindowRcd &iRecord) {
128  auto prod = std::make_unique<EcalTPGSlidingWindow>();
129  parseTextFile();
130  for (int subdet = 0; subdet < 2; subdet++) {
131  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
132  for (it = mapStrip_[subdet].begin(); it != mapStrip_[subdet].end(); it++) {
133  prod->setValue(it->first, (it->second)[0]);
134  }
135  }
136  return prod;
137 }
138 
139 std::unique_ptr<EcalTPGFineGrainEBIdMap> EcalTrigPrimESProducer::produceFineGrainEB(
140  const EcalTPGFineGrainEBIdMapRcd &iRecord) {
141  auto prod = std::make_unique<EcalTPGFineGrainEBIdMap>();
142  parseTextFile();
144  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
145  for (it = mapFg_.begin(); it != mapFg_.end(); it++) {
146  fg.setValues((it->second)[0], (it->second)[1], (it->second)[2], (it->second)[3], (it->second)[4]);
147  prod->setValue(it->first, fg);
148  }
149  return prod;
150 }
151 
152 std::unique_ptr<EcalTPGFineGrainStripEE> EcalTrigPrimESProducer::produceFineGrainEEstrip(
153  const EcalTPGFineGrainStripEERcd &iRecord) {
154  auto prod = std::make_unique<EcalTPGFineGrainStripEE>();
155  parseTextFile();
156  // EE Strips
157  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
158  for (it = mapStrip_[1].begin(); it != mapStrip_[1].end(); it++) {
160  item.threshold = (it->second)[3];
161  item.lut = (it->second)[4];
162  prod->setValue(it->first, item);
163  }
164  // EB Strips
165  for (it = mapStrip_[0].begin(); it != mapStrip_[0].end(); it++) {
167  item.threshold = (it->second)[3];
168  item.lut = (it->second)[4];
169  prod->setValue(it->first, item);
170  }
171  return prod;
172 }
173 
174 std::unique_ptr<EcalTPGFineGrainTowerEE> EcalTrigPrimESProducer::produceFineGrainEEtower(
175  const EcalTPGFineGrainTowerEERcd &iRecord) {
176  auto prod = std::make_unique<EcalTPGFineGrainTowerEE>();
177  parseTextFile();
178  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
179  for (it = mapTower_[1].begin(); it != mapTower_[1].end(); it++) {
180  prod->setValue(it->first, (it->second)[1]);
181  }
182  return prod;
183 }
184 
185 std::unique_ptr<EcalTPGLutIdMap> EcalTrigPrimESProducer::produceLUT(const EcalTPGLutIdMapRcd &iRecord) {
186  auto prod = std::make_unique<EcalTPGLutIdMap>();
187  parseTextFile();
188  EcalTPGLut lut;
189  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
190  for (it = mapLut_.begin(); it != mapLut_.end(); it++) {
191  unsigned int lutArray[1024];
192  for (int i = 0; i < 1024; i++)
193  lutArray[i] = (it->second)[i];
194  lut.setLut(lutArray);
195  prod->setValue(it->first, lut);
196  }
197  return prod;
198 }
199 
200 std::unique_ptr<EcalTPGWeightIdMap> EcalTrigPrimESProducer::produceWeight(const EcalTPGWeightIdMapRcd &iRecord) {
201  auto prod = std::make_unique<EcalTPGWeightIdMap>();
202  parseTextFile();
204  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
205  for (it = mapWeight_.begin(); it != mapWeight_.end(); it++) {
206  weights.setValues((it->second)[0], (it->second)[1], (it->second)[2], (it->second)[3], (it->second)[4]);
207  prod->setValue(it->first, weights);
208  }
209  return prod;
210 }
211 
212 std::unique_ptr<EcalTPGWeightGroup> EcalTrigPrimESProducer::produceWeightGroup(const EcalTPGWeightGroupRcd &iRecord) {
213  auto prod = std::make_unique<EcalTPGWeightGroup>();
214  parseTextFile();
215  for (int subdet = 0; subdet < 2; subdet++) {
216  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
217  for (it = mapStrip_[subdet].begin(); it != mapStrip_[subdet].end(); it++) {
218  prod->setValue(it->first, (it->second)[1]);
219  }
220  }
221  return prod;
222 }
223 
224 std::unique_ptr<EcalTPGOddWeightIdMap> EcalTrigPrimESProducer::produceOddWeight(
225  const EcalTPGOddWeightIdMapRcd &iRecord) {
226  auto prod = std::make_unique<EcalTPGOddWeightIdMap>();
227  parseTextFile();
229  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
230  for (it = mapWeight_odd_.begin(); it != mapWeight_odd_.end(); it++) {
231  weights.setValues((it->second)[0], (it->second)[1], (it->second)[2], (it->second)[3], (it->second)[4]);
232  prod->setValue(it->first, weights);
233  }
234  return prod;
235 }
236 
237 std::unique_ptr<EcalTPGOddWeightGroup> EcalTrigPrimESProducer::produceOddWeightGroup(
238  const EcalTPGOddWeightGroupRcd &iRecord) {
239  auto prod = std::make_unique<EcalTPGOddWeightGroup>();
240  parseTextFile();
241  for (int subdet = 0; subdet < 2; subdet++) {
242  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
243  for (it = mapStrip_[subdet].begin(); it != mapStrip_[subdet].end(); it++) {
244  prod->setValue(it->first, (it->second)[2]);
245  }
246  }
247  return prod;
248 }
249 
250 std::unique_ptr<EcalTPGTPMode> EcalTrigPrimESProducer::produceTPMode(const EcalTPGTPModeRcd &iRecord) {
251  auto prod = std::make_unique<EcalTPGTPMode>();
252  parseTextFile();
253  if (tpMode_.size() < 14)
254  edm::LogError("EcalTPG") << "Missing TPMode entries!";
255 
256  prod->EnableEBOddFilter = tpMode_[0];
257  prod->EnableEEOddFilter = tpMode_[1];
258  prod->EnableEBOddPeakFinder = tpMode_[2];
259  prod->EnableEEOddPeakFinder = tpMode_[3];
260  prod->DisableEBEvenPeakFinder = tpMode_[4];
261  prod->DisableEEEvenPeakFinder = tpMode_[5];
262  prod->FenixEBStripOutput = tpMode_[6];
263  prod->FenixEEStripOutput = tpMode_[7];
264  prod->FenixEBStripInfobit2 = tpMode_[8];
265  prod->FenixEEStripInfobit2 = tpMode_[9];
266  prod->EBFenixTcpOutput = tpMode_[10];
267  prod->EBFenixTcpInfobit1 = tpMode_[11];
268  prod->EEFenixTcpOutput = tpMode_[12];
269  prod->EEFenixTcpInfobit1 = tpMode_[13];
270  prod->FenixPar15 = tpMode_[14];
271  prod->FenixPar16 = tpMode_[15];
272  prod->FenixPar17 = tpMode_[16];
273  prod->FenixPar18 = tpMode_[17];
274  return prod;
275 }
276 
277 std::unique_ptr<EcalTPGLutGroup> EcalTrigPrimESProducer::produceLutGroup(const EcalTPGLutGroupRcd &iRecord) {
278  auto prod = std::make_unique<EcalTPGLutGroup>();
279  parseTextFile();
280  for (int subdet = 0; subdet < 2; subdet++) {
281  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
282  for (it = mapTower_[subdet].begin(); it != mapTower_[subdet].end(); it++) {
283  prod->setValue(it->first, (it->second)[0]);
284  }
285  }
286  return prod;
287 }
288 
289 std::unique_ptr<EcalTPGFineGrainEBGroup> EcalTrigPrimESProducer::produceFineGrainEBGroup(
290  const EcalTPGFineGrainEBGroupRcd &iRecord) {
291  auto prod = std::make_unique<EcalTPGFineGrainEBGroup>();
292  parseTextFile();
293  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
294  for (it = mapTower_[0].begin(); it != mapTower_[0].end(); it++) {
295  prod->setValue(it->first, (it->second)[1]);
296  }
297  return prod;
298 }
299 
300 std::unique_ptr<EcalTPGPhysicsConst> EcalTrigPrimESProducer::producePhysicsConst(const EcalTPGPhysicsConstRcd &iRecord) {
301  auto prod = std::make_unique<EcalTPGPhysicsConst>();
302  parseTextFile();
303  std::map<uint32_t, std::vector<float>>::const_iterator it;
304  for (it = mapPhys_.begin(); it != mapPhys_.end(); it++) {
306  item.EtSat = (it->second)[0];
307  item.ttf_threshold_Low = (it->second)[1];
308  item.ttf_threshold_High = (it->second)[2];
309  item.FG_lowThreshold = (it->second)[3];
310  item.FG_highThreshold = (it->second)[4];
311  item.FG_lowRatio = (it->second)[5];
312  item.FG_highRatio = (it->second)[6];
313  prod->setValue(it->first, item);
314  }
315  return prod;
316 }
317 
318 std::unique_ptr<EcalTPGCrystalStatus> EcalTrigPrimESProducer::produceBadX(const EcalTPGCrystalStatusRcd &iRecord) {
319  auto prod = std::make_unique<EcalTPGCrystalStatus>();
320  parseTextFile();
321  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
322  for (it = mapXtal_.begin(); it != mapXtal_.end(); it++) {
323  EcalTPGCrystalStatusCode badXValue;
324  badXValue.setStatusCode(0);
325  prod->setValue(it->first, badXValue);
326  }
327  return prod;
328 }
329 
330 std::unique_ptr<EcalTPGStripStatus> EcalTrigPrimESProducer::produceBadStrip(const EcalTPGStripStatusRcd &iRecord) {
331  auto prod = std::make_unique<EcalTPGStripStatus>();
332  // returns an empty map
333  return prod;
334 }
335 
336 std::unique_ptr<EcalTPGTowerStatus> EcalTrigPrimESProducer::produceBadTT(const EcalTPGTowerStatusRcd &iRecord) {
337  auto prod = std::make_unique<EcalTPGTowerStatus>();
338  parseTextFile();
339  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
340  // Barrel
341  for (it = mapTower_[0].begin(); it != mapTower_[0].end(); it++) {
342  // set the BadTT status to 0
343  prod->setValue(it->first, 0);
344  }
345  // Endcap
346  for (it = mapTower_[1].begin(); it != mapTower_[1].end(); it++) {
347  // set the BadTT status to 0
348  prod->setValue(it->first, 0);
349  }
350 
351  return prod;
352 }
353 
354 std::unique_ptr<EcalTPGSpike> EcalTrigPrimESProducer::produceSpike(const EcalTPGSpikeRcd &iRecord) {
355  auto prod = std::make_unique<EcalTPGSpike>();
356  parseTextFile();
357  // Only need to do barrel
358  std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
359  for (it = mapTower_[0].begin(); it != mapTower_[0].end(); ++it) {
360  prod->setValue(it->first, (it->second)[2]);
361  }
362  return prod;
363 }
364 
366  if (!mapXtal_.empty())
367  return; // just parse the file once!
368 
369  uint32_t id;
370  std::string dataCard;
372  std::ifstream infile;
373  std::vector<unsigned int> param;
374  std::vector<float> paramF;
375  int NBstripparams[2] = {5, 5};
376  unsigned int data;
377  float dataF;
378 
379  std::string bufString;
380  std::string iString;
381  std::string fString;
382  std::string filename = "SimCalorimetry/EcalTrigPrimProducers/data/" + dbFilename_;
383  std::string finalFileName;
384  size_t slash = dbFilename_.find('/');
385  if (slash != 0) {
386  edm::FileInPath fileInPath(filename);
387  finalFileName = fileInPath.fullPath();
388  } else {
389  finalFileName = dbFilename_;
390  edm::LogWarning("EcalTPG") << "Couldnt find database file via fileinpath, "
391  "trying with pathname directly!!";
392  }
393 
394  int k = 0;
395 
396  GzInputStream gis(finalFileName.c_str());
397  while (gis >> dataCard) {
398  if (dataCard == "PHYSICS_EB" || dataCard == "PHYSICS_EE") {
399  gis >> std::dec >> id;
400 
401  if (flagPrint_) {
402  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
403  }
404 
405  paramF.clear();
406 
407  std::string st1;
408  std::string st2;
409 
410  for (int i = 0; i < 7; i++) {
411  gis >> std::dec >> dataF;
412  paramF.push_back(dataF);
413 
414  // edm::LogVerbatim("EcalTrigPrimESProducer")<<", "<<std::dec<<dataF ;
415  if (flagPrint_) {
416  //---------------------------------
417  if (i < 3) {
418  std::ostringstream oss;
419  oss << dataF;
420  std::string result1 = oss.str();
421 
422  st1.append(result1);
423  if (i != 2)
424  st1.append(" ");
425  }
426 
427  if (i > 2) {
428  std::ostringstream oss;
429  oss << dataF;
430  std::string result2 = oss.str();
431 
432  st2.append(result2);
433  if (i != 6)
434  st2.append(" ");
435  }
436  //----------------------------------
437  }
438  }
439 
440  if (flagPrint_) {
441  edm::LogVerbatim("EcalTrigPrimESProducer") << "" << st1;
442  edm::LogVerbatim("EcalTrigPrimESProducer") << "" << st2;
443  edm::LogVerbatim("EcalTrigPrimESProducer") << "";
444  }
445 
446  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
447  mapPhys_[id] = paramF;
448  }
449 
450  if (dataCard == "CRYSTAL") {
451  gis >> std::dec >> id;
452  // edm::LogVerbatim("EcalTrigPrimESProducer")<<dataCard<<" "<<std::dec<<id;
453  std::string st3;
454  std::string st4;
455  std::string st5;
456 
457  if (flagPrint_) {
458  // Print this comment only one time
459  if (k == 0)
460  edm::LogVerbatim("EcalTrigPrimESProducer") << "COMMENT ====== barrel crystals ====== ";
461 
462  if (k == 61200)
463  edm::LogVerbatim("EcalTrigPrimESProducer") << "COMMENT ====== endcap crystals ====== ";
464 
465  k = k + 1;
466 
467  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
468  }
469 
470  param.clear();
471  for (int i = 0; i < 9; i++) {
472  gis >> std::hex >> data;
473  // edm::LogVerbatim("EcalTrigPrimESProducer")<<", "<<std::hex<<data ;
474  param.push_back(data);
475 
476  if (flagPrint_) {
477  if (i < 3) {
478  std::ostringstream oss;
479  oss << std::hex << data;
480  std::string result1 = oss.str();
481 
482  st3.append("0x");
483  st3.append(result1);
484  if (i != 2)
485  st3.append(" ");
486 
487  } else if (i > 2 && i < 6) {
488  std::ostringstream oss;
489  oss << std::hex << data;
490  std::string result2 = oss.str();
491 
492  st4.append("0x");
493  st4.append(result2);
494  if (i != 5)
495  st4.append(" ");
496  } else if (i > 5 && i < 9) {
497  std::ostringstream oss;
498  oss << std::hex << data;
499  std::string result3 = oss.str();
500 
501  st5.append("0x");
502  st5.append(result3);
503  if (i != 8)
504  st5.append(" ");
505  }
506  }
507 
508  } // end for
509 
510  if (flagPrint_) {
511  edm::LogVerbatim("EcalTrigPrimESProducer") << " " << st3;
512  edm::LogVerbatim("EcalTrigPrimESProducer") << " " << st4;
513  edm::LogVerbatim("EcalTrigPrimESProducer") << " " << st5;
514  }
515 
516  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
517  mapXtal_[id] = param;
518  }
519 
520  if (dataCard == "STRIP_EB") {
521  gis >> std::dec >> id;
522 
523  std::string st1;
524 
525  if (flagPrint_)
526  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
527 
528  param.clear();
529  for (int i = 0; i < NBstripparams[0]; i++) {
530  gis >> std::hex >> data;
531  // edm::LogVerbatim("EcalTrigPrimESProducer") << " data = " << data;
532  param.push_back(data);
533 
534  if (flagPrint_) {
535  if (i == 0) {
536  edm::LogVerbatim("EcalTrigPrimESProducer") << "0x" << std::hex << data;
537  } else if (i >= 1 && i < 3) {
538  edm::LogVerbatim("EcalTrigPrimESProducer") << "" << std::dec << data;
539  } else if (i > 2) {
540  std::ostringstream oss;
541  if (i == 3) {
542  oss << "0x" << std::hex << data;
543  std::string result4 = oss.str();
544  st1.append(result4);
545  } else if (i == 4) {
546  std::ostringstream oss;
547  oss << " 0x" << std::hex << data;
548  std::string result5 = oss.str();
549  st1.append(result5);
550  edm::LogVerbatim("EcalTrigPrimESProducer") << "" << st1;
551  }
552  }
553  }
554  }
555 
556  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
557  mapStrip_[0][id] = param;
558  }
559 
560  if (dataCard == "STRIP_EE") {
561  gis >> std::dec >> id;
562 
563  std::string st6;
564 
565  if (flagPrint_) {
566  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
567  }
568 
569  param.clear();
570  for (int i = 0; i < NBstripparams[1]; i++) {
571  gis >> std::hex >> data;
572  param.push_back(data);
573 
574  if (flagPrint_) {
575  if (i == 0) {
576  edm::LogVerbatim("EcalTrigPrimESProducer") << "0x" << std::hex << data;
577  } else if (i >= 1 && i < 3) {
578  edm::LogVerbatim("EcalTrigPrimESProducer") << " " << std::hex << data;
579  } else if (i > 2) {
580  std::ostringstream oss;
581  if (i == 3) {
582  oss << "0x" << std::hex << data;
583  std::string result4 = oss.str();
584  st6.append(result4);
585  } else if (i == 4) {
586  std::ostringstream oss;
587  oss << " 0x" << std::hex << data;
588  std::string result5 = oss.str();
589 
590  st6.append(result5);
591  edm::LogVerbatim("EcalTrigPrimESProducer") << "" << st6;
592  }
593  }
594  }
595  }
596 
597  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
598  mapStrip_[1][id] = param;
599  }
600 
601  if (dataCard == "TOWER_EE") {
602  gis >> std::dec >> id;
603 
604  if (flagPrint_)
605  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
606 
607  param.clear();
608  for (int i = 0; i < 2; i++) {
609  gis >> std::hex >> data;
610  param.push_back(data);
611 
612  if (flagPrint_) {
613  if (i == 1) {
614  edm::LogVerbatim("EcalTrigPrimESProducer") << "0x" << std::dec << data;
615  } else {
616  edm::LogVerbatim("EcalTrigPrimESProducer") << " " << std::dec << data;
617  }
618  }
619  }
620 
621  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
622  mapTower_[1][id] = param;
623  }
624 
625  if (dataCard == "TOWER_EB") {
626  gis >> std::dec >> id;
627 
628  if (flagPrint_)
629  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
630 
631  param.clear();
632  for (int i = 0; i < 3; i++) {
633  gis >> std::dec >> data;
634 
635  if (flagPrint_) {
636  edm::LogVerbatim("EcalTrigPrimESProducer") << " " << std::dec << data;
637  }
638 
639  param.push_back(data);
640  }
641 
642  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
643  mapTower_[0][id] = param;
644  }
645 
646  if (dataCard == "WEIGHT") {
647  gis >> std::hex >> id;
648  if (flagPrint_) {
649  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
650  }
651 
652  param.clear();
653 
654  std::string st6;
655  for (int i = 0; i < 5; i++) {
656  gis >> std::hex >> data;
657  param.push_back(data);
658 
659  if (flagPrint_) {
660  std::ostringstream oss;
661  oss << std::hex << data;
662  std::string result4 = oss.str();
663 
664  st6.append("0x");
665  st6.append(result4);
666  st6.append(" ");
667  }
668  }
669 
670  if (flagPrint_) {
671  edm::LogVerbatim("EcalTrigPrimESProducer") << st6;
672  }
673 
674  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
675  mapWeight_[id] = param;
676  }
677 
678  if (dataCard == "WEIGHT_ODD") {
679  gis >> std::hex >> id;
680  if (flagPrint_) {
681  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
682  }
683 
684  param.clear();
685 
686  std::string st6;
687  for (int i = 0; i < 5; i++) {
688  gis >> std::hex >> data;
689  param.push_back(data);
690 
691  if (flagPrint_) {
692  std::ostringstream oss;
693  oss << std::hex << data;
694  std::string result4 = oss.str();
695 
696  st6.append("0x");
697  st6.append(result4);
698  st6.append(" ");
699  }
700  }
701 
702  if (flagPrint_) {
703  edm::LogVerbatim("EcalTrigPrimESProducer") << st6;
704  }
705 
706  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
707  mapWeight_odd_[id] = param;
708  }
709 
710  if (dataCard == "FG") {
711  gis >> std::hex >> id;
712  if (flagPrint_)
713  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
714 
715  param.clear();
716  std::string st7;
717  for (int i = 0; i < 5; i++) {
718  gis >> std::hex >> data;
719  param.push_back(data);
720 
721  if (flagPrint_) {
722  std::ostringstream oss;
723  oss << std::hex << data;
724 
725  std::string result5 = oss.str();
726 
727  st7.append("0x");
728  st7.append(result5);
729  if (i != 4)
730  st7.append(" ");
731  }
732  }
733 
734  if (flagPrint_) {
735  edm::LogVerbatim("EcalTrigPrimESProducer") << st7;
736  }
737 
738  mapFg_[id] = param;
739  }
740 
741  if (dataCard == "LUT") {
742  gis >> std::hex >> id;
743 
744  if (flagPrint_)
745  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << std::dec << id;
746 
747  param.clear();
748  for (int i = 0; i < 1024; i++) {
749  gis >> std::hex >> data;
750  param.push_back(data);
751 
752  if (flagPrint_) {
753  edm::LogVerbatim("EcalTrigPrimESProducer") << "0x" << std::hex << data;
754  }
755  }
756 
757  mapLut_[id] = param;
758  }
759 
760  if (dataCard == "TP_MODE") {
761  param.clear();
762 
763  std::string st8;
764  for (int i = 0; i < 18; i++) {
765  gis >> std::dec >> data;
766  param.push_back(data);
767 
768  if (flagPrint_) {
769  std::ostringstream oss;
770  oss << std::dec << data;
771  std::string result6 = oss.str();
772 
773  st8.append(result6);
774  st8.append(" ");
775  }
776  }
777 
778  if (flagPrint_) {
779  edm::LogVerbatim("EcalTrigPrimESProducer") << dataCard << " " << st8;
780  }
781 
782  // edm::LogVerbatim("EcalTrigPrimESProducer")<<std::endl ;
783  tpMode_ = param;
784  }
785  }
786 }
787 
789  int subdet, int tccNb, int towerNbInTcc, int stripNbInTower, int xtalNbInStrip) {
790  std::vector<int> range;
791  if (subdet == 0) {
792  // Barrel
793  range.push_back(37); // stccNbMin
794  range.push_back(73); // tccNbMax
795  range.push_back(1); // towerNbMin
796  range.push_back(69); // towerNbMax
797  range.push_back(1); // stripNbMin
798  range.push_back(6); // stripNbMax
799  range.push_back(1); // xtalNbMin
800  range.push_back(6); // xtalNbMax
801  } else {
802  // Endcap eta >0
803  if (subdet > 0) {
804  range.push_back(73); // tccNbMin
805  range.push_back(109); // tccNbMax
806  } else { // endcap eta <0
807  range.push_back(1); // tccNbMin
808  range.push_back(37); // tccNbMax
809  }
810  range.push_back(1); // towerNbMin
811  range.push_back(29); // towerNbMax
812  range.push_back(1); // stripNbMin
813  range.push_back(6); // stripNbMax
814  range.push_back(1); // xtalNbMin
815  range.push_back(6); // xtalNbMax
816  }
817 
818  if (tccNb > 0) {
819  range[0] = tccNb;
820  range[1] = tccNb + 1;
821  }
822  if (towerNbInTcc > 0) {
823  range[2] = towerNbInTcc;
824  range[3] = towerNbInTcc + 1;
825  }
826  if (stripNbInTower > 0) {
827  range[4] = stripNbInTower;
828  range[5] = stripNbInTower + 1;
829  }
830  if (xtalNbInStrip > 0) {
831  range[6] = xtalNbInStrip;
832  range[7] = xtalNbInStrip + 1;
833  }
834 
835  return range;
836 }
837 
838 // bool EcalTrigPrimESProducer::getNextString(gzFile &gzf){
839 // size_t blank;
840 // if (bufpos_==0) {
841 // gzgets(gzf,buf_,80);
842 // if (gzeof(gzf)) return true;
843 // bufString_=std::string(buf_);
844 // }
845 // int pos=0;
846 // pos =bufpos_;
847 // // look for next non-blank
848 // while (pos<bufString_.size()) {
849 // if (!bufString_.compare(pos,1," ")) pos++;
850 // else break;
851 // }
852 // blank=bufString_.find(" ",pos);
853 // size_t end = blank;
854 // if (blank==std::string::npos) end=bufString_.size();
855 // sub_=bufString_.substr(pos,end-pos);
856 // bufpos_= blank;
857 // if (blank==std::string::npos) bufpos_=0;
858 // return false;
859 // }
860 //
861 // int EcalTrigPrimESProducer::converthex() {
862 // // converts hex dec string sub to hexa
863 // //FIXME:: find something better (istrstream?)!!!!
864 //
865 // std::string chars("0123456789abcdef");
866 // int hex=0;
867 // for (size_t i=2;i<sub_.length();++i) {
868 // size_t f=chars.find(sub_[i]);
869 // if (f==std::string::npos) break; //FIXME: length is 4 for 0x3!!
870 // hex=hex*16+chars.find(sub_[i]);
871 // }
872 // return hex;
873 // }
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
std::vector< int > getRange(int subdet, int smNb, int towerNbInSm, int stripNbInTower=0, int xtalNbInStrip=0)
std::unique_ptr< EcalTPGWeightGroup > produceWeightGroup(const EcalTPGWeightGroupRcd &)
std::string fullPath() const
Definition: FileInPath.cc:161
std::unique_ptr< EcalTPGCrystalStatus > produceBadX(const EcalTPGCrystalStatusRcd &)
GzInputStream & operator>>(GzInputStream &gis, T &var)
void setValues(const uint32_t &ThresholdETLow, const uint32_t &ThresholdETHigh, const uint32_t &RatioLow, const uint32_t &RatioHigh, const uint32_t &LUT)
std::vector< uint32_t > tpMode_
std::map< uint32_t, std::vector< uint32_t > > mapWeight_odd_
std::unique_ptr< EcalTPGLinearizationConst > produceLinearizationConst(const EcalTPGLinearizationConstRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapTower_[2]
std::unique_ptr< EcalTPGFineGrainEBIdMap > produceFineGrainEB(const EcalTPGFineGrainEBIdMapRcd &)
std::unique_ptr< EcalTPGLutIdMap > produceLUT(const EcalTPGLutIdMapRcd &)
Definition: Electron.h:6
void setLut(const unsigned int *lut)
Definition: EcalTPGLut.cc:15
std::unique_ptr< EcalTPGTowerStatus > produceBadTT(const EcalTPGTowerStatusRcd &)
std::unique_ptr< EcalTPGPedestals > producePedestals(const EcalTPGPedestalsRcd &)
std::unique_ptr< EcalTPGPhysicsConst > producePhysicsConst(const EcalTPGPhysicsConstRcd &)
void setStatusCode(const uint16_t &val)
std::unique_ptr< EcalTPGOddWeightGroup > produceOddWeightGroup(const EcalTPGOddWeightGroupRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapXtal_
std::unique_ptr< EcalTPGTPMode > produceTPMode(const EcalTPGTPModeRcd &)
std::unique_ptr< EcalTPGFineGrainTowerEE > produceFineGrainEEtower(const EcalTPGFineGrainTowerEERcd &)
std::unique_ptr< EcalTPGSpike > produceSpike(const EcalTPGSpikeRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapWeight_
std::unique_ptr< EcalTPGSlidingWindow > produceSlidingWindow(const EcalTPGSlidingWindowRcd &)
std::unique_ptr< EcalTPGOddWeightIdMap > produceOddWeight(const EcalTPGOddWeightIdMapRcd &)
std::unique_ptr< EcalTPGFineGrainEBGroup > produceFineGrainEBGroup(const EcalTPGFineGrainEBGroupRcd &)
EcalTrigPrimESProducer(const edm::ParameterSet &)
std::unique_ptr< EcalTPGLutGroup > produceLutGroup(const EcalTPGLutGroupRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapFg_
GzInputStream(const char *file)
std::map< uint32_t, std::vector< float > > mapPhys_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
std::unique_ptr< EcalTPGFineGrainStripEE > produceFineGrainEEstrip(const EcalTPGFineGrainStripEERcd &)
Log< level::Warning, false > LogWarning
std::unique_ptr< EcalTPGWeightIdMap > produceWeight(const EcalTPGWeightIdMapRcd &)
std::unique_ptr< EcalTPGStripStatus > produceBadStrip(const EcalTPGStripStatusRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapLut_
long double T
std::map< uint32_t, std::vector< uint32_t > > mapStrip_[2]