CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StoreEcalCondition.cc
Go to the documentation of this file.
2 
9 
10 #include <fstream>
11 #include <string>
12 #include <cstring>
13 #include <ctime>
14 #include <unistd.h>
15 
16 using std::string;
17 
19  prog_name_ = "StoreEcalCondition";
20 
21  logfile_ = iConfig.getParameter<std::string>("logfile");
22  sm_slot_ = iConfig.getUntrackedParameter<unsigned int>("smSlot", 1);
23 
24  typedef std::vector<edm::ParameterSet> Parameters;
25  Parameters toPut = iConfig.getParameter<Parameters>("toPut");
26  for (Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut) {
27  inpFileName_.push_back(itToPut->getUntrackedParameter<std::string>("inputFile"));
28  inpFileNameEE_.push_back(itToPut->getUntrackedParameter<std::string>("inputFileEE"));
29  objectName_.push_back(itToPut->getUntrackedParameter<std::string>("conditionType"));
30  since_.push_back(itToPut->getUntrackedParameter<unsigned int>("since"));
31  }
32 
33  sm_constr_ = -1;
34 }
35 
38  if (!mydbservice.isAvailable()) {
39  edm::LogError("StoreEcalCondition") << "PoolDBOutputService is unavailable";
40  return;
41  }
42 
43  bool toAppend = false;
44  // copy a string to the char *
45  std::string message = "finished OK\n";
46  size_t messageSize = message.size() + 1;
47  char* messChar = new char[messageSize];
48  strncpy(messChar, message.c_str(), messageSize);
49 
50  for (unsigned int i = 0; i < objectName_.size(); i++) {
51  cond::Time_t newTime;
52 
53  if (mydbservice->isNewTagRequest(objectName_[i] + std::string("Rcd"))) {
54  // This is the first object for this tag.
55  // Append mode should be off.
56  // newTime is the end of this new objects IOV.
57  newTime = mydbservice->beginOfTime();
58  } else {
59  // There should already be an object in the DB for this tag.
60  // Append IOV mode should be on.
61  // newTime is the beginning of this new objects IOV.
62  toAppend = true;
63  newTime = (cond::Time_t)since_[i];
64  }
65  edm::LogInfo("StoreEcalCondition") << "Reading " << objectName_[i] << " from file and writing to DB with newTime "
66  << newTime;
67 
68  if (objectName_[i] == "EcalWeightXtalGroups") {
69  const auto mycali = readEcalWeightXtalGroupsFromFile(inpFileName_[i].c_str());
70  if (!toAppend) {
71  mydbservice->createOneIOV<EcalWeightXtalGroups>(*mycali, newTime, "EcalWeightXtalGroupsRcd");
72  } else {
73  mydbservice->appendOneIOV<EcalWeightXtalGroups>(*mycali, newTime, "EcalWeightXtalGroupsRcd");
74  }
75  } else if (objectName_[i] == "EcalTBWeights") {
76  const auto mycali = readEcalTBWeightsFromFile(inpFileName_[i].c_str());
77  if (!toAppend) {
78  mydbservice->createOneIOV<EcalTBWeights>(*mycali, newTime, "EcalTBWeightsRcd");
79  } else {
80  mydbservice->appendOneIOV<EcalTBWeights>(*mycali, newTime, "EcalTBWeightsRcd");
81  }
82  } else if (objectName_[i] == "EcalADCToGeVConstant") {
83  const auto mycali = readEcalADCToGeVConstantFromFile(inpFileName_[i].c_str());
84  if (!toAppend) {
85  mydbservice->createOneIOV<EcalADCToGeVConstant>(*mycali, newTime, "EcalADCToGeVConstantRcd");
86  } else {
87  mydbservice->appendOneIOV<EcalADCToGeVConstant>(*mycali, newTime, "EcalADCToGeVConstantRcd");
88  }
89  } else if (objectName_[i] == "EcalIntercalibConstants") {
90  const auto mycali = readEcalIntercalibConstantsFromFile(inpFileName_[i].c_str(), inpFileNameEE_[i].c_str());
91  if (!toAppend) {
92  mydbservice->createOneIOV<EcalIntercalibConstants>(*mycali, newTime, "EcalIntercalibConstantsRcd");
93  } else {
94  mydbservice->appendOneIOV<EcalIntercalibConstants>(*mycali, newTime, "EcalIntercalibConstantsRcd");
95  }
96  } else if (objectName_[i] == "EcalPFRecHitThresholds") {
97  const auto mycali = readEcalPFRecHitThresholdsFromFile(inpFileName_[i].c_str(), inpFileNameEE_[i].c_str());
98  if (!toAppend) {
99  mydbservice->createOneIOV<EcalPFRecHitThresholds>(*mycali, newTime, "EcalPFRecHitThresholdsRcd");
100  } else {
101  mydbservice->appendOneIOV<EcalPFRecHitThresholds>(*mycali, newTime, "EcalPFRecHitThresholdsRcd");
102  }
103  } else if (objectName_[i] == "EcalIntercalibConstantsMC") {
104  const auto mycali = readEcalIntercalibConstantsMCFromFile(inpFileName_[i].c_str(), inpFileNameEE_[i].c_str());
105  if (!toAppend) {
106  mydbservice->createOneIOV<EcalIntercalibConstantsMC>(*mycali, newTime, "EcalIntercalibConstantsMCRcd");
107  } else {
108  mydbservice->appendOneIOV<EcalIntercalibConstantsMC>(*mycali, newTime, "EcalIntercalibConstantsMCRcd");
109  }
110  } else if (objectName_[i] == "EcalGainRatios") {
111  const auto mycali = readEcalGainRatiosFromFile(inpFileName_[i].c_str());
112  if (!toAppend) {
113  mydbservice->createOneIOV<EcalGainRatios>(*mycali, newTime, "EcalGainRatiosRcd");
114  } else {
115  mydbservice->appendOneIOV<EcalGainRatios>(*mycali, newTime, "EcalGainRatiosRcd");
116  }
117  } else if (objectName_[i] == "EcalChannelStatus") {
118  const auto mycali = readEcalChannelStatusFromFile(inpFileName_[i].c_str());
119  if (!toAppend) {
120  mydbservice->createOneIOV<EcalChannelStatus>(*mycali, newTime, "EcalChannelStatusRcd");
121  } else {
122  mydbservice->appendOneIOV<EcalChannelStatus>(*mycali, newTime, "EcalChannelStatusRcd");
123  }
124  } else {
125  edm::LogError("StoreEcalCondition") << "Object " << objectName_[i] << " is not supported by this program.";
126  }
127 
128  // writeToLogFile(objectName_[i], inpFileName_[i], since_[i]);
129  //writeToLogFileResults("finished OK\n");
130  writeToLogFileResults(messChar);
131 
132  edm::LogInfo("StoreEcalCondition") << "Finished endJob";
133  }
134 
135  delete[] messChar;
136 }
137 
139 
140 //-------------------------------------------------------------
141 void StoreEcalCondition::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
142  //-------------------------------------------------------------
143 }
144 
145 //------------------------------------------------------------
146 void StoreEcalCondition::writeToLogFile(string a, string b, unsigned long long since) {
147  //-------------------------------------------------------------
148 
149  FILE* outFile; // output log file for appending
150  outFile = fopen(logfile_.c_str(), "a");
151  if (!outFile) {
152  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << logfile_;
153  return;
154  }
155  char header[256];
156  fillHeader(header);
157  char appendMode[10];
158  if (since != 0)
159  sprintf(appendMode, "append");
160  else
161  sprintf(appendMode, "create");
162 
163  fprintf(outFile,
164  "%s %s condition from file %s written into DB for SM %d (mapped to SM %d) in %s mode (since run %u)\n",
165  header,
166  a.c_str(),
167  b.c_str(),
168  sm_constr_,
169  sm_slot_,
170  appendMode,
171  (unsigned int)since);
172 
173  fclose(outFile); // close out file
174 }
175 //------------------------------------------------------------
177  //-------------------------------------------------------------
178 
179  FILE* outFile; // output log file for appending
180  outFile = fopen(logfile_.c_str(), "a");
181  if (!outFile) {
182  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << logfile_;
183  return;
184  }
185  char header[256];
186  fillHeader(header);
187  fprintf(outFile, "%s %s\n", header, arg);
188  fclose(outFile); // close out file
189 }
190 
191 //------------------------------------------------------------
193 //------------------------------------------------------------
194 {
195  time_t rawtime;
196  struct tm* timeinfo;
197  time(&rawtime);
198  timeinfo = localtime(&rawtime);
199  char user[50];
200  sprintf(user, "%s", getlogin());
201  sprintf(header, "%s %s:", asctime(timeinfo), user);
202 }
203 
204 /*
205  * Format for ASCII groups & weights file
206  * Updated by Alex Zabi Imperial College
207  * 03/07/06: implementing final weights format
208  * Accepted format:
209  * groupId nSamples nTDCbins (introductory line)
210  * and then nTDCbins x (3 + nSamples) lines of nSamples numbers containing
211  * For TDCbin1
212  * gain 12 weights (before gain switch)
213  * ===========================================
214  * ampWeight[0] ampWeight[1] ............. |
215  * pedWeight[0] pedWeight[1] ............. |
216  * jitWeight[0] jitWeight[1] ............. |
217  * chi2Matri[0][0] chi2Matrix[0][1] .......... |
218  * chi2Matrix[1][0] chi2Matrix[1][1] .......... |
219  * ..... |
220  * chi2Matrix[nsamples-1][0] chi2Matrix[nsamples-1][1] .......... |
221  * gain 6 and 1 weights (after gain switch)
222  * ===========================================
223  * ampWeight[0] ampWeight[1] ............. |
224  * pedWeight[0] pedWeight[1] ............. |
225  * jitWeight[0] jitWeight[1] ............. |
226  * chi2Matri[0][0] chi2Matrix[0][1] .......... |
227  * chi2Matrix[1][0] chi2Matrix[1][1] .......... |
228  * ..... |
229  * chi2Matrix[nsamples-1][0] chi2Matrix[nsamples-1][1] .......... |
230  * ===========================================
231  * For TDCbin nTDCBins
232  * ............
233  */
234 
235 //-------------------------------------------------------------
236 std::shared_ptr<EcalWeightXtalGroups> StoreEcalCondition::readEcalWeightXtalGroupsFromFile(const char* inputFile) {
237  //-------------------------------------------------------------
238 
239  // Code taken from EcalWeightTools/test/MakeOfflineDbFromAscii.cpp
240 
241  auto xtalGroups = std::make_shared<EcalWeightXtalGroups>();
242  std::ifstream groupid_in(inputFile);
243 
244  if (!groupid_in.is_open()) {
245  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
246  return nullptr;
247  }
248 
249  int smnumber = -99999;
250 
251  std::ostringstream str;
252  groupid_in >> smnumber;
253  if (smnumber == -99999) {
254  edm::LogError("StoreEcalCondition") << "ERROR: SM number not found in file";
255  return nullptr;
256  }
257  str << "sm= " << smnumber << "\n";
258  sm_constr_ = smnumber;
259 
260  char temp[256];
261  //Reading the other 5 header lines containing various informations
262  for (int i = 0; i <= 5; i++) {
263  groupid_in.getline(temp, 255);
264  str << temp << "\n";
265  }
266 
267  // Skip the nGroup/Mean line
268  groupid_in.getline(temp, 255);
269  str << temp << "\n";
270 
271  edm::LogInfo("StoreEcalCondition") << "GROUPID file " << str.str();
272 
273  int xtals = 0;
274  int xtal, ietaf, iphif, groupID;
275  while (groupid_in.good()) {
276  groupid_in >> xtal >> ietaf >> iphif >> groupID;
277  if (groupid_in.eof()) {
278  break;
279  }
280 
281  LogDebug("StoreEcalCondition") << "XTAL=" << xtal << " ETA=" << ietaf << " PHI=" << iphif << " GROUP=" << groupID;
282 
283  //EBDetId ebid(ieta,iphi);
285  // xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId( ebid.hashedIndex()) );
286  xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(groupID));
287  xtals++;
288  } //loop iphi
289 
290  if (xtals != 1700) {
291  edm::LogError("StoreEcalCondition") << "ERROR: GROUPID file did not contain data for 1700 crystals";
292  return nullptr;
293  }
294 
295  edm::LogInfo("StoreEcalCondition") << "Groups for " << xtals << " xtals written into DB";
296  sm_constr_ = smnumber;
297 
298  return xtalGroups;
299 }
300 
301 //-------------------------------------------------------------
302 std::shared_ptr<EcalTBWeights> StoreEcalCondition::readEcalTBWeightsFromFile(const char* inputFile) {
303  //-------------------------------------------------------------
304 
305  // Zabi code to be written here
306 
307  auto tbwgt = std::make_shared<EcalTBWeights>();
308 
309  std::ifstream WeightsFileTB(inputFile);
310  if (!WeightsFileTB.is_open()) {
311  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
312  return nullptr;
313  }
314 
315  int smnumber = -99999;
316 
317  std::ostringstream str;
318  WeightsFileTB >> smnumber;
319  if (smnumber == -99999)
320  return nullptr;
321 
322  str << "sm= " << smnumber << "\n";
323 
324  char temp[256];
325  //Reading the other 5 header lines containing various informations
326  for (int i = 0; i <= 5; i++) {
327  WeightsFileTB.getline(temp, 255);
328  str << temp << "\n";
329  }
330 
331  edm::LogInfo("StoreEcalCondition") << "Weights file " << str.str();
332 
333  int ngroups = 0;
334  while (WeightsFileTB.good()) {
335  int igroup_ID = -99999;
336  int nSamples = -99999;
337  int nTdcBins = -99999;
338 
339  WeightsFileTB >> igroup_ID >> nSamples >> nTdcBins;
340  if (igroup_ID == -99999 || nSamples == -99999 || nTdcBins == -99999)
341  break;
342 
343  std::ostringstream str;
344  str << "Igroup=" << igroup_ID << " Nsamples=" << nSamples << " NTdcBins=" << nTdcBins << "\n";
345 
346  for (int iTdcBin = 0; iTdcBin < nTdcBins; iTdcBin++) {
347  EcalWeightSet wgt; // one set of weights
352 
353  // std::vector<EcalWeight> wamp, wped, wtime; //weights before gain switch
354  // std::vector<EcalWeight> wamp2, wped2, wtime2; //weights after gain switch
355 
356  //WEIGHTS BEFORE GAIN SWITCH
357  //Amplitude weights
358  for (int j = 0; j < nSamples; ++j) {
359  double ww = 0.0;
360  WeightsFileTB >> ww;
361  wgt1(0, j) = ww;
362  str << ww << " ";
363  } // loop Samples
364  str << "\n";
365 
366  //Pedestal weights
367  for (int j = 0; j < nSamples; ++j) {
368  double ww = 0.0;
369  WeightsFileTB >> ww;
370  wgt1(1, j) = ww;
371  str << ww << " ";
372  } //loop Samples
373  str << "\n";
374 
375  //Timing weights
376  for (int j = 0; j < nSamples; ++j) {
377  double ww = 0.0;
378  WeightsFileTB >> ww;
379  wgt1(2, j) = ww;
380  str << ww << " ";
381  } //loop Samples
382  str << "\n";
383 
384  for (int j = 0; j < nSamples; ++j) {
385  // fill chi2 matrix
386  //std::vector<EcalWeight> vChi2; // row of chi2 matrix
387  for (int k = 0; k < nSamples; ++k) {
388  double ww = 0.0;
389  WeightsFileTB >> ww;
390  chisq1(j, k) = ww;
391  str << ww << " ";
392  } //loop samples
393  str << "\n";
394  } //loop lines
395 
396  //WEIGHTS AFTER GAIN SWITCH
397  for (int j = 0; j < nSamples; ++j) {
398  double ww = 0.0;
399  WeightsFileTB >> ww;
400  wgt2(0, j) = ww;
401  str << ww << " ";
402  } // loop Samples
403  str << "\n";
404 
405  //Pedestal weights
406  for (int j = 0; j < nSamples; ++j) {
407  double ww = 0.0;
408  WeightsFileTB >> ww;
409  wgt2(1, j) = ww;
410  str << ww << " ";
411  } //loop Samples
412  str << "\n";
413 
414  //Timing weights
415  for (int j = 0; j < nSamples; ++j) {
416  double ww = 0.0;
417  WeightsFileTB >> ww;
418  wgt2(2, j) = ww;
419  str << ww << " ";
420  } //loop Samples
421  str << "\n";
422 
423  for (int j = 0; j < nSamples; ++j) {
424  // fill chi2 matrix
425  //std::vector<EcalWeight> vChi2; // row of chi2 matrix
426  for (int k = 0; k < nSamples; ++k) {
427  double ww = 0.0;
428  WeightsFileTB >> ww;
429  chisq2(j, k) = ww;
430  str << ww << " ";
431  } //loop samples
432  str << "\n";
433  } //loop lines
434 
435  LogDebug("StoreEcalCondition") << str.str();
436 
437  //modif-27-07-06 tdcid should start from 1
438  tbwgt->setValue(std::make_pair(igroup_ID, iTdcBin + 1), wgt);
439  } //loop Tdc bins
440  ngroups++;
441  } //loop groupID
442 
443  sm_constr_ = smnumber;
444 
445  edm::LogInfo("StoreEcalCondition") << "Weights for " << ngroups << " groups written into DB";
446  return tbwgt;
447 }
448 
449 //-------------------------------------------------------------
450 std::shared_ptr<EcalADCToGeVConstant> StoreEcalCondition::readEcalADCToGeVConstantFromFile(const char* inputFile) {
451  //-------------------------------------------------------------
452 
453  FILE* inpFile; // input file
454  inpFile = fopen(inputFile, "r");
455  if (!inpFile) {
456  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
457  return nullptr;
458  }
459 
460  char line[256];
461 
462  std::ostringstream str;
463 
464  fgets(line, 255, inpFile);
465  int sm_number = atoi(line);
466  str << "sm= " << sm_number << "\n";
467 
468  fgets(line, 255, inpFile);
469  //int nevents=atoi(line); // not necessary here just for online conddb
470 
471  fgets(line, 255, inpFile);
472  string gen_tag = to_string(line);
473  str << "gen tag " << gen_tag << "\n"; // should I use this?
474 
475  fgets(line, 255, inpFile);
476  string cali_method = to_string(line);
477  str << "cali method " << cali_method << "\n"; // not important
478 
479  fgets(line, 255, inpFile);
480  string cali_version = to_string(line);
481  str << "cali version " << cali_version << "\n"; // not important
482 
483  fgets(line, 255, inpFile);
484  string cali_type = to_string(line);
485  str << "cali type " << cali_type << "\n"; // not important
486 
487  edm::LogInfo("StoreEcalCondition") << "ADCToGeV file " << str.str();
488 
489  fgets(line, 255, inpFile);
490  float adc_to_gev = 0;
491  sscanf(line, "%f", &adc_to_gev);
492  LogDebug("StoreEcalCondition") << " calib=" << adc_to_gev;
493  fgets(line, 255, inpFile);
494  float adc_to_gev_ee = 0;
495  sscanf(line, "%f", &adc_to_gev_ee);
496  LogDebug("StoreEcalCondition") << " calib=" << adc_to_gev_ee;
497 
498  fclose(inpFile); // close inp. file
499 
500  sm_constr_ = sm_number;
501 
502  // barrel and endcaps the same
503  auto agc = std::make_shared<EcalADCToGeVConstant>(adc_to_gev, adc_to_gev_ee);
504  edm::LogInfo("StoreEcalCondition") << "ADCtoGeV scale written into the DB";
505  return agc;
506 }
507 
508 //-------------------------------------------------------------
509 std::shared_ptr<EcalPFRecHitThresholds> StoreEcalCondition::readEcalPFRecHitThresholdsFromFile(
510  const char* inputFile, const char* inputFileEE) {
511  //-------------------------------------------------------------
512 
513  auto ical = std::make_shared<EcalPFRecHitThresholds>();
514 
515  FILE* inpFile; // input file
516  inpFile = fopen(inputFile, "r");
517  if (!inpFile) {
518  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
519  return nullptr;
520  }
521 
522  char line[256];
523 
524  int ieta = 0;
525  int iphi = 0;
526  int ix = 0;
527  int iy = 0;
528  int iz = 0;
529 
530  float thresh = 0;
531 
532  int ii = 0;
533  while (fgets(line, 255, inpFile)) {
534  sscanf(line, "%d %d %f ", &ieta, &iphi, &thresh);
535  if (ii == 0)
536  edm::LogVerbatim("StoreEcalCondition") << "crystal " << ieta << "/" << iphi << " Thresh= " << thresh << "\n";
537 
538  if (EBDetId::validDetId(ieta, iphi)) {
539  EBDetId ebid(ieta, iphi);
540  ical->setValue(ebid.rawId(), thresh);
541  ii++;
542  }
543  }
544 
545  // inf.close(); // close inp. file
546  fclose(inpFile); // close inp. file
547 
548  edm::LogInfo("StoreEcalCondition") << "Read PF RecHits for " << ii << " xtals ";
549 
550  FILE* inpFileEE; // input file
551  inpFileEE = fopen(inputFileEE, "r");
552  if (!inpFileEE) {
553  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFileEE;
554  return nullptr;
555  }
556  ii = 0;
557  while (fgets(line, 255, inpFileEE)) {
558  sscanf(line, "%d %d %d %f ", &ix, &iy, &iz, &thresh);
559  if (ii == 0)
560  edm::LogVerbatim("StoreEcalCondition")
561  << "crystal " << ix << "/" << iy << "/" << iz << " Thresh= " << thresh << "\n";
562  if (EEDetId::validDetId(ix, iy, iz)) {
563  EEDetId eeid(ix, iy, iz);
564  ical->setValue(eeid.rawId(), thresh);
565  ii++;
566  }
567  }
568 
569  // inf.close(); // close inp. file
570  fclose(inpFileEE); // close inp. file
571 
572  edm::LogInfo("StoreEcalCondition") << "loop on EE channels done - number of crystals =" << ii;
573 
574  return ical;
575 }
576 
577 //-------------------------------------------------------------
578 std::shared_ptr<EcalIntercalibConstants> StoreEcalCondition::readEcalIntercalibConstantsFromFile(
579  const char* inputFile, const char* inputFileEE) {
580  //-------------------------------------------------------------
581 
582  auto ical = std::make_shared<EcalIntercalibConstants>();
583 
584  FILE* inpFile; // input file
585  inpFile = fopen(inputFile, "r");
586  if (!inpFile) {
587  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
588  return nullptr;
589  }
590 
591  char line[256];
592 
593  std::ostringstream str;
594 
595  fgets(line, 255, inpFile);
596  string sm_or_all = to_string(line);
597  int sm_number = 0;
598  int nchan = 1700;
599  sm_number = atoi(line);
600  str << "sm= " << sm_number << "\n";
601  if (sm_number != -1) {
602  nchan = 1700;
603  } else {
604  nchan = 61200;
605  }
606 
607  fgets(line, 255, inpFile);
608  //int nevents=atoi(line); // not necessary here just for online conddb
609 
610  fgets(line, 255, inpFile);
611  string gen_tag = to_string(line);
612  str << "gen tag " << gen_tag << "\n"; // should I use this?
613 
614  fgets(line, 255, inpFile);
615  string cali_method = to_string(line);
616  str << "cali method " << cali_method << "\n"; // not important
617 
618  fgets(line, 255, inpFile);
619  string cali_version = to_string(line);
620  str << "cali version " << cali_version << "\n"; // not important
621 
622  fgets(line, 255, inpFile);
623  string cali_type = to_string(line);
624  str << "cali type " << cali_type << "\n"; // not important
625 
626  edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str();
627 
628  int sm_num[61200] = {0};
629  int cry_num[61200] = {0};
630  float calib[61200] = {0};
631  float calib_rms[61200] = {0};
632  int calib_nevents[61200] = {0};
633  int calib_status[61200] = {0};
634 
635  int ii = 0;
636  if (sm_number != -1) {
637  while (fgets(line, 255, inpFile)) {
638  sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii]);
639  // if(ii<10) { // print out only the first ten channels
640  // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
641  // }
642  sm_num[ii] = sm_number;
643  ii++;
644  }
645  } else {
646  // this is for the whole Barrel
647  edm::LogInfo("StoreEcalCondition") << "mode ALL BARREL";
648  while (fgets(line, 255, inpFile)) {
649  sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii]);
650  if (ii == 0)
651  edm::LogVerbatim("StoreEcalCondition")
652  << "crystal " << cry_num[ii] << " of sm " << sm_num[ii] << " cali= " << calib[ii] << "\n";
653  ii++;
654  }
655  }
656 
657  // inf.close(); // close inp. file
658  fclose(inpFile); // close inp. file
659 
660  edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals ";
661 
662  if (ii != nchan)
663  edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0";
664 
665  // Get channel ID
666 
667  sm_constr_ = sm_number;
668 
669  // Set the data
670  for (int i = 0; i < nchan; i++) {
671  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
672  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
673 
674  int slot_num = convertFromConstructionSMToSlot(sm_num[i], -1);
675  EBDetId ebid(slot_num, cry_num[i], EBDetId::SMCRYSTALMODE);
676 
677  ical->setValue(ebid.rawId(), calib[i]);
678 
679  if (i == 0)
680  edm::LogVerbatim("StoreEcalCondition") << "crystal " << cry_num[i] << " of sm " << sm_num[i] << " in slot "
681  << slot_num << " calib= " << calib[i] << "\n";
682 
683  } // loop over channels
684 
685  edm::LogInfo("StoreEcalCondition") << "loop on channels done";
686 
687  FILE* inpFileEE; // input file
688  inpFileEE = fopen(inputFileEE, "r");
689  if (!inpFileEE) {
690  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
691 
692  // dummy endcap data
693 
694  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
695  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
696  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
697  if (EEDetId::validDetId(iX, iY, 1)) {
698  EEDetId eedetidpos(iX, iY, 1);
699  ical->setValue(eedetidpos, 1.0);
700  }
701  if (EEDetId::validDetId(iX, iY, -1)) {
702  EEDetId eedetidneg(iX, iY, -1);
703  ical->setValue(eedetidneg, 1.0);
704  }
705  }
706  }
707 
708  } else {
709  edm::LogInfo("StoreEcalCondition") << "... now reading EE file ...";
710 
711  int ii = 0;
712  while (fgets(line, 255, inpFileEE)) {
713  int iz, ix, iy;
714  float calibee;
715  sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee);
716  if (ii <= 0)
717  edm::LogVerbatim("StoreEcalCondition")
718  << "crystal " << iz << "/" << ix << "/" << iy << " cali=" << calibee << "\n";
719 
720  if (EEDetId::validDetId(ix, iy, iz)) {
721  EEDetId eedetid(ix, iy, iz);
722  ical->setValue(eedetid, calibee);
723  }
724 
725  ii++;
726  }
727 
728  fclose(inpFileEE); // close inp. file
729  }
730 
731  edm::LogInfo("StoreEcalCondition") << "loop on EE channels done";
732 
733  return ical;
734 }
735 
736 //-------------------------------------------------------------
737 std::shared_ptr<EcalIntercalibConstantsMC> StoreEcalCondition::readEcalIntercalibConstantsMCFromFile(
738  const char* inputFile, const char* inputFileEE) {
739  //-------------------------------------------------------------
740 
741  auto ical = std::make_shared<EcalIntercalibConstantsMC>();
742 
743  FILE* inpFile; // input file
744  inpFile = fopen(inputFile, "r");
745  if (!inpFile) {
746  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
747  return nullptr;
748  }
749 
750  char line[256];
751 
752  std::ostringstream str;
753 
754  fgets(line, 255, inpFile);
755  string sm_or_all = to_string(line);
756  int sm_number = 0;
757  int nchan = 1700;
758  sm_number = atoi(line);
759  str << "sm= " << sm_number << "\n";
760  if (sm_number != -1) {
761  nchan = 1700;
762  } else {
763  nchan = 61200;
764  }
765 
766  fgets(line, 255, inpFile);
767  //int nevents=atoi(line); // not necessary here just for online conddb
768 
769  fgets(line, 255, inpFile);
770  string gen_tag = to_string(line);
771  str << "gen tag " << gen_tag << "\n"; // should I use this?
772 
773  fgets(line, 255, inpFile);
774  string cali_method = to_string(line);
775  str << "cali method " << cali_method << "\n"; // not important
776 
777  fgets(line, 255, inpFile);
778  string cali_version = to_string(line);
779  str << "cali version " << cali_version << "\n"; // not important
780 
781  fgets(line, 255, inpFile);
782  string cali_type = to_string(line);
783  str << "cali type " << cali_type << "\n"; // not important
784 
785  edm::LogInfo("StoreEcalCondition") << "Intercalibration file " << str.str();
786 
787  int sm_num[61200] = {0};
788  int cry_num[61200] = {0};
789  float calib[61200] = {0};
790  float calib_rms[61200] = {0};
791  int calib_nevents[61200] = {0};
792  int calib_status[61200] = {0};
793 
794  int ii = 0;
795  if (sm_number != -1) {
796  while (fgets(line, 255, inpFile)) {
797  sscanf(line, "%d %f %f %d %d", &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_nevents[ii], &calib_status[ii]);
798  // if(ii<10) { // print out only the first ten channels
799  // cout << "cry="<<cry_num[ii]<<" calib="<<calib[ii]<<endl;
800  // }
801  sm_num[ii] = sm_number;
802  ii++;
803  }
804  } else {
805  // this is for the whole Barrel
806  edm::LogInfo("StoreEcalCondition") << "mode ALL BARREL";
807  while (fgets(line, 255, inpFile)) {
808  sscanf(line, "%d %d %f %f %d", &sm_num[ii], &cry_num[ii], &calib[ii], &calib_rms[ii], &calib_status[ii]);
809  if (ii == 0)
810  edm::LogVerbatim("StoreEcalCondition")
811  << "crystal " << cry_num[ii] << " of sm " << sm_num[ii] << " cali= " << calib[ii] << "\n";
812  ii++;
813  }
814  }
815 
816  // inf.close(); // close inp. file
817  fclose(inpFile); // close inp. file
818 
819  edm::LogInfo("StoreEcalCondition") << "Read intercalibrations for " << ii << " xtals ";
820 
821  if (ii != nchan)
822  edm::LogWarning("StoreEcalCondition") << "Some crystals missing. Missing channels will be set to 0";
823 
824  // Get channel ID
825 
826  sm_constr_ = sm_number;
827 
828  // Set the data
829  for (int i = 0; i < nchan; i++) {
830  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
831  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
832 
833  int slot_num = convertFromConstructionSMToSlot(sm_num[i], -1);
834  EBDetId ebid(slot_num, cry_num[i], EBDetId::SMCRYSTALMODE);
835 
836  ical->setValue(ebid.rawId(), calib[i]);
837 
838  if (i == 0)
839  edm::LogVerbatim("StoreEcalCondition") << "crystal " << cry_num[i] << " of sm " << sm_num[i] << " in slot "
840  << slot_num << " calib= " << calib[i] << "\n";
841 
842  } // loop over channels
843 
844  edm::LogInfo("StoreEcalCondition") << "loop on channels done";
845 
846  FILE* inpFileEE; // input file
847  inpFileEE = fopen(inputFileEE, "r");
848  if (!inpFileEE) {
849  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
850 
851  // dummy endcap data
852 
853  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
854  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
855  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
856  if (EEDetId::validDetId(iX, iY, 1)) {
857  EEDetId eedetidpos(iX, iY, 1);
858  ical->setValue(eedetidpos, 1.0);
859  }
860  if (EEDetId::validDetId(iX, iY, -1)) {
861  EEDetId eedetidneg(iX, iY, -1);
862  ical->setValue(eedetidneg, 1.0);
863  }
864  }
865  }
866 
867  } else {
868  edm::LogInfo("StoreEcalCondition") << "... now reading EE file ...";
869 
870  int ii = 0;
871  while (fgets(line, 255, inpFileEE)) {
872  int iz, ix, iy;
873  float calibee;
874  sscanf(line, "%d %d %d %f", &iz, &ix, &iy, &calibee);
875  if (ii <= 0)
876  edm::LogVerbatim("StoreEcalCondition")
877  << "crystal " << iz << "/" << ix << "/" << iy << " cali=" << calibee << "\n";
878 
879  if (EEDetId::validDetId(ix, iy, iz)) {
880  EEDetId eedetid(ix, iy, iz);
881  ical->setValue(eedetid, calibee);
882  }
883 
884  ii++;
885  }
886 
887  fclose(inpFileEE); // close inp. file
888  }
889 
890  edm::LogInfo("StoreEcalCondition") << "loop on EE channels done";
891 
892  return ical;
893 }
894 
895 //-------------------------------------------------------------
897  // input either cosntruction number or slot number and returns the other
898  // the slots are numbered first EB+ slot 1 ...18 then EB- 1... 18
899  // the slots start at 1 and the SM start at 0
900  //-------------------------------------------------------------
901  int slot_to_constr[37] = {-1, 12, 17, 10, 1, 8, 4, 27, 20, 23, 25, 6, 34, 35, 15, 18, 30, 21, 9,
902  24, 22, 13, 31, 26, 16, 2, 11, 5, 0, 29, 28, 14, 33, 32, 3, 7, 19};
903  int constr_to_slot[36] = {28, 4, 25, 34, 6, 27, 11, 35, 5, 18, 3, 26, 1, 21, 31, 14, 24, 2,
904  15, 36, 8, 17, 20, 9, 19, 10, 23, 7, 30, 29, 16, 22, 33, 32, 12, 13};
905 
906  int result = 0;
907  if (sm_constr != -1) {
908  result = constr_to_slot[sm_constr];
909  } else if (sm_slot != -1) {
910  result = slot_to_constr[sm_slot];
911  }
912  return result;
913 }
914 
915 //-------------------------------------------------------------
916 std::shared_ptr<EcalGainRatios> StoreEcalCondition::readEcalGainRatiosFromFile(const char* inputFile) {
917  //-------------------------------------------------------------
918 
919  // create gain ratios
920  auto gratio = std::make_shared<EcalGainRatios>();
921 
922  FILE* inpFile; // input file
923  inpFile = fopen(inputFile, "r");
924  if (!inpFile) {
925  edm::LogError("StoreEcalCondition") << "*** Can not open file: " << inputFile;
926  return nullptr;
927  }
928 
929  char line[256];
930  std::ostringstream str;
931 
932  fgets(line, 255, inpFile);
933  string sm_or_all = to_string(line);
934  int sm_number = 0;
935  sm_number = atoi(line);
936  str << "sm= " << sm_number << "\n";
937 
938  fgets(line, 255, inpFile);
939  //int nevents=atoi(line);
940 
941  fgets(line, 255, inpFile);
942  string gen_tag = to_string(line);
943  str << "gen tag " << gen_tag << "\n";
944 
945  fgets(line, 255, inpFile);
946  string cali_method = to_string(line);
947  str << "cali method " << cali_method << "\n";
948 
949  fgets(line, 255, inpFile);
950  string cali_version = to_string(line);
951  str << "cali version " << cali_version << "\n";
952 
953  fgets(line, 255, inpFile);
954  string cali_type = to_string(line);
955 
956  str << "cali type " << cali_type << "\n";
957 
958  edm::LogInfo("StoreEcalCondition") << "GainRatio file " << str.str();
959 
960  int cry_num[61200] = {0};
961  float g1_g12[61200] = {0};
962  float g6_g12[61200] = {0};
963  int calib_status[61200] = {0};
964  int dummy1 = 0;
965  int dummy2 = 0;
966  int hash1 = 0;
967 
968  int ii = 0;
969 
970  if (sm_number != -1) {
971  while (fgets(line, 255, inpFile)) {
972  sscanf(line, "%d %d %d %f %f %d", &dummy1, &dummy2, &cry_num[ii], &g1_g12[ii], &g6_g12[ii], &calib_status[ii]);
973  ii++;
974  }
975 
976  fclose(inpFile); // close inp. file
977 
978  edm::LogInfo("StoreEcalCondition") << "Read gainRatios for " << ii << " xtals ";
979  if (ii != 1700)
980  edm::LogWarning("StoreEcalCondition") << " Missing crystals:: missing channels will be set to 0";
981 
982  // Get channel ID
983  sm_constr_ = sm_number;
984 
985  for (int i = 0; i < 1700; i++) {
986  // EBDetId(int index1, int index2, int mode = ETAPHIMODE)
987  // sm and crys index SMCRYSTALMODE index1 is SM index2 is crystal number a la H4
988  EBDetId ebid(sm_slot_, cry_num[i], EBDetId::SMCRYSTALMODE);
990  gr.setGain12Over6(g6_g12[i]);
991  gr.setGain6Over1(g1_g12[i] / g6_g12[i]);
992  gratio->setValue(ebid.rawId(), gr);
993  } // loop over channels
994 
995  } else {
996  // this is for the whole Barrel
997  edm::LogInfo("StoreEcalCondition") << "mode ALL BARREL";
998  while (fgets(line, 255, inpFile)) {
999  int eta = 0;
1000  int phi = 0;
1001  sscanf(line, "%d %d %d %f %f", &hash1, &eta, &phi, &g1_g12[ii], &g6_g12[ii]);
1002  if (ii < 20)
1003  edm::LogVerbatim("StoreEcalCondition")
1004  << "crystal eta/phi=" << eta << "/" << phi << " g1_12/g6_12= " << g1_g12[ii] << "/" << g6_g12[ii] << "\n";
1005 
1006  if (g1_g12[ii] < 9 || g1_g12[ii] > 15)
1007  g1_g12[ii] = 12.0;
1008  if (g6_g12[ii] < 1 || g6_g12[ii] > 3)
1009  g6_g12[ii] = 2.0;
1010 
1011  if (eta < -85 || eta > 85 || eta == 0)
1012  edm::LogVerbatim("StoreEcalCondition") << "error!!!\n";
1013  if (phi < 1 || phi > 360)
1014  edm::LogVerbatim("StoreEcalCondition") << "error!!!\n";
1015 
1016  EBDetId ebid(eta, phi, EBDetId::ETAPHIMODE);
1017  EcalMGPAGainRatio gr;
1018  gr.setGain12Over6(g6_g12[ii]);
1019  gr.setGain6Over1(g1_g12[ii] / g6_g12[ii]);
1020  gratio->setValue(ebid.rawId(), gr);
1021 
1022  ii++;
1023  }
1024 
1025  fclose(inpFile); // close inp. file
1026  if (ii != 61200)
1027  edm::LogWarning("StoreEcalCondition") << " Missing crystals !!!!!!!";
1028 
1029  edm::LogInfo("StoreEcalCondition") << "number of crystals read:" << ii;
1030  }
1031 
1032  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1033  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1034  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1035  EcalMGPAGainRatio gr;
1036  gr.setGain12Over6(2.);
1037  gr.setGain6Over1(6.);
1038 
1039  if (EEDetId::validDetId(iX, iY, 1)) {
1040  EEDetId eedetidpos(iX, iY, 1);
1041  gratio->setValue(eedetidpos.rawId(), gr);
1042  }
1043  if (EEDetId::validDetId(iX, iY, -1)) {
1044  EEDetId eedetidneg(iX, iY, -1);
1045  gratio->setValue(eedetidneg.rawId(), gr);
1046  }
1047  }
1048  }
1049 
1050  edm::LogInfo("StoreEcalCondition") << " gratio pointer=" << gratio;
1051 
1052  edm::LogInfo("StoreEcalCondition") << "now leaving";
1053 
1054  return gratio;
1055 }
1056 
1057 std::shared_ptr<EcalChannelStatus> StoreEcalCondition::readEcalChannelStatusFromFile(const char* inputFile) {
1058  auto status = std::make_shared<EcalChannelStatus>();
1059  // barrel
1060  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1061  if (ieta == 0)
1062  continue;
1063  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1064  if (EBDetId::validDetId(ieta, iphi)) {
1065  EBDetId ebid(ieta, iphi);
1066  status->setValue(ebid, 0);
1067  }
1068  }
1069  }
1070  // endcap
1071  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1072  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1073  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1074  if (EEDetId::validDetId(iX, iY, 1)) {
1075  EEDetId eedetidpos(iX, iY, 1);
1076  status->setValue(eedetidpos, 0);
1077  }
1078  if (EEDetId::validDetId(iX, iY, -1)) {
1079  EEDetId eedetidneg(iX, iY, -1);
1080  status->setValue(eedetidneg, 0);
1081  }
1082  }
1083  }
1084 
1085  edm::LogInfo("StoreEcalCondition") << "Reading channel status from file " << inputFile;
1086  FILE* ifile = fopen(inputFile, "r");
1087  if (!ifile)
1088  throw cms::Exception("Cannot open ECAL channel status file");
1089 
1090  char line[256];
1091 
1092  fgets(line, 255, ifile);
1093  std::string gen_tag = line;
1094  edm::LogVerbatim("StoreEcalCondition") << "Gen tag " << gen_tag << "\n";
1095 
1096  fgets(line, 255, ifile);
1097  std::string comment = line;
1098  edm::LogVerbatim("StoreEcalCondition") << "Gen comment " << comment << "\n";
1099 
1100  int iovRunStart(0);
1101  fgets(line, 255, ifile);
1102  sscanf(line, "%d", &iovRunStart);
1103  edm::LogVerbatim("StoreEcalCondition") << "IOV START " << iovRunStart << "\n";
1104  //if -1 start of time
1105 
1106  int iovRunEnd(0);
1107  fgets(line, 255, ifile);
1108  sscanf(line, "%d", &iovRunEnd);
1109  edm::LogVerbatim("StoreEcalCondition") << "IOV END " << iovRunEnd << "\n";
1110  //if -1 end of time
1111 
1112  int ii = 0;
1113  while (fgets(line, 255, ifile)) {
1114  std::string EBorEE;
1115  int hashedIndex(0);
1116  int chStatus(0);
1117  std::stringstream aStrStream;
1118  aStrStream << line;
1119  aStrStream >> EBorEE >> hashedIndex >> chStatus;
1120  // if(ii==0)
1121  edm::LogVerbatim("StoreEcalCondition")
1122  << EBorEE << " hashedIndex " << hashedIndex << " status " << chStatus << "\n";
1123 
1124  if (EBorEE == "EB") {
1125  EBDetId aEBDetId = EBDetId::unhashIndex(hashedIndex);
1126  status->setValue(aEBDetId, chStatus);
1127  } else if (EBorEE == "EE") {
1128  // chStatus=1;
1129  EEDetId aEEDetId = EEDetId::unhashIndex(hashedIndex);
1130  status->setValue(aEEDetId, chStatus);
1131  } else if (EBorEE == "EBTT") {
1132  int ism = hashedIndex;
1133  int itt = chStatus;
1134 
1135  int ixtt = (itt - 1) % 4;
1136  int iytt = (itt - 1) / 4;
1137  int ixmin = ixtt * 5;
1138  int iymin = iytt * 5;
1139  int ixmax = (ixtt + 1) * 5 - 1;
1140  int iymax = (iytt + 1) * 5 - 1;
1141  for (int ieta = iymin; ieta <= iymax; ieta++) {
1142  for (int iphi = ixmin; iphi <= ixmax; iphi++) {
1143  int ixt = ieta * 20 + iphi + 1;
1144  edm::LogVerbatim("StoreEcalCondition") << "killing crystal " << ism << "/" << ixt << "\n";
1145  EBDetId ebid(ism, ixt, EBDetId::SMCRYSTALMODE);
1146  status->setValue(ebid, 1);
1147  }
1148  }
1149  }
1150 
1151  ii++;
1152  }
1153 
1154  fclose(ifile);
1155 
1156  /*
1157  std::cout <<"KILLING CHANNELS FOR CRAFT EB+16 AND EB+7"<<endl;
1158 
1159  int ism=7;
1160  for(int ixt=1; ixt<=500; ixt++) {
1161  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1162  status->setValue( ebid, 1 );
1163  }
1164  for(int ixt=501; ixt<=900; ixt++) {
1165  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1166  if( ((ixt)%20==0) || ((ixt)%20>10) ){
1167  status->setValue( ebid, 1 );
1168  }
1169  }
1170  ism=16;
1171  for(int ixt=501; ixt<=900; ixt++) {
1172  EBDetId ebid(ism,ixt,EBDetId::SMCRYSTALMODE);
1173  if( ((ixt)%20==0) || ((ixt)%20>10) ){
1174  status->setValue( ebid, 1 );
1175  }
1176  }
1177 
1178  */
1179 
1180  return status;
1181 }
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:28
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
static const int MIN_IPHI
Definition: EBDetId.h:135
void writeToLogFileResults(char *)
std::vector< std::string > inpFileName_
StoreEcalCondition(const edm::ParameterSet &iConfig)
std::vector< std::string > inpFileNameEE_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
list status
Definition: mps_update.py:107
std::shared_ptr< EcalChannelStatus > readEcalChannelStatusFromFile(const char *)
std::shared_ptr< EcalIntercalibConstants > readEcalIntercalibConstantsFromFile(const char *, const char *)
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:20
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
Log< level::Error, false > LogError
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
int ii
Definition: cuy.py:589
A arg
Definition: Factorize.h:31
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
tuple result
Definition: mps_fire.py:311
void setGain12Over6(const float &g)
std::shared_ptr< EcalADCToGeVConstant > readEcalADCToGeVConstantFromFile(const char *)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:36
unsigned long long Time_t
Definition: Time.h:14
vector< ParameterSet > Parameters
bool isNewTagRequest(const std::string &recordName)
void endJob() override
std::vector< unsigned long long > since_
bool isAvailable() const
Definition: Service.h:40
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
Definition: EcalWeightSet.h:29
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
constexpr size_t nSamples
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
static const int ETAPHIMODE
Definition: EBDetId.h:158
std::shared_ptr< EcalTBWeights > readEcalTBWeightsFromFile(const char *)
std::shared_ptr< EcalIntercalibConstantsMC > readEcalIntercalibConstantsMCFromFile(const char *, const char *)
void writeToLogFile(std::string, std::string, unsigned long long)
static const int IX_MAX
Definition: EEDetId.h:298
Log< level::Info, false > LogInfo
std::shared_ptr< EcalWeightXtalGroups > readEcalWeightXtalGroupsFromFile(const char *)
std::string to_string(char value[])
int convertFromConstructionSMToSlot(int, int)
static const int MAX_IPHI
Definition: EBDetId.h:137
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const int MAX_IETA
Definition: EBDetId.h:136
double b
Definition: hdecay.h:118
std::shared_ptr< EcalGainRatios > readEcalGainRatiosFromFile(const char *)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
double a
Definition: hdecay.h:119
std::shared_ptr< EcalPFRecHitThresholds > readEcalPFRecHitThresholdsFromFile(const char *, const char *)
static const int IY_MAX
Definition: EEDetId.h:302
std::vector< std::string > objectName_
Log< level::Warning, false > LogWarning
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
#define str(s)
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:49
void setGain6Over1(const float &g)
#define LogDebug(id)