CMS 3D CMS Logo

EcalTPGParamBuilder.cc
Go to the documentation of this file.
1 #include "EcalTPGParamBuilder.h"
2 
4 
11 
15 
24 
25 //modif-alex-27-july-2015
28 
33 #include <iostream>
34 #include <string>
35 #include <sstream>
36 #include <vector>
37 #include <ctime>
38 
39 #include <TF1.h>
40 #include <TH2F.h>
41 #include <TFile.h>
42 #include <TNtuple.h>
43 #include <iomanip>
44 #include <fstream>
45 
46 using namespace std;
47 
48 double oneOverEtResolEt(double* x, double* par) {
49  double Et = x[0];
50  if (Et < 1e-6)
51  return 1. / par[1]; // to avoid division by 0.
52  double resolEt_overEt =
53  sqrt((par[0] / sqrt(Et)) * (par[0] / sqrt(Et)) + (par[1] / Et) * (par[1] / Et) + par[2] * par[2]);
54  return 1. / (Et * resolEt_overEt);
55 }
56 
58  : xtal_LSB_EB_(0), xtal_LSB_EE_(0), nSample_(5), complement2_(7), useDBShape_(true) {
59  ped_conf_id_ = 0;
60  lin_conf_id_ = 0;
61  lut_conf_id_ = 0;
62  wei_conf_id_ = 0;
63  fgr_conf_id_ = 0;
64  sli_conf_id_ = 0;
65  spi_conf_id_ = 0; //modif-alex 21/01/11
66  del_conf_id_ = 0; //modif-alex 21/01/11
67  bxt_conf_id_ = 0;
68  btt_conf_id_ = 0;
69  bst_conf_id_ = 0;
70  tag_ = "";
71  version_ = 0;
72 
73  m_write_ped = 1;
74  m_write_lin = 1;
75  m_write_lut = 1;
76  m_write_wei = 1;
77  m_write_fgr = 1;
78  m_write_sli = 1;
79  m_write_spi = 1; //modif-alex 21/01/11
80  m_write_del = 1; //modif-alex 21/01/11
81  m_write_bxt = 1;
82  m_write_btt = 1;
83  m_write_bst = 1;
84 
85  writeToDB_ = pSet.getParameter<bool>("writeToDB");
86  DBEE_ = pSet.getParameter<bool>("allowDBEE");
87  string DBsid = pSet.getParameter<std::string>("DBsid");
88  string DBuser = pSet.getParameter<std::string>("DBuser");
89  string DBpass = pSet.getParameter<std::string>("DBpass");
90  //uint32_t DBport = pSet.getParameter<unsigned int>("DBport") ;
91 
92  tag_ = pSet.getParameter<std::string>("TPGtag");
93  version_ = pSet.getParameter<unsigned int>("TPGversion");
94 
95  m_write_ped = pSet.getParameter<unsigned int>("TPGWritePed");
96  m_write_lin = pSet.getParameter<unsigned int>("TPGWriteLin");
97  m_write_lut = pSet.getParameter<unsigned int>("TPGWriteLut");
98  m_write_wei = pSet.getParameter<unsigned int>("TPGWriteWei");
99  m_write_fgr = pSet.getParameter<unsigned int>("TPGWriteFgr");
100  m_write_sli = pSet.getParameter<unsigned int>("TPGWriteSli");
101  m_write_spi = pSet.getParameter<unsigned int>("TPGWriteSpi"); //modif-alex 21/01/11
102  m_write_del = pSet.getParameter<unsigned int>("TPGWriteDel"); //modif-alex 21/01/11
103  m_write_bxt = pSet.getParameter<unsigned int>("TPGWriteBxt");
104  m_write_btt = pSet.getParameter<unsigned int>("TPGWriteBtt");
105  m_write_bst = pSet.getParameter<unsigned int>("TPGWriteBst");
106 
110 
111  if (m_write_ped != 0 && m_write_ped != 1)
113 
114  if (writeToDB_)
115  edm::LogInfo("TopInfo") << "data will be saved with tag and version=" << tag_ << ".version" << version_ << "\n";
116  db_ = new EcalTPGDBApp(DBsid, DBuser, DBpass);
117 
118  writeToFiles_ = pSet.getParameter<bool>("writeToFiles");
119  if (writeToFiles_) {
120  std::string outFile = pSet.getParameter<std::string>("outFile");
121  out_file_ = new std::ofstream(outFile.c_str(), std::ios::out);
122  }
123  geomFile_ = new std::ofstream("geomFile.txt", std::ios::out);
124 
125  useTransverseEnergy_ = pSet.getParameter<bool>("useTransverseEnergy");
126 
127  Et_sat_EB_ = pSet.getParameter<double>("Et_sat_EB");
128  Et_sat_EE_ = pSet.getParameter<double>("Et_sat_EE");
129  sliding_ = pSet.getParameter<unsigned int>("sliding");
130  weight_timeShift_ = pSet.getParameter<double>("weight_timeShift");
131  sampleMax_ = pSet.getParameter<unsigned int>("weight_sampleMax");
132  weight_unbias_recovery_ = pSet.getParameter<bool>("weight_unbias_recovery");
133 
134  forcedPedestalValue_ = pSet.getParameter<int>("forcedPedestalValue");
135  forceEtaSlice_ = pSet.getParameter<bool>("forceEtaSlice");
136 
137  LUT_option_ = pSet.getParameter<std::string>("LUT_option");
138  LUT_threshold_EB_ = pSet.getParameter<double>("LUT_threshold_EB");
139  LUT_threshold_EE_ = pSet.getParameter<double>("LUT_threshold_EE");
140  LUT_stochastic_EB_ = pSet.getParameter<double>("LUT_stochastic_EB");
141  LUT_noise_EB_ = pSet.getParameter<double>("LUT_noise_EB");
142  LUT_constant_EB_ = pSet.getParameter<double>("LUT_constant_EB");
143  LUT_stochastic_EE_ = pSet.getParameter<double>("LUT_stochastic_EE");
144  LUT_noise_EE_ = pSet.getParameter<double>("LUT_noise_EE");
145  LUT_constant_EE_ = pSet.getParameter<double>("LUT_constant_EE");
146 
147  TTF_lowThreshold_EB_ = pSet.getParameter<double>("TTF_lowThreshold_EB");
148  TTF_highThreshold_EB_ = pSet.getParameter<double>("TTF_highThreshold_EB");
149  TTF_lowThreshold_EE_ = pSet.getParameter<double>("TTF_lowThreshold_EE");
150  TTF_highThreshold_EE_ = pSet.getParameter<double>("TTF_highThreshold_EE");
151 
152  FG_lowThreshold_EB_ = pSet.getParameter<double>("FG_lowThreshold_EB");
153  FG_highThreshold_EB_ = pSet.getParameter<double>("FG_highThreshold_EB");
154  FG_lowRatio_EB_ = pSet.getParameter<double>("FG_lowRatio_EB");
155  FG_highRatio_EB_ = pSet.getParameter<double>("FG_highRatio_EB");
156  FG_lut_EB_ = pSet.getParameter<unsigned int>("FG_lut_EB");
157  FG_Threshold_EE_ = pSet.getParameter<double>("FG_Threshold_EE");
158  FG_lut_strip_EE_ = pSet.getParameter<unsigned int>("FG_lut_strip_EE");
159  FG_lut_tower_EE_ = pSet.getParameter<unsigned int>("FG_lut_tower_EE");
160  SFGVB_Threshold_ = pSet.getParameter<unsigned int>("SFGVB_Threshold");
161  SFGVB_lut_ = pSet.getParameter<unsigned int>("SFGVB_lut");
162  SFGVB_SpikeKillingThreshold_ = pSet.getParameter<int>("SFGVB_SpikeKillingThreshold"); //modif-alex 21/01/11
163  pedestal_offset_ = pSet.getParameter<unsigned int>("pedestal_offset");
164 
165  useInterCalibration_ = pSet.getParameter<bool>("useInterCalibration");
166  H2_ = pSet.getUntrackedParameter<bool>("H2", false);
167 
168  useTransparencyCorr_ = false;
169  useTransparencyCorr_ = pSet.getParameter<bool>("useTransparencyCorr"); //modif-alex-25/04/2012
170  Transparency_Corr_ = pSet.getParameter<std::string>("transparency_corrections"); //modif-alex-30/01/2012
171 
172  //modif-alex-23/02/2011
173  //convert the spike killing first from GeV to ADC (10 bits)
174  //depending on the saturation scale: Et_sat_EB_
176  SFGVB_SpikeKillingThreshold_ = 1023; //nokilling
177  else
179  edm::LogInfo("TopInfo") << "INFO:SPIKE KILLING THRESHOLD (ADC)=" << SFGVB_SpikeKillingThreshold_ << "\n";
180 
181  //modif-alex-02/02/11
182  //TIMING information
183  TimingDelays_EB_ = pSet.getParameter<std::string>("timing_delays_EB");
184  TimingDelays_EE_ = pSet.getParameter<std::string>("timing_delays_EE");
185  TimingPhases_EB_ = pSet.getParameter<std::string>("timing_phases_EB");
186  TimingPhases_EE_ = pSet.getParameter<std::string>("timing_phases_EE");
187 
188  std::ostringstream ss;
189  // edm::LogInfo("TopInfo") << "INFO: READING timing files" << "\n";
190  ss << "INFO: READING timing files\n";
191  std::ifstream delay_eb(TimingDelays_EB_.c_str());
192  if (!delay_eb)
193  edm::LogError("TopInfo") << "ERROR: File " << TimingDelays_EB_.c_str() << " could not be opened"
194  << "\n";
195  std::ifstream delay_ee(TimingDelays_EE_.c_str());
196  if (!delay_ee)
197  edm::LogError("TopInfo") << "ERROR: File " << TimingDelays_EE_.c_str() << " could not be opened"
198  << "\n";
199  std::ifstream phase_eb(TimingPhases_EB_.c_str());
200  if (!phase_eb)
201  edm::LogError("TopInfo") << "ERROR: File " << TimingPhases_EB_.c_str() << " could not be opened"
202  << "\n";
203  std::ifstream phase_ee(TimingPhases_EE_.c_str());
204  if (!phase_ee)
205  edm::LogError("TopInfo") << "ERROR: File " << TimingPhases_EE_.c_str() << " could not be opened"
206  << "\n";
207 
208  char buf[1024];
209  //READING DELAYS EB
210  delay_eb.getline(buf, sizeof(buf), '\n');
211  while (delay_eb) {
212  std::stringstream sin(buf);
213 
214  int tcc;
215  sin >> tcc;
216 
217  vector<int> vec_delays_eb;
218  for (int ieb = 0; ieb < 68; ++ieb) {
219  int time_delay = -1;
220  sin >> time_delay;
221  vec_delays_eb.push_back(time_delay);
222  if (time_delay == -1)
223  edm::LogError("TopInfo") << "ERROR:Barrel timing delay -1, check file"
224  << "\n";
225  }
226 
227  if (vec_delays_eb.size() != 68)
228  edm::LogError("TopInfo") << "ERROR:Barrel timing delay wrong, not enough towers, check file"
229  << "\n";
230 
231  if (delays_EB_.find(tcc) == delays_EB_.end())
232  delays_EB_.insert(make_pair(tcc, vec_delays_eb));
233 
234  // edm::LogInfo("TopInfo") << tcc << "\n";
235  ss << tcc;
236  for (unsigned int ieb = 0; ieb < vec_delays_eb.size(); ++ieb)
237  // edm::LogInfo("TopInfo") << vec_delays_eb[ieb] << "\n";
238  ss << " " << vec_delays_eb[ieb];
239  delay_eb.getline(buf, sizeof(buf), '\n');
240  ss << "\n";
241  } //loop delay file EB
242  delay_eb.close();
243 
244  //READING PHASES EB
245  phase_eb.getline(buf, sizeof(buf), '\n');
246  while (phase_eb) {
247  std::stringstream sin(buf);
248  int tcc;
249  sin >> tcc;
250 
251  vector<int> vec_phases_eb;
252  for (unsigned int ieb = 0; ieb < 68; ++ieb) {
253  int time_phase = -1;
254  sin >> time_phase;
255  vec_phases_eb.push_back(time_phase);
256  if (time_phase == -1)
257  edm::LogError("TopInfo") << "ERROR:Barrel timing phase -1, check file"
258  << "\n";
259  }
260 
261  if (vec_phases_eb.size() != 68)
262  edm::LogError("TopInfo") << "ERROR:Barrel timing phase wrong, not enough towers, check file"
263  << "\n";
264 
265  if (phases_EB_.find(tcc) == phases_EB_.end())
266  phases_EB_.insert(make_pair(tcc, vec_phases_eb));
267 
268  // edm::LogInfo("TopInfo") << tcc << "\n";
269  ss << tcc;
270  for (unsigned int ieb = 0; ieb < vec_phases_eb.size(); ++ieb)
271  // edm::LogInfo("TopInfo") << vec_phases_eb[ieb] << "\n";
272  ss << " " << vec_phases_eb[ieb];
273  phase_eb.getline(buf, sizeof(buf), '\n');
274  ss << "\n";
275  } //loop phase file EB
276  phase_eb.close();
277 
278  //READING DELAYS EE//------------------------------------------------
279  delay_ee.getline(buf, sizeof(buf), '\n');
280  while (delay_ee) {
281  std::stringstream sin(buf);
282  int tcc;
283  sin >> tcc;
284 
285  vector<int> vec_delays_ee;
286  for (unsigned int iee = 0; iee < 48; ++iee) {
287  int time_delay = -1;
288  sin >> time_delay;
289  vec_delays_ee.push_back(time_delay);
290  if (time_delay == -1)
291  edm::LogError("TopInfo") << "ERROR:EE timing delay -1, check file"
292  << "\n";
293  }
294 
295  if (vec_delays_ee.size() != 48)
296  edm::LogError("TopInfo") << "ERROR:EE timing delay wrong, not enough towers, check file"
297  << "\n";
298 
299  if (delays_EE_.find(tcc) == delays_EE_.end())
300  delays_EE_.insert(make_pair(tcc, vec_delays_ee));
301 
302  // edm::LogInfo("TopInfo") << tcc << "\n";
303  ss << tcc;
304  for (unsigned int iee = 0; iee < vec_delays_ee.size(); ++iee)
305  // edm::LogInfo("TopInfo") << vec_delays_ee[iee] << "\n";
306  ss << " " << vec_delays_ee[iee];
307  ss << "\n";
308  delay_ee.getline(buf, sizeof(buf), '\n');
309  } //loop delay file EE
310  delay_ee.close();
311 
312  //READING PHASES EE
313  phase_ee.getline(buf, sizeof(buf), '\n');
314  while (phase_ee) {
315  std::stringstream sin(buf);
316  int tcc;
317  sin >> tcc;
318 
319  vector<int> vec_phases_ee;
320  for (unsigned int iee = 0; iee < 48; ++iee) {
321  int time_phase = -1;
322  sin >> time_phase;
323  vec_phases_ee.push_back(time_phase);
324  if (time_phase == -1)
325  edm::LogError("TopInfo") << "ERROR:EE timing phase -1, check file"
326  << "\n";
327  }
328 
329  if (vec_phases_ee.size() != 48)
330  edm::LogError("TopInfo") << "ERROR:EE timing phase wrong, not enough towers, check file"
331  << "\n";
332 
333  if (phases_EE_.find(tcc) == phases_EE_.end())
334  phases_EE_.insert(make_pair(tcc, vec_phases_ee));
335  // edm::LogInfo("TopInfo") << tcc << "\n";
336  ss << tcc;
337  for (unsigned int iee = 0; iee < vec_phases_ee.size(); ++iee)
338  // edm::LogInfo("TopInfo") << vec_phases_ee[iee] << "\n";
339  ss << " " << vec_phases_ee[iee];
340  ss << "\n";
341  phase_ee.getline(buf, sizeof(buf), '\n');
342  } //loop phase file EE
343  phase_ee.close();
344 
345  // edm::LogInfo("TopInfo") << "INFO: DONE reading timing files for EB and EE" << "\n";
346  ss << "INFO: DONE reading timing files for EB and EE\n";
347  edm::LogInfo("TopInfo") << ss.str();
348 }
349 
351  if (writeToFiles_) {
352  (*out_file_) << "EOF" << std::endl;
353  out_file_->close();
354  delete out_file_;
355  }
356 }
357 
359  bool result = true;
360  if (item.mean_x1 < 150. || item.mean_x1 > 250)
361  result = false;
362  if (item.mean_x6 < 150. || item.mean_x6 > 250)
363  result = false;
364  if (item.mean_x12 < 150. || item.mean_x12 > 250)
365  result = false;
366  if (item.rms_x1 < 0 || item.rms_x1 > 2)
367  result = false;
368  if (item.rms_x6 < 0 || item.rms_x6 > 3)
369  result = false;
370  if (item.rms_x12 < 0 || item.rms_x12 > 5)
371  result = false;
372  return result;
373 }
374 
375 int EcalTPGParamBuilder::getEtaSlice(int tccId, int towerInTCC) {
376  int etaSlice = (towerInTCC - 1) / 4 + 1;
377  // barrel
378  if (tccId > 36 && tccId < 73)
379  return etaSlice;
380  //endcap
381  else {
382  if (tccId >= 1 && tccId <= 18)
383  etaSlice += 21; // inner -
384  if (tccId >= 19 && tccId <= 36)
385  etaSlice += 17; // outer -
386  if (tccId >= 91 && tccId <= 108)
387  etaSlice += 21; // inner +
388  if (tccId >= 73 && tccId <= 90)
389  etaSlice += 17; // outer +
390  }
391  return etaSlice;
392 }
393 
394 void EcalTPGParamBuilder::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
395  using namespace edm;
396  using namespace std;
397 
398  // geometry
399  ESHandle<CaloGeometry> theGeometry;
400  ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
401  evtSetup.get<CaloGeometryRecord>().get(theGeometry);
402  evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap", theEndcapGeometry_handle);
403  evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel", theBarrelGeometry_handle);
404  evtSetup.get<IdealGeometryRecord>().get(eTTmap_);
405  theEndcapGeometry_ = theEndcapGeometry_handle.product();
406  theBarrelGeometry_ = theBarrelGeometry_handle.product();
407 
408  // electronics mapping
410  evtSetup.get<EcalMappingRcd>().get(ecalmapping);
411  theMapping_ = ecalmapping.product();
412 
413  // get record for alpha
414  std::ostringstream ss;
415  ss << "EcalLaserDbAnalyzer::analyze\n";
417  evtSetup.get<EcalLaserAlphasRcd>().get(handle);
418  ss << "EcalLaserDbAnalyzer::analyze-> got EcalLaserDbRecord: \n";
419  const EcalLaserAlphaMap& laserAlphaMap = handle.product()->getMap(); // map of apdpns
420 
421  //modif-alex-27-july-2015-+ Jean june 2016 beg
422  // use alpha to check
424  int cnt = 0;
425  // Barrel loop
426  for (italpha = laserAlphaMap.barrelItems().begin(); italpha != laserAlphaMap.barrelItems().end(); ++italpha) {
427  if (cnt % 1000 == 0) {
428  EBDetId ebdetid = EBDetId::unhashIndex(cnt);
429  ss << " Barrel ALPHA = " << (*italpha) << " cmsswId " << ebdetid.rawId() << "\n";
430  }
431  cnt++;
432  }
433  ss << "Number of barrel Alpha parameters : " << cnt << "\n";
434  // Endcap loop
435  cnt = 0;
436  for (italpha = laserAlphaMap.endcapItems().begin(); italpha != laserAlphaMap.endcapItems().end(); ++italpha) {
437  if (cnt % 1000 == 0) {
438  EEDetId eedetid = EEDetId::unhashIndex(cnt);
439  ss << "EndCap ALPHA = " << (*italpha) << " cmsswId " << eedetid.rawId() << "\n";
440  }
441  cnt++;
442  }
443  ss << "Number of Endcap Alpha parameters : " << cnt << "\n";
444  edm::LogInfo("TopInfo") << ss.str();
445  ss.str("");
446  //modif-alex-27-july-2015 +-Jean june 2016-end
447 
448  //modif-alex-30/01/2012 displaced in analyze Jean 2018
449  ss.str("");
450  if (useTransparencyCorr_) {
451  if (Transparency_Corr_ != "tag") { // Jean 2018
452  edm::LogInfo("TopInfo") << "INFO: READING transparency correction files"
453  << "\n";
454  ss << "INFO: READING transparency correction files\n";
455  std::ifstream transparency(Transparency_Corr_.c_str());
456  if (!transparency)
457  edm::LogError("TopInfo") << "ERROR: File " << Transparency_Corr_.c_str() << " could not be opened"
458  << "\n";
459 
460  char buf[1024];
461  transparency.getline(buf, sizeof(buf), '\n');
462  int xtalcounter = 0;
463  while (transparency) {
464  std::stringstream sin(buf);
465 
466  int raw_xtal_id;
467  sin >> raw_xtal_id;
468 
469  double xtal_trans_corr;
470  sin >> xtal_trans_corr;
471 
472  // edm::LogInfo("TopInfo") << raw_xtal_id << " " << xtal_trans_corr << "\n";
473  ss << raw_xtal_id << " " << xtal_trans_corr << "\n";
474 
475  Transparency_Correction_.insert(make_pair(raw_xtal_id, xtal_trans_corr));
476 
477  xtalcounter++;
478  transparency.getline(buf, sizeof(buf), '\n');
479  } //loop transparency
480  transparency.close();
481  ss << "INFO: DONE transparency correction files " << xtalcounter << "\n";
482  edm::LogInfo("TopInfo") << ss.str();
483  ss.str("");
484  } // file
485  else { // Jean 2018
486  edm::LogInfo("TopInfo") << "INFO: READING transparency correction tag"
487  << "\n";
488  // std::cout << "new feature, read a tag" << std::endl;
489  ESHandle<EcalLaserAPDPNRatios> pAPDPNRatios;
490  evtSetup.get<EcalLaserAPDPNRatiosRcd>().get(pAPDPNRatios);
491  const EcalLaserAPDPNRatios* lratio = pAPDPNRatios.product();
492  // std::cout << " laser map size " << lratio->getLaserMap().size() << std::endl;
493 
495  // Barrel loop
496  for (int ib = 0; ib < 61200; ib++) {
497  EBDetId ebdetid = EBDetId::unhashIndex(ib);
498  itratio = lratio->getLaserMap().find(ebdetid.rawId());
499  // std::cout << ib << " " << ebdetid.rawId() << " Barrel APDPNRatios = " << (*itratio).p1 << " " << (*itratio).p2 << " " << (*itratio).p3 << std::endl;
500  Transparency_Correction_.insert(make_pair(ebdetid.rawId(), (*itratio).p2));
501  }
502  // Endcap loop
503  for (int ie = 0; ie < 14648; ie++) {
504  EEDetId eedetid = EEDetId::unhashIndex(ie);
505  itratio = lratio->getLaserMap().find(eedetid.rawId());
506  // std::cout << ie << " " << eedetid.rawId() << " Endcap APDPNRatios = " << (*itratio).p1 << " " << (*itratio).p2 << " " << (*itratio).p3 << std::endl;
507  Transparency_Correction_.insert(make_pair(eedetid.rawId(), (*itratio).p2));
508  }
509  ss << "INFO: DONE transparency correction tag\n";
510  edm::LogInfo("TopInfo") << ss.str();
511  ss.str("");
512  } // Jean 2018
513  } //if transparency
514 
515  // histo
516  TFile saving("EcalTPGParam.root", "recreate");
517  saving.cd();
518  TH2F* ICEB = new TH2F("ICEB", "IC: Barrel", 360, 1, 361, 172, -86, 86);
519  ICEB->GetYaxis()->SetTitle("eta index");
520  ICEB->GetXaxis()->SetTitle("phi index");
521  TH2F* tpgFactorEB = new TH2F("tpgFactorEB", "tpgFactor: Barrel", 360, 1, 361, 172, -86, 86);
522  tpgFactorEB->GetYaxis()->SetTitle("eta index");
523  tpgFactorEB->GetXaxis()->SetTitle("phi index");
524 
525  TH2F* ICEEPlus = new TH2F("ICEEPlus", "IC: Plus Endcap", 120, -9, 111, 120, -9, 111);
526  ICEEPlus->GetYaxis()->SetTitle("y index");
527  ICEEPlus->GetXaxis()->SetTitle("x index");
528  TH2F* tpgFactorEEPlus = new TH2F("tpgFactorEEPlus", "tpgFactor: Plus Endcap", 120, -9, 111, 120, -9, 111);
529  tpgFactorEEPlus->GetYaxis()->SetTitle("y index");
530  tpgFactorEEPlus->GetXaxis()->SetTitle("x index");
531  TH2F* ICEEMinus = new TH2F("ICEEMinus", "IC: Minus Endcap", 120, -9, 111, 120, -9, 111);
532  ICEEMinus->GetYaxis()->SetTitle("y index");
533  ICEEMinus->GetXaxis()->SetTitle("x index");
534  TH2F* tpgFactorEEMinus = new TH2F("tpgFactorEEMinus", "tpgFactor: Minus Endcap", 120, -9, 111, 120, -9, 111);
535  tpgFactorEEMinus->GetYaxis()->SetTitle("y index");
536  tpgFactorEEMinus->GetXaxis()->SetTitle("x index");
537 
538  TH2F* IC = new TH2F("IC", "IC", 720, -acos(-1.), acos(-1.), 600, -3., 3.);
539  IC->GetYaxis()->SetTitle("eta");
540  IC->GetXaxis()->SetTitle("phi");
541  TH2F* tpgFactor = new TH2F("tpgFactor", "tpgFactor", 720, -acos(-1.), acos(-1.), 600, -3., 3.);
542  tpgFactor->GetYaxis()->SetTitle("eta");
543  tpgFactor->GetXaxis()->SetTitle("phi");
544 
545  TH1F* hshapeEB = new TH1F("shapeEB", "shapeEB", 250, 0., 10.);
546  TH1F* hshapeEE = new TH1F("shapeEE", "shapeEE", 250, 0., 10.);
547 
548  TTree* ntuple = new TTree("tpgmap", "TPG geometry map");
549  const std::string branchFloat[26] = {
550  "fed", "tcc", "tower", "stripInTower", "xtalInStrip", "CCU", "VFE", "xtalInVFE", "xtalInCCU",
551  "ieta", "iphi", "ix", "iy", "iz", "hashedId", "ic", "cmsswId", "dbId",
552  "ietaTT", "iphiTT", "TCCch", "TCCslot", "SLBch", "SLBslot", "ietaGCT", "iphiGCT"};
553  ntupleInts_ = new Int_t[26];
554  for (int i = 0; i < 26; i++)
555  ntuple->Branch(branchFloat[i].c_str(), &ntupleInts_[i], (branchFloat[i] + string("/I")).c_str());
556  ntuple->Branch("det", ntupleDet_, "det/C");
557  ntuple->Branch("crate", ntupleCrate_, "crate/C");
558 
559  TNtuple* ntupleSpike = new TNtuple("spikeParam", "Spike parameters", "gainId:theta:G:g:ped:pedLin");
560 
562  // Initialization section //
564  list<uint32_t> towerListEB;
565  list<uint32_t> stripListEB;
566  list<uint32_t> towerListEE;
567  list<uint32_t> stripListEE;
568  list<uint32_t>::iterator itList;
569 
570  map<int, uint32_t> stripMapEB; // <EcalLogicId.hashed, strip elec id>
571  map<uint32_t, uint32_t> stripMapEBsintheta; // <strip elec id, sintheta>
572 
573  // Pedestals
574 
575  EcalPedestalsMap pedMap;
576 
577  if (m_write_ped == 1) {
578  ss << "Getting the pedestals from offline DB...\n";
579 
580  ESHandle<EcalPedestals> pedHandle;
581  evtSetup.get<EcalPedestalsRcd>().get(pedHandle);
582  pedMap = pedHandle.product()->getMap();
583 
584  EcalPedestalsMapIterator pedIter;
585  int nPed = 0;
586  for (pedIter = pedMap.begin(); pedIter != pedMap.end() && nPed < 10; ++pedIter, nPed++) {
587  EcalPedestals::Item aped = (*pedIter);
588  ss << aped.mean_x12 << ", " << aped.mean_x6 << ", " << aped.mean_x1 << "\n";
589  }
590  } else if (m_write_ped == 0) {
591  ss << "Getting the pedestals from previous configuration\n";
592 
593  EcalPedestals peds;
594 
595  FEConfigMainInfo fe_main_info;
596  fe_main_info.setConfigTag(tag_);
597  ss << "trying to read previous tag if it exists tag=" << tag_ << ".version" << version_ << "\n";
598  db_->fetchConfigSet(&fe_main_info);
599  if (fe_main_info.getPedId() > 0)
600  ped_conf_id_ = fe_main_info.getPedId();
601 
602  FEConfigPedInfo fe_ped_info;
603  fe_ped_info.setId(ped_conf_id_);
604  db_->fetchConfigSet(&fe_ped_info);
605  std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
606  db_->fetchDataSet(&dataset_TpgPed, &fe_ped_info);
607 
608  typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
609  EcalLogicID ecid_xt;
610  FEConfigPedDat rd_ped;
611  int icells = 0;
612  for (CIfeped p = dataset_TpgPed.begin(); p != dataset_TpgPed.end(); p++) {
613  ecid_xt = p->first;
614  rd_ped = p->second;
615 
616  std::string ecid_name = ecid_xt.getName();
617 
618  // EB data
619  if (ecid_name == "EB_crystal_number") {
620  int sm_num = ecid_xt.getID1();
621  int xt_num = ecid_xt.getID2();
622 
623  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
625  item.mean_x1 = rd_ped.getPedMeanG1();
626  item.mean_x6 = rd_ped.getPedMeanG6();
627  item.mean_x12 = rd_ped.getPedMeanG12();
628  item.rms_x1 = 0.5;
629  item.rms_x6 = 1.;
630  item.rms_x12 = 1.2;
631 
632  if (icells < 10)
633  ss << " copy the EB data "
634  << " ped = " << item.mean_x12 << "\n";
635 
636  peds.insert(std::make_pair(ebdetid.rawId(), item));
637 
638  ++icells;
639  } else if (ecid_name == "EE_crystal_number") {
640  // EE data
641  int z = ecid_xt.getID1();
642  int x = ecid_xt.getID2();
643  int y = ecid_xt.getID3();
644  EEDetId eedetid(x, y, z, EEDetId::XYMODE);
646  item.mean_x1 = rd_ped.getPedMeanG1();
647  item.mean_x6 = rd_ped.getPedMeanG6();
648  item.mean_x12 = rd_ped.getPedMeanG12();
649  item.rms_x1 = 0.5;
650  item.rms_x6 = 1.;
651  item.rms_x12 = 1.2;
652 
653  peds.insert(std::make_pair(eedetid.rawId(), item));
654  ++icells;
655  }
656  }
657 
658  pedMap = peds.getMap();
659 
660  EcalPedestalsMapIterator pedIter;
661  int nPed = 0;
662  for (pedIter = pedMap.begin(); pedIter != pedMap.end() && nPed < 10; ++pedIter, nPed++) {
663  EcalPedestals::Item aped = (*pedIter);
664  ss << aped.mean_x12 << ", " << aped.mean_x6 << ", " << aped.mean_x1 << "\n";
665  }
666 
667  } else if (m_write_ped > 1) {
668  ss << "Getting the pedestals from configuration number" << m_write_ped << "\n";
669 
670  EcalPedestals peds;
671 
672  FEConfigPedInfo fe_ped_info;
673  fe_ped_info.setId(m_write_ped);
674  db_->fetchConfigSet(&fe_ped_info);
675  std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
676  db_->fetchDataSet(&dataset_TpgPed, &fe_ped_info);
677 
678  typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
679  EcalLogicID ecid_xt;
680  FEConfigPedDat rd_ped;
681  int icells = 0;
682  for (CIfeped p = dataset_TpgPed.begin(); p != dataset_TpgPed.end(); p++) {
683  ecid_xt = p->first;
684  rd_ped = p->second;
685 
686  std::string ecid_name = ecid_xt.getName();
687 
688  // EB data
689  if (ecid_name == "EB_crystal_number") {
690  if (icells < 10)
691  edm::LogInfo("TopInfo") << " copy the EB data "
692  << " icells = " << icells << "\n";
693  int sm_num = ecid_xt.getID1();
694  int xt_num = ecid_xt.getID2();
695 
696  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
698  item.mean_x1 = (unsigned int)rd_ped.getPedMeanG1();
699  item.mean_x6 = (unsigned int)rd_ped.getPedMeanG6();
700  item.mean_x12 = (unsigned int)rd_ped.getPedMeanG12();
701  item.rms_x1 = 0.5;
702  item.rms_x6 = 1.;
703  item.rms_x12 = 1.2;
704 
705  peds.insert(std::make_pair(ebdetid.rawId(), item));
706  ++icells;
707  } else if (ecid_name == "EE_crystal_number") {
708  // EE data
709  int z = ecid_xt.getID1();
710  int x = ecid_xt.getID2();
711  int y = ecid_xt.getID3();
712  EEDetId eedetid(x, y, z, EEDetId::XYMODE);
714  item.mean_x1 = (unsigned int)rd_ped.getPedMeanG1();
715  item.mean_x6 = (unsigned int)rd_ped.getPedMeanG6();
716  item.mean_x12 = (unsigned int)rd_ped.getPedMeanG12();
717  item.rms_x1 = 0.5;
718  item.rms_x6 = 1.;
719  item.rms_x12 = 1.2;
720 
721  peds.insert(std::make_pair(eedetid.rawId(), item));
722  ++icells;
723  }
724  }
725 
726  pedMap = peds.getMap();
727 
728  EcalPedestalsMapIterator pedIter;
729  int nPed = 0;
730  for (pedIter = pedMap.begin(); pedIter != pedMap.end() && nPed < 10; ++pedIter, nPed++) {
731  EcalPedestals::Item aped = (*pedIter);
732  ss << aped.mean_x12 << ", " << aped.mean_x6 << ", " << aped.mean_x1 << "\n";
733  }
734  }
735 
736  edm::LogInfo("TopInfo") << ss.str();
737  ss.str("");
738 
739  // Intercalib constants
740  ss << "Getting intercalib from offline DB...\n";
742  evtSetup.get<EcalIntercalibConstantsRcd>().get(pIntercalib);
743  const EcalIntercalibConstants* intercalib = pIntercalib.product();
744  const EcalIntercalibConstantMap& calibMap = intercalib->getMap();
746  int nCal = 0;
747  for (calIter = calibMap.begin(); calIter != calibMap.end() && nCal < 10; ++calIter, nCal++) {
748  ss << (*calIter) << "\n";
749  }
750  edm::LogInfo("TopInfo") << ss.str();
751  ss.str("");
752  float calibvec[1700];
753  if (H2_) {
754  edm::LogInfo("TopInfo") << "H2: overwriting IC coef with file"
755  << "\n";
756  std::ifstream calibfile("calib_sm36.txt", std::ios::out);
757  int idata, icry;
758  float fdata, fcali;
759  std::string strdata;
760  if (calibfile.is_open()) {
761  calibfile >> strdata >> strdata >> strdata >> strdata >> strdata;
762  while (!calibfile.eof()) {
763  calibfile >> idata >> icry >> fcali >> fdata >> fdata;
764  calibvec[icry - 1] = fcali;
765  if (calibfile.eof()) {
766  break; // avoid last line duplication
767  }
768  }
769  }
770  }
771 
772  // Gain Ratios
773  ss << "Getting the gain ratios from offline DB...\n";
775  evtSetup.get<EcalGainRatiosRcd>().get(pRatio);
776  const EcalGainRatioMap& gainMap = pRatio.product()->getMap();
778  int nGain = 0;
779  for (gainIter = gainMap.begin(); gainIter != gainMap.end() && nGain < 10; ++gainIter, nGain++) {
780  const EcalMGPAGainRatio& aGain = (*gainIter);
781  ss << aGain.gain12Over6() << ", " << aGain.gain6Over1() * aGain.gain12Over6() << "\n";
782  }
783  edm::LogInfo("TopInfo") << ss.str();
784  ss.str("");
785 
786  // ADCtoGeV
787  ss << "Getting the ADC to GeV from offline DB...\n";
789  evtSetup.get<EcalADCToGeVConstantRcd>().get(pADCToGeV);
790  const EcalADCToGeVConstant* ADCToGeV = pADCToGeV.product();
791  xtal_LSB_EB_ = ADCToGeV->getEBValue();
792  xtal_LSB_EE_ = ADCToGeV->getEEValue();
793  ss << "xtal_LSB_EB_ = " << xtal_LSB_EB_ << "\n";
794  ss << "xtal_LSB_EE_ = " << xtal_LSB_EE_ << "\n";
795 
796  vector<EcalLogicID> my_EcalLogicId;
797  vector<EcalLogicID> my_TTEcalLogicId;
798  vector<EcalLogicID> my_StripEcalLogicId;
799  EcalLogicID my_EcalLogicId_EB;
800  // Endcap identifiers
801  EcalLogicID my_EcalLogicId_EE;
802  vector<EcalLogicID> my_TTEcalLogicId_EE;
803  vector<EcalLogicID> my_RTEcalLogicId_EE;
804  vector<EcalLogicID> my_StripEcalLogicId1_EE;
805  vector<EcalLogicID> my_StripEcalLogicId2_EE;
806  vector<EcalLogicID> my_CrystalEcalLogicId_EE;
807  vector<EcalLogicID> my_TTEcalLogicId_EB_by_TCC;
808  vector<EcalLogicID> my_StripEcalLogicId_EE_strips_by_TCC;
809 
812  my_EcalLogicId = db_->getEcalLogicIDSetOrdered(
813  "EB_crystal_number", 1, 36, 1, 1700, EcalLogicID::NULLID, EcalLogicID::NULLID, "EB_crystal_number", 12);
814  my_TTEcalLogicId = db_->getEcalLogicIDSetOrdered(
815  "EB_trigger_tower", 1, 36, 1, 68, EcalLogicID::NULLID, EcalLogicID::NULLID, "EB_trigger_tower", 12);
816  my_StripEcalLogicId = db_->getEcalLogicIDSetOrdered(
817  "EB_VFE", 1, 36, 1, 68, 1, 5, "EB_VFE", 123); //last digi means ordered 1st by SM,then TT, then strip
818  ss << "got the 3 ecal barrel logic id set\n";
819 
820  // EE crystals identifiers
821  my_CrystalEcalLogicId_EE =
822  db_->getEcalLogicIDSetOrdered("EE_crystal_number", -1, 1, 0, 200, 0, 200, "EE_crystal_number", 123);
823 
824  // EE Strip identifiers
825  // DCC=601-609 TT = ~40 EEstrip = 5
826  my_StripEcalLogicId1_EE =
827  db_->getEcalLogicIDSetOrdered("ECAL_readout_strip", 601, 609, 1, 100, 0, 5, "ECAL_readout_strip", 123);
828  // EE Strip identifiers
829  // DCC=646-654 TT = ~40 EEstrip = 5
830  my_StripEcalLogicId2_EE =
831  db_->getEcalLogicIDSetOrdered("ECAL_readout_strip", 646, 654, 1, 100, 0, 5, "ECAL_readout_strip", 123);
832  // ----> modif here 31/1/2011
833  // EE Strip identifiers by TCC tower strip
834  // TCC=1-108 TT = ~40 EEstrip = 1-5
835  my_StripEcalLogicId_EE_strips_by_TCC =
836  db_->getEcalLogicIDSetOrdered("EE_trigger_strip", 1, 108, 1, 100, 1, 5, "EE_trigger_strip", 123);
837 
838  // ----> modif here 31/1/2011
839  // ECAL Barrel trigger towers by TCC/tower identifiers
840  // TTC=38-72 TT = 1-68
841  my_TTEcalLogicId_EB_by_TCC = db_->getEcalLogicIDSetOrdered(
842  "ECAL_trigger_tower", 1, 108, 1, 68, EcalLogicID::NULLID, EcalLogicID::NULLID, "ECAL_trigger_tower", 12);
843 
844  // EE TT identifiers
845  // TTC=72 TT = 1440
846  my_TTEcalLogicId_EE = db_->getEcalLogicIDSetOrdered(
847  "EE_trigger_tower", 1, 108, 1, 40, EcalLogicID::NULLID, EcalLogicID::NULLID, "EE_trigger_tower", 12);
848 
849  // EE TT identifiers
850  // TTC=72 TT = 1440
851  my_RTEcalLogicId_EE = db_->getEcalLogicIDSetOrdered(
852  "EE_readout_tower", 1, 1000, 1, 100, EcalLogicID::NULLID, EcalLogicID::NULLID, "EE_readout_tower", 12);
853  edm::LogInfo("TopInfo") << ss.str();
854  ss.str("");
855 
856  if (writeToDB_) {
857  ss << "Getting the latest ids for this tag (latest version) "
858  << "\n";
859 
860  FEConfigMainInfo fe_main_info;
861  fe_main_info.setConfigTag(tag_);
862 
863  ss << "trying to read previous tag if it exists tag=" << tag_ << ".version" << version_ << "\n";
864 
865  db_->fetchConfigSet(&fe_main_info);
866  if (fe_main_info.getPedId() > 0 && ped_conf_id_ == 0)
867  ped_conf_id_ = fe_main_info.getPedId();
868  lin_conf_id_ = fe_main_info.getLinId();
869  lut_conf_id_ = fe_main_info.getLUTId();
870  wei_conf_id_ = fe_main_info.getWeiId();
871  fgr_conf_id_ = fe_main_info.getFgrId();
872  sli_conf_id_ = fe_main_info.getSliId();
873  spi_conf_id_ = fe_main_info.getSpiId(); //modif-alex 21/01/11
874  del_conf_id_ = fe_main_info.getTimId(); //modif-alex 21/01/11
875  if (fe_main_info.getBxtId() > 0 && bxt_conf_id_ == 0)
876  bxt_conf_id_ = fe_main_info.getBxtId();
877  if (fe_main_info.getBttId() > 0 && btt_conf_id_ == 0)
878  btt_conf_id_ = fe_main_info.getBttId();
879  if (fe_main_info.getBstId() > 0 && bst_conf_id_ == 0)
880  bst_conf_id_ = fe_main_info.getBstId();
881  // those that are not written specifically in this program are propagated
882  // from the previous record with the same tag and the highest version
883  }
884 
886  // Compute linearization coeff section //
888 
889  map<EcalLogicID, FEConfigPedDat> pedset;
890  map<EcalLogicID, FEConfigLinDat> linset;
891  map<EcalLogicID, FEConfigLinParamDat> linparamset;
892  map<EcalLogicID, FEConfigLUTParamDat> lutparamset;
893  map<EcalLogicID, FEConfigFgrParamDat> fgrparamset;
894 
895  map<int, linStruc> linEtaSlice;
896  map<vector<int>, linStruc> linMap;
897 
898  // count number of strip per tower
899  int NbOfStripPerTCC[108][68];
900  for (int i = 0; i < 108; i++)
901  for (int j = 0; j < 68; j++)
902  NbOfStripPerTCC[i][j] = 0;
903  const std::vector<DetId>& ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
904  const std::vector<DetId>& eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
905  for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
906  EBDetId id(*it);
907  const EcalTrigTowerDetId towid = id.tower();
909  int tccNb = theMapping_->TCCid(towid);
910  int towerInTCC = theMapping_->iTT(towid);
911  int stripInTower = elId.pseudoStripId();
912  if (stripInTower > NbOfStripPerTCC[tccNb - 1][towerInTCC - 1])
913  NbOfStripPerTCC[tccNb - 1][towerInTCC - 1] = stripInTower;
914  }
915  for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
916  EEDetId id(*it);
917  const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id);
919  int tccNb = theMapping_->TCCid(towid);
920  int towerInTCC = theMapping_->iTT(towid);
921  int stripInTower = elId.pseudoStripId();
922  if (stripInTower > NbOfStripPerTCC[tccNb - 1][towerInTCC - 1])
923  NbOfStripPerTCC[tccNb - 1][towerInTCC - 1] = stripInTower;
924  }
925 
926  // loop on EB xtals
927  if (writeToFiles_)
928  (*out_file_) << "COMMENT ====== barrel crystals ====== " << std::endl;
929 
930  // special case of eta slices
931  for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
932  EBDetId id(*it);
933  double theta = theBarrelGeometry_->getGeometry(id)->getPosition().theta();
935  theta = acos(0.);
936  const EcalTrigTowerDetId towid = id.tower();
938  int dccNb = theMapping_->DCCid(towid);
939  int tccNb = theMapping_->TCCid(towid);
940  int towerInTCC = theMapping_->iTT(towid); // from 1 to 68 (EB)
941  int stripInTower = elId.pseudoStripId(); // from 1 to 5
942  int xtalInStrip = elId.channelId(); // from 1 to 5
944  int CCUid = Id.towerId();
945  int VFEid = Id.stripId();
946  int xtalInVFE = Id.xtalId();
947  int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1; // Evgueni expects [0,24]
948 
949  (*geomFile_) << "dccNb = " << dccNb << " tccNb = " << tccNb << " towerInTCC = " << towerInTCC
950  << " stripInTower = " << stripInTower << " xtalInStrip = " << xtalInStrip << " CCUid = " << CCUid
951  << " VFEid = " << VFEid << " xtalInVFE = " << xtalInVFE << " xtalWithinCCUid = " << xtalWithinCCUid
952  << " ieta = " << id.ieta() << " iphi = " << id.iphi() << " xtalhashedId = " << id.hashedIndex()
953  << " xtalNb = " << id.ic() << " ietaTT = " << towid.ieta() << " iphiTT = " << towid.iphi() << endl;
954 
955  int TCCch = towerInTCC;
956  int SLBslot = int((towerInTCC - 1) / 8.) + 1;
957  int SLBch = (towerInTCC - 1) % 8 + 1;
958  int cmsswId = id.rawId();
959  int ixtal = (id.ism() - 1) * 1700 + (id.ic() - 1);
960  EcalLogicID logicId = my_EcalLogicId[ixtal];
961  int dbId = logicId.getLogicID();
962  int val[] = {dccNb + 600,
963  tccNb,
964  towerInTCC,
965  stripInTower,
966  xtalInStrip,
967  CCUid,
968  VFEid,
969  xtalInVFE,
970  xtalWithinCCUid,
971  id.ieta(),
972  id.iphi(),
973  -999,
974  -999,
975  towid.ieta() / abs(towid.ieta()),
976  id.hashedIndex(),
977  id.ic(),
978  cmsswId,
979  dbId,
980  towid.ieta(),
981  towid.iphi(),
982  TCCch,
983  getCrate(tccNb).second,
984  SLBch,
985  SLBslot,
986  getGCTRegionEta(towid.ieta()),
987  getGCTRegionPhi(towid.iphi())};
988  for (int i = 0; i < 26; i++)
989  ntupleInts_[i] = val[i];
990 
991  strcpy(ntupleDet_, getDet(tccNb).c_str());
992  strcpy(ntupleCrate_, getCrate(tccNb).first.c_str());
993  ntuple->Fill();
994 
995  if (tccNb == 37 && stripInTower == 3 && xtalInStrip == 3 && (towerInTCC - 1) % 4 == 0) {
996  int etaSlice = towid.ietaAbs();
997  coeffStruc coeff;
998  //getCoeff(coeff, calibMap, id.rawId()) ;
999  //modif-alex-27-july-2015
1000  string str;
1001  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str);
1002  ss << str;
1003  getCoeff(coeff, gainMap, id.rawId());
1004  getCoeff(coeff, pedMap, id.rawId());
1005  linStruc lin;
1006  for (int i = 0; i < 3; i++) {
1007  int mult, shift;
1008  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EB", mult, shift);
1009  if (!ok)
1010  edm::LogError("TopInfo") << "unable to compute the parameters for SM=" << id.ism() << " xt=" << id.ic() << " "
1011  << dec << id.rawId() << "\n";
1012  else {
1013  lin.pedestal_[i] = coeff.pedestals_[i];
1014  lin.mult_[i] = mult;
1015  lin.shift_[i] = shift;
1016  }
1017  }
1018 
1019  bool ok(true);
1020  if (forcedPedestalValue_ == -2)
1021  ok = realignBaseline(lin, 0);
1022  if (!ok)
1023  ss << "SM=" << id.ism() << " xt=" << id.ic() << " " << dec << id.rawId() << "\n";
1024  linEtaSlice[etaSlice] = lin;
1025  }
1026  }
1027 
1028  // general case
1029  for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
1030  EBDetId id(*it);
1031  double theta = theBarrelGeometry_->getGeometry(id)->getPosition().theta();
1032  if (!useTransverseEnergy_)
1033  theta = acos(0.);
1034  const EcalTrigTowerDetId towid = id.tower();
1035  towerListEB.push_back(towid.rawId());
1037  stripListEB.push_back(elId.rawId() & 0xfffffff8);
1038  int dccNb = theMapping_->DCCid(towid);
1039  //int tccNb = theMapping_->TCCid(towid) ;
1040  int towerInTCC = theMapping_->iTT(towid); // from 1 to 68 (EB)
1041  //int stripInTower = elId.pseudoStripId() ; // from 1 to 5
1042  //int xtalInStrip = elId.channelId() ; // from 1 to 5
1044  int CCUid = Id.towerId();
1045  int VFEid = Id.stripId();
1046  int xtalInVFE = Id.xtalId();
1047  int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1; // Evgueni expects [0,24]
1048  int etaSlice = towid.ietaAbs();
1049 
1050  // hashed index of strip EcalLogicID:
1051  int hashedStripLogicID = 68 * 5 * (id.ism() - 1) + 5 * (towerInTCC - 1) + (VFEid - 1);
1052  stripMapEB[hashedStripLogicID] = elId.rawId() & 0xfffffff8;
1053  stripMapEBsintheta[elId.rawId() & 0xfffffff8] = SFGVB_Threshold_ + abs(int(sin(theta) * pedestal_offset_));
1054 
1055  //modif-debug
1056  /*
1057  FEConfigFgrEEStripDat stripdebug;
1058  EcalLogicID thestrip_debug = my_StripEcalLogicId[hashedStripLogicID] ;
1059  if(towid.ieta() == 6 && towid.iphi() == 7){
1060  std::cout << "xtal info=" << id << " VFE=" << VFEid << std::endl;
1061  std::cout << "TOWER DEBUG ieta=" << towid.ieta() << " iphi=" << towid.iphi() << " SFGVB=" << SFGVB_Threshold_ + abs(int(sin(theta)*pedestal_offset_))
1062  << " dbId=" << (elId.rawId() & 0xfffffff8) << " " << hashedStripLogicID << " " << thestrip_debug.getLogicID() << std::endl; //modif-debug
1063  }//EB+3 TT24
1064  */
1065  //std::cout<<std::dec<<SFGVB_Threshold_ + abs(int(sin(theta)*pedestal_offset_))<<" "<<SFGVB_Threshold_<<" "<<abs(int(sin(theta)*pedestal_offset_))<<std::endl ;
1066 
1067  FEConfigPedDat pedDB;
1068  FEConfigLinDat linDB;
1069  if (writeToFiles_)
1070  (*out_file_) << "CRYSTAL " << dec << id.rawId() << std::endl;
1071  // if (writeToDB_) logicId = db_->getEcalLogicID ("EB_crystal_number", id.ism(), id.ic()) ;
1072 
1073  coeffStruc coeff;
1074  //getCoeff(coeff, calibMap, id.rawId()) ;
1075  //modif-alex-27-july-2015
1076  std::string str;
1077  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str);
1078  ss << str;
1079 
1080  if (H2_)
1081  coeff.calibCoeff_ = calibvec[id.ic() - 1];
1082  getCoeff(coeff, gainMap, id.rawId());
1083  getCoeff(coeff, pedMap, id.rawId());
1084  ICEB->Fill(id.iphi(), id.ieta(), coeff.calibCoeff_);
1085  IC->Fill(theBarrelGeometry_->getGeometry(id)->getPosition().phi(),
1086  theBarrelGeometry_->getGeometry(id)->getPosition().eta(),
1087  coeff.calibCoeff_);
1088 
1089  vector<int> xtalCCU;
1090  xtalCCU.push_back(dccNb + 600);
1091  xtalCCU.push_back(CCUid);
1092  xtalCCU.push_back(xtalWithinCCUid);
1093  xtalCCU.push_back(id.rawId());
1094 
1095  // compute and fill linearization parameters
1096  // case of eta slice
1097  if (forceEtaSlice_) {
1098  map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1099  if (itLin != linEtaSlice.end()) {
1100  linMap[xtalCCU] = itLin->second;
1101  if (writeToFiles_) {
1102  for (int i = 0; i < 3; i++)
1103  (*out_file_) << hex << " 0x" << itLin->second.pedestal_[i] << " 0x" << itLin->second.mult_[i] << " 0x"
1104  << itLin->second.shift_[i] << std::endl;
1105  }
1106  if (writeToDB_) {
1107  for (int i = 0; i < 3; i++) {
1108  if (i == 0) {
1109  pedDB.setPedMeanG12(itLin->second.pedestal_[i]);
1110  linDB.setMultX12(itLin->second.mult_[i]);
1111  linDB.setShift12(itLin->second.shift_[i]);
1112  }
1113  if (i == 1) {
1114  pedDB.setPedMeanG6(itLin->second.pedestal_[i]);
1115  linDB.setMultX6(itLin->second.mult_[i]);
1116  linDB.setShift6(itLin->second.shift_[i]);
1117  }
1118  if (i == 2) {
1119  pedDB.setPedMeanG1(itLin->second.pedestal_[i]);
1120  linDB.setMultX1(itLin->second.mult_[i]);
1121  linDB.setShift1(itLin->second.shift_[i]);
1122  }
1123  }
1124  }
1125  float factor = float(itLin->second.mult_[0]) * pow(2., -itLin->second.shift_[0]) / xtal_LSB_EB_;
1126  tpgFactorEB->Fill(id.iphi(), id.ieta(), factor);
1127  tpgFactor->Fill(theBarrelGeometry_->getGeometry(id)->getPosition().phi(),
1128  theBarrelGeometry_->getGeometry(id)->getPosition().eta(),
1129  factor);
1130  } else
1131  ss << "current EtaSlice = " << etaSlice << " not found in the EtaSlice map"
1132  << "\n";
1133  } else {
1134  // general case
1135  linStruc lin;
1136  int forceBase12 = 0;
1137  for (int i = 0; i < 3; i++) {
1138  int mult, shift;
1139  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EB", mult, shift);
1140  if (!ok)
1141  edm::LogError("TopInfo") << "unable to compute the parameters for SM=" << id.ism() << " xt=" << id.ic() << " "
1142  << dec << id.rawId() << "\n";
1143  else {
1144  //PP begin
1145  // mult = 0 ; shift = 0 ;
1146  // if (CCUid==1 && xtalWithinCCUid==21) {
1147  // if (i==0) {mult = 0x80 ; shift = 0x3 ;}
1148  // if (i==1) {mult = 0x80 ; shift = 0x2 ;}
1149  // if (i==2) {mult = 0xc0 ; shift = 0x0 ;}
1150  // }
1151  //PP end
1152  double base = coeff.pedestals_[i];
1153  if (forcedPedestalValue_ == -3 && i == 0) {
1154  double G = mult * pow(2.0, -(shift + 2));
1155  double g = G / sin(theta);
1156  // int pedestal = coeff.pedestals_[i] ;
1157  base = double(coeff.pedestals_[i]) - pedestal_offset_ / g;
1158  if (base < 0.)
1159  base = 0;
1160  forceBase12 = int(base);
1161  }
1162  lin.pedestal_[i] = coeff.pedestals_[i];
1163  lin.mult_[i] = mult;
1164  lin.shift_[i] = shift;
1165 
1166  // if (xtalWithinCCUid != 14) {
1167  // forceBase12 = 0 ;
1168  // lin.pedestal_[i] = 0 ;
1169  // lin.mult_[i] = 0 ;
1170  // lin.shift_[i] = 0 ;
1171  // }
1172  }
1173  }
1174 
1175  bool ok(true);
1176  if (forcedPedestalValue_ == -2)
1177  ok = realignBaseline(lin, 0);
1178  if (forcedPedestalValue_ == -3)
1179  ok = realignBaseline(lin, forceBase12);
1180  if (!ok)
1181  ss << "SM=" << id.ism() << " xt=" << id.ic() << " " << dec << id.rawId() << "\n";
1182 
1183  for (int i = 0; i < 3; i++) {
1184  if (writeToFiles_)
1185  (*out_file_) << hex << " 0x" << lin.pedestal_[i] << " 0x" << lin.mult_[i] << " 0x" << lin.shift_[i]
1186  << std::endl;
1187  if (writeToDB_) {
1188  if (i == 0) {
1189  pedDB.setPedMeanG12(lin.pedestal_[i]);
1190  linDB.setMultX12(lin.mult_[i]);
1191  linDB.setShift12(lin.shift_[i]);
1192  }
1193  if (i == 1) {
1194  pedDB.setPedMeanG6(lin.pedestal_[i]);
1195  linDB.setMultX6(lin.mult_[i]);
1196  linDB.setShift6(lin.shift_[i]);
1197  }
1198  if (i == 2) {
1199  pedDB.setPedMeanG1(lin.pedestal_[i]);
1200  linDB.setMultX1(lin.mult_[i]);
1201  linDB.setShift1(lin.shift_[i]);
1202  }
1203  }
1204  if (i == 0) {
1205  float factor = float(lin.mult_[i]) * pow(2., -lin.shift_[i]) / xtal_LSB_EB_;
1206  tpgFactorEB->Fill(id.iphi(), id.ieta(), factor);
1207  tpgFactor->Fill(theBarrelGeometry_->getGeometry(id)->getPosition().phi(),
1208  theBarrelGeometry_->getGeometry(id)->getPosition().eta(),
1209  factor);
1210  }
1211  double G = lin.mult_[i] * pow(2.0, -(lin.shift_[i] + 2));
1212  double g = G / sin(theta);
1213  float val[] = {float(i),
1214  float(theta),
1215  float(G),
1216  float(g),
1217  float(coeff.pedestals_[i]),
1218  float(lin.pedestal_[i])}; // first arg = gainId (0 means gain12)
1219  ntupleSpike->Fill(val);
1220  }
1221  linMap[xtalCCU] = lin;
1222  }
1223  if (writeToDB_) {
1224  // 1700 crystals/SM in the ECAL barrel
1225  int ixtal = (id.ism() - 1) * 1700 + (id.ic() - 1);
1226  EcalLogicID logicId = my_EcalLogicId[ixtal];
1227  pedset[logicId] = pedDB;
1228  linset[logicId] = linDB;
1229  }
1230  } //ebCells
1231 
1232  if (writeToDB_) {
1233  // EcalLogicID of the whole barrel is: my_EcalLogicId_EB
1234  FEConfigLinParamDat linparam;
1235  linparam.setETSat(Et_sat_EB_);
1236  linparamset[my_EcalLogicId_EB] = linparam;
1237 
1238  FEConfigFgrParamDat fgrparam;
1241  fgrparam.setFGlowratio(FG_lowRatio_EB_);
1242  fgrparam.setFGhighratio(FG_highRatio_EB_);
1243  fgrparamset[my_EcalLogicId_EB] = fgrparam;
1244 
1245  FEConfigLUTParamDat lutparam;
1246  lutparam.setETSat(Et_sat_EB_);
1249  lutparamset[my_EcalLogicId_EB] = lutparam;
1250  }
1251 
1252  // loop on EE xtals
1253  if (writeToFiles_)
1254  (*out_file_) << "COMMENT ====== endcap crystals ====== " << std::endl;
1255 
1256  // special case of eta slices
1257  for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1258  EEDetId id(*it);
1259  double theta = theEndcapGeometry_->getGeometry(id)->getPosition().theta();
1260  if (!useTransverseEnergy_)
1261  theta = acos(0.);
1262  const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id);
1265  int dccNb = Id.dccId();
1266  int tccNb = theMapping_->TCCid(towid);
1267  int towerInTCC = theMapping_->iTT(towid);
1268  int stripInTower = elId.pseudoStripId();
1269  int xtalInStrip = elId.channelId();
1270  int CCUid = Id.towerId();
1271  int VFEid = Id.stripId();
1272  int xtalInVFE = Id.xtalId();
1273  int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1; // Evgueni expects [0,24]
1274 
1275  (*geomFile_) << "dccNb = " << dccNb << " tccNb = " << tccNb << " towerInTCC = " << towerInTCC
1276  << " stripInTower = " << stripInTower << " xtalInStrip = " << xtalInStrip << " CCUid = " << CCUid
1277  << " VFEid = " << VFEid << " xtalInVFE = " << xtalInVFE << " xtalWithinCCUid = " << xtalWithinCCUid
1278  << " ix = " << id.ix() << " iy = " << id.iy() << " xtalhashedId = " << id.hashedIndex()
1279  << " xtalNb = " << id.isc() << " ietaTT = " << towid.ieta() << " iphiTT = " << towid.iphi() << endl;
1280 
1281  int TCCch = stripInTower;
1282  int SLBslot, SLBch;
1283  if (towerInTCC < 5) {
1284  SLBslot = 1;
1285  SLBch = 4 + towerInTCC;
1286  } else {
1287  SLBslot = int((towerInTCC - 5) / 8.) + 2;
1288  SLBch = (towerInTCC - 5) % 8 + 1;
1289  }
1290  for (int j = 0; j < towerInTCC - 1; j++)
1291  TCCch += NbOfStripPerTCC[tccNb - 1][j];
1292 
1293  int cmsswId = id.rawId();
1294  EcalLogicID logicId;
1295  int iz = id.positiveZ();
1296  if (iz == 0)
1297  iz = -1;
1298  for (int k = 0; k < (int)my_CrystalEcalLogicId_EE.size(); k++) {
1299  int z = my_CrystalEcalLogicId_EE[k].getID1();
1300  int x = my_CrystalEcalLogicId_EE[k].getID2();
1301  int y = my_CrystalEcalLogicId_EE[k].getID3();
1302  if (id.ix() == x && id.iy() == y && iz == z)
1303  logicId = my_CrystalEcalLogicId_EE[k];
1304  }
1305  int dbId = logicId.getLogicID();
1306 
1307  int val[] = {dccNb + 600,
1308  tccNb,
1309  towerInTCC,
1310  stripInTower,
1311  xtalInStrip,
1312  CCUid,
1313  VFEid,
1314  xtalInVFE,
1315  xtalWithinCCUid,
1316  -999,
1317  -999,
1318  id.ix(),
1319  id.iy(),
1320  towid.ieta() / abs(towid.ieta()),
1321  id.hashedIndex(),
1322  id.ic(),
1323  cmsswId,
1324  dbId,
1325  towid.ieta(),
1326  towid.iphi(),
1327  TCCch,
1328  getCrate(tccNb).second,
1329  SLBch,
1330  SLBslot,
1331  getGCTRegionEta(towid.ieta()),
1332  getGCTRegionPhi(towid.iphi())};
1333  for (int i = 0; i < 26; i++)
1334  ntupleInts_[i] = val[i];
1335  strcpy(ntupleDet_, getDet(tccNb).c_str());
1336  strcpy(ntupleCrate_, getCrate(tccNb).first.c_str());
1337  ntuple->Fill();
1338 
1339  if ((tccNb == 76 || tccNb == 94) && stripInTower == 1 && xtalInStrip == 3 && (towerInTCC - 1) % 4 == 0) {
1340  int etaSlice = towid.ietaAbs();
1341  coeffStruc coeff;
1342  //getCoeff(coeff, calibMap, id.rawId()) ;
1343  //modif-alex-27-july-2015
1344  std::string str;
1345  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str);
1346  ss << str;
1347  getCoeff(coeff, gainMap, id.rawId());
1348  getCoeff(coeff, pedMap, id.rawId());
1349  linStruc lin;
1350  for (int i = 0; i < 3; i++) {
1351  int mult, shift;
1352  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EE", mult, shift);
1353  if (!ok)
1354  edm::LogError("TopInfo") << "unable to compute the parameters for Quadrant=" << id.iquadrant()
1355  << " xt=" << id.ic() << " " << dec << id.rawId() << "\n";
1356  else {
1357  lin.pedestal_[i] = coeff.pedestals_[i];
1358  lin.mult_[i] = mult;
1359  lin.shift_[i] = shift;
1360  }
1361  }
1362 
1363  bool ok(true);
1364  if (forcedPedestalValue_ == -2 || forcedPedestalValue_ == -3)
1365  ok = realignBaseline(lin, 0);
1366  if (!ok)
1367  ss << "Quadrant=" << id.iquadrant() << " xt=" << id.ic() << " " << dec << id.rawId() << "\n";
1368 
1369  linEtaSlice[etaSlice] = lin;
1370  }
1371  }
1372 
1373  // general case
1374  for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1375  EEDetId id(*it);
1376  double theta = theEndcapGeometry_->getGeometry(id)->getPosition().theta();
1377  if (!useTransverseEnergy_)
1378  theta = acos(0.);
1379  const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id);
1382  towerListEE.push_back(towid.rawId());
1383  // special case of towers in inner rings of EE
1384  if (towid.ietaAbs() == 27 || towid.ietaAbs() == 28) {
1385  EcalTrigTowerDetId additionalTower(towid.zside(), towid.subDet(), towid.ietaAbs(), towid.iphi() + 1);
1386  towerListEE.push_back(additionalTower.rawId());
1387  }
1388  stripListEE.push_back(elId.rawId() & 0xfffffff8);
1389  int dccNb = Id.dccId();
1390  //int tccNb = theMapping_->TCCid(towid) ;
1391  //int towerInTCC = theMapping_->iTT(towid) ;
1392  //int stripInTower = elId.pseudoStripId() ;
1393  //int xtalInStrip = elId.channelId() ;
1394  int CCUid = Id.towerId();
1395  int VFEid = Id.stripId();
1396  int xtalInVFE = Id.xtalId();
1397  int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1; // Evgueni expects [0,24]
1398  int etaSlice = towid.ietaAbs();
1399 
1400  EcalLogicID logicId;
1401  FEConfigPedDat pedDB;
1402  FEConfigLinDat linDB;
1403  if (writeToFiles_)
1404  (*out_file_) << "CRYSTAL " << dec << id.rawId() << std::endl;
1405  if (writeToDB_ && DBEE_) {
1406  int iz = id.positiveZ();
1407  if (iz == 0)
1408  iz = -1;
1409  for (int k = 0; k < (int)my_CrystalEcalLogicId_EE.size(); k++) {
1410  int z = my_CrystalEcalLogicId_EE[k].getID1();
1411  int x = my_CrystalEcalLogicId_EE[k].getID2();
1412  int y = my_CrystalEcalLogicId_EE[k].getID3();
1413  if (id.ix() == x && id.iy() == y && iz == z)
1414  logicId = my_CrystalEcalLogicId_EE[k];
1415  }
1416  }
1417 
1418  coeffStruc coeff;
1419  //getCoeff(coeff, calibMap, id.rawId()) ;
1420  //modif-alex-27-july-2015
1421  string str;
1422  getCoeff(coeff, calibMap, laserAlphaMap, id.rawId(), str);
1423  ss << str;
1424  getCoeff(coeff, gainMap, id.rawId());
1425  getCoeff(coeff, pedMap, id.rawId());
1426  if (id.zside() > 0)
1427  ICEEPlus->Fill(id.ix(), id.iy(), coeff.calibCoeff_);
1428  else
1429  ICEEMinus->Fill(id.ix(), id.iy(), coeff.calibCoeff_);
1430  IC->Fill(theEndcapGeometry_->getGeometry(id)->getPosition().phi(),
1431  theEndcapGeometry_->getGeometry(id)->getPosition().eta(),
1432  coeff.calibCoeff_);
1433 
1434  vector<int> xtalCCU;
1435  xtalCCU.push_back(dccNb + 600);
1436  xtalCCU.push_back(CCUid);
1437  xtalCCU.push_back(xtalWithinCCUid);
1438  xtalCCU.push_back(id.rawId());
1439 
1440  // compute and fill linearization parameters
1441  // case of eta slice
1442  if (forceEtaSlice_) {
1443  map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1444  if (itLin != linEtaSlice.end()) {
1445  linMap[xtalCCU] = itLin->second;
1446  if (writeToFiles_) {
1447  for (int i = 0; i < 3; i++)
1448  (*out_file_) << hex << " 0x" << itLin->second.pedestal_[i] << " 0x" << itLin->second.mult_[i] << " 0x"
1449  << itLin->second.shift_[i] << std::endl;
1450  }
1451  if (writeToDB_ && DBEE_) {
1452  for (int i = 0; i < 3; i++) {
1453  if (i == 0) {
1454  pedDB.setPedMeanG12(itLin->second.pedestal_[i]);
1455  linDB.setMultX12(itLin->second.mult_[i]);
1456  linDB.setShift12(itLin->second.shift_[i]);
1457  }
1458  if (i == 1) {
1459  pedDB.setPedMeanG6(itLin->second.pedestal_[i]);
1460  linDB.setMultX6(itLin->second.mult_[i]);
1461  linDB.setShift6(itLin->second.shift_[i]);
1462  }
1463  if (i == 2) {
1464  pedDB.setPedMeanG1(itLin->second.pedestal_[i]);
1465  linDB.setMultX1(itLin->second.mult_[i]);
1466  linDB.setShift1(itLin->second.shift_[i]);
1467  }
1468  }
1469  }
1470  float factor = float(itLin->second.mult_[0]) * pow(2., -itLin->second.shift_[0]) / xtal_LSB_EE_;
1471  if (id.zside() > 0)
1472  tpgFactorEEPlus->Fill(id.ix(), id.iy(), factor);
1473  else
1474  tpgFactorEEMinus->Fill(id.ix(), id.iy(), factor);
1475  tpgFactor->Fill(theEndcapGeometry_->getGeometry(id)->getPosition().phi(),
1476  theEndcapGeometry_->getGeometry(id)->getPosition().eta(),
1477  factor);
1478  } else
1479  ss << "current EtaSlice = " << etaSlice << " not found in the EtaSlice map"
1480  << "\n";
1481  } else {
1482  // general case
1483  linStruc lin;
1484  for (int i = 0; i < 3; i++) {
1485  int mult, shift;
1486  bool ok = computeLinearizerParam(theta, coeff.gainRatio_[i], coeff.calibCoeff_, "EE", mult, shift);
1487  if (!ok)
1488  edm::LogError("TopInfo") << "unable to compute the parameters for " << dec << id.rawId() << "\n";
1489  else {
1490  lin.pedestal_[i] = coeff.pedestals_[i];
1491  lin.mult_[i] = mult;
1492  lin.shift_[i] = shift;
1493  }
1494  }
1495 
1496  bool ok(true);
1497  if (forcedPedestalValue_ == -2 || forcedPedestalValue_ == -3)
1498  ok = realignBaseline(lin, 0);
1499  if (!ok)
1500  ss << "Quadrant=" << id.iquadrant() << " xt=" << id.ic() << " " << dec << id.rawId() << "\n";
1501 
1502  for (int i = 0; i < 3; i++) {
1503  if (writeToFiles_)
1504  (*out_file_) << hex << " 0x" << lin.pedestal_[i] << " 0x" << lin.mult_[i] << " 0x" << lin.shift_[i]
1505  << std::endl;
1506  if (writeToDB_ && DBEE_) {
1507  if (i == 0) {
1508  pedDB.setPedMeanG12(lin.pedestal_[i]);
1509  linDB.setMultX12(lin.mult_[i]);
1510  linDB.setShift12(lin.shift_[i]);
1511  }
1512  if (i == 1) {
1513  pedDB.setPedMeanG6(lin.pedestal_[i]);
1514  linDB.setMultX6(lin.mult_[i]);
1515  linDB.setShift6(lin.shift_[i]);
1516  }
1517  if (i == 2) {
1518  pedDB.setPedMeanG1(lin.pedestal_[i]);
1519  linDB.setMultX1(lin.mult_[i]);
1520  linDB.setShift1(lin.shift_[i]);
1521  }
1522  }
1523  if (i == 0) {
1524  float factor = float(lin.mult_[i]) * pow(2., -lin.shift_[i]) / xtal_LSB_EE_;
1525  if (id.zside() > 0)
1526  tpgFactorEEPlus->Fill(id.ix(), id.iy(), factor);
1527  else
1528  tpgFactorEEMinus->Fill(id.ix(), id.iy(), factor);
1529  tpgFactor->Fill(theEndcapGeometry_->getGeometry(id)->getPosition().phi(),
1530  theEndcapGeometry_->getGeometry(id)->getPosition().eta(),
1531  factor);
1532  }
1533  }
1534  linMap[xtalCCU] = lin;
1535  }
1536  if (writeToDB_ && DBEE_) {
1537  pedset[logicId] = pedDB;
1538  linset[logicId] = linDB;
1539  }
1540  } //eeCells
1541  edm::LogInfo("TopInfo") << ss.str();
1542  ss.str("");
1543 
1544  if (writeToDB_) {
1545  // EcalLogicID of the whole barrel is: my_EcalLogicId_EB
1546  FEConfigLinParamDat linparam;
1547  linparam.setETSat(Et_sat_EE_);
1548  linparamset[my_EcalLogicId_EE] = linparam;
1549 
1550  FEConfigLUTParamDat lutparam;
1551  lutparam.setETSat(Et_sat_EE_);
1554  lutparamset[my_EcalLogicId_EE] = lutparam;
1555 
1556  FEConfigFgrParamDat fgrparam;
1557  fgrparam.setFGlowthresh(FG_Threshold_EE_);
1559  fgrparamset[my_EcalLogicId_EE] = fgrparam;
1560  }
1561 
1562  if (writeToDB_) {
1563  ostringstream ltag;
1564  ltag.str("EB_");
1565  ltag << Et_sat_EB_ << "_EE_" << Et_sat_EE_;
1566  std::string lin_tag = ltag.str();
1567  ss << " LIN tag " << lin_tag << "\n";
1568 
1569  if (m_write_ped == 1) {
1570  ped_conf_id_ = db_->writeToConfDB_TPGPedestals(pedset, 1, "from_OfflineDB");
1571  } else {
1572  ss << "the ped id =" << ped_conf_id_ << " will be used for the pedestals "
1573  << "\n";
1574  }
1575 
1576  if (m_write_lin == 1)
1577  lin_conf_id_ = db_->writeToConfDB_TPGLinearCoef(linset, linparamset, 1, lin_tag);
1578  }
1579 
1581  // Evgueni interface
1583  std::ofstream evgueni("TPG_hardcoded.hh", std::ios::out);
1584  evgueni << "void getLinParamTPG_hardcoded(int fed, int ccu, int xtal," << endl;
1585  evgueni << " int & mult12, int & shift12, int & base12," << endl;
1586  evgueni << " int & mult6, int & shift6, int & base6," << endl;
1587  evgueni << " int & mult1, int & shift1, int & base1)" << endl;
1588  evgueni << "{" << endl;
1589  evgueni << " mult12 = 0 ; shift12 = 0 ; base12 = 0 ; mult6 = 0 ; shift6 = 0 ; base6 = 0 ; mult1 = 0 ; shift1 = 0 ; "
1590  "base1 = 0 ;"
1591  << endl;
1592  map<vector<int>, linStruc>::const_iterator itLinMap;
1593  for (itLinMap = linMap.begin(); itLinMap != linMap.end(); itLinMap++) {
1594  vector<int> xtalInCCU = itLinMap->first;
1595  evgueni << " if (fed==" << xtalInCCU[0] << " && ccu==" << xtalInCCU[1] << " && xtal==" << xtalInCCU[2] << ") {";
1596  evgueni << " mult12 = " << itLinMap->second.mult_[0] << " ; shift12 = " << itLinMap->second.shift_[0]
1597  << " ; base12 = " << itLinMap->second.pedestal_[0] << " ; ";
1598  evgueni << " mult6 = " << itLinMap->second.mult_[1] << " ; shift6 = " << itLinMap->second.shift_[1]
1599  << " ; base6 = " << itLinMap->second.pedestal_[1] << " ; ";
1600  evgueni << " mult1 = " << itLinMap->second.mult_[2] << " ; shift1 = " << itLinMap->second.shift_[2]
1601  << " ; base1 = " << itLinMap->second.pedestal_[2] << " ; ";
1602  evgueni << " return ;}" << endl;
1603  }
1604  evgueni << "}" << endl;
1605  evgueni.close();
1606 
1608  // Compute weights section //
1610 
1611  const int NWEIGROUPS = 2;
1612  std::vector<unsigned int> weights[NWEIGROUPS];
1613 
1614  bool useDBShape = useDBShape_;
1615  EBShape shapeEB(useDBShape);
1616  shapeEB.setEventSetup(evtSetup); // EBShape, EEShape are fetched now from DB (2018.05.22 K. Theofilatos)
1617  EEShape shapeEE(useDBShape);
1618  shapeEE.setEventSetup(evtSetup); //
1619  weights[0] = computeWeights(shapeEB, hshapeEB);
1620  weights[1] = computeWeights(shapeEE, hshapeEE);
1621 
1622  map<EcalLogicID, FEConfigWeightGroupDat> dataset;
1623 
1624  for (int igrp = 0; igrp < NWEIGROUPS; igrp++) {
1625  if (weights[igrp].size() == 5) {
1626  if (writeToFiles_) {
1627  (*out_file_) << std::endl;
1628  (*out_file_) << "WEIGHT " << igrp << endl;
1629  for (unsigned int sample = 0; sample < 5; sample++)
1630  (*out_file_) << "0x" << hex << weights[igrp][sample] << " ";
1631  (*out_file_) << std::endl;
1632  (*out_file_) << std::endl;
1633  }
1634  if (writeToDB_) {
1635  ss << "going to write the weights for groupe:" << igrp << "\n";
1637  gut.setWeightGroupId(igrp);
1638  //PP WARNING: weights order is reverted when stored in the DB
1639  gut.setWeight0(weights[igrp][4]);
1640  gut.setWeight1(weights[igrp][3] +
1641  0x80); //0x80 to identify the max of the pulse in the FENIX (doesn't exist in emulator)
1642  gut.setWeight2(weights[igrp][2]);
1643  gut.setWeight3(weights[igrp][1]);
1644  gut.setWeight4(weights[igrp][0]);
1645  EcalLogicID ecid = EcalLogicID("DUMMY", igrp, igrp); //1 dummy ID per group
1646  // Fill the dataset
1647  dataset[ecid] = gut;
1648  }
1649  }
1650  }
1651 
1652  if (writeToDB_) {
1653  // now we store in the DB the correspondence btw channels and groups
1654  map<EcalLogicID, FEConfigWeightDat> dataset2;
1655 
1656  // EB loop
1657  for (int ich = 0; ich < (int)my_StripEcalLogicId.size(); ich++) {
1658  FEConfigWeightDat wut;
1659  int igroup = 0; // this group is for EB
1660  wut.setWeightGroupId(igroup);
1661  dataset2[my_StripEcalLogicId[ich]] = wut;
1662  }
1663 
1664  // EE loop
1665  for (int ich = 0; ich < (int)my_StripEcalLogicId1_EE.size(); ich++) {
1666  FEConfigWeightDat wut;
1667  int igroup = 1; // this group is for EE
1668  wut.setWeightGroupId(igroup);
1669  // Fill the dataset
1670  dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1671  }
1672  // EE loop 2 (we had to split the ids of EE in 2 vectors to avoid crash!)
1673  for (int ich = 0; ich < (int)my_StripEcalLogicId2_EE.size(); ich++) {
1674  FEConfigWeightDat wut;
1675  int igroup = 1; // this group is for EE
1676  wut.setWeightGroupId(igroup);
1677  // Fill the dataset
1678  dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1679  }
1680 
1681  // Insert the datasets
1682  ostringstream wtag;
1683  wtag.str("");
1684  wtag << "Shape_NGroups_" << NWEIGROUPS;
1685  std::string weight_tag = wtag.str();
1686  ss << " weight tag " << weight_tag << "\n";
1687  if (m_write_wei == 1)
1688  wei_conf_id_ = db_->writeToConfDB_TPGWeight(dataset, dataset2, NWEIGROUPS, weight_tag);
1689  }
1690  edm::LogInfo("TopInfo") << ss.str();
1691  ss.str("");
1692 
1694  // Compute FG section //
1696 
1697  // barrel
1698  unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG;
1699  computeFineGrainEBParameters(lowRatio, highRatio, lowThreshold, highThreshold, lutFG);
1700  if (writeToFiles_) {
1701  (*out_file_) << std::endl;
1702  (*out_file_) << "FG 0" << std::endl;
1703  (*out_file_) << hex << "0x" << lowThreshold << " 0x" << highThreshold << " 0x" << lowRatio << " 0x" << highRatio
1704  << " 0x" << lutFG << std::endl;
1705  }
1706 
1707  // endcap
1708  unsigned int threshold, lut_tower;
1709  unsigned int lut_strip;
1710  computeFineGrainEEParameters(threshold, lut_strip, lut_tower);
1711 
1712  // and here we store the fgr part
1713 
1714  if (writeToDB_) {
1715  ss << "going to write the fgr "
1716  << "\n";
1717  map<EcalLogicID, FEConfigFgrGroupDat> dataset;
1718  // we create 1 group
1719  int NFGRGROUPS = 1;
1720  for (int ich = 0; ich < NFGRGROUPS; ich++) {
1721  FEConfigFgrGroupDat gut;
1722  gut.setFgrGroupId(ich);
1723  gut.setThreshLow(lowRatio);
1724  gut.setThreshHigh(highRatio);
1725  gut.setRatioLow(lowThreshold);
1726  gut.setRatioHigh(highThreshold);
1727  gut.setLUTValue(lutFG);
1728  EcalLogicID ecid = EcalLogicID("DUMMY", ich, ich);
1729  // Fill the dataset
1730  dataset[ecid] = gut; // we use any logic id but different, because it is in any case ignored...
1731  }
1732 
1733  // now we store in the DB the correspondence btw channels and groups
1734  map<EcalLogicID, FEConfigFgrDat> dataset2;
1735  // in this case I decide in a stupid way which channel belongs to which group
1736  for (int ich = 0; ich < (int)my_TTEcalLogicId.size(); ich++) {
1737  FEConfigFgrDat wut;
1738  int igroup = 0;
1739  wut.setFgrGroupId(igroup);
1740  // Fill the dataset
1741  // the logic ids are ordered by SM (1,...36) and TT (1,...68)
1742  // you have to calculate the right index here
1743  dataset2[my_TTEcalLogicId[ich]] = wut;
1744  }
1745 
1746  // endcap loop
1747  for (int ich = 0; ich < (int)my_RTEcalLogicId_EE.size(); ich++) {
1748  // std::cout << " endcap FGR " << std::endl;
1749  FEConfigFgrDat wut;
1750  int igroup = 0;
1751  wut.setFgrGroupId(igroup);
1752  // Fill the dataset
1753  // the logic ids are ordered by .... ?
1754  // you have to calculate the right index here
1755  dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1756  }
1757 
1758  // endcap TT loop for the FEfgr EE Tower
1759  map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1760  for (int ich = 0; ich < (int)my_TTEcalLogicId_EE.size(); ich++) {
1761  FEConfigFgrEETowerDat fgreett;
1762  fgreett.setLutValue(lut_tower);
1763  dataset3[my_TTEcalLogicId_EE[ich]] = fgreett;
1764  }
1765 
1766  // endcap strip loop for the FEfgr EE strip
1767  // and barrel strip loop for the spike parameters (same structure than EE FGr)
1768  map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1769  for (int ich = 0; ich < (int)my_StripEcalLogicId1_EE.size(); ich++) {
1771  zut.setThreshold(threshold);
1772  zut.setLutFgr(lut_strip);
1773  dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1774  }
1775  for (int ich = 0; ich < (int)my_StripEcalLogicId2_EE.size(); ich++) {
1777  zut.setThreshold(threshold);
1778  zut.setLutFgr(lut_strip);
1779  // Fill the dataset
1780  dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1781  }
1782  for (int ich = 0; ich < (int)my_StripEcalLogicId.size(); ich++) {
1783  // EB
1785  EcalLogicID thestrip = my_StripEcalLogicId[ich];
1786  uint32_t elStripId = stripMapEB[ich];
1787  map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId);
1788  if (it != stripMapEBsintheta.end())
1789  zut.setThreshold(it->second);
1790  else {
1791  edm::LogError("TopInfo") << "ERROR: strip SFGVB threshold parameter not found for that strip:"
1792  << thestrip.getID1() << " " << thestrip.getID3() << " " << thestrip.getID3() << "\n";
1793  edm::LogError("TopInfo") << " using value = " << SFGVB_Threshold_ + pedestal_offset_ << "\n";
1795  }
1796  zut.setLutFgr(SFGVB_lut_);
1797  // Fill the dataset
1798  dataset4[thestrip] = zut;
1799  }
1800 
1801  // Insert the dataset
1802  ostringstream wtag;
1803  wtag.str("");
1804  wtag << "FGR_" << lutFG << "_N_" << NFGRGROUPS << "_eb_" << FG_lowThreshold_EB_ << "_EB_" << FG_highThreshold_EB_;
1805  std::string weight_tag = wtag.str();
1806  ss << " weight tag " << weight_tag << "\n";
1807  if (m_write_fgr == 1)
1808  fgr_conf_id_ =
1809  db_->writeToConfDB_TPGFgr(dataset, dataset2, fgrparamset, dataset3, dataset4, NFGRGROUPS, weight_tag);
1810 
1811  //modif-alex 21/01/11
1812  map<EcalLogicID, FEConfigSpikeDat> datasetspike; //loob EB TT
1813  for (int ich = 0; ich < (int)my_TTEcalLogicId.size(); ich++) {
1814  FEConfigSpikeDat spiketh;
1816  datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1817  } //loop EB TT towers
1818 
1819  //modif-alex 21/01/11
1820  ostringstream stag;
1821  stag.str("");
1822  stag << "SpikeTh" << SFGVB_SpikeKillingThreshold_;
1823  std::string spike_tag = stag.str();
1824  ss << " spike tag " << spike_tag << "\n";
1825  if (m_write_spi == 1)
1826  spi_conf_id_ = db_->writeToConfDB_Spike(datasetspike, spike_tag); //modif-alex 21/01/11
1827 
1828  //modif-alex 31/01/11
1829  //DELAYS EB
1830  map<EcalLogicID, FEConfigTimingDat>
1831  datasetdelay; // the loop goes from TCC 38 to 72 and throught the towers from 1 to 68
1832  for (int ich = 0; ich < (int)my_TTEcalLogicId_EB_by_TCC.size(); ich++) {
1834 
1835  EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich];
1836  int id1_tcc = my_TTEcalLogicId_EB_by_TCC[ich].getID1(); // the TCC
1837  int id2_tt = my_TTEcalLogicId_EB_by_TCC[ich].getID2(); // the tower
1838  std::map<int, vector<int> >::const_iterator ittEB = delays_EB_.find(id1_tcc);
1839  std::vector<int> TimingDelaysEB = ittEB->second;
1840 
1841  if (ittEB != delays_EB_.end()) {
1842  if (TimingDelaysEB[id2_tt - 1] == -1) {
1843  edm::LogError("TopInfo") << "ERROR: Barrel timing delay not specified, check file, putting default value 1"
1844  << "\n";
1845  delay.setTimingPar1(1);
1846  } else
1847  delay.setTimingPar1(TimingDelaysEB[id2_tt - 1]);
1848  } else {
1849  edm::LogError("TopInfo") << "ERROR:Barrel Could not find delay parameter for that trigger tower "
1850  << "\n";
1851  edm::LogError("TopInfo") << "Using default value = 1"
1852  << "\n";
1853  delay.setTimingPar1(1);
1854  }
1855 
1856  std::map<int, vector<int> >::const_iterator ittpEB = phases_EB_.find(id1_tcc);
1857  std::vector<int> TimingPhasesEB = ittpEB->second;
1858 
1859  if (ittpEB != phases_EB_.end()) {
1860  if (TimingPhasesEB[id2_tt - 1] == -1) {
1861  edm::LogError("TopInfo") << "ERROR: Barrel timing phase not specified, check file, putting default value 0"
1862  << "\n";
1863  delay.setTimingPar2(0);
1864  } else
1865  delay.setTimingPar2(TimingPhasesEB[id2_tt - 1]);
1866  } else {
1867  edm::LogError("TopInfo") << "ERROR:Barrel Could not find phase parameter for that trigger tower "
1868  << "\n";
1869  edm::LogError("TopInfo") << "Using default value = 0"
1870  << "\n";
1871  delay.setTimingPar2(0);
1872  }
1873 
1874  ss << ich << " tcc=" << id1_tcc << " TT=" << id2_tt << " logicId=" << logiciddelay.getLogicID()
1875  << " delay=" << TimingDelaysEB[id2_tt - 1] << " phase=" << TimingPhasesEB[id2_tt - 1] << "\n";
1876 
1877  //delay.setTimingPar1(1);
1878  //delay.setTimingPar2(2);
1879  datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] = delay;
1880  } //loop EB TT towers
1881 
1882  //DELAYS EE
1883  int stripindex = 0;
1884  int tccin = 1;
1885  for (int ich = 0; ich < (int)my_StripEcalLogicId_EE_strips_by_TCC.size(); ich++) {
1887  //int id1_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID1(); // the TCC
1888  //int id2_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2(); // the Tower
1889  //int id3_strip=my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3(); // the strip
1890 
1891  EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich];
1892  int id1_tcc = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID1(); // the TCC
1893  int id2_tt = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2(); // the tower
1894  int id3_st = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3(); // the strip
1895 
1896  //reset strip counter
1897  if (id1_tcc != tccin) {
1898  tccin = id1_tcc;
1899  stripindex = 0;
1900  }
1901 
1902  std::map<int, vector<int> >::const_iterator ittEE = delays_EE_.find(id1_tcc);
1903  std::vector<int> TimingDelaysEE = ittEE->second;
1904 
1905  if (ittEE != delays_EE_.end()) {
1906  if (TimingDelaysEE[stripindex] == -1) {
1907  edm::LogError("TopInfo") << "ERROR: Endcap timing delay not specified, check file, putting default value 1"
1908  << "\n";
1909  delay.setTimingPar1(1);
1910  } else
1911  delay.setTimingPar1(TimingDelaysEE[stripindex]);
1912  } else {
1913  edm::LogError("TopInfo") << "ERROR:Endcap Could not find delay parameter for that trigger tower "
1914  << "\n";
1915  edm::LogError("TopInfo") << "Using default value = 1"
1916  << "\n";
1917  delay.setTimingPar1(1);
1918  }
1919 
1920  std::map<int, vector<int> >::const_iterator ittpEE = phases_EE_.find(id1_tcc);
1921  std::vector<int> TimingPhasesEE = ittpEE->second;
1922 
1923  if (ittpEE != phases_EE_.end()) {
1924  if (TimingPhasesEE[stripindex] == -1) {
1925  edm::LogError("TopInfo") << "ERROR: Endcap timing phase not specified, check file, putting default value 0"
1926  << "\n";
1927  delay.setTimingPar2(0);
1928  } else
1929  delay.setTimingPar2(TimingPhasesEE[stripindex]);
1930  } else {
1931  edm::LogError("TopInfo") << "ERROR:Endcap Could not find phase parameter for that trigger tower "
1932  << "\n";
1933  edm::LogError("TopInfo") << "Using default value = 0"
1934  << "\n";
1935  delay.setTimingPar2(0);
1936  }
1937 
1938  ss << ich << " stripindex=" << stripindex << " tcc=" << id1_tcc << " TT=" << id2_tt << " id3_st=" << id3_st
1939  << " logicId=" << logiciddelay.getLogicID() << " delay=" << TimingDelaysEE[stripindex]
1940  << " phase=" << TimingPhasesEE[stripindex] << "\n";
1941 
1942  //delay.setTimingPar1(1);
1943  //delay.setTimingPar2(2);
1944  datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] = delay;
1945  stripindex++;
1946  } //loop EE strip towers
1947 
1948  ostringstream de_tag;
1949  de_tag.str("");
1950  de_tag << "DelaysFromFile";
1951  std::string delay_tag = de_tag.str();
1952  ss << " delay tag " << delay_tag << "\n";
1953  if (m_write_del == 1)
1954  del_conf_id_ = db_->writeToConfDB_Delay(datasetdelay, delay_tag); //modif-alex 31/01/11
1955 
1956  } //write to DB
1957 
1958  if (writeToDB_) {
1959  ss << "going to write the sliding "
1960  << "\n";
1961  map<EcalLogicID, FEConfigSlidingDat> dataset;
1962  // in this case I decide in a stupid way which channel belongs to which group
1963  for (int ich = 0; ich < (int)my_StripEcalLogicId.size(); ich++) {
1964  FEConfigSlidingDat wut;
1965  wut.setSliding(sliding_);
1966  // Fill the dataset
1967  // the logic ids are ordered by SM (1,...36) , TT (1,...68) and strip (1..5)
1968  // you have to calculate the right index here
1969  dataset[my_StripEcalLogicId[ich]] = wut;
1970  }
1971 
1972  // endcap loop
1973  for (int ich = 0; ich < (int)my_StripEcalLogicId1_EE.size(); ich++) {
1974  FEConfigSlidingDat wut;
1975  wut.setSliding(sliding_);
1976  // Fill the dataset
1977  // the logic ids are ordered by fed tower strip
1978  // you have to calculate the right index here
1979  dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1980  }
1981  for (int ich = 0; ich < (int)my_StripEcalLogicId2_EE.size(); ich++) {
1982  FEConfigSlidingDat wut;
1983  wut.setSliding(sliding_);
1984  // Fill the dataset
1985  // the logic ids are ordered by ... ?
1986  // you have to calculate the right index here
1987  dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1988  }
1989 
1990  // Insert the dataset
1991  ostringstream wtag;
1992  wtag.str("");
1993  wtag << "Sliding_" << sliding_;
1994  std::string justatag = wtag.str();
1995  ss << " sliding tag " << justatag << "\n";
1996  int iov_id = 0; // just a parameter ...
1997  if (m_write_sli == 1)
1998  sli_conf_id_ = db_->writeToConfDB_TPGSliding(dataset, iov_id, justatag);
1999  }
2000 
2002  // Compute LUT section //
2004 
2005  int lut_EB[1024], lut_EE[1024];
2006 
2007  // barrel
2008  computeLUT(lut_EB, "EB");
2009  if (writeToFiles_) {
2010  (*out_file_) << std::endl;
2011  (*out_file_) << "LUT 0" << std::endl;
2012  for (int i = 0; i < 1024; i++)
2013  (*out_file_) << "0x" << hex << lut_EB[i] << endl;
2014  (*out_file_) << endl;
2015  }
2016 
2017  // endcap
2018  computeLUT(lut_EE, "EE");
2019  // check first if lut_EB and lut_EE are the same
2020  bool newLUT(false);
2021  for (int i = 0; i < 1024; i++)
2022  if (lut_EE[i] != lut_EB[i])
2023  newLUT = true;
2024  if (newLUT && writeToFiles_) {
2025  (*out_file_) << std::endl;
2026  (*out_file_) << "LUT 1" << std::endl;
2027  for (int i = 0; i < 1024; i++)
2028  (*out_file_) << "0x" << hex << lut_EE[i] << endl;
2029  (*out_file_) << endl;
2030  }
2031 
2032  if (writeToDB_) {
2033  map<EcalLogicID, FEConfigLUTGroupDat> dataset;
2034  // we create 1 LUT group
2035  int NLUTGROUPS = 0;
2036  int ich = 0;
2037  FEConfigLUTGroupDat lut;
2038  lut.setLUTGroupId(ich);
2039  for (int i = 0; i < 1024; i++) {
2040  lut.setLUTValue(i, lut_EB[i]);
2041  }
2042  EcalLogicID ecid = EcalLogicID("DUMMY", ich, ich);
2043  // Fill the dataset
2044  dataset[ecid] = lut; // we use any logic id but different, because it is in any case ignored...
2045 
2046  ich++;
2047 
2048  FEConfigLUTGroupDat lute;
2049  lute.setLUTGroupId(ich);
2050  for (int i = 0; i < 1024; i++) {
2051  lute.setLUTValue(i, lut_EE[i]);
2052  }
2053  EcalLogicID ecide = EcalLogicID("DUMMY", ich, ich);
2054  // Fill the dataset
2055  dataset[ecide] = lute; // we use any logic id but different, because it is in any case ignored...
2056 
2057  ich++;
2058 
2059  NLUTGROUPS = ich;
2060 
2061  // now we store in the DB the correspondence btw channels and LUT groups
2062  map<EcalLogicID, FEConfigLUTDat> dataset2;
2063  // in this case I decide in a stupid way which channel belongs to which group
2064  for (int ich = 0; ich < (int)my_TTEcalLogicId.size(); ich++) {
2065  FEConfigLUTDat lut;
2066  int igroup = 0;
2067  lut.setLUTGroupId(igroup);
2068  // calculate the right TT - in the vector they are ordered by SM and by TT
2069  // Fill the dataset
2070  dataset2[my_TTEcalLogicId[ich]] = lut;
2071  }
2072 
2073  // endcap loop
2074  for (int ich = 0; ich < (int)my_TTEcalLogicId_EE.size(); ich++) {
2075  FEConfigLUTDat lut;
2076  int igroup = 1;
2077  lut.setLUTGroupId(igroup);
2078  // calculate the right TT
2079  // Fill the dataset
2080  dataset2[my_TTEcalLogicId_EE[ich]] = lut;
2081  }
2082 
2083  // Insert the dataset
2084  ostringstream ltag;
2085  ltag.str("");
2086  ltag << LUT_option_ << "_NGroups_" << NLUTGROUPS;
2087  std::string lut_tag = ltag.str();
2088  ss << " LUT tag " << lut_tag << "\n";
2089  if (m_write_lut == 1)
2090  lut_conf_id_ = db_->writeToConfDB_TPGLUT(dataset, dataset2, lutparamset, NLUTGROUPS, lut_tag);
2091  }
2092 
2093  // last we insert the FE_CONFIG_MAIN table
2094  if (writeToDB_) {
2095  //int conf_id_=db_->writeToConfDB_TPGMain(ped_conf_id_,lin_conf_id_, lut_conf_id_, fgr_conf_id_,
2096  // sli_conf_id_, wei_conf_id_, bxt_conf_id_, btt_conf_id_, tag_, version_) ;
2097  int conf_id_ = db_->writeToConfDB_TPGMain(ped_conf_id_,
2098  lin_conf_id_,
2099  lut_conf_id_,
2100  fgr_conf_id_,
2101  sli_conf_id_,
2102  wei_conf_id_,
2103  spi_conf_id_,
2104  del_conf_id_,
2105  bxt_conf_id_,
2106  btt_conf_id_,
2107  bst_conf_id_,
2108  tag_,
2109  version_); //modif-alex 21/01/11
2110 
2111  ss << "\n Conf ID = " << conf_id_ << "\n";
2112  }
2113 
2115  // loop on strips and associate them with values //
2117 
2118  // Barrel
2119  stripListEB.sort();
2120  stripListEB.unique();
2121  ss << "Number of EB strips=" << dec << stripListEB.size() << "\n";
2122  if (writeToFiles_) {
2123  (*out_file_) << std::endl;
2124  for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++) {
2125  (*out_file_) << "STRIP_EB " << dec << (*itList) << endl;
2126  (*out_file_) << hex << "0x" << sliding_ << std::endl;
2127  (*out_file_) << "0" << std::endl;
2128  (*out_file_) << "0x" << stripMapEBsintheta[(*itList)] << " 0x" << SFGVB_lut_ << std::endl;
2129  }
2130  }
2131 
2132  // Endcap
2133  stripListEE.sort();
2134  stripListEE.unique();
2135  ss << "Number of EE strips=" << dec << stripListEE.size() << "\n";
2136  if (writeToFiles_) {
2137  (*out_file_) << std::endl;
2138  for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++) {
2139  (*out_file_) << "STRIP_EE " << dec << (*itList) << endl;
2140  (*out_file_) << hex << "0x" << sliding_ << std::endl;
2141  //(*out_file_) <<" 0" << std::endl ;
2142  (*out_file_) << " 1" << std::endl; //modif-debug to get the correct EE TPG
2143  (*out_file_) << hex << "0x" << threshold << " 0x" << lut_strip << std::endl;
2144  }
2145  }
2146  edm::LogInfo("TopInfo") << ss.str();
2147  ss.str("");
2148 
2150  // loop on towers and associate them with default values //
2152 
2153  // Barrel
2154  towerListEB.sort();
2155  towerListEB.unique();
2156  ss << "Number of EB towers=" << dec << towerListEB.size() << "\n";
2157  if (writeToFiles_) {
2158  (*out_file_) << std::endl;
2159  for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++) {
2160  (*out_file_) << "TOWER_EB " << dec << (*itList) << endl;
2161  (*out_file_) << " 0\n 0\n";
2162  (*out_file_) << " " << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex
2163  }
2164  }
2165 
2166  // Endcap
2167  towerListEE.sort();
2168  towerListEE.unique();
2169  ss << "Number of EE towers=" << dec << towerListEE.size() << "\n";
2170  if (writeToFiles_) {
2171  (*out_file_) << std::endl;
2172  for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++) {
2173  (*out_file_) << "TOWER_EE " << dec << (*itList) << endl;
2174  if (newLUT)
2175  (*out_file_) << " 1\n";
2176  else
2177  (*out_file_) << " 0\n";
2178  (*out_file_) << hex << "0x" << lut_tower << std::endl;
2179  }
2180  }
2181  edm::LogInfo("TopInfo") << ss.str();
2182  ss.str("");
2183 
2185  // store control histos //
2187  ICEB->Write();
2188  tpgFactorEB->Write();
2189  ICEEPlus->Write();
2190  tpgFactorEEPlus->Write();
2191  ICEEMinus->Write();
2192  tpgFactorEEMinus->Write();
2193  IC->Write();
2194  tpgFactor->Write();
2195  hshapeEB->Write();
2196  hshapeEE->Write();
2197  ntuple->Write();
2198  ntupleSpike->Write();
2199  saving.Close();
2200 }
2201 
2203  using namespace edm;
2204  using namespace std;
2205 
2206  edm::LogInfo("TopInfo") << "we are in beginJob\n";
2207 
2208  create_header();
2209 
2212 
2213  if (writeToFiles_) {
2214  (*out_file_) << "PHYSICS_EB " << dec << eb.rawId() << std::endl;
2215  (*out_file_) << Et_sat_EB_ << " " << TTF_lowThreshold_EB_ << " " << TTF_highThreshold_EB_ << std::endl;
2216  (*out_file_) << FG_lowThreshold_EB_ << " " << FG_highThreshold_EB_ << " " << FG_lowRatio_EB_ << " "
2217  << FG_highRatio_EB_ << std::endl;
2218  //(*out_file_) << SFGVB_SpikeKillingThreshold_ << std::endl; //modif-alex02/02/2011
2219  (*out_file_) << std::endl;
2220 
2221  (*out_file_) << "PHYSICS_EE " << dec << ee.rawId() << std::endl;
2222  (*out_file_) << Et_sat_EE_ << " " << TTF_lowThreshold_EE_ << " " << TTF_highThreshold_EE_ << std::endl;
2223  (*out_file_) << FG_Threshold_EE_ << " " << -1 << " " << -1 << " " << -1 << std::endl;
2224  (*out_file_) << std::endl;
2225  }
2226 }
2227 
2229  double theta, double gainRatio, double calibCoeff, std::string subdet, int& mult, int& shift) {
2230  /*
2231  Linearization coefficient are determined in order to satisfy:
2232  tpg(ADC_sat) = 1024
2233  where:
2234  tpg() is a model of the linearized tpg response on 10b
2235  ADC_sat is the number of ADC count corresponding the Et_sat, the maximum scale of the transverse energy
2236 
2237  Since we have:
2238  Et_sat = xtal_LSB * ADC_sat * gainRatio * calibCoeff * sin(theta)
2239  and a simple model of tpg() being given by:
2240  tpg(X) = [ (X*mult) >> (shift+2) ] >> (sliding+shiftDet)
2241  we must satisfy:
2242  [ (Et_sat/(xtal_LSB * gainRatio * calibCoeff * sin(theta)) * mult) >> (shift+2) ] >> (sliding+shiftDet) = 1024
2243  that is:
2244  mult = 1024/Et_sat * xtal_LSB * gainRatio * calibCoeff * sin(theta) * 2^-(sliding+shiftDet+2) * 2^-shift
2245  mult = factor * 2^-shift
2246  */
2247 
2248  // case barrel:
2249  int shiftDet = 2; //fixed, due to FE FENIX TCP format
2250  double ratio = xtal_LSB_EB_ / Et_sat_EB_;
2251  // case endcap:
2252  if (subdet == "EE") {
2253  shiftDet = 2; //applied in TCC-EE and not in FE FENIX TCP... This parameters is setable in the TCC-EE
2254  //shiftDet = 0 ; //was like this before with FE bug
2256  }
2257 
2258  //modif-alex-30/01/2012
2259  //std::cout << "calibCoeff="<<calibCoeff<<endl;
2260 
2261  double factor = 1024 * ratio * gainRatio * calibCoeff * sin(theta) * (1 << (sliding_ + shiftDet + 2));
2262  // Let's try first with shift = 0 (trivial solution)
2263  mult = (int)(factor + 0.5);
2264  for (shift = 0; shift < 15; shift++) {
2265  if (mult >= 128 && mult < 256)
2266  return true;
2267  factor *= 2;
2268  mult = (int)(factor + 0.5);
2269  }
2270  edm::LogError("TopInfo") << "too bad we did not manage to calculate the factor for calib=" << calibCoeff << "\n";
2271  return false;
2272 }
2273 
2275  if (!writeToFiles_)
2276  return;
2277  (*out_file_) << "COMMENT put your comments here" << std::endl;
2278 
2279  (*out_file_) << "COMMENT =================================" << std::endl;
2280  (*out_file_) << "COMMENT physics EB structure" << std::endl;
2281  (*out_file_) << "COMMENT" << std::endl;
2282  (*out_file_) << "COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)" << std::endl;
2283  (*out_file_) << "COMMENT FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio" << std::endl;
2284  //(*out_file_) <<"COMMENT SFGVB_SpikeKillingThreshold (GeV)"<<std::endl ; //modif-alex-02/02/2011
2285  (*out_file_) << "COMMENT =================================" << std::endl;
2286  (*out_file_) << "COMMENT" << std::endl;
2287 
2288  (*out_file_) << "COMMENT =================================" << std::endl;
2289  (*out_file_) << "COMMENT physics EE structure" << std::endl;
2290  (*out_file_) << "COMMENT" << std::endl;
2291  (*out_file_) << "COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)" << std::endl;
2292  (*out_file_) << "COMMENT FG_Threshold (GeV), dummy, dummy, dummy" << std::endl;
2293  (*out_file_) << "COMMENT =================================" << std::endl;
2294  (*out_file_) << "COMMENT" << std::endl;
2295 
2296  (*out_file_) << "COMMENT =================================" << std::endl;
2297  (*out_file_) << "COMMENT crystal structure (same for EB and EE)" << std::endl;
2298  (*out_file_) << "COMMENT" << std::endl;
2299  (*out_file_) << "COMMENT ped, mult, shift [gain12]" << std::endl;
2300  (*out_file_) << "COMMENT ped, mult, shift [gain6]" << std::endl;
2301  (*out_file_) << "COMMENT ped, mult, shift [gain1]" << std::endl;
2302  (*out_file_) << "COMMENT =================================" << std::endl;
2303  (*out_file_) << "COMMENT" << std::endl;
2304 
2305  (*out_file_) << "COMMENT =================================" << std::endl;
2306  (*out_file_) << "COMMENT strip EB structure" << std::endl;
2307  (*out_file_) << "COMMENT" << std::endl;
2308  (*out_file_) << "COMMENT sliding_window" << std::endl;
2309  (*out_file_) << "COMMENT weightGroupId" << std::endl;
2310  (*out_file_) << "COMMENT threshold_sfg lut_sfg" << std::endl;
2311  (*out_file_) << "COMMENT =================================" << std::endl;
2312  (*out_file_) << "COMMENT" << std::endl;
2313 
2314  (*out_file_) << "COMMENT =================================" << std::endl;
2315  (*out_file_) << "COMMENT strip EE structure" << std::endl;
2316  (*out_file_) << "COMMENT" << std::endl;
2317  (*out_file_) << "COMMENT sliding_window" << std::endl;
2318  (*out_file_) << "COMMENT weightGroupId" << std::endl;
2319  (*out_file_) << "COMMENT threshold_fg lut_fg" << std::endl;
2320  (*out_file_) << "COMMENT =================================" << std::endl;
2321  (*out_file_) << "COMMENT" << std::endl;
2322 
2323  (*out_file_) << "COMMENT =================================" << std::endl;
2324  (*out_file_) << "COMMENT tower EB structure" << std::endl;
2325  (*out_file_) << "COMMENT" << std::endl;
2326  (*out_file_) << "COMMENT LUTGroupId" << std::endl;
2327  (*out_file_) << "COMMENT FgGroupId" << std::endl;
2328  (*out_file_) << "COMMENT spike_killing_threshold" << std::endl; //modif alex
2329  (*out_file_) << "COMMENT =================================" << std::endl;
2330  (*out_file_) << "COMMENT" << std::endl;
2331 
2332  (*out_file_) << "COMMENT =================================" << std::endl;
2333  (*out_file_) << "COMMENT tower EE structure" << std::endl;
2334  (*out_file_) << "COMMENT" << std::endl;
2335  (*out_file_) << "COMMENT LUTGroupId" << std::endl;
2336  (*out_file_) << "COMMENT tower_lut_fg" << std::endl;
2337  (*out_file_) << "COMMENT =================================" << std::endl;
2338  (*out_file_) << "COMMENT" << std::endl;
2339 
2340  (*out_file_) << "COMMENT =================================" << std::endl;
2341  (*out_file_) << "COMMENT Weight structure" << std::endl;
2342  (*out_file_) << "COMMENT" << std::endl;
2343  (*out_file_) << "COMMENT weightGroupId" << std::endl;
2344  (*out_file_) << "COMMENT w0, w1, w2, w3, w4" << std::endl;
2345  (*out_file_) << "COMMENT =================================" << std::endl;
2346  (*out_file_) << "COMMENT" << std::endl;
2347 
2348  (*out_file_) << "COMMENT =================================" << std::endl;
2349  (*out_file_) << "COMMENT lut structure" << std::endl;
2350  (*out_file_) << "COMMENT" << std::endl;
2351  (*out_file_) << "COMMENT LUTGroupId" << std::endl;
2352  (*out_file_) << "COMMENT LUT[1-1024]" << std::endl;
2353  (*out_file_) << "COMMENT =================================" << std::endl;
2354  (*out_file_) << "COMMENT" << std::endl;
2355 
2356  (*out_file_) << "COMMENT =================================" << std::endl;
2357  (*out_file_) << "COMMENT fg EB structure" << std::endl;
2358  (*out_file_) << "COMMENT" << std::endl;
2359  (*out_file_) << "COMMENT FgGroupId" << std::endl;
2360  (*out_file_) << "COMMENT el, eh, tl, th, lut_fg" << std::endl;
2361  (*out_file_) << "COMMENT =================================" << std::endl;
2362  (*out_file_) << "COMMENT" << std::endl;
2363 
2364  (*out_file_) << std::endl;
2365 }
2366 
2367 int EcalTPGParamBuilder::uncodeWeight(double weight, int complement2) {
2368  int iweight;
2369  unsigned int max = (unsigned int)(pow(2., complement2) - 1);
2370  if (weight > 0)
2371  iweight = int((1 << 6) * weight + 0.5); // +0.5 for rounding pb
2372  else
2373  iweight = max - int(-weight * (1 << 6) + 0.5) + 1;
2374  iweight = iweight & max;
2375  return iweight;
2376 }
2377 
2378 double EcalTPGParamBuilder::uncodeWeight(int iweight, int complement2) {
2379  double weight = double(iweight) / pow(2., 6.);
2380  // test if negative weight:
2381  if ((iweight & (1 << (complement2 - 1))) != 0)
2382  weight = (double(iweight) - pow(2., complement2)) / pow(2., 6.);
2383  return weight;
2384 }
2385 
2386 std::vector<unsigned int> EcalTPGParamBuilder::computeWeights(EcalShapeBase& shape, TH1F* histo) {
2387  std::ostringstream ss;
2388  ss << "Computing Weights...\n";
2389  double timeMax = shape.timeOfMax() - shape.timeOfThr(); // timeMax w.r.t begining of pulse
2390  double max = shape(timeMax);
2391 
2392  double sumf = 0.;
2393  double sumf2 = 0.;
2394  for (unsigned int sample = 0; sample < nSample_; sample++) {
2395  double time = timeMax - ((double)sampleMax_ - (double)sample) * 25.;
2397  sumf += shape(time) / max;
2398  sumf2 += shape(time) / max * shape(time) / max;
2399  for (int subtime = 0; subtime < 25; subtime++)
2400  histo->Fill(float(sample * 25. + subtime) / 25., shape(time + subtime));
2401  }
2402  double lambda = 1. / (sumf2 - sumf * sumf / nSample_);
2403  double gamma = -lambda * sumf / nSample_;
2404  double* weight = new double[nSample_];
2405  for (unsigned int sample = 0; sample < nSample_; sample++) {
2406  double time = timeMax - ((double)sampleMax_ - (double)sample) * 25.;
2408  weight[sample] = lambda * shape(time) / max + gamma;
2409  }
2410 
2411  int* iweight = new int[nSample_];
2412  for (unsigned int sample = 0; sample < nSample_; sample++)
2414 
2415  // Let's check:
2416  int isumw = 0;
2417  for (unsigned int sample = 0; sample < nSample_; sample++)
2418  isumw += iweight[sample];
2419  unsigned int imax = (unsigned int)(pow(2., int(complement2_)) - 1);
2420  isumw = (isumw & imax);
2421 
2422  double ampl = 0.;
2423  double sumw = 0.;
2424  for (unsigned int sample = 0; sample < nSample_; sample++) {
2425  double time = timeMax - ((double)sampleMax_ - (double)sample) * 25.;
2427  ampl += weight[sample] * shape(time);
2428  sumw += weight[sample];
2429  ss << "weight=" << weight[sample] << " shape=" << shape(time) << "\n";
2430  }
2431  ss << "Weights: sum=" << isumw << " in float =" << uncodeWeight(isumw, complement2_) << " sum of floats =" << sumw
2432  << "\n";
2433  ss << "Weights: sum (weight*shape) = " << ampl << "\n";
2434 
2435  // Let's correct for bias if any
2437  int count = 0;
2438  while (isumw != 0 && count < 10) {
2439  double min = 99.;
2440  unsigned int index = 0;
2441  if ((isumw & (1 << (complement2_ - 1))) != 0) {
2442  // add 1:
2443  ss << "Correcting for bias: adding 1\n";
2444  for (unsigned int sample = 0; sample < nSample_; sample++) {
2445  int new_iweight = iweight[sample] + 1;
2446  double new_weight = uncodeWeight(new_iweight, complement2_);
2447  if (fabs(new_weight - weight[sample]) < min) {
2448  min = fabs(new_weight - weight[sample]);
2449  index = sample;
2450  }
2451  }
2452  iweight[index]++;
2453  } else {
2454  // Sub 1:
2455  ss << "Correcting for bias: subtracting 1\n";
2456  for (unsigned int sample = 0; sample < nSample_; sample++) {
2457  int new_iweight = iweight[sample] - 1;
2458  double new_weight = uncodeWeight(new_iweight, complement2_);
2459  if (fabs(new_weight - weight[sample]) < min) {
2460  min = fabs(new_weight - weight[sample]);
2461  index = sample;
2462  }
2463  }
2464  iweight[index]--;
2465  }
2466  isumw = 0;
2467  for (unsigned int sample = 0; sample < nSample_; sample++)
2468  isumw += iweight[sample];
2469  imax = (unsigned int)(pow(2., int(complement2_)) - 1);
2470  isumw = (isumw & imax);
2471  ss << "Correcting weight number: " << index << " sum weights = " << isumw << "\n";
2472  count++;
2473  }
2474  }
2475 
2476  // let's check again
2477  isumw = 0;
2478  for (unsigned int sample = 0; sample < nSample_; sample++)
2479  isumw += iweight[sample];
2480  imax = (unsigned int)(pow(2., int(complement2_)) - 1);
2481  isumw = (isumw & imax);
2482  ampl = 0.;
2483  for (unsigned int sample = 0; sample < nSample_; sample++) {
2484  double time = timeMax - ((double)sampleMax_ - (double)sample) * 25.;
2486  double new_weight = uncodeWeight(iweight[sample], complement2_);
2487  sumw += uncodeWeight(iweight[sample], complement2_);
2488  ampl += new_weight * shape(time);
2489  ss << "weight unbiased after integer conversion=" << new_weight << " shape=" << shape(time) << "\n";
2490  }
2491  ss << "Weights: sum=" << isumw << " in float =" << uncodeWeight(isumw, complement2_) << " sum of floats =" << sumw
2492  << "\n";
2493  ss << "Weights: sum (weight*shape) = " << ampl << "\n";
2494  edm::LogInfo("TopInfo") << ss.str();
2495 
2496  std::vector<unsigned int> theWeights;
2497  for (unsigned int sample = 0; sample < nSample_; sample++)
2498  theWeights.push_back(iweight[sample]);
2499 
2500  delete[] weight;
2501  delete[] iweight;
2502  return theWeights;
2503 }
2504 
2506  double Et_sat = Et_sat_EB_;
2507  double LUT_threshold = LUT_threshold_EB_;
2508  double LUT_stochastic = LUT_stochastic_EB_;
2509  double LUT_noise = LUT_noise_EB_;
2510  double LUT_constant = LUT_constant_EB_;
2511  double TTF_lowThreshold = TTF_lowThreshold_EB_;
2512  double TTF_highThreshold = TTF_highThreshold_EB_;
2513  if (det == "EE") {
2514  Et_sat = Et_sat_EE_;
2515  LUT_threshold = LUT_threshold_EE_;
2516  LUT_stochastic = LUT_stochastic_EE_;
2517  LUT_noise = LUT_noise_EE_;
2518  LUT_constant = LUT_constant_EE_;
2519  TTF_lowThreshold = TTF_lowThreshold_EE_;
2520  TTF_highThreshold = TTF_highThreshold_EE_;
2521  }
2522 
2523  // initialisation with identity
2524  for (int i = 0; i < 1024; i++) {
2525  lut[i] = i;
2526  if (lut[i] > 0xff)
2527  lut[i] = 0xff;
2528  }
2529 
2530  // case linear LUT
2531  if (LUT_option_ == "Linear") {
2532  int mylut = 0;
2533  for (int i = 0; i < 1024; i++) {
2534  lut[i] = mylut;
2535  if ((i + 1) % 4 == 0)
2536  mylut++;
2537  //if ((i+1)%8 == 0 ) mylut++ ;//modif-alex 16/12/2010 LSB==500MeV ONLY USED FOR BEAMV4 key
2538  }
2539  }
2540 
2541  // case LUT following Ecal resolution
2542  if (LUT_option_ == "EcalResolution") {
2543  TF1* func = new TF1("func", oneOverEtResolEt, 0., Et_sat, 3);
2544  func->SetParameters(LUT_stochastic, LUT_noise, LUT_constant);
2545  double norm = func->Integral(0., Et_sat);
2546  for (int i = 0; i < 1024; i++) {
2547  double Et = i * Et_sat / 1024.;
2548  lut[i] = int(0xff * func->Integral(0., Et) / norm + 0.5);
2549  }
2550  }
2551 
2552  // Now, add TTF thresholds to LUT and apply LUT threshold if needed
2553  for (int j = 0; j < 1024; j++) {
2554  double Et_GeV = Et_sat / 1024 * (j + 0.5);
2555  if (Et_GeV <= LUT_threshold)
2556  lut[j] = 0; // LUT threshold
2557  int ttf = 0x0;
2558  if (Et_GeV >= TTF_highThreshold)
2559  ttf = 3;
2560  if (Et_GeV >= TTF_lowThreshold && Et_GeV < TTF_highThreshold)
2561  ttf = 1;
2562  ttf = ttf << 8;
2563  lut[j] += ttf;
2564  }
2565 }
2566 
2568  const EcalIntercalibConstantMap& calibMap,
2569  const EcalLaserAlphaMap& laserAlphaMap,
2570  uint rawId,
2571  std::string& st) {
2572  // get current intercalibration coeff
2573  coeff.calibCoeff_ = 1.;
2574  if (!useInterCalibration_)
2575  return;
2576  EcalIntercalibConstantMap::const_iterator icalit = calibMap.find(rawId);
2577 
2578  //modif-alex-30/01/2012
2579  std::map<int, double>::const_iterator itCorr = Transparency_Correction_.find(rawId);
2580  double icorr = 1.0;
2581  double alpha_factor = 1.0;
2582 
2583  if (useTransparencyCorr_) {
2584  icorr = itCorr->second;
2585  if (itCorr != Transparency_Correction_.end()) {
2586  stringstream ss;
2587  ss << rawId;
2588  stringstream ss1;
2589  ss1 << icorr;
2590  stringstream ss2;
2591  ss2 << (*icalit);
2592  st = "Transparency correction found for xtal " + ss.str() + " corr=" + ss1.str() + " intercalib=" + ss2.str() +
2593  "\n";
2594  } else
2595  edm::LogError("TopInfo") << "ERROR = Transparency correction not found for xtal " << rawId << "\n";
2596 
2597  //modif-alex-27-july-2015
2598  DetId ECALdetid(rawId);
2599  // ss << "DETID=" << ECALdetid.subdetId() << "\n";
2600  stringstream ss;
2601  ss << ECALdetid.subdetId();
2602  st += "DETID=" + ss.str() + "\n";
2603  if (ECALdetid.subdetId() == 1) { //ECAL BARREL
2604  EBDetId barrel_detid(rawId);
2605  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(barrel_detid);
2606  if (italpha != laserAlphaMap.end())
2607  alpha_factor = (*italpha);
2608  else
2609  edm::LogError("TopInfo") << "ERROR:LaserAlphe parameter note found!!"
2610  << "\n";
2611  }
2612  if (ECALdetid.subdetId() == 2) { //ECAL ENDCAP
2613  EEDetId endcap_detid(rawId);
2614  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(endcap_detid);
2615  if (italpha != laserAlphaMap.end())
2616  alpha_factor = (*italpha);
2617  else
2618  edm::LogError("TopInfo") << "ERROR:LaserAlphe parameter note found!!"
2619  << "\n";
2620  }
2621 
2622  } //transparency corrections applied
2623 
2624  //if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit) ;
2625  //if( icalit != calibMap.end() ) coeff.calibCoeff_ = (*icalit)/icorr; //modif-alex-30/01/2010 tansparency corrections
2626  // ss << "rawId " << (*icalit) << " " << icorr << " " << alpha_factor << "\n";
2627  stringstream ss;
2628  ss << (*icalit);
2629  stringstream ss1;
2630  ss1 << icorr;
2631  stringstream ss2;
2632  ss2 << alpha_factor;
2633  st += "rawId " + ss.str() + " " + ss1.str() + " " + ss2.str() + "\n";
2634  if (icalit != calibMap.end())
2635  coeff.calibCoeff_ =
2636  (*icalit) /
2637  std::pow(icorr, alpha_factor); //modif-alex-27/07/2015 tansparency corrections with alpha parameters
2638 
2639  else
2640  edm::LogError("TopInfo") << "getCoeff: " << rawId << " not found in EcalIntercalibConstantMap"
2641  << "\n";
2642 }
2643 
2644 void EcalTPGParamBuilder::getCoeff(coeffStruc& coeff, const EcalGainRatioMap& gainMap, unsigned int rawId) {
2645  // get current gain ratio
2646  coeff.gainRatio_[0] = 1.;
2647  coeff.gainRatio_[1] = 2.;
2648  coeff.gainRatio_[2] = 12.;
2649  EcalGainRatioMap::const_iterator gainIter = gainMap.find(rawId);
2650  if (gainIter != gainMap.end()) {
2651  const EcalMGPAGainRatio& aGain = (*gainIter);
2652  coeff.gainRatio_[1] = aGain.gain12Over6();
2653  coeff.gainRatio_[2] = aGain.gain6Over1() * aGain.gain12Over6();
2654  } else
2655  edm::LogError("TopInfo") << "getCoeff: " << rawId << " not found in EcalGainRatioMap"
2656  << "\n";
2657 }
2658 
2659 void EcalTPGParamBuilder::getCoeff(coeffStruc& coeff, const EcalPedestalsMap& pedMap, unsigned int rawId) {
2660  coeff.pedestals_[0] = 0;
2661  coeff.pedestals_[1] = 0;
2662  coeff.pedestals_[2] = 0;
2663 
2664  if (forcedPedestalValue_ >= 0) {
2665  coeff.pedestals_[0] = forcedPedestalValue_;
2666  coeff.pedestals_[1] = forcedPedestalValue_;
2667  coeff.pedestals_[2] = forcedPedestalValue_;
2668  return;
2669  }
2670 
2671  // get current pedestal
2672  EcalPedestalsMapIterator pedIter = pedMap.find(rawId);
2673  if (pedIter != pedMap.end()) {
2674  EcalPedestals::Item aped = (*pedIter);
2675  coeff.pedestals_[0] = int(aped.mean_x12 + 0.5);
2676  coeff.pedestals_[1] = int(aped.mean_x6 + 0.5);
2677  coeff.pedestals_[2] = int(aped.mean_x1 + 0.5);
2678  } else
2679  edm::LogError("TopInfo") << "getCoeff: " << rawId << " not found in EcalPedestalsMap\n";
2680 }
2681 
2683  const map<EcalLogicID, MonPedestalsDat>& pedMap,
2684  const EcalLogicID& logicId) {
2685  // get current pedestal
2686  coeff.pedestals_[0] = 0;
2687  coeff.pedestals_[1] = 0;
2688  coeff.pedestals_[2] = 0;
2689 
2690  map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2691  if (it != pedMap.end()) {
2692  MonPedestalsDat ped = it->second;
2693  coeff.pedestals_[0] = int(ped.getPedMeanG12() + 0.5);
2694  coeff.pedestals_[1] = int(ped.getPedMeanG6() + 0.5);
2695  coeff.pedestals_[2] = int(ped.getPedMeanG1() + 0.5);
2696  } else
2697  edm::LogError("TopInfo") << "getCoeff: " << logicId.getID1() << ", " << logicId.getID2() << ", " << logicId.getID3()
2698  << " not found in map<EcalLogicID, MonPedestalsDat\n";
2699 }
2700 
2702  unsigned int& highRatio,
2703  unsigned int& lowThreshold,
2704  unsigned int& highThreshold,
2705  unsigned int& lut) {
2706  lowRatio = int(0x80 * FG_lowRatio_EB_ + 0.5);
2707  if (lowRatio > 0x7f)
2708  lowRatio = 0x7f;
2709  highRatio = int(0x80 * FG_highRatio_EB_ + 0.5);
2710  if (highRatio > 0x7f)
2711  highRatio = 0x7f;
2712 
2713  // lsb at the stage of the FG calculation is:
2714  double lsb_FG = Et_sat_EB_ / 1024. / 4;
2715  lowThreshold = int(FG_lowThreshold_EB_ / lsb_FG + 0.5);
2716  if (lowThreshold > 0xff)
2717  lowThreshold = 0xff;
2718  highThreshold = int(FG_highThreshold_EB_ / lsb_FG + 0.5);
2719  if (highThreshold > 0xff)
2720  highThreshold = 0xff;
2721 
2722  // FG lut: FGVB response is LUT(adress) where adress is:
2723  // bit3: maxof2/ET >= lowRatio, bit2: maxof2/ET >= highRatio, bit1: ET >= lowThreshold, bit0: ET >= highThreshold
2724  // FGVB =1 if jet-like (veto active), =0 if E.M.-like
2725  // the condition for jet-like is: ET>Threshold and maxof2/ET < Ratio (only TT with enough energy are vetoed)
2726 
2727  // With the following lut, what matters is only max(TLow, Thigh) and max(Elow, Ehigh)
2728  // So, jet-like if maxof2/ettot<max(TLow, Thigh) && ettot >= max(Elow, Ehigh)
2729  if (FG_lut_EB_ == 0)
2730  lut = 0x0888;
2731  else
2732  lut = FG_lut_EB_; // let's use the users value (hope he/she knows what he/she does!)
2733 }
2734 
2736  unsigned int& lut_strip,
2737  unsigned int& lut_tower) {
2738  // lsb for EE:
2739  double lsb_FG = Et_sat_EE_ / 1024.; // FIXME is it true????
2740  threshold = int(FG_Threshold_EE_ / lsb_FG + 0.5);
2741  lut_strip = FG_lut_strip_EE_;
2742  lut_tower = FG_lut_tower_EE_;
2743 }
2744 
2745 bool EcalTPGParamBuilder::realignBaseline(linStruc& lin, float forceBase12) {
2746  bool ok(true);
2747  float base[3] = {forceBase12, float(lin.pedestal_[1]), float(lin.pedestal_[2])};
2748  for (int i = 1; i < 3; i++) {
2749  if (lin.mult_[i] > 0) {
2750  base[i] = float(lin.pedestal_[i]) - float(lin.mult_[0]) / float(lin.mult_[i]) *
2751  pow(2., -(lin.shift_[0] - lin.shift_[i])) * (lin.pedestal_[0] - base[0]);
2752  } else
2753  base[i] = 0;
2754  }
2755 
2756  for (int i = 0; i < 3; i++) {
2757  lin.pedestal_[i] = base[i];
2758  //cout<<lin.pedestal_[i]<<" "<<base[i]<<endl ;
2759  if (base[i] < 0 || lin.pedestal_[i] > 1000) {
2760  edm::LogError("TopInfo") << "WARNING: base= " << base[i] << ", " << lin.pedestal_[i] << " for gainId[0-2]=" << i
2761  << " ==> forcing at 0"
2762  << "\n";
2763  lin.pedestal_[i] = 0;
2764  ok = false;
2765  }
2766  }
2767  return ok;
2768 }
2769 
2771  int gctphi = 0;
2772  gctphi = (ttphi + 1) / 4;
2773  if (ttphi <= 2)
2774  gctphi = 0;
2775  if (ttphi >= 71)
2776  gctphi = 0;
2777  return gctphi;
2778 }
2779 
2781  int gcteta = 0;
2782  if (tteta > 0)
2783  gcteta = (tteta - 1) / 4 + 11;
2784  else if (tteta < 0)
2785  gcteta = (tteta + 1) / 4 + 10;
2786  return gcteta;
2787 }
2788 
2790  std::stringstream sdet;
2791 
2792  if (tcc > 36 && tcc < 55)
2793  sdet << "EB-" << tcc - 36;
2794  else if (tcc >= 55 && tcc < 73)
2795  sdet << "EB+" << tcc - 54;
2796  else if (tcc <= 36)
2797  sdet << "EE-";
2798  else
2799  sdet << "EE+";
2800 
2801  if (tcc <= 36 || tcc >= 73) {
2802  if (tcc >= 73)
2803  tcc -= 72;
2804  if (tcc == 1 || tcc == 18 || tcc == 19 || tcc == 36)
2805  sdet << 7;
2806  else if (tcc == 2 || tcc == 3 || tcc == 20 || tcc == 21)
2807  sdet << 8;
2808  else if (tcc == 4 || tcc == 5 || tcc == 22 || tcc == 23)
2809  sdet << 9;
2810  else if (tcc == 6 || tcc == 7 || tcc == 24 || tcc == 25)
2811  sdet << 1;
2812  else if (tcc == 8 || tcc == 9 || tcc == 26 || tcc == 27)
2813  sdet << 2;
2814  else if (tcc == 10 || tcc == 11 || tcc == 28 || tcc == 29)
2815  sdet << 3;
2816  else if (tcc == 12 || tcc == 13 || tcc == 30 || tcc == 31)
2817  sdet << 4;
2818  else if (tcc == 14 || tcc == 15 || tcc == 32 || tcc == 33)
2819  sdet << 5;
2820  else if (tcc == 16 || tcc == 17 || tcc == 34 || tcc == 35)
2821  sdet << 6;
2822  }
2823 
2824  return sdet.str();
2825 }
2826 
2827 std::pair<std::string, int> EcalTPGParamBuilder::getCrate(int tcc) {
2828  std::stringstream crate;
2829  std::string pos;
2830  int slot = 0;
2831 
2832  crate << "S2D";
2833  if (tcc >= 40 && tcc <= 42) {
2834  crate << "02d";
2835  slot = 5 + (tcc - 40) * 6;
2836  }
2837  if (tcc >= 43 && tcc <= 45) {
2838  crate << "03d";
2839  slot = 5 + (tcc - 43) * 6;
2840  }
2841  if (tcc >= 37 && tcc <= 39) {
2842  crate << "04d";
2843  slot = 5 + (tcc - 37) * 6;
2844  }
2845  if (tcc >= 52 && tcc <= 54) {
2846  crate << "06d";
2847  slot = 5 + (tcc - 52) * 6;
2848  }
2849  if (tcc >= 46 && tcc <= 48) {
2850  crate << "07d";
2851  slot = 5 + (tcc - 46) * 6;
2852  }
2853  if (tcc >= 49 && tcc <= 51) {
2854  crate << "08d";
2855  slot = 5 + (tcc - 49) * 6;
2856  }
2857  if (tcc >= 58 && tcc <= 60) {
2858  crate << "02h";
2859  slot = 5 + (tcc - 58) * 6;
2860  }
2861  if (tcc >= 61 && tcc <= 63) {
2862  crate << "03h";
2863  slot = 5 + (tcc - 61) * 6;
2864  }
2865  if (tcc >= 55 && tcc <= 57) {
2866  crate << "04h";
2867  slot = 5 + (tcc - 55) * 6;
2868  }
2869  if (tcc >= 70 && tcc <= 72) {
2870  crate << "06h";
2871  slot = 5 + (tcc - 70) * 6;
2872  }
2873  if (tcc >= 64 && tcc <= 66) {
2874  crate << "07h";
2875  slot = 5 + (tcc - 64) * 6;
2876  }
2877  if (tcc >= 67 && tcc <= 69) {
2878  crate << "08h";
2879  slot = 5 + (tcc - 67) * 6;
2880  }
2881 
2882  if (tcc >= 76 && tcc <= 81) {
2883  crate << "02l";
2884  if (tcc % 2 == 0)
2885  slot = 2 + (tcc - 76) * 3;
2886  else
2887  slot = 4 + (tcc - 77) * 3;
2888  }
2889  if (tcc >= 94 && tcc <= 99) {
2890  crate << "02l";
2891  if (tcc % 2 == 0)
2892  slot = 3 + (tcc - 94) * 3;
2893  else
2894  slot = 5 + (tcc - 95) * 3;
2895  }
2896 
2897  if (tcc >= 22 && tcc <= 27) {
2898  crate << "03l";
2899  if (tcc % 2 == 0)
2900  slot = 2 + (tcc - 22) * 3;
2901  else
2902  slot = 4 + (tcc - 23) * 3;
2903  }
2904  if (tcc >= 4 && tcc <= 9) {
2905  crate << "03l";
2906  if (tcc % 2 == 0)
2907  slot = 3 + (tcc - 4) * 3;
2908  else
2909  slot = 5 + (tcc - 5) * 3;
2910  }
2911 
2912  if (tcc >= 82 && tcc <= 87) {
2913  crate << "07l";
2914  if (tcc % 2 == 0)
2915  slot = 2 + (tcc - 82) * 3;
2916  else
2917  slot = 4 + (tcc - 83) * 3;
2918  }
2919  if (tcc >= 100 && tcc <= 105) {
2920  crate << "07l";
2921  if (tcc % 2 == 0)
2922  slot = 3 + (tcc - 100) * 3;
2923  else
2924  slot = 5 + (tcc - 101) * 3;
2925  }
2926 
2927  if (tcc >= 28 && tcc <= 33) {
2928  crate << "08l";
2929  if (tcc % 2 == 0)
2930  slot = 2 + (tcc - 28) * 3;
2931  else
2932  slot = 4 + (tcc - 29) * 3;
2933  }
2934  if (tcc >= 10 && tcc <= 15) {
2935  crate << "08l";
2936  if (tcc % 2 == 0)
2937  slot = 3 + (tcc - 10) * 3;
2938  else
2939  slot = 5 + (tcc - 11) * 3;
2940  }
2941 
2942  if (tcc == 34) {
2943  crate << "04l";
2944  slot = 2;
2945  }
2946  if (tcc == 16) {
2947  crate << "04l";
2948  slot = 3;
2949  }
2950  if (tcc == 35) {
2951  crate << "04l";
2952  slot = 4;
2953  }
2954  if (tcc == 17) {
2955  crate << "04l";
2956  slot = 5;
2957  }
2958  if (tcc == 36) {
2959  crate << "04l";
2960  slot = 8;
2961  }
2962  if (tcc == 18) {
2963  crate << "04l";
2964  slot = 9;
2965  }
2966  if (tcc == 19) {
2967  crate << "04l";
2968  slot = 10;
2969  }
2970  if (tcc == 1) {
2971  crate << "04l";
2972  slot = 11;
2973  }
2974  if (tcc == 20) {
2975  crate << "04l";
2976  slot = 14;
2977  }
2978  if (tcc == 2) {
2979  crate << "04l";
2980  slot = 15;
2981  }
2982  if (tcc == 21) {
2983  crate << "04l";
2984  slot = 16;
2985  }
2986  if (tcc == 3) {
2987  crate << "04l";
2988  slot = 17;
2989  }
2990 
2991  if (tcc == 88) {
2992  crate << "06l";
2993  slot = 2;
2994  }
2995  if (tcc == 106) {
2996  crate << "06l";
2997  slot = 3;
2998  }
2999  if (tcc == 89) {
3000  crate << "06l";
3001  slot = 4;
3002  }
3003  if (tcc == 107) {
3004  crate << "06l";
3005  slot = 5;
3006  }
3007  if (tcc == 90) {
3008  crate << "06l";
3009  slot = 8;
3010  }
3011  if (tcc == 108) {
3012  crate << "06l";
3013  slot = 9;
3014  }
3015  if (tcc == 73) {
3016  crate << "06l";
3017  slot = 10;
3018  }
3019  if (tcc == 91) {
3020  crate << "06l";
3021  slot = 11;
3022  }
3023  if (tcc == 74) {
3024  crate << "06l";
3025  slot = 14;
3026  }
3027  if (tcc == 92) {
3028  crate << "06l";
3029  slot = 15;
3030  }
3031  if (tcc == 75) {
3032  crate << "06l";
3033  slot = 16;
3034  }
3035  if (tcc == 93) {
3036  crate << "06l";
3037  slot = 17;
3038  }
3039 
3040  return std::pair<std::string, int>(crate.str(), slot);
3041 }
EcalTPGParamBuilder::FG_lowRatio_EB_
double FG_lowRatio_EB_
Definition: EcalTPGParamBuilder.h:116
EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:80
EcalTPGParamBuilder::weight_timeShift_
double weight_timeShift_
Definition: EcalTPGParamBuilder.h:106
EcalTPGParamBuilder::Transparency_Corr_
std::string Transparency_Corr_
Definition: EcalTPGParamBuilder.h:127
FEConfigMainInfo::getSpiId
int getSpiId() const
Definition: FEConfigMainInfo.h:52
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
EcalTPGParamBuilder::db_
EcalTPGDBApp * db_
Definition: EcalTPGParamBuilder.h:145
FEConfigFgrDat
Definition: FEConfigFgrDat.h:11
EcalTPGParamBuilder::create_header
void create_header()
Definition: EcalTPGParamBuilder.cc:2274
MonPedestalsDat::getPedMeanG1
float getPedMeanG1() const
Definition: MonPedestalsDat.h:21
EcalTPGParamBuilder::xtal_LSB_EB_
double xtal_LSB_EB_
Definition: EcalTPGParamBuilder.h:102
DDAxes::y
EcalTPGParamBuilder::SFGVB_lut_
unsigned int SFGVB_lut_
Definition: EcalTPGParamBuilder.h:122
EcalShapeBase::setEventSetup
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalShapeBase.cc:19
EcalTPGParamBuilder::getGCTRegionPhi
int getGCTRegionPhi(int ttphi)
Definition: EcalTPGParamBuilder.cc:2770
FEConfigFgrGroupDat
Definition: FEConfigFgrGroupDat.h:11
EcalTPGParamBuilder::geomFile_
std::ofstream * geomFile_
Definition: EcalTPGParamBuilder.h:144
EcalTPGParamBuilder::m_write_bxt
int m_write_bxt
Definition: EcalTPGParamBuilder.h:172
HLT_2018_cff.weights
weights
Definition: HLT_2018_cff.py:87167
FEConfigLUTParamDat
Definition: FEConfigLUTParamDat.h:11
ecaldqm::tccId
unsigned tccId(DetId const &)
Definition: EcalDQMCommonUtils.cc:56
mps_fire.i
i
Definition: mps_fire.py:355
EcalTrigTowerDetId::iphi
int iphi() const
get the tower iphi
Definition: EcalTrigTowerDetId.h:52
oneOverEtResolEt
double oneOverEtResolEt(double *x, double *par)
Definition: EcalTPGParamBuilder.cc:48
FEConfigLUTParamDat::setTTThreshlow
void setTTThreshlow(float x)
Definition: FEConfigLUTParamDat.h:21
FEConfigWeightGroupDat::setWeight4
void setWeight4(float x)
Definition: FEConfigWeightGroupDat.h:31
EcalTPGParamBuilder::spi_conf_id_
int spi_conf_id_
Definition: EcalTPGParamBuilder.h:157
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
EcalTPGParamBuilder::useInterCalibration_
bool useInterCalibration_
Definition: EcalTPGParamBuilder.h:124
FEConfigFgrGroupDat::setThreshHigh
void setThreshHigh(float x)
Definition: FEConfigFgrGroupDat.h:25
EcalLaserAPDPNRatiosRcd
Definition: EcalLaserAPDPNRatiosRcd.h:24
EcalTPGParamBuilder::theEndcapGeometry_
const CaloSubdetectorGeometry * theEndcapGeometry_
Definition: EcalTPGParamBuilder.h:96
EcalCondObjectContainer::endcapItems
const Items & endcapItems() const
Definition: EcalCondObjectContainer.h:32
FEConfigPedDat::setPedMeanG6
void setPedMeanG6(float mean)
Definition: FEConfigPedDat.h:26
EcalTPGParamBuilder::nSample_
unsigned int nSample_
Definition: EcalTPGParamBuilder.h:108
FEConfigLinDat::setMultX12
void setMultX12(int x)
Definition: FEConfigLinDat.h:20
EcalPedestal::mean_x6
float mean_x6
Definition: EcalPedestals.h:21
EcalTPGParamBuilder::fgr_conf_id_
int fgr_conf_id_
Definition: EcalTPGParamBuilder.h:154
EcalTriggerElectronicsId
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
Definition: EcalTriggerElectronicsId.h:18
EcalTPGParamBuilder::phases_EE_
std::map< int, std::vector< int > > phases_EE_
Definition: EcalTPGParamBuilder.h:138
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
EcalTPGParamBuilder::checkIfOK
bool checkIfOK(EcalPedestals::Item item)
Definition: EcalTPGParamBuilder.cc:358
FEConfigWeightDat
Definition: FEConfigWeightDat.h:11
EcalTrigTowerDetId::ietaAbs
int ietaAbs() const
get the absolute value of the tower ieta
Definition: EcalTrigTowerDetId.h:36
EBShape
Definition: EBShape.h:6
EcalTPGParamBuilder::writeToDB_
bool writeToDB_
Definition: EcalTPGParamBuilder.h:146
patZpeak.handle
handle
Definition: patZpeak.py:23
min
T min(T a, T b)
Definition: MathUtil.h:58
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EcalElectronicsMapping::iTT
int iTT(const EcalTrigTowerDetId &id) const
returns the index of a Trigger Tower within its TCC.
Definition: EcalElectronicsMapping.cc:102
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EcalTPGParamBuilder::version_
int version_
Definition: EcalTPGParamBuilder.h:163
EcalTPGParamBuilder::bxt_conf_id_
int bxt_conf_id_
Definition: EcalTPGParamBuilder.h:159
EcalTPGDBApp::writeToConfDB_Spike
int writeToConfDB_Spike(const std::map< EcalLogicID, FEConfigSpikeDat > &spikegroupset, std::string tag)
Definition: EcalTPGDBApp.cc:324
EBDetId
Definition: EBDetId.h:17
EcalTPGParamBuilder::m_write_spi
int m_write_spi
Definition: EcalTPGParamBuilder.h:170
FEConfigMainInfo::getLinId
int getLinId() const
Definition: FEConfigMainInfo.h:37
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalShapeBase::timeOfThr
double timeOfThr() const
Definition: EcalShapeBase.cc:21
EcalTPGParamBuilder::SFGVB_Threshold_
unsigned int SFGVB_Threshold_
Definition: EcalTPGParamBuilder.h:122
mps_merge.weight
weight
Definition: mps_merge.py:88
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
linStruc::shift_
int shift_[3]
Definition: EcalTPGParamBuilder.h:56
FEConfigLUTGroupDat::setLUTValue
void setLUTValue(int i, int x)
Definition: FEConfigLUTGroupDat.h:23
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FEConfigLinParamDat::setETSat
void setETSat(float x)
Definition: FEConfigLinParamDat.h:20
EcalCondDBInterface::fetchConfigSet
void fetchConfigSet(ICONF *iconf) noexcept(false)
Definition: EcalCondDBInterface.h:387
EcalTPGParamBuilder::SFGVB_SpikeKillingThreshold_
int SFGVB_SpikeKillingThreshold_
Definition: EcalTPGParamBuilder.h:123
HLT_2018_cff.timeMax
timeMax
Definition: HLT_2018_cff.py:7109
pos
Definition: PixelAliasList.h:18
MonPedestalsDat
Definition: MonPedestalsDat.h:11
EcalLogicID::getName
std::string getName() const
Definition: EcalLogicID.cc:26
EBDetId.h
FEConfigMainInfo
Definition: FEConfigMainInfo.h:14
EEDetId.h
FEConfigPedDat::getPedMeanG12
float getPedMeanG12() const
Definition: FEConfigPedDat.h:30
edm::LogInfo
Definition: MessageLogger.h:254
EBDetId::unhashIndex
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
EcalEndcapGeometryRecord
Definition: EcalEndcapGeometryRecord.h:23
FEConfigLinDat::setShift1
void setShift1(int x)
Definition: FEConfigLinDat.h:25
FEConfigFgrEEStripDat::setLutFgr
void setLutFgr(unsigned int mean)
Definition: FEConfigFgrEEStripDat.h:26
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
callgraph.G
G
Definition: callgraph.py:13
FEConfigFgrGroupDat::setThreshLow
void setThreshLow(float x)
Definition: FEConfigFgrGroupDat.h:23
EcalTPGDBApp.h
EcalTPGParamBuilder::pedestal_offset_
unsigned int pedestal_offset_
Definition: EcalTPGParamBuilder.h:122
EcalTPGParamBuilder::beginJob
void beginJob() override
Definition: EcalTPGParamBuilder.cc:2202
EcalADCToGeVConstant
Definition: EcalADCToGeVConstant.h:13
EcalShapeBase::timeOfMax
double timeOfMax() const
Definition: EcalShapeBase.cc:23
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
FEConfigSpikeDat::setSpikeThreshold
void setSpikeThreshold(int x)
Definition: FEConfigSpikeDat.h:20
DDAxes::x
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalElectronicsId::dccId
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Definition: EcalElectronicsId.h:31
linStruc
Definition: EcalTPGParamBuilder.h:51
FEConfigPedDat::setPedMeanG1
void setPedMeanG1(float mean)
Definition: FEConfigPedDat.h:23
EcalLogicID::getID1
int getID1() const
Definition: EcalLogicID.cc:30
EcalTPGParamBuilder::FG_highThreshold_EB_
double FG_highThreshold_EB_
Definition: EcalTPGParamBuilder.h:116
EcalTPGParamBuilder::LUT_constant_EE_
double LUT_constant_EE_
Definition: EcalTPGParamBuilder.h:113
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
EcalCondObjectContainer< float >
tools.TF1
TF1
Definition: tools.py:23
EcalTrigTowerDetId::zside
int zside() const
get the z-side of the tower (1/-1)
Definition: EcalTrigTowerDetId.h:30
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
parallelization.uint
uint
Definition: parallelization.py:124
dqmdumpme.first
first
Definition: dqmdumpme.py:55
EcalBarrelGeometryRecord
Definition: EcalBarrelGeometryRecord.h:23
EcalTPGParamBuilder::xtal_LSB_EE_
double xtal_LSB_EE_
Definition: EcalTPGParamBuilder.h:102
FEConfigLinParamDat
Definition: FEConfigLinParamDat.h:11
EcalBarrel
Definition: EcalSubdetector.h:10
FEConfigMainInfo::getFgrId
int getFgrId() const
Definition: FEConfigMainInfo.h:43
FEConfigLUTParamDat::setETSat
void setETSat(float x)
Definition: FEConfigLUTParamDat.h:20
FEConfigMainInfo::getBttId
int getBttId() const
Definition: FEConfigMainInfo.h:61
EcalTPGParamBuilder::useTransverseEnergy_
bool useTransverseEnergy_
Definition: EcalTPGParamBuilder.h:101
EcalTPGParamBuilder::LUT_threshold_EB_
double LUT_threshold_EB_
Definition: EcalTPGParamBuilder.h:111
EcalSimParameterMap.h
EcalElectronicsId::towerId
int towerId() const
get the tower id
Definition: EcalElectronicsId.h:33
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
EBShape.h
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalCondObjectContainer::begin
const_iterator begin() const
Definition: EcalCondObjectContainer.h:74
EcalPedestal::mean_x1
float mean_x1
Definition: EcalPedestals.h:23
EcalLogicID::getID2
int getID2() const
Definition: EcalLogicID.cc:32
EEShape.h
EcalTPGParamBuilder::useDBShape_
bool useDBShape_
Definition: EcalTPGParamBuilder.h:180
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
coeffStruc::calibCoeff_
double calibCoeff_
Definition: EcalTPGParamBuilder.h:46
EcalTPGParamBuilder::FG_highRatio_EB_
double FG_highRatio_EB_
Definition: EcalTPGParamBuilder.h:116
EcalTPGDBApp::writeToConfDB_TPGWeight
int writeToConfDB_TPGWeight(const std::map< EcalLogicID, FEConfigWeightGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigWeightDat > &lutdat, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:254
EcalTPGParamBuilder::EcalTPGParamBuilder
EcalTPGParamBuilder(edm::ParameterSet const &pSet)
Definition: EcalTPGParamBuilder.cc:57
EcalLaserAPDPNRatios::getLaserMap
const EcalLaserAPDPNRatiosMap & getLaserMap() const
Definition: EcalLaserAPDPNRatios.h:40
EcalTPGParamBuilder::delays_EB_
std::map< int, std::vector< int > > delays_EB_
Definition: EcalTPGParamBuilder.h:135
FEConfigLinDat::setShift6
void setShift6(int x)
Definition: FEConfigLinDat.h:24
EcalTPGParamBuilder::LUT_noise_EB_
double LUT_noise_EB_
Definition: EcalTPGParamBuilder.h:112
FEConfigLinDat::setMultX6
void setMultX6(int x)
Definition: FEConfigLinDat.h:21
FEConfigFgrDat::setFgrGroupId
void setFgrGroupId(int x)
Definition: FEConfigFgrDat.h:20
EcalTPGParamBuilder::getGCTRegionEta
int getGCTRegionEta(int tteta)
Definition: EcalTPGParamBuilder.cc:2780
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
FEConfigLUTGroupDat::setLUTGroupId
void setLUTGroupId(int x)
Definition: FEConfigLUTGroupDat.h:20
EcalShapeBase
Definition: EcalShapeBase.h:24
FEConfigSpikeDat
Definition: FEConfigSpikeDat.h:11
EcalPedestal::mean_x12
float mean_x12
Definition: EcalPedestals.h:19
EcalTPGParamBuilder::del_conf_id_
int del_conf_id_
Definition: EcalTPGParamBuilder.h:158
FEConfigPedDat::getPedMeanG1
float getPedMeanG1() const
Definition: FEConfigPedDat.h:24
FEConfigFgrGroupDat::setRatioHigh
void setRatioHigh(float x)
Definition: FEConfigFgrGroupDat.h:29
EcalTPGParamBuilder::DBEE_
bool DBEE_
Definition: EcalTPGParamBuilder.h:149
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EcalTPGParamBuilder::getEtaSlice
int getEtaSlice(int tccId, int towerInTCC)
Definition: EcalTPGParamBuilder.cc:375
MonPedestalsDat::getPedMeanG6
float getPedMeanG6() const
Definition: MonPedestalsDat.h:24
EcalTPGParamBuilder::out_file_
std::ofstream * out_file_
Definition: EcalTPGParamBuilder.h:143
EcalMappingRcd.h
EcalLaserDbService.h
DDAxes::z
EcalTPGParamBuilder::TimingPhases_EE_
std::string TimingPhases_EE_
Definition: EcalTPGParamBuilder.h:134
str
#define str(s)
Definition: TestProcessor.cc:48
edm::ESHandle< CaloGeometry >
EcalElectronicsMapping::getElectronicsId
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
Definition: EcalElectronicsMapping.cc:324
FEConfigFgrParamDat::setFGhighthresh
void setFGhighthresh(float x)
Definition: FEConfigFgrParamDat.h:21
EcalLogicID
Definition: EcalLogicID.h:7
EcalTPGParamBuilder::m_write_lut
int m_write_lut
Definition: EcalTPGParamBuilder.h:166
EcalTPGParamBuilder::complement2_
unsigned int complement2_
Definition: EcalTPGParamBuilder.h:109
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
coeffStruc::gainRatio_
double gainRatio_[3]
Definition: EcalTPGParamBuilder.h:47
EcalTPGParamBuilder::writeToFiles_
bool writeToFiles_
Definition: EcalTPGParamBuilder.h:147
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
FEConfigPedDat::getPedMeanG6
float getPedMeanG6() const
Definition: FEConfigPedDat.h:27
EcalMGPAGainRatio.h
EcalTPGParamBuilder::m_write_wei
int m_write_wei
Definition: EcalTPGParamBuilder.h:167
EcalTPGParamBuilder::useTransparencyCorr_
bool useTransparencyCorr_
Definition: EcalTPGParamBuilder.h:128
dqmdumpme.k
k
Definition: dqmdumpme.py:60
FEConfigMainInfo::getBxtId
int getBxtId() const
Definition: FEConfigMainInfo.h:58
EcalTPGParamBuilder::Et_sat_EB_
double Et_sat_EB_
Definition: EcalTPGParamBuilder.h:103
EEShape
Definition: EEShape.h:6
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
CaloSubdetectorGeometry::getValidDetIds
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
Definition: CaloSubdetectorGeometry.cc:32
FEConfigFgrParamDat::setFGhighratio
void setFGhighratio(float x)
Definition: FEConfigFgrParamDat.h:23
EcalCondObjectContainer::barrelItems
const Items & barrelItems() const
Definition: EcalCondObjectContainer.h:30
EcalMGPAGainRatio::gain12Over6
float gain12Over6() const
Definition: EcalMGPAGainRatio.h:19
particleFlowDisplacedVertex_cfi.ratio
ratio
Definition: particleFlowDisplacedVertex_cfi.py:93
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
EcalTPGParamBuilder::m_write_sli
int m_write_sli
Definition: EcalTPGParamBuilder.h:169
EcalGainRatiosRcd
Definition: EcalGainRatiosRcd.h:5
L1TdeCSCTF_cfi.outFile
outFile
Definition: L1TdeCSCTF_cfi.py:5
FEConfigLUTDat
Definition: FEConfigLUTDat.h:11
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalTPGParamBuilder::Et_sat_EE_
double Et_sat_EE_
Definition: EcalTPGParamBuilder.h:103
EcalSubdetector.h
EcalTPGParamBuilder::LUT_option_
std::string LUT_option_
Definition: EcalTPGParamBuilder.h:110
EcalEndcap
Definition: EcalSubdetector.h:10
EcalADCToGeVConstant.h
FEConfigMainInfo::getWeiId
int getWeiId() const
Definition: FEConfigMainInfo.h:49
EcalTPGParamBuilder::m_write_bst
int m_write_bst
Definition: EcalTPGParamBuilder.h:174
EcalTPGParamBuilder::phases_EB_
std::map< int, std::vector< int > > phases_EB_
Definition: EcalTPGParamBuilder.h:136
funct::true
true
Definition: Factorize.h:173
EcalTPGParamBuilder::LUT_threshold_EE_
double LUT_threshold_EE_
Definition: EcalTPGParamBuilder.h:111
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
CaloSubdetectorGeometry.h
EcalTPGParamBuilder::FG_lowThreshold_EB_
double FG_lowThreshold_EB_
Definition: EcalTPGParamBuilder.h:116
EcalTPGParamBuilder::forcedPedestalValue_
int forcedPedestalValue_
Definition: EcalTPGParamBuilder.h:120
edm::ParameterSet
Definition: ParameterSet.h:36
EcalADCToGeVConstant::getEEValue
float getEEValue() const
Definition: EcalADCToGeVConstant.h:21
edm::LogError
Definition: MessageLogger.h:183
EcalTPGParamBuilder::computeFineGrainEBParameters
void computeFineGrainEBParameters(uint &lowRatio, uint &highRatio, uint &lowThreshold, uint &highThreshold, uint &lut)
Definition: EcalTPGParamBuilder.cc:2701
EcalTPGParamBuilder::delays_EE_
std::map< int, std::vector< int > > delays_EE_
Definition: EcalTPGParamBuilder.h:137
EcalTPGParamBuilder::sli_conf_id_
int sli_conf_id_
Definition: EcalTPGParamBuilder.h:155
FEConfigWeightGroupDat
Definition: FEConfigWeightGroupDat.h:11
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
EcalCondObjectContainer< EcalPedestal >::Item
EcalPedestal Item
Definition: EcalCondObjectContainer.h:15
FEConfigFgrEEStripDat
Definition: FEConfigFgrEEStripDat.h:11
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
EcalTriggerElectronicsId::pseudoStripId
int pseudoStripId() const
get the tower id
Definition: EcalTriggerElectronicsId.h:35
FEConfigSlidingDat
Definition: FEConfigSlidingDat.h:11
EcalTPGDBApp::writeToConfDB_TPGLinearCoef
int writeToConfDB_TPGLinearCoef(const std::map< EcalLogicID, FEConfigLinDat > &linset, const std::map< EcalLogicID, FEConfigLinParamDat > &linparamset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:37
FEConfigWeightGroupDat::setWeightGroupId
void setWeightGroupId(int x)
Definition: FEConfigWeightGroupDat.h:20
EcalPedestalsMapIterator
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
Definition: EcalPedestals.h:49
EcalElectronicsMapping.h
EcalADCToGeVConstantRcd.h
FEConfigLinDat::setShift12
void setShift12(int x)
Definition: FEConfigLinDat.h:23
EcalTPGParamBuilder::computeLinearizerParam
bool computeLinearizerParam(double theta, double gainRatio, double calibCoeff, std::string subdet, int &mult, int &shift)
Definition: EcalTPGParamBuilder.cc:2228
createfilelist.int
int
Definition: createfilelist.py:10
EcalTPGDBApp::writeToConfDB_TPGLUT
int writeToConfDB_TPGLUT(const std::map< EcalLogicID, FEConfigLUTGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigLUTDat > &lutdat, const std::map< EcalLogicID, FEConfigLUTParamDat > &lutparamset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:221
EcalTPGParamBuilder::lin_conf_id_
int lin_conf_id_
Definition: EcalTPGParamBuilder.h:152
EcalElectronicsMapping::getTriggerElectronicsId
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
Definition: EcalElectronicsMapping.cc:389
EcalTPGParamBuilder::m_write_ped
int m_write_ped
Definition: EcalTPGParamBuilder.h:164
EcalTPGParamBuilder::weight_unbias_recovery_
bool weight_unbias_recovery_
Definition: EcalTPGParamBuilder.h:107
EcalTPGParamBuilder::wei_conf_id_
int wei_conf_id_
Definition: EcalTPGParamBuilder.h:156
FEConfigFgrGroupDat::setFgrGroupId
void setFgrGroupId(int x)
Definition: FEConfigFgrGroupDat.h:20
EcalCondDBInterface::fetchDataSet
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
Definition: EcalCondDBInterface.h:495
EcalLaserAlphasRcd
Definition: EcalLaserAlphasRcd.h:24
EcalTPGParamBuilder::ntupleDet_
Char_t ntupleDet_[10]
Definition: EcalTPGParamBuilder.h:177
EcalTPGParamBuilder::TTF_highThreshold_EE_
double TTF_highThreshold_EE_
Definition: EcalTPGParamBuilder.h:115
FEConfigPedDat
Definition: FEConfigPedDat.h:11
FEConfigWeightGroupDat::setWeight2
void setWeight2(float x)
Definition: FEConfigWeightGroupDat.h:27
EcalTPGParamBuilder::eTTmap_
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
Definition: EcalTPGParamBuilder.h:98
EcalTPGPedestals.h
EcalTPGParamBuilder::btt_conf_id_
int btt_conf_id_
Definition: EcalTPGParamBuilder.h:160
FEConfigFgrParamDat::setFGlowratio
void setFGlowratio(float x)
Definition: FEConfigFgrParamDat.h:22
EcalElectronicsMapping::DCCid
int DCCid(const EBDetId &id) const
returns the DCC of an EBDetId
Definition: EcalElectronicsMapping.cc:70
cuy.ib
ib
Definition: cuy.py:662
EcalTPGDBApp::writeToConfDB_TPGFgr
int writeToConfDB_TPGFgr(const std::map< EcalLogicID, FEConfigFgrGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigFgrDat > &lutdat, const std::map< EcalLogicID, FEConfigFgrParamDat > &fgrparamset, const std::map< EcalLogicID, FEConfigFgrEETowerDat > &dataset3, const std::map< EcalLogicID, FEConfigFgrEEStripDat > &dataset4, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:285
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:57
EcalTriggerElectronicsId::channelId
int channelId() const
get the channel id
Definition: EcalTriggerElectronicsId.h:37
EcalTPGParamBuilder::uncodeWeight
int uncodeWeight(double weight, int complement2=7)
Definition: EcalTPGParamBuilder.cc:2367
EcalTPGParamBuilder::lut_conf_id_
int lut_conf_id_
Definition: EcalTPGParamBuilder.h:153
EcalTPGParamBuilder::getCrate
std::pair< std::string, int > getCrate(int tcc)
Definition: EcalTPGParamBuilder.cc:2827
EcalGainRatiosRcd.h
DetId::Ecal
Definition: DetId.h:27
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
FEConfigLUTDat::setLUTGroupId
void setLUTGroupId(int x)
Definition: FEConfigLUTDat.h:20
EcalCondDBInterface::getEcalLogicID
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
EcalTrigTowerDetId::subDet
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
Definition: EcalTrigTowerDetId.h:33
FEConfigFgrGroupDat::setRatioLow
void setRatioLow(float x)
Definition: FEConfigFgrGroupDat.h:27
get
#define get
EcalTPGParamBuilder::TimingDelays_EB_
std::string TimingDelays_EB_
Definition: EcalTPGParamBuilder.h:131
EcalTPGParamBuilder::analyze
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: EcalTPGParamBuilder.cc:394
EcalTPGParamBuilder::computeWeights
std::vector< unsigned int > computeWeights(EcalShapeBase &shape, TH1F *histo)
Definition: EcalTPGParamBuilder.cc:2386
EcalTrigTowerDetId::ieta
int ieta() const
get the tower ieta
Definition: EcalTrigTowerDetId.h:44
EcalTPGParamBuilder::m_write_lin
int m_write_lin
Definition: EcalTPGParamBuilder.h:165
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
FEConfigSlidingDat::setSliding
void setSliding(float mean)
Definition: FEConfigSlidingDat.h:20
FEConfigMainInfo::getSliId
int getSliId() const
Definition: FEConfigMainInfo.h:46
linStruc::mult_
int mult_[3]
Definition: EcalTPGParamBuilder.h:55
EcalTPGDBApp::writeToConfDB_TPGSliding
int writeToConfDB_TPGSliding(const std::map< EcalLogicID, FEConfigSlidingDat > &sliset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:196
FEConfigFgrParamDat
Definition: FEConfigFgrParamDat.h:11
FEConfigFgrEETowerDat
Definition: FEConfigFgrEETowerDat.h:11
EcalTPGParamBuilder::m_write_fgr
int m_write_fgr
Definition: EcalTPGParamBuilder.h:168
FEConfigFgrParamDat::setFGlowthresh
void setFGlowthresh(float x)
Definition: FEConfigFgrParamDat.h:20
EcalTPGParamBuilder.h
EcalTPGParamBuilder::TTF_lowThreshold_EE_
double TTF_lowThreshold_EE_
Definition: EcalTPGParamBuilder.h:115
coeffStruc::pedestals_
int pedestals_[3]
Definition: EcalTPGParamBuilder.h:48
linStruc::pedestal_
int pedestal_[3]
Definition: EcalTPGParamBuilder.h:54
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalTPGParamBuilder::TTF_lowThreshold_EB_
double TTF_lowThreshold_EB_
Definition: EcalTPGParamBuilder.h:114
EcalTPGParamBuilder::~EcalTPGParamBuilder
~EcalTPGParamBuilder() override
Definition: EcalTPGParamBuilder.cc:350
EcalLaserDbRecord.h
FEConfigWeightGroupDat::setWeight0
void setWeight0(float x)
Definition: FEConfigWeightGroupDat.h:23
CaloCellGeometry.h
EcalTPGParamBuilder::m_write_del
int m_write_del
Definition: EcalTPGParamBuilder.h:171
EcalLogicID::NULLID
static const int NULLID
Definition: EcalLogicID.h:35
EcalElectronicsMapping::TCCid
int TCCid(const EBDetId &id) const
returns the TCCid of an EBDetId
Definition: EcalElectronicsMapping.cc:86
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.dataset
dataset
Definition: writedatasetfile.py:19
EcalTPGParamBuilder::m_write_btt
int m_write_btt
Definition: EcalTPGParamBuilder.h:173
EcalTPGParamBuilder::H2_
bool H2_
Definition: EcalTPGParamBuilder.h:124
FEConfigWeightDat::setWeightGroupId
void setWeightGroupId(int x)
Definition: FEConfigWeightDat.h:20
EcalMappingRcd
Definition: EcalMappingRcd.h:15
EcalCondObjectContainer::insert
void insert(std::pair< uint32_t, Item > const &a)
Definition: EcalCondObjectContainer.h:38
EcalTPGParamBuilder::ntupleInts_
Int_t * ntupleInts_
Definition: EcalTPGParamBuilder.h:176
FEConfigPedInfo::setId
void setId(int id)
Definition: FEConfigPedInfo.h:24
EcalTPGDBApp::writeToConfDB_Delay
int writeToConfDB_Delay(const std::map< EcalLogicID, FEConfigTimingDat > &delaygroupset, std::string tag)
Definition: EcalTPGDBApp.cc:348
EcalTPGParamBuilder::FG_lut_strip_EE_
unsigned int FG_lut_strip_EE_
Definition: EcalTPGParamBuilder.h:119
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
EcalTPGParamBuilder::Transparency_Correction_
std::map< int, double > Transparency_Correction_
Definition: EcalTPGParamBuilder.h:141
EEDetId::XYMODE
static const int XYMODE
Definition: EEDetId.h:335
EcalTPGDBApp::writeToConfDB_TPGMain
int writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int spi, int tim, int bxt, int btt, int bst, std::string tag, int ver)
Definition: EcalTPGDBApp.cc:64
FEConfigWeightGroupDat::setWeight1
void setWeight1(float x)
Definition: FEConfigWeightGroupDat.h:25
EcalTPGParamBuilder::realignBaseline
bool realignBaseline(linStruc &lin, float forceBase12)
Definition: EcalTPGParamBuilder.cc:2745
EcalTPGParamBuilder::theBarrelGeometry_
const CaloSubdetectorGeometry * theBarrelGeometry_
Definition: EcalTPGParamBuilder.h:97
EcalTPGParamBuilder::theMapping_
const EcalElectronicsMapping * theMapping_
Definition: EcalTPGParamBuilder.h:99
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EcalTPGParamBuilder::FG_lut_EB_
unsigned int FG_lut_EB_
Definition: EcalTPGParamBuilder.h:117
FEConfigTimingDat
Definition: FEConfigTimingDat.h:11
FEConfigLUTParamDat::setTTThreshhigh
void setTTThreshhigh(float x)
Definition: FEConfigLUTParamDat.h:22
EcalMGPAGainRatio::gain6Over1
float gain6Over1() const
Definition: EcalMGPAGainRatio.h:20
CaloGeometry.h
EcalTPGParamBuilder::LUT_noise_EE_
double LUT_noise_EE_
Definition: EcalTPGParamBuilder.h:113
EcalPedestal
Definition: EcalPedestals.h:8
FEConfigLinDat
Definition: FEConfigLinDat.h:11
MonPedestalsDat::getPedMeanG12
float getPedMeanG12() const
Definition: MonPedestalsDat.h:27
EcalTPGDBApp::writeToConfDB_TPGPedestals
int writeToConfDB_TPGPedestals(const std::map< EcalLogicID, FEConfigPedDat > &pedset, int iovId, std::string tag)
Definition: EcalTPGDBApp.cc:14
EcalLogicID::getID3
int getID3() const
Definition: EcalLogicID.cc:34
VarParsing.mult
mult
Definition: VarParsing.py:659
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FEConfigMainInfo::getPedId
int getPedId() const
Definition: FEConfigMainInfo.h:34
EcalTPGParamBuilder::TimingPhases_EB_
std::string TimingPhases_EB_
Definition: EcalTPGParamBuilder.h:133
dataset
Definition: dataset.py:1
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
EcalPedestalsRcd.h
EcalTPGParamBuilder::FG_Threshold_EE_
double FG_Threshold_EE_
Definition: EcalTPGParamBuilder.h:118
EcalTPGPedestalsRcd.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
EcalCondObjectContainer< float >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
mps_fire.result
result
Definition: mps_fire.py:303
EcalElectronicsId::stripId
int stripId() const
get the tower id
Definition: EcalElectronicsId.h:35
phase2TrackerDigitizer_cfi.delay
delay
Definition: phase2TrackerDigitizer_cfi.py:67
EcalTPGParamBuilder::LUT_stochastic_EB_
double LUT_stochastic_EB_
Definition: EcalTPGParamBuilder.h:112
FEConfigMainInfo::getTimId
int getTimId() const
Definition: FEConfigMainInfo.h:55
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ntuple
Definition: ntuple.py:1
FEConfigLinDat::setMultX1
void setMultX1(int x)
Definition: FEConfigLinDat.h:22
EcalLaserAPDPNRatios
Definition: EcalLaserAPDPNRatios.h:14
FEConfigPedDat::setPedMeanG12
void setPedMeanG12(float mean)
Definition: FEConfigPedDat.h:29
IODConfig::setConfigTag
void setConfigTag(std::string x)
Definition: IODConfig.h:29
FEConfigMainInfo::getBstId
int getBstId() const
Definition: FEConfigMainInfo.h:64
EcalPedestalsRcd
Definition: EcalPedestalsRcd.h:5
FEConfigPedInfo
Definition: FEConfigPedInfo.h:11
EcalTPGParamBuilder::LUT_constant_EB_
double LUT_constant_EB_
Definition: EcalTPGParamBuilder.h:112
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
FEConfigLUTGroupDat
Definition: FEConfigLUTGroupDat.h:11
EcalTPGParamBuilder::bst_conf_id_
int bst_conf_id_
Definition: EcalTPGParamBuilder.h:161
ntuplemaker.time
time
Definition: ntuplemaker.py:310
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
edm::Event
Definition: Event.h:73
EcalTPGParamBuilder::sampleMax_
unsigned int sampleMax_
Definition: EcalTPGParamBuilder.h:105
EcalTPGParamBuilder::LUT_stochastic_EE_
double LUT_stochastic_EE_
Definition: EcalTPGParamBuilder.h:113
EcalTPGParamBuilder::forceEtaSlice_
bool forceEtaSlice_
Definition: EcalTPGParamBuilder.h:121
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
EcalTPGParamBuilder::TTF_highThreshold_EB_
double TTF_highThreshold_EB_
Definition: EcalTPGParamBuilder.h:114
EcalElectronicsId::xtalId
int xtalId() const
get the channel id
Definition: EcalElectronicsId.h:37
EBDetId::SMCRYSTALMODE
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
FEConfigWeightGroupDat::setWeight3
void setWeight3(float x)
Definition: FEConfigWeightGroupDat.h:29
ecalpyutils::hashedIndex
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
EcalADCToGeVConstant::getEBValue
float getEBValue() const
Definition: EcalADCToGeVConstant.h:20
EcalIntercalibConstantsRcd
Definition: EcalIntercalibConstantsRcd.h:5
EcalIntercalibConstantsRcd.h
FEConfigFgrGroupDat::setLUTValue
void setLUTValue(int x)
Definition: FEConfigFgrGroupDat.h:31
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
EcalADCToGeVConstantRcd
Definition: EcalADCToGeVConstantRcd.h:5
EcalTPGParamBuilder::computeFineGrainEEParameters
void computeFineGrainEEParameters(uint &threshold, uint &lut_strip, uint &lut_tower)
Definition: EcalTPGParamBuilder.cc:2735
EcalTPGParamBuilder::FG_lut_tower_EE_
unsigned int FG_lut_tower_EE_
Definition: EcalTPGParamBuilder.h:119
EcalTriggerElectronicsId::rawId
uint32_t rawId() const
Definition: EcalTriggerElectronicsId.h:28
EcalTPGParamBuilder::computeLUT
void computeLUT(int *lut, std::string det="EB")
Definition: EcalTPGParamBuilder.cc:2505
FEConfigFgrEEStripDat::setThreshold
void setThreshold(unsigned int mean)
Definition: FEConfigFgrEEStripDat.h:20
EcalTPGParamBuilder::TimingDelays_EE_
std::string TimingDelays_EE_
Definition: EcalTPGParamBuilder.h:132
EcalTPGParamBuilder::getDet
std::string getDet(int tcc)
Definition: EcalTPGParamBuilder.cc:2789
EcalTPGParamBuilder::tag_
std::string tag_
Definition: EcalTPGParamBuilder.h:162
weight
Definition: weight.py:1
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
EcalTPGParamBuilder::getCoeff
void getCoeff(coeffStruc &coeff, const EcalGainRatioMap &gainMap, uint rawId)
EcalCondDBInterface::getEcalLogicIDSetOrdered
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) noexcept(false)
Definition: EcalCondDBInterface.cc:388
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
coeffStruc
Definition: EcalTPGParamBuilder.h:43
EcalMGPAGainRatio
Definition: EcalMGPAGainRatio.h:13
EcalTPGParamBuilder::sliding_
unsigned int sliding_
Definition: EcalTPGParamBuilder.h:104
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
EcalTPGParamBuilder::ntupleCrate_
Char_t ntupleCrate_[10]
Definition: EcalTPGParamBuilder.h:178
EcalTPGDBApp
Definition: EcalTPGDBApp.h:16
FEConfigMainInfo::getLUTId
int getLUTId() const
Definition: FEConfigMainInfo.h:40
EcalTPGParamBuilder::ped_conf_id_
int ped_conf_id_
Definition: EcalTPGParamBuilder.h:151
FEConfigFgrEETowerDat::setLutValue
void setLutValue(int mean)
Definition: FEConfigFgrEETowerDat.h:22