CMS 3D CMS Logo

HcalDbASCIIIO.cc
Go to the documentation of this file.
1 //
2 // F.Ratnikov (UMd), Oct 28, 2005
3 //
4 #include <vector>
5 #include <string>
6 #include <cstdio>
7 #include <sstream>
8 #include <memory>
9 
14 
18 
19 namespace {
20  class DetIdLess {
21  public:
22  bool operator () (DetId fFirst, DetId fSecond) const {
23  HcalGenericDetId first (fFirst);
24  HcalGenericDetId second (fSecond);
25  if (first.genericSubdet () != second.genericSubdet ()) return first.genericSubdet () < second.genericSubdet ();
26  if (first.isHcalDetId ()) {
27  HcalDetId f1 (first);
28  HcalDetId s1 (second);
29  return f1.zside () != s1.zside () ? f1.zside () < s1.zside () :
30  f1.iphi () != s1.iphi () ? f1.iphi () < s1.iphi () :
31  f1.ietaAbs () != s1.ietaAbs () ? f1.ietaAbs () < s1.ietaAbs () :
32  f1.depth () < s1.depth ();
33  }
34  else {
35  return first.rawId() < second.rawId();
36  }
37  }
38  };
39  class HcalElectronicsIdLess {
40  public:
41  bool operator () (HcalElectronicsId first, HcalElectronicsId second) const {
42  return
43  first.readoutVMECrateId () != second.readoutVMECrateId () ? first.readoutVMECrateId () < second.readoutVMECrateId () :
44  first.htrSlot () != second.htrSlot () ? first.htrSlot () < second.htrSlot () :
45  first.htrTopBottom () != second.htrTopBottom () ? first.htrTopBottom () < second.htrTopBottom () :
46  first.fiberIndex () != second.fiberIndex () ? first.fiberIndex () < second.fiberIndex () :
47  first.fiberChanId () < second.fiberChanId ();
48  }
49  };
50 }
51 
52 // ------------------------------ some little helpers ------------------------------
53 
54 std::vector <std::string> splitString (const std::string& fLine) {
55  std::vector <std::string> result;
56  int start = 0;
57  bool empty = true;
58  for (unsigned i = 0; i <= fLine.size (); i++) {
59  if (fLine [i] == ' ' || i == fLine.size ()) {
60  if (!empty) {
61  std::string item (fLine, start, i-start);
62  result.push_back (item);
63  empty = true;
64  }
65  start = i+1;
66  }
67  else {
68  if (empty) empty = false;
69  }
70  }
71  return result;
72 }
73 
74 std::vector <unsigned int> splitStringToIntByComma (const std::string& fLine) {
75  std::vector <unsigned int> result;
76  int start = 0;
77  bool empty = true;
78  for (unsigned i = 0; i <= fLine.size (); i++) {
79  if (fLine [i] == ',' || i == fLine.size ()) {
80  if (!empty) {
81  std::string itemString (fLine, start, i-start);
82  result.push_back (atoi (itemString.c_str()) );
83  empty = true;
84  }
85  start = i+1;
86  }
87  else {
88  if (empty) empty = false;
89  }
90  }
91  return result;
92 }
93 
94 std::vector <float> splitStringToFloatByComma (const std::string& fLine) {
95  std::vector <float> result;
96  int start = 0;
97  bool empty = true;
98  for (unsigned i = 0; i <= fLine.size (); i++) {
99  if (fLine [i] == ',' || i == fLine.size ()) {
100  if (!empty) {
101  std::string itemString (fLine, start, i-start);
102  result.push_back (atof (itemString.c_str()) );
103  empty = true;
104  }
105  start = i+1;
106  }
107  else {
108  if (empty) empty = false;
109  }
110  }
111  return result;
112 }
113 
114 std::vector <double> splitStringToDoubleByComma (const std::string& fLine) {
115  std::vector <double> result;
116  int start = 0;
117  bool empty = true;
118  for (unsigned i = 0; i <= fLine.size (); i++) {
119  if (fLine [i] == ',' || i == fLine.size ()) {
120  if (!empty) {
121  std::string itemString (fLine, start, i-start);
122  result.push_back (atof (itemString.c_str()) );
123  empty = true;
124  }
125  start = i+1;
126  }
127  else {
128  if (empty) empty = false;
129  }
130  }
131  return result;
132 }
133 
134 DetId HcalDbASCIIIO::getId (const std::vector <std::string> & items) {
135  HcalText2DetIdConverter converter (items [3], items [0], items [1], items [2]);
136  return converter.getId ();
137 }
138 
139 void HcalDbASCIIIO::dumpId (std::ostream& fOutput, DetId id) {
141  char buffer [1024];
142  sprintf (buffer, " %15s %15s %15s %15s",
143  converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
144  fOutput << buffer;
145 }
146 
147 void HcalDbASCIIIO::dumpIdShort (std::ostream& fOutput, DetId id) {
149  char buffer [1024];
150  sprintf (buffer, " %5s %4s %4s %10s",
151  converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());
152  fOutput << buffer;
153 }
154 
155 
156 // ------------------------------ start templates ------------------------------
157 
158 template<class T>
159 bool from_string(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&)) {
160  std::istringstream iss(s);
161  return !(iss >> f >> t).fail();
162 }
163 
164 template <class T,class S>
165 bool getHcalObject (std::istream& fInput, T* fObject, S* fCondObject) {
166  if (!fObject) return false; //fObject = new T;
167  char buffer [1024];
168  while (fInput.getline(buffer, 1024)) {
169  if (buffer [0] == '#') continue; //ignore comment
170  std::vector <std::string> items = splitString (std::string (buffer));
171  if (items.size()==0) continue; // blank line
172  if (items.size () < 8) {
173  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
174  continue;
175  }
176  DetId id = HcalDbASCIIIO::getId (items);
177 
178 // if (fObject->exists(id) )
179 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
180 // else
181 // {
182  fCondObject = new S(id, atof (items [4].c_str()), atof (items [5].c_str()),
183  atof (items [6].c_str()), atof (items [7].c_str()));
184  fObject->addValues(*fCondObject);
185  delete fCondObject;
186  // }
187  }
188 
189  return true;
190 }
191 
192 template <class T>
193 bool dumpHcalObject (std::ostream& fOutput, const T& fObject) {
194  char buffer [1024];
195  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n", "eta", "phi", "dep", "det", "cap0", "cap1", "cap2", "cap3", "DetId");
196  fOutput << buffer;
197  std::vector<DetId> channels = fObject.getAllChannels ();
198  std::sort (channels.begin(), channels.end(), DetIdLess ());
199  for (std::vector<DetId>::iterator channel = channels.begin ();
200  channel != channels.end ();
201  ++channel) {
202  const float* values = fObject.getValues (*channel)->getValues ();
203  if (values) {
204  HcalDbASCIIIO::dumpId (fOutput, *channel);
205  sprintf (buffer, " %10.7f %10.7f %10.7f %10.7f %10X\n",
206  values[0], values[1], values[2], values[3], channel->rawId ());
207  fOutput << buffer;
208  }
209  }
210  return true;
211 }
212 
213 template <class T,class S>
214 bool getHcalSingleFloatObject (std::istream& fInput, T* fObject, S* fCondObject) {
215  if (!fObject) return false; //fObject = new T;
216  char buffer [1024];
217  while (fInput.getline(buffer, 1024)) {
218  if (buffer [0] == '#') continue; //ignore comment
219  std::vector <std::string> items = splitString (std::string (buffer));
220  if (items.size()==0) continue; // blank line
221  if (items.size () < 5) {
222  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
223  continue;
224  }
225  DetId id = HcalDbASCIIIO::getId (items);
226 
227 // if (fObject->exists(id) )
228 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
229 // else
230 // {
231  fCondObject = new S(id, atof (items [4].c_str()) );
232  fObject->addValues(*fCondObject);
233  delete fCondObject;
234  // }
235  }
236  return true;
237 }
238 
239 template <class T>
240 bool dumpHcalSingleFloatObject (std::ostream& fOutput, const T& fObject) {
241  char buffer [1024];
242  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
243  fOutput << buffer;
244  std::vector<DetId> channels = fObject.getAllChannels ();
245  std::sort (channels.begin(), channels.end(), DetIdLess ());
246  for (std::vector<DetId>::iterator channel = channels.begin ();
247  channel != channels.end ();
248  ++channel) {
249  const float value = fObject.getValues (*channel)->getValue ();
250  HcalDbASCIIIO::dumpId (fOutput, *channel);
251  sprintf (buffer, " %8.5f %10X\n",
252  value, channel->rawId ());
253  fOutput << buffer;
254  }
255  return true;
256 }
257 
258 template <class T,class S>
259 bool getHcalSingleIntObject (std::istream& fInput, T* fObject, S* fCondObject) {
260  if (!fObject) return false; //fObject = new T;
261  char buffer [1024];
262  while (fInput.getline(buffer, 1024)) {
263  if (buffer [0] == '#') continue; //ignore comment
264  std::vector <std::string> items = splitString (std::string (buffer));
265  if (items.size()==0) continue; // blank line
266  if (items.size () < 5) {
267  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
268  continue;
269  }
270  DetId id = HcalDbASCIIIO::getId (items);
271 
272 // if (fObject->exists(id) )
273 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
274 // else
275 // {
276  fCondObject = new S(id, atoi (items [4].c_str()) );
277  fObject->addValues(*fCondObject);
278  delete fCondObject;
279  // }
280  }
281  return true;
282 }
283 
284 template <class T>
285 bool dumpHcalSingleIntObject (std::ostream& fOutput, const T& fObject) {
286  char buffer [1024];
287  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
288  fOutput << buffer;
289  std::vector<DetId> channels = fObject.getAllChannels ();
290  std::sort (channels.begin(), channels.end(), DetIdLess ());
291  for (std::vector<DetId>::iterator channel = channels.begin ();
292  channel != channels.end ();
293  ++channel) {
294  const int value = fObject.getValues (*channel)->getValue ();
295  HcalDbASCIIIO::dumpId (fOutput, *channel);
296  sprintf (buffer, " %15d %10X\n",
297  value, channel->rawId ());
298  fOutput << buffer;
299  }
300  return true;
301 }
302 
303 template <class T,class S>
304 bool getHcalMatrixObject (std::istream& fInput, T* fObject, S* fCondObject) {
305  if (!fObject) return false; //fObject = new T;
306  char buffer [1024];
307  while (fInput.getline(buffer, 1024)) {
308  if (buffer [0] == '#') continue; //ignore comment
309  std::vector <std::string> items = splitString (std::string (buffer));
310  if (items.size()==0) continue; // blank line
311  DetId firstid = HcalDbASCIIIO::getId (items);
312  fCondObject = new S(firstid.rawId());
313  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), 0, j, atof(items[j+5].c_str()));
314  for(int i = 1; i != 40; i++){
315  fInput.getline(buffer, 1024);
316  items = splitString (std::string (buffer));
317  DetId id = HcalDbASCIIIO::getId (items);
318  if(id.rawId() != firstid.rawId()) break;//throw cms::Exception("Wrong number of elements");
319  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), i%10, j, atof(items[j+5].c_str()));
320  }
321  fObject->addValues(*fCondObject);
322  delete fCondObject;
323  }
324  return true;
325 }
326 
327 template <class T>
328 bool dumpHcalMatrixObject (std::ostream& fOutput, const T& fObject) {
329  char buffer [1024];
330  sprintf (buffer, "# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
331  "eta", "phi", "dep", "det", "capid","c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "DetId");
332  fOutput << buffer;
333  std::vector<DetId> channels = fObject.getAllChannels ();
334  std::sort (channels.begin(), channels.end(), DetIdLess ());
335  for (std::vector<DetId>::iterator channel = channels.begin ();
336  channel != channels.end ();
337  ++channel) {
338  float thisline[10];
339  for(int m = 0; m != 4; m++){
340  for(int i = 0; i != 10; i++){
341  for(int j = 0; j != 10; j++){
342 // std::cout <<"test "<<(fObject.getValues(*channel))->getValue(0,0,0);
343  thisline[j] = fObject.getValues(*channel)->getValue(m,i,j);
344 // thisline[j] = fObject.getValues(*channel)->getValue(1,1,1);
345  }
346  HcalDbASCIIIO::dumpId (fOutput, *channel);
347  sprintf(buffer, " %5i %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
348  m, thisline[0], thisline[1], thisline[2], thisline[3], thisline[4], thisline[5], thisline[6], thisline[7],
349  thisline[8], thisline[9], channel->rawId());
350  fOutput << buffer;
351  }
352  }
353  }
354 
355  return true;
356 }
357 
358 // ------------------------------ end templates ------------------------------
359 
360 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalGains* fObject) {return getHcalObject (fInput, fObject, new HcalGain);}
361 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalGains& fObject) {return dumpHcalObject (fOutput, fObject);}
362 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalGainWidths* fObject) {return getHcalObject (fInput, fObject, new HcalGainWidth);}
363 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalGainWidths& fObject) {return dumpHcalObject (fOutput, fObject);}
364 
365 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalRespCorrs* fObject) {return getHcalSingleFloatObject (fInput, fObject, new HcalRespCorr); }
366 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalRespCorrs& fObject) {return dumpHcalSingleFloatObject (fOutput, fObject); }
367 
368 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalLUTCorrs* fObject) {return getHcalSingleFloatObject (fInput, fObject, new HcalLUTCorr); }
369 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalLUTCorrs& fObject) {return dumpHcalSingleFloatObject (fOutput, fObject); }
370 
371 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalPFCorrs* fObject) {return getHcalSingleFloatObject (fInput, fObject, new HcalPFCorr); }
372 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalPFCorrs& fObject) {return dumpHcalSingleFloatObject (fOutput, fObject); }
373 
374 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalTimeCorrs* fObject) {return getHcalSingleFloatObject (fInput, fObject, new HcalTimeCorr); }
375 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalTimeCorrs& fObject) {return dumpHcalSingleFloatObject (fOutput, fObject); }
376 
377 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalZSThresholds* fObject) {return getHcalSingleIntObject (fInput, fObject, new HcalZSThreshold); }
378 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalZSThresholds& fObject) {return dumpHcalSingleIntObject (fOutput, fObject); }
379 
380 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalZDCLowGainFractions* fObject) {return getHcalSingleFloatObject (fInput, fObject, new HcalZDCLowGainFraction); }
381 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalZDCLowGainFractions& fObject) {return dumpHcalSingleFloatObject (fOutput, fObject); }
382 
383 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalValidationCorrs* fObject) {return getHcalSingleFloatObject (fInput, fObject, new HcalValidationCorr); }
384 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalValidationCorrs& fObject) {return dumpHcalSingleFloatObject (fOutput, fObject); }
385 
386 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalQIETypes* fObject) {return getHcalSingleIntObject (fInput, fObject, new HcalQIEType); }
387 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalQIETypes& fObject) {return dumpHcalSingleIntObject (fOutput, fObject); }
388 
389 // ------------------------------ start specific implementations ------------------------------
390 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalRecoParams* fObject)
391 {
392  if (!fObject) return false; // fObject = new HcalRecoParams(); This was always useless...
393  char buffer [1024];
394  while (fInput.getline(buffer, 1024)) {
395  if (buffer [0] == '#') continue; //ignore comment
396  std::vector <std::string> items = splitString (std::string (buffer));
397  if (items.size()==0) continue; // blank line
398  if (items.size () < 6) {
399  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 6 items: eta, phi, depth, subdet, param1, param2" << std::endl;
400  continue;
401  }
402  DetId id = HcalDbASCIIIO::getId (items);
403 
404  int packingScheme =0;
405  if(items.size ()>22) {
406  packingScheme = atoi (items [22].c_str());
407  }
408 
409  int param1=0;
410  int param2=0;
411  if(packingScheme==0) {
412  param1=atoi (items [4].c_str());
413  param2=atoi (items [5].c_str());
414  } // packing scheme 0 (old format).
415 
416  if(packingScheme==1) {
417  // 0 1 2 3 4 5 6 7 8 9
418  int aabits[6]= {1,1, 8, 4, 4, 9};
419  int aamax[ 6]= {1,1,255,15,15,511};
420 
421  int bbbits[10]={1, 4,1, 4,1, 4, 4, 4, 4, 4};
422  int bbmax [10]={1,15,1,15,1,15,15,15,15,15};
423 
424  // param 1
425  int j=0;
426  int aa;
427  int aashift=0;
428  for(int i=0; i<6; i++) {
429  j=i+7;
430  if(i==2) {
431  float phase=atof (items [j].c_str());
432  float xphase=(phase+32.0)*4.0; // range of phase [-30.0,30.0]
433  aa=xphase;
434  } else {
435  aa=atoi (items [j].c_str());
436  }
437  if(aa>aamax[i] || aa<0) {
438  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n value for a"<<i<<" should be less than"<<aamax[i]<< std::endl;
439  }
440  param1=param1|aa<<aashift;
441  aashift=aashift+aabits[i];
442  }
443 
444  // param 2
445  int bb;
446  int bbshift=0;
447  for(int i=0; i<10; i++) {
448  j=i+13;
449  bb=atoi (items [j].c_str());
450  if(bb>bbmax[i]) {
451  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n value for b"<<i<<" should be less than"<<bbmax[i]<< std::endl;
452  }
453  param2=param2|bb<<bbshift;
454  bbshift=bbshift+bbbits[i];
455  }
456  } // packing sheme 1.
457 
458  // HcalRecoParam* fCondObject = new HcalRecoParam(id, atoi (items [4].c_str()), atoi (items [5].c_str()) );
459 
460  // std::cout<<" buffer "<<buffer<<std::endl;
461  // std::cout<<" param1, param2 "<<param1<<" "<<param2<<std::endl;
462 
463  HcalRecoParam* fCondObject = new HcalRecoParam(id, param1, param2 );
464  fObject->addValues(*fCondObject);
465  delete fCondObject;
466  }
467  return true;
468 }
469 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalRecoParams& fObject)
470 {
471  char buffer [1024];
472  // sprintf (buffer, "# %15s %15s %15s %15s %18s %15s %10s\n", "eta", "phi", "dep", "det", "firstSample", "samplesToAdd", "DetId");
473  // fOutput << buffer;
474  std::vector<DetId> channels = fObject.getAllChannels ();
475  std::sort (channels.begin(), channels.end(), DetIdLess ());
476  int myCounter=0;
477  for (std::vector<DetId>::iterator channel = channels.begin ();
478  channel != channels.end ();
479  ++channel) {
480  myCounter++;
481  int param1=fObject.getValues (*channel)->param1();
482  int param2=fObject.getValues (*channel)->param2();
483  int packingScheme=fObject.getValues (*channel)->packingScheme();
484 
485  // std::cout<<" Param1 "<<Param1<<" Param2 "<<Param2<<" packing "<<packingScheme<<std::endl;
486 
487  if(packingScheme==0) {
488  // old format
489  if(myCounter==1) {
490  sprintf (buffer, "# %15s %15s %15s %15s %18s %15s %10s\n", "eta", "phi", "dep", "det", "firstSample", "samplesToAdd", "DetId");
491  }
492  HcalDbASCIIIO::dumpId(fOutput, *channel);
493  sprintf (buffer, " %15d %15d %16X\n",
494  fObject.getValues (*channel)->firstSample(), fObject.getValues (*channel)->samplesToAdd(), channel->rawId ());
495  fOutput << buffer;
496  }
497 
498  if(packingScheme==1) {
499 
500  if(myCounter==1) {
501  char lineT[100],lineA[200],lineB[200];
502  //
503  sprintf (lineT, "#%50s"," "); fOutput << lineT;
504  sprintf (lineA, " %31s","a0: correctForPhaseContainment"); fOutput << lineA;
505  sprintf (lineB, " %36s","b0: useLeakCorrection\n"); fOutput << lineB;
506  //
507  sprintf (lineT, "#%50s"," "); fOutput << lineT;
508  sprintf (lineA, " %31s","a1: correctForLeadingEdge"); fOutput << lineA;
509  sprintf (lineB, " %36s","b1: leakCorrectionID\n"); fOutput << lineB;
510  //
511  sprintf (lineT, "#%50s"," "); fOutput << lineT;
512  sprintf (lineA, " %31s","a2: correctionPhaseNS"); fOutput << lineA;
513  sprintf (lineB, " %36s","b2: correctForTimeslew\n"); fOutput << lineB;
514  //
515  sprintf (lineT, "#%50s"," "); fOutput << lineT;
516  sprintf (lineA, " %31s","a3: firstSample"); fOutput << lineA;
517  sprintf (lineB, " %36s","b3: timeslewCorrectionID\n"); fOutput << lineB;
518  //
519  sprintf (lineT, "#%50s"," "); fOutput << lineT;
520  sprintf (lineA, " %31s","a4: samplesToAdd"); fOutput << lineA;
521  sprintf (lineB, " %36s","b4: correctTiming\n"); fOutput << lineB;
522  //
523  sprintf (lineT, "#%50s"," "); fOutput << lineT;
524  sprintf (lineA, " %31s","a5: pulseShapeID"); fOutput << lineA;
525  sprintf (lineB, " %36s","b5: firstAuxTS\n"); fOutput << lineB;
526  //
527  sprintf (lineT, "#%50s"," "); fOutput << lineT;
528  sprintf (lineA, " %31s"," "); fOutput << lineA;
529  sprintf (lineB, " %36s","b6: specialCaseID\n"); fOutput << lineB;
530  //
531  sprintf (lineT, "#%50s"," "); fOutput << lineT;
532  sprintf (lineA, " %31s"," "); fOutput << lineA;
533  sprintf (lineB, " %36s","b7: noiseFlaggingID\n"); fOutput << lineB;
534  //
535  sprintf (lineT, "#%50s"," "); fOutput << lineT;
536  sprintf (lineA, " %31s"," "); fOutput << lineA;
537  sprintf (lineB, " %36s","b8: pileupCleaningID\n"); fOutput << lineB;
538 
539  sprintf (lineT, "#%50s"," "); fOutput << lineT;
540  sprintf (lineA, " %31s"," "); fOutput << lineA;
541  sprintf (lineB, " %36s","b9: packingScheme\n"); fOutput << lineB;
542 
543  //
544  sprintf (lineT, "# %5s %4s %4s %10s %11s %10s %10s", "eta", "phi", "dep", "det", "param1", "param2", "DetId");
545  fOutput << lineT;
546 
547  sprintf (lineA, " %6s %4s %6s %4s %4s %4s", "a0", "a1", "a2", "a3", "a4", "a5");
548  fOutput << lineA;
549 
550  sprintf (lineB, " %6s %3s %3s %3s %3s %3s %3s %3s %3s\n", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8");
551  fOutput << lineB;
552  }
553 
554  HcalDbASCIIIO::dumpIdShort(fOutput, *channel);
555  sprintf (buffer, " %11d %10d %10X", param1, param2, channel->rawId ());
556  fOutput << buffer;
557 
558  bool aa0=fObject.getValues (*channel)->correctForPhaseContainment();
559  bool aa1=fObject.getValues (*channel)->correctForLeadingEdge();
560  float aa2=fObject.getValues (*channel)->correctionPhaseNS();
561  int aa3=fObject.getValues (*channel)->firstSample();
562  int aa4=fObject.getValues (*channel)->samplesToAdd();
563  int aa5=fObject.getValues (*channel)->pulseShapeID();
564  sprintf (buffer, " %6d %4d %6.1f %4d %4d %4d",aa0,aa1,aa2,aa3,aa4,aa5);
565  fOutput << buffer;
566 
567  bool bb0=fObject.getValues (*channel)->useLeakCorrection();
568  int bb1=fObject.getValues (*channel)->leakCorrectionID();
569  bool bb2=fObject.getValues (*channel)->correctForTimeslew();
570  int bb3=fObject.getValues (*channel)->timeslewCorrectionID();
571  bool bb4=fObject.getValues (*channel)->correctTiming();
572  int bb5=fObject.getValues (*channel)->firstAuxTS();
573  int bb6=fObject.getValues (*channel)->specialCaseID();
574  int bb7=fObject.getValues (*channel)->noiseFlaggingID();
575  int bb8=fObject.getValues (*channel)->pileupCleaningID();
576  int bb9=fObject.getValues (*channel)->packingScheme();
577  sprintf(buffer," %6d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",bb0,bb1,bb2,bb3,bb4,bb5,bb6,bb7,bb8,bb9);
578  fOutput << buffer;
579  } // packingScheme 1.
580 
581  } // loop ever channels
582  return true;
583 }
584 
585 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalLongRecoParams* fObject)
586 {
587  if (!fObject) return false; // fObject = new HcalLongRecoParams();
588  char buffer [1024];
589  while (fInput.getline(buffer, 1024)) {
590  if (buffer [0] == '#') continue; //ignore comment
591  std::vector <std::string> items = splitString (std::string (buffer));
592  if (items.size()==0) continue; // blank line
593  if (items.size() < 5) {
594  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs" << std::endl;
595  continue;
596  }
597  if (items.size() > 7) {
598  edm::LogWarning("Format Error") << "Check line: " << buffer << "\n line must contain 6 items: eta, phi, depth, subdet, signalTSs, noiseTSs. "
599  << "\n ! signalTS and noiseTS must be of format <ts1,ts2,ts3,...> withOUT spaces. Ignoring line for safety" << std::endl;
600  continue;
601  }
602  DetId id = HcalDbASCIIIO::getId (items);
603 
604  std::vector<unsigned int> mySignalTS = splitStringToIntByComma(items[4]);
605  std::vector<unsigned int> myNoiseTS = splitStringToIntByComma(items[5]);
606 
607  HcalLongRecoParam* fCondObject = new HcalLongRecoParam(id, mySignalTS, myNoiseTS );
608  fObject->addValues(*fCondObject);
609  delete fCondObject;
610  }
611  return true;
612 }
613 
614 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalTimingParams* fObject)
615 {
616  if (!fObject) return false; // fObject = new HcalTimingParams();
617  char buffer [1024];
618  while (fInput.getline(buffer, 1024)) {
619  if (buffer [0] == '#') continue; //ignore comment
620  std::vector <std::string> items = splitString (std::string (buffer));
621  if (items.size()==0) continue; // blank line
622  if (items.size () < 7) {
623  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 7 items: eta, phi, depth, subdet, nhit, phase, rms,detid" << std::endl;
624  continue;
625  }
626  //std::cout<<"items[3] "<<items [3]<<std::endl;
627  //std::cout<<"items[0] "<<items [0]<<std::endl;
628  //std::cout<<"items[1] "<<items [1]<<std::endl;
629  //std::cout<<"items[2] "<<items [2]<<std::endl;
630 
631  //std::cout<<"items[4] "<<items [4]<<std::endl;
632  //std::cout<<"items[5] "<<items [5]<<std::endl;
633  //std::cout<<"items[6] "<<items [6]<<std::endl;
634  DetId id = HcalDbASCIIIO::getId (items);
635  //std::cout<<"calculated id "<<id.rawId()<<std::endl;
636  HcalTimingParam* fCondObject = new HcalTimingParam(id, atoi (items [4].c_str()), atof (items [5].c_str()), atof (items [6].c_str()));
637  fObject->addValues(*fCondObject);
638  delete fCondObject;
639  }
640  return true;
641 }
642 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalTimingParams& fObject)
643 {
644  char buffer [1024];
645  sprintf (buffer, "# %15s %15s %15s %15s %15s %15s %15s %15s\n", "eta", "phi", "dep", "det", "nhit", "mean","rms" ,"DetId");
646  fOutput << buffer;
647  std::vector<DetId> channels = fObject.getAllChannels ();
648  std::sort (channels.begin(), channels.end(), DetIdLess ());
649  for (std::vector<DetId>::iterator channel = channels.begin ();
650  channel != channels.end ();
651  ++channel) {
652  HcalDbASCIIIO::dumpId (fOutput, *channel);
653  sprintf (buffer, " %15d %8.5f %8.5f %16X\n",
654  fObject.getValues (*channel)->nhits(), fObject.getValues (*channel)->phase(),fObject.getValues(*channel)->rms(),channel->rawId ());
655  fOutput << buffer;
656  }
657  return true;
658 }
659 
660 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalLongRecoParams& fObject)
661 {
662  char buffer [1024];
663  sprintf (buffer, "# %15s %15s %15s %15s %10s %10s %10s\n", "eta", "phi", "dep", "det", "signalTSs", "noiseTSs", "DetId");
664  fOutput << buffer;
665  std::vector<DetId> channels = fObject.getAllChannels ();
666  std::sort (channels.begin(), channels.end(), DetIdLess ());
667  for (std::vector<DetId>::iterator channel = channels.begin ();
668  channel != channels.end ();
669  ++channel) {
670  HcalGenericDetId fId(*channel);
671  if (fId.isHcalZDCDetId())
672  {
673  std::vector<unsigned int> vSignalTS = fObject.getValues (*channel)->signalTS();
674  std::vector<unsigned int> vNoiseTS = fObject.getValues (*channel)->noiseTS();
675  HcalDbASCIIIO::dumpId (fOutput, *channel);
676  sprintf (buffer, " ");
677  fOutput << buffer;
678  for (unsigned int i=0; i<vSignalTS.size(); i++)
679  {
680  if (i>0) {sprintf (buffer, ","); fOutput << buffer;}
681  sprintf (buffer, "%u", vSignalTS.at(i));
682  fOutput << buffer;
683  }
684  sprintf (buffer, " ");
685  fOutput << buffer;
686  for (unsigned int i=0; i<vNoiseTS.size(); i++)
687  {
688  if (i>0) { sprintf (buffer, ","); fOutput << buffer;}
689  sprintf (buffer, "%u", vNoiseTS.at(i));
690  fOutput << buffer;
691  }
692  sprintf (buffer, " %10X\n", channel->rawId ());
693  fOutput << buffer;
694  }
695  }
696  return true;
697 }
698 
699 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalMCParams* fObject)
700 {
701  if (!fObject) return false; // fObject = new HcalMCParams();
702  char buffer [1024];
703  while (fInput.getline(buffer, 1024)) {
704  if (buffer [0] == '#') continue; //ignore comment
705  std::vector <std::string> items = splitString (std::string (buffer));
706  if (items.size()==0) continue; // blank line
707  if (items.size () < 5) {
708  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, signalShape" << std::endl;
709  continue;
710  }
711  DetId id = HcalDbASCIIIO::getId (items);
712 
713  int packingScheme=0;
714  if(items.size ()>11) {
715  packingScheme = atoi (items [11].c_str());
716  }
717 
718  int param1=0;
719  if(packingScheme==0) {
720  param1=atoi (items [4].c_str());
721  }
722 
723  if(packingScheme==1) {
724  int aabits[6]={ 9,1, 4, 8,5, 4}; // 4 spear bits added to aabits[5]
725  int aamax [6]={511,1,15,255,1,16};
726  int j=0;
727  int aa;
728  int aashift=0;
729  for(int i=0; i<6; i++) {
730  j=i+6;
731  if(i==3) {
732  float phase=atof (items [j].c_str());
733  float xphase=(phase+32.0)*4.0; // range of phase [-30.0,30.0]
734  aa=xphase;
735  } else {
736  aa=atoi (items [j].c_str());
737  }
738  if(aa>aamax[i] || aa<0) {
739  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n value for a"<<i<<" should be less than"<<aamax[i]<< std::endl;
740  }
741 
742  param1=param1|aa<<aashift;
743  aashift=aashift+aabits[i];
744  }
745  }
746 
747  HcalMCParam* fCondObject = new HcalMCParam(id, param1 );
748  fObject->addValues(*fCondObject);
749  delete fCondObject;
750  }
751  return true;
752 }
753 
754 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalMCParams& fObject)
755 {
756  char buffer [1024];
757  // sprintf (buffer, "# %15s %15s %15s %15s %14s %10s\n", "eta", "phi", "dep", "det", "signalShape", "DetId");
758  // fOutput << buffer;
759  std::vector<DetId> channels = fObject.getAllChannels ();
760  std::sort (channels.begin(), channels.end(), DetIdLess ());
761  int myCounter=0;
762  for (std::vector<DetId>::iterator channel = channels.begin ();
763  channel != channels.end ();
764  ++channel) {
765  myCounter++;;
766  int packingScheme=fObject.getValues (*channel)->packingScheme();
767  if(packingScheme==0) {
768  if(myCounter==1) {
769  sprintf (buffer, "# %15s %15s %15s %15s %14s %10s\n", "eta", "phi", "dep", "det", "signalShape", "DetId");
770  fOutput << buffer;
771  }
772  const int value = fObject.getValues (*channel)->signalShape();
773  HcalDbASCIIIO::dumpId (fOutput, *channel);
774  sprintf (buffer, " %10d %17X\n", value, channel->rawId ());
775  fOutput << buffer;
776  } // packingScheme 0
777  if(packingScheme==1) {
778  if(myCounter==1) {
779  char lineT[100],lineA[200];
780  //
781  sprintf (lineT, "#%40s"," "); fOutput << lineT;
782  sprintf (lineA, " %31s","a0: signalShape\n"); fOutput << lineA;
783  sprintf (lineT, "#%40s"," "); fOutput << lineT;
784  sprintf (lineA, " %31s","a1: syncPhase\n"); fOutput << lineA;
785  sprintf (lineT, "#%40s"," "); fOutput << lineT;
786  sprintf (lineA, " %31s","a2: binOfMaximum\n"); fOutput << lineA;
787  sprintf (lineT, "#%40s"," "); fOutput << lineT;
788  sprintf (lineA, " %31s","a3: timePhase\n"); fOutput << lineA;
789  sprintf (lineT, "#%40s"," "); fOutput << lineT;
790  sprintf (lineA, " %31s","a4: timeSmearing\n"); fOutput << lineA;
791  sprintf (lineT, "#%40s"," "); fOutput << lineT;
792  sprintf (lineA, " %31s","a5: packingScheme\n"); fOutput << lineA;
793  sprintf (lineT, "# %5s %4s %4s %10s %11s %10s", "eta", "phi", "dep", "det", "param1", "DetId");
794  fOutput << lineT;
795  sprintf (lineA, " %6s %4s %4s %6s %4s %4s\n", "a0", "a1", "a2", "a3", "a4", "a5");
796  fOutput << lineA;
797  }
798  int param1 = fObject.getValues (*channel)->param1();
799  HcalDbASCIIIO::dumpIdShort (fOutput, *channel);
800  sprintf (buffer, " %11d %10X", param1, channel->rawId ());
801  fOutput << buffer;
802  int aa0 = fObject.getValues (*channel)->signalShape();
803  bool aa1 = fObject.getValues (*channel)->syncPhase();
804  int aa2 = fObject.getValues (*channel)->binOfMaximum();
805  float aa3 = fObject.getValues (*channel)->timePhase();
806  bool aa4 = fObject.getValues (*channel)->timeSmearing() ;
807  int aa5 = fObject.getValues (*channel)->packingScheme();
808  sprintf (buffer, "%6d %4d %4d %6.1f %4d %4d\n",aa0,aa1,aa2,aa3,aa4,aa5);
809  fOutput << buffer;
810  }
811  }
812  return true;
813 }
814 
815 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalPedestals* fObject) {
816  char buffer [1024];
817 
818  while (fInput.getline(buffer, 1024)) {
819  std::vector <std::string> items = splitString (std::string (buffer));
820  if (items.size()==0) continue; // blank line
821  else {
822  if (items[0] == "#U")
823  {
824  if (items[1] == (std::string)"ADC") fObject->setUnitADC(true);
825  else if (items[1] == (std::string)"fC") fObject->setUnitADC(false);
826  else
827  {
828  edm::LogWarning("Pedestal Unit Error") << "Unrecognized unit for pedestals. Assuming fC." << std::endl;
829  fObject->setUnitADC(false);
830  }
831  break;
832  }
833  else
834  {
835  edm::LogWarning("Pedestal Unit Missing") << "The unit for the pedestals is missing in the txt file." << std::endl;
836  return false;
837  }
838  }
839  }
840  while (fInput.getline(buffer, 1024)) {
841  if (buffer [0] == '#') continue;
842  std::vector <std::string> items = splitString (std::string (buffer));
843  if (items.size()==0) continue; // blank line
844  if (items.size () < 8) {
845  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
846  << " or 12 items: eta, phi, depth, subdet, 4x values for mean, 4x values for width"
847  << std::endl;
848  continue;
849  }
850  DetId id = getId (items);
851 
852 // if (fObject->exists(id) )
853 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
854 // else
855 // {
856 
857  if (items.size() < 12) // old format without widths
858  {
859  HcalPedestal* fCondObject = new HcalPedestal(id, atof (items [4].c_str()), atof (items [5].c_str()),
860  atof (items [6].c_str()), atof (items [7].c_str()),
861  0., 0., 0., 0. );
862  fObject->addValues(*fCondObject);
863  delete fCondObject;
864  }
865  else // new format with widths
866  {
867  HcalPedestal* fCondObject = new HcalPedestal(id, atof (items [4].c_str()), atof (items [5].c_str()),
868  atof (items [6].c_str()), atof (items [7].c_str()),
869  atof (items [8].c_str()), atof (items [9].c_str()),
870  atof (items [10].c_str()), atof (items [11].c_str()) );
871  fObject->addValues(*fCondObject);
872  delete fCondObject;
873  }
874 
875  // }
876  }
877  return true;
878 }
879 
880 
881 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalPedestals& fObject) {
882  char buffer [1024];
883  if (fObject.isADC() ) sprintf (buffer, "#U ADC << this is the unit \n");
884  else sprintf (buffer, "#U fC << this is the unit \n");
885  fOutput << buffer;
886 
887  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n", "eta", "phi", "dep", "det", "cap0", "cap1", "cap2", "cap3", "widthcap0", "widthcap1", "widthcap2", "widthcap3", "DetId");
888  fOutput << buffer;
889 
890  std::vector<DetId> channels = fObject.getAllChannels ();
891  std::sort (channels.begin(), channels.end(), DetIdLess ());
892  for (std::vector<DetId>::iterator channel = channels.begin ();
893  channel != channels.end ();
894  ++channel) {
895  const float* values = fObject.getValues (*channel)->getValues ();
896  if (values) {
897  dumpId (fOutput, *channel);
898  sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
899  values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], channel->rawId ());
900  fOutput << buffer;
901  }
902  }
903  return true;
904 }
905 
906 
907 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
908 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalChannelQuality* fObject)
909 {
910  if (!fObject) return false; //fObject = new HcalChannelQuality;
911  char buffer [1024];
912  while (fInput.getline(buffer, 1024)) {
913  if (buffer [0] == '#') continue; //ignore comment
914  std::vector <std::string> items = splitString (std::string (buffer));
915  if (items.size()==0) continue; // blank line
916  if (items.size () < 6) {
917  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 6 items: eta, phi, depth, subdet, base - either (hex) or (dec), value" << std::endl;
918  continue;
919  }
920  DetId id = getId (items);
921 
922 // if (fObject->exists(id) )
923 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
924 // else
925 // {
926  uint32_t mystatus;
927  if (items[4] == "(hex)")
928  sscanf(items[5].c_str(),"%X", &mystatus);
929  else if (items[4] == "(dec)")
930  sscanf(items[5].c_str(),"%u", &mystatus);
931  else
932  {
933  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n value field must contain the base: one of (hex), (dec)" << std::endl;
934  continue;
935  }
936 
937  HcalChannelStatus* fCondObject = new HcalChannelStatus(id, mystatus); //atoi (items [4].c_str()) );
938  fObject->addValues(*fCondObject);
939  delete fCondObject;
940  // }
941  }
942  return true;
943 }
944 
945 
946 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalChannelQuality& fObject) {
947  char buffer [1024];
948  sprintf (buffer, "# %15s %15s %15s %15s %15s %10s\n", "eta", "phi", "dep", "det", "(base) value", "DetId");
949  fOutput << buffer;
950  std::vector<DetId> channels = fObject.getAllChannels ();
951  std::sort (channels.begin(), channels.end(), DetIdLess ());
952  for (std::vector<DetId>::iterator channel = channels.begin ();
953  channel != channels.end ();
954  ++channel) {
955  const int value = fObject.getValues (*channel)->getValue ();
956  dumpId (fOutput, *channel);
957  sprintf (buffer, "%6s %15X %10X\n", "(hex)",
958  value, channel->rawId ());
959  fOutput << buffer;
960  }
961  return true;
962 }
963 
964 
965 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
966 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalL1TriggerObjects* fObject)
967 {
968  char buffer [1024];
969 
970  while (fInput.getline(buffer, 1024)) {
971  if (buffer [0] == '#')
972  {
973  if (buffer [1] == 'T') // contains tag name
974  {
975  std::vector <std::string> items = splitString (std::string (buffer) );
976  fObject->setTagString(items[1]);
977  continue;
978  }
979  if (buffer [1] == 'A') // contains algo name
980  {
981  std::vector <std::string> items = splitString (std::string (buffer) );
982  fObject->setAlgoString(items[1]);
983  continue;
984  }
985  else continue; //ignore comment
986  }
987  std::vector <std::string> items = splitString (std::string (buffer));
988  if (items.size()==0) continue; // blank line
989  if (items.size () < 7) {
990  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 7 items: eta, phi, depth, subdet, pedestal, resp.corr.gain, flag" << std::endl;
991  continue;
992  }
993  DetId id = getId (items);
994 
995  HcalL1TriggerObject* fCondObject = new HcalL1TriggerObject(id, atof(items[4].c_str()), atof(items[5].c_str()), atoi(items[6].c_str()) );
996 
997  fObject->addValues(*fCondObject);
998  delete fCondObject;
999  }
1000  return true;
1001 }
1002 
1003 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalL1TriggerObjects& fObject)
1004 {
1005  char buffer [1024];
1006  //first print tag and algo
1007  sprintf (buffer, "#T %s << this is the tag name \n", fObject.getTagString().c_str() );
1008  fOutput << buffer;
1009  sprintf (buffer, "#A %s << this is the algorithm name \n", fObject.getAlgoString().c_str() );
1010  fOutput << buffer;
1011 
1012  //then the values
1013  sprintf (buffer, "# %15s %15s %15s %15s %8s %13s %8s %10s\n",
1014  "eta", "phi", "dep", "det", "ped", "respcorrgain", "flag",
1015  "DetId");
1016  fOutput << buffer;
1017  std::vector<DetId> channels = fObject.getAllChannels ();
1018  // std::sort (channels.begin(), channels.end(), DetIdLess ());
1019  for (std::vector<DetId>::iterator channel = channels.begin ();
1020  channel != channels.end ();
1021  ++channel) {
1022  const HcalL1TriggerObject* item = fObject.getValues (*channel);
1023  if (item) {
1024  dumpId (fOutput, *channel);
1025  sprintf (buffer, " %10.7f %10.7f %12d %10X\n",
1026  item->getPedestal(), item->getRespGain(), item->getFlag(), channel->rawId ());
1027  fOutput << buffer;
1028  }
1029  }
1030  return true;
1031 
1032 }
1033 
1034 
1035 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1036 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalPedestalWidths* fObject) {
1037  char buffer [1024];
1038  int linecounter = 0;
1039 
1040  while (fInput.getline(buffer, 1024)) {
1041  linecounter++;
1042  std::vector <std::string> items = splitString (std::string (buffer));
1043  if (items.size()==0) continue; // blank line
1044  else {
1045  if (items[0] == (std::string)"#U")
1046  {
1047  if (items[1] == (std::string)"ADC") fObject->setUnitADC(true);
1048  else if (items[1] == (std::string)"fC") fObject->setUnitADC(false);
1049  else
1050  {
1051  edm::LogWarning("Pedestal Width Unit Error") << "Unrecognized unit for pedestal widths. Assuming fC." << std::endl;
1052  fObject->setUnitADC(false);
1053  }
1054  break;
1055  }
1056  else
1057  {
1058  edm::LogWarning("Pedestal Width Unit Missing") << "The unit for the pedestal widths is missing in the txt file." << std::endl;
1059  return false;
1060  }
1061  }
1062  }
1063 
1064  while (fInput.getline(buffer, 1024)) {
1065  linecounter++;
1066  if (buffer [0] == '#') continue; //ignore comment
1067  std::vector <std::string> items = splitString (std::string (buffer));
1068  if (items.size()==0) continue; // blank line
1069  if (items.size () < 14) {
1070  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line number: " << linecounter << "\n line must contain 14 items: eta, phi, depth, subdet, 10x correlations"
1071  << " or 20 items: eta, phi, depth, subdet, 16x correlations"
1072  << std::endl;
1073  continue;
1074  }
1075  DetId id = getId (items);
1076 
1077 // if (fObject->exists(id) )
1078 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
1079 // else
1080 // {
1081 
1082  if (items.size() < 20) //old format
1083  {
1085  values.setSigma (0, 0, atof (items [4].c_str()));
1086  values.setSigma (1, 0, atof (items [5].c_str()));
1087  values.setSigma (1, 1, atof (items [6].c_str()));
1088  values.setSigma (2, 0, atof (items [7].c_str()));
1089  values.setSigma (2, 1, atof (items [8].c_str()));
1090  values.setSigma (2, 2, atof (items [9].c_str()));
1091  values.setSigma (3, 0, atof (items [10].c_str()));
1092  values.setSigma (3, 1, atof (items [11].c_str()));
1093  values.setSigma (3, 2, atof (items [12].c_str()));
1094  values.setSigma (3, 3, atof (items [13].c_str()));
1095  values.setSigma (0, 1, 0.);
1096  values.setSigma (0, 2, 0.);
1097  values.setSigma (0, 3, 0.);
1098  values.setSigma (1, 2, 0.);
1099  values.setSigma (1, 3, 0.);
1100  values.setSigma (2, 3, 0.);
1101  fObject->addValues(values);
1102  }
1103  else // new format
1104  {
1106  values.setSigma (0, 0, atof (items [4].c_str()) );
1107  values.setSigma (0, 1, atof (items [5].c_str()) );
1108  values.setSigma (0, 2, atof (items [6].c_str()) );
1109  values.setSigma (0, 3, atof (items [7].c_str()) );
1110  values.setSigma (1, 0, atof (items [8].c_str()) );
1111  values.setSigma (1, 1, atof (items [9].c_str()) );
1112  values.setSigma (1, 2, atof (items [10].c_str()) );
1113  values.setSigma (1, 3, atof (items [11].c_str()) );
1114  values.setSigma (2, 0, atof (items [12].c_str()) );
1115  values.setSigma (2, 1, atof (items [13].c_str()) );
1116  values.setSigma (2, 2, atof (items [14].c_str()) );
1117  values.setSigma (2, 3, atof (items [15].c_str()) );
1118  values.setSigma (3, 0, atof (items [16].c_str()) );
1119  values.setSigma (3, 1, atof (items [17].c_str()) );
1120  values.setSigma (3, 2, atof (items [18].c_str()) );
1121  values.setSigma (3, 3, atof (items [19].c_str()) );
1122  fObject->addValues(values);
1123  }
1124 
1125  // }
1126  }
1127  return true;
1128 }
1129 
1130 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalPedestalWidths& fObject) {
1131  char buffer [1024];
1132  if (fObject.isADC() ) sprintf (buffer, "#U ADC << this is the unit \n");
1133  else sprintf (buffer, "#U fC << this is the unit \n");
1134  fOutput << buffer;
1135 
1136  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
1137  "eta", "phi", "dep", "det",
1138  "cov_0_0", "cov_0_1", "cov_0_2", "cov_0_3", "cov_1_0", "cov_1_1", "cov_1_2", "cov_1_3", "cov_2_0", "cov_2_1", "cov_2_2", "cov_2_3", "cov_3_0", "cov_3_1", "cov_3_2", "cov_3_3",
1139  "DetId");
1140  fOutput << buffer;
1141  std::vector<DetId> channels = fObject.getAllChannels ();
1142  std::sort (channels.begin(), channels.end(), DetIdLess ());
1143  for (std::vector<DetId>::iterator channel = channels.begin ();
1144  channel != channels.end ();
1145  ++channel) {
1146  const HcalPedestalWidth* item = fObject.getValues (*channel);
1147  if (item) {
1148  dumpId (fOutput, *channel);
1149  sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
1150  item->getSigma (0,0), item->getSigma (0,1), item->getSigma (0,2), item->getSigma (0,3),
1151  item->getSigma (1,0), item->getSigma (1,1), item->getSigma (1,2), item->getSigma (1,3),
1152  item->getSigma (2,0), item->getSigma (2,1), item->getSigma (2,2), item->getSigma (2,3),
1153  item->getSigma (3,0), item->getSigma (3,1), item->getSigma (3,2), item->getSigma (3,3), channel->rawId ());
1154  fOutput << buffer;
1155  }
1156  }
1157  return true;
1158 }
1159 
1160 
1161 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1162 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalQIEData* fObject) {
1163  char buffer [1024];
1164  while (fInput.getline(buffer, 1024)) {
1165  if (buffer [0] == '#') continue; //ignore comment
1166  std::vector <std::string> items = splitString (std::string (buffer));
1167  if (items.size()<1) continue;
1168  if (items [0] == "SHAPE") { // basic shape
1169  //this shape keyword is obsolete
1170  }
1171  else { // QIE parameters
1172  if (items.size () < 36) {
1173  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 36 items: eta, phi, depth, subdet, 4 capId x 4 Ranges x offsets, 4 capId x 4 Ranges x slopes" << std::endl;
1174  continue;
1175  }
1176  DetId id = getId (items);
1177  fObject->sort ();
1178  // try {
1179  // fObject->getCoder (id);
1180  // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
1181  // }
1182 // catch (cms::Exception& e) {
1183  HcalQIECoder coder (id.rawId ());
1184  int index = 4;
1185  for (unsigned capid = 0; capid < 4; capid++) {
1186  for (unsigned range = 0; range < 4; range++) {
1187  coder.setOffset (capid, range, atof (items [index++].c_str ()));
1188  }
1189  }
1190  for (unsigned capid = 0; capid < 4; capid++) {
1191  for (unsigned range = 0; range < 4; range++) {
1192  coder.setSlope (capid, range, atof (items [index++].c_str ()));
1193  }
1194  }
1195 
1196  fObject->addCoder (coder);
1197 // }
1198  }
1199  }
1200  fObject->sort ();
1201  return true;
1202 }
1203 
1204 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalQIEData& fObject) {
1205 
1206  char buffer [1024];
1207 
1208  fOutput << "# QIE data" << std::endl;
1209  sprintf (buffer, "# %15s %15s %15s %15s %36s %36s %36s %36s %36s %36s %36s %36s\n",
1210  "eta", "phi", "dep", "det",
1211  "4 x offsets cap0", "4 x offsets cap1", "4 x offsets cap2", "4 x offsets cap3",
1212  "4 x slopes cap0", "4 x slopes cap1", "4 x slopes cap2", "4 x slopes cap3");
1213  fOutput << buffer;
1214  std::vector<DetId> channels = fObject.getAllChannels ();
1215  std::sort (channels.begin(), channels.end(), DetIdLess ());
1216  for (std::vector<DetId>::iterator channel = channels.begin ();
1217  channel != channels.end ();
1218  ++channel) {
1219  const HcalQIECoder* coder = fObject.getCoder (*channel);
1220  dumpId (fOutput, *channel);
1221  for (unsigned capid = 0; capid < 4; capid++) {
1222  for (unsigned range = 0; range < 4; range++) {
1223  sprintf (buffer, " %8.5f", coder->offset (capid, range));
1224  fOutput << buffer;
1225  }
1226  }
1227  for (unsigned capid = 0; capid < 4; capid++) {
1228  for (unsigned range = 0; range < 4; range++) {
1229  sprintf (buffer, " %8.5f", coder->slope (capid, range));
1230  fOutput << buffer;
1231  }
1232  }
1233  fOutput << std::endl;
1234  }
1235  return true;
1236 }
1237 
1238 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1239 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalCalibrationQIEData* fObject) {
1240  char buffer [1024];
1241  while (fInput.getline(buffer, 1024)) {
1242  if (buffer [0] == '#') continue; //ignore comment
1243  std::vector <std::string> items = splitString (std::string (buffer));
1244  if (items.size () < 36) {
1245  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 36 items: eta, phi, depth, subdet, 32 bin values" << std::endl;
1246  continue;
1247  }
1248  DetId id = getId (items);
1249  fObject->sort ();
1250  // try {
1251  // fObject->getCoder (id);
1252  // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
1253  // }
1254 // catch (cms::Exception& e) {
1255  HcalCalibrationQIECoder coder (id.rawId ());
1256  int index = 4;
1257  float values [32];
1258  for (unsigned bin = 0; bin < 32; bin++) {
1259  values[bin] = atof (items [index++].c_str ());
1260  }
1261  coder.setMinCharges (values);
1262  fObject->addCoder (coder);
1263 // }
1264  }
1265  fObject->sort ();
1266  return true;
1267 }
1268 
1269 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalCalibrationQIEData& fObject) {
1270  char buffer [1024];
1271  fOutput << "# QIE data in calibration mode" << std::endl;
1272  sprintf (buffer, "# %15s %15s %15s %15s %288s\n",
1273  "eta", "phi", "dep", "det", "32 x charges");
1274  fOutput << buffer;
1275  std::vector<DetId> channels = fObject.getAllChannels ();
1276  std::sort (channels.begin(), channels.end(), DetIdLess ());
1277  for (std::vector<DetId>::iterator channel = channels.begin ();
1278  channel != channels.end ();
1279  ++channel) {
1280  const HcalCalibrationQIECoder* coder = fObject.getCoder (*channel);
1281  if (coder) {
1282  dumpId (fOutput, *channel);
1283  const float* lowEdge = coder->minCharges ();
1284  for (unsigned bin = 0; bin < 32; bin++) {
1285  sprintf (buffer, " %8.5f", lowEdge [bin]);
1286  fOutput << buffer;
1287  }
1288  fOutput << std::endl;
1289  }
1290  }
1291  return true;
1292 }
1293 
1294 
1295 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1296 namespace HcalDbASCIIIO {
1297 template<> std::unique_ptr<HcalElectronicsMap> createObject<HcalElectronicsMap>(std::istream& fInput) {
1298  HcalElectronicsMapAddons::Helper fObjectHelper;
1299  char buffer [1024];
1300  while (fInput.getline(buffer, 1024)) {
1301  if (buffer [0] == '#') continue; //ignore comment
1302  std::vector <std::string> items = splitString (std::string (buffer));
1303  if (items.size () < 12) {
1304  if (items.size()==0) continue; // no warning here
1305  if (items.size()<9) {
1306  edm::LogError("MapFormat") << "HcalElectronicsMap-> line too short: " << buffer;
1307  continue;
1308  }
1309  if (items[8]=="NA" || items[8]=="NT") {
1310  while (items.size()<12) items.push_back(""); // don't worry here
1311  } else if (items[8]=="HT") {
1312  if (items.size()==11) items.push_back("");
1313  else {
1314  edm::LogError("MapFormat") << "HcalElectronicsMap-> Bad line: " << buffer
1315  << "\n HT line must contain at least 11 items: i cr sl tb dcc spigot fiber fiberchan subdet=HT ieta iphi";
1316  continue;
1317  }
1318  } else {
1319  edm::LogError("MapFormat") << "HcalElectronicsMap-> Bad line: " << buffer
1320  << "\n line must contain 12 items: i cr sl tb dcc spigot fiber fiberchan subdet ieta iphi depth";
1321  continue;
1322  }
1323  }
1324  int crate = atoi (items [1].c_str());
1325  int slot = atoi (items [2].c_str());
1326  int top = 1;
1327  if (items [3] == "b") top = 0;
1328  int dcc = atoi (items [4].c_str());
1329  int spigot = atoi (items [5].c_str());
1330  HcalElectronicsId elId;
1331  if (items[3][0] == 'u') { // uTCA!
1332  int fiber = atoi (items [6].c_str());
1333  int fiberCh = atoi (items [7].c_str());
1334  bool isTrig=(items[8] == "HT" || items[8] == "NT");
1335  elId=HcalElectronicsId(crate, slot, fiber, fiberCh,isTrig);
1336  } else if (items[8] == "HT" || items[8] == "NT") {
1337  int slb = atoi (items [6].c_str());
1338  int slbCh = atoi (items [7].c_str());
1339  elId=HcalElectronicsId(slbCh, slb, spigot, dcc,crate,slot,top);
1340  } else {
1341  int fiber = atoi (items [6].c_str());
1342  int fiberCh = atoi (items [7].c_str());
1343 
1344  elId=HcalElectronicsId(fiberCh, fiber, spigot, dcc);
1345  elId.setHTR (crate, slot, top);
1346  }
1347 
1348  // first, handle undefined cases
1349  if (items [8] == "NA") { // undefined channel
1350  fObjectHelper.mapEId2chId (elId, DetId (HcalDetId::Undefined));
1351  } else if (items [8] == "NT") { // undefined trigger channel
1352  fObjectHelper.mapEId2tId (elId, DetId (HcalTrigTowerDetId::Undefined));
1353  } else {
1354  HcalText2DetIdConverter converter (items [8], items [9], items [10], items [11]);
1355  if (converter.isHcalDetId() or converter.isHcalCalibDetId() or converter.isHcalZDCDetId()) {
1356  fObjectHelper.mapEId2chId (elId, converter.getId ());
1357  }
1358  else if (converter.isHcalTrigTowerDetId ()) {
1359  fObjectHelper.mapEId2tId (elId, converter.getId ());
1360  }
1361  else {
1362  edm::LogWarning("Format Error") << "HcalElectronicsMap-> Unknown subdetector: "
1363  << items [8] << '/' << items [9] << '/' << items [10] << '/' << items [11] << std::endl;
1364  }
1365  }
1366  }
1367  auto fObject = std::make_unique<HcalElectronicsMap>(fObjectHelper);
1368  return fObject;
1369 }
1370 }
1371 
1372 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalElectronicsMap& fObject) {
1373  std::vector<HcalElectronicsId> eids = fObject.allElectronicsId ();
1374  char buf [1024];
1375  // changes by Jared, 6.03.09/(included 25.03.09)
1376  // sprintf (buf, "#%10s %6s %6s %6s %6s %6s %6s %6s %15s %15s %15s %15s",
1377  sprintf (buf, "# %7s %3s %3s %3s %4s %7s %10s %14s %7s %5s %5s %6s",
1378  "i", "cr", "sl", "tb", "dcc", "spigot", "fiber/slb", "fibcha/slbcha", "subdet", "ieta", "iphi", "depth");
1379  fOutput << buf << std::endl;
1380 
1381  for (unsigned i = 0; i < eids.size (); i++) {
1382  HcalElectronicsId eid = eids[i];
1383  if (eid.isTriggerChainId()) {
1384  DetId trigger = fObject.lookupTrigger (eid);
1385  if (trigger.rawId ()) {
1387  if( eid.isVMEid() ){
1388  // changes by Jared, 6.03.09/(included 25.03.09)
1389  // sprintf (buf, " %10X %6d %6d %6c %6d %6d %6d %6d %15s %15s %15s %15s",
1390  sprintf (buf, " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1391  // i,
1392  converter.getId().rawId(),
1393  // changes by Jared, 6.03.09/(included 25.03.09)
1394  // eid.readoutVMECrateId(), eid.htrSlot(), eid.htrTopBottom()>0?'t':'b', eid.dccid(), eid.spigot(), eid.fiberIndex(), eid.fiberChanId(),
1395  eid.readoutVMECrateId(), eid.htrSlot(), eid.htrTopBottom()>0?'t':'b', eid.dccid(), eid.spigot(), eid.slbSiteNumber(), eid.slbChannelIndex(),
1396  converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1397  );
1398  fOutput << buf << std::endl;
1399  }else if( eid.isUTCAid() ){
1400  sprintf (buf, " %7X %3d %3d u %4d %7d %10d %14d %7s %5s %5s %6s",
1401  converter.getId().rawId(),
1402 // eid.crateId(), eid.slot(), 0, eid.spigot(), eid.fiberIndex(), eid.fiberChanId(),
1403  eid.crateId(), eid.slot(), 0, 0, eid.fiberIndex(), eid.fiberChanId(),
1404  converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1405  );
1406  fOutput << buf << std::endl;
1407  }else{
1408  sprintf (buf, "NOT SUPPORTED!");
1409  fOutput << buf << std::endl;
1410  }
1411  }
1412  } else {
1413  DetId channel = fObject.lookup (eid);
1414  if (channel.rawId()) {
1416  if (eid.isVMEid()) {
1417  // changes by Jared, 6.03.09/(included 25.03.09)
1418  // sprintf (buf, " %10X %6d %6d %6c %6d %6d %6d %6d %15s %15s %15s %15s",
1419  sprintf (buf, " %7X %3d %3d %3c %4d %7d %10d %14d %7s %5s %5s %6s",
1420  // i,
1421  converter.getId().rawId(),
1422  eid.readoutVMECrateId(), eid.htrSlot(), eid.htrTopBottom()>0?'t':'b', eid.dccid(), eid.spigot(), eid.fiberIndex(), eid.fiberChanId(),
1423  converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1424  );
1425  } else {
1426  sprintf (buf, " %7X %3d %3d u %4d %7d %10d %14d %7s %5s %5s %6s",
1427  // i,
1428  converter.getId().rawId(),
1429 // eid.crateId(), eid.slot(), 0, eid.slot(), eid.fiberIndex(), eid.fiberChanId(),
1430  eid.crateId(), eid.slot(), 0, 0, eid.fiberIndex(), eid.fiberChanId(),
1431  converter.getFlavor ().c_str (), converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str ()
1432  );
1433  }
1434  fOutput << buf << std::endl;
1435  }
1436  }
1437  }
1438  return true;
1439 }
1440 
1441 
1442 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalLutMetadata* fObject){
1443  if (!fObject) return false; //fObject = new HcalLutMetadata;
1444  char buffer [1024];
1445  while (fInput.getline(buffer, 1024)) {
1446  if (buffer [0] == '#') continue; //ignore comment
1447  std::vector <std::string> items = splitString (std::string (buffer));
1448  if (items.size()==0) continue; // blank line
1449  // now get non-channel data
1450  if (items.size() > 1 &&
1451  items[0].find("RctLsb")!=std::string::npos){
1452  fObject->setRctLsb( atof( items[1].c_str() ) );
1453  continue;
1454  }
1455  if (items.size() > 1 &&
1456  items[0].find("Gain")!=std::string::npos){
1457  fObject->setNominalGain( atof( items[1].c_str() ) );
1458  continue;
1459  }
1460  // now proceeed to per-channel data
1461  if (items.size () < 7) {
1462  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 7 items: eta, phi, depth, subdet, Rcalib, LutGranularity, OutputLutThreshold" << std::endl;
1463  continue;
1464  }
1465  DetId id = getId (items);
1466 
1467  HcalLutMetadatum * fCondObject = new HcalLutMetadatum(id,
1468  atof (items [4].c_str()),
1469  atoi (items [5].c_str()),
1470  atoi (items [6].c_str()));
1471  fObject->addValues(*fCondObject);
1472  delete fCondObject;
1473  }
1474  return true;
1475 }
1476 
1477 
1478 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalLutMetadata& fObject){
1479  char buffer [1024];
1480  const float _rctLsb = fObject.getRctLsb();
1481  const float _gain = fObject.getNominalGain();
1482  sprintf (buffer, "# %20s\n", "Non-channel data");
1483  fOutput << buffer;
1484  sprintf (buffer, "%8s %8.5f\n", "RctLsb", _rctLsb);
1485  fOutput << buffer;
1486  sprintf (buffer, "%8s %8.5f\n", "Gain", _gain);
1487  fOutput << buffer;
1488  sprintf (buffer, "# %15s %15s %15s %15s %8s %15s %19s %10s\n", "eta", "phi", "dep", "det", "Rcalib", "LutGranularity", "OutputLutThreshold", "DetId");
1489  fOutput << buffer;
1490  std::vector<DetId> channels = fObject.getAllChannels ();
1491  std::sort (channels.begin(), channels.end(), DetIdLess ());
1492  for (std::vector<DetId>::iterator channel = channels.begin ();
1493  channel != channels.end ();
1494  ++channel) {
1495  const float _rCalib = fObject.getValues (*channel)->getRCalib();
1496  const uint8_t _lutGranularity = fObject.getValues (*channel)->getLutGranularity();
1497  const uint8_t _outputLutThreshold = fObject.getValues (*channel)->getOutputLutThreshold();
1498  dumpId (fOutput, *channel);
1499  sprintf (buffer, " %8.5f %15d %19d %10X\n",
1500  _rCalib,
1501  _lutGranularity,
1502  _outputLutThreshold,
1503  channel->rawId ());
1504  fOutput << buffer;
1505  }
1506  return true;
1507 }
1508 
1509 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1510 bool HcalDbASCIIIO::getObject(std::istream& fInput, HcalDcsValues * fObject) {
1511  if (!fObject) return false; //fObject = new HcalDcsValues;
1513  while (getline(fInput, buffer)) {
1514  if (buffer.at(0) == '#') continue; //ignore comment
1515  std::vector <std::string> items = splitString (buffer);
1516  if (items.size()==0) continue; // blank line
1517 
1518  if (items.size() < 9) {
1519  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 9 items: subDet, side_ring, slice, type, subChannel, LS, Value, UpperLimit, LowerLimit" << std::endl;
1520  continue;
1521  }
1522 
1523  HcalOtherSubdetector subd;
1524  int sidering;
1525  unsigned int slice, subchan;
1526  switch (items[0].at(1)) {
1527  case 'B':
1528  subd = HcalDcsBarrel;
1529  break;
1530  case 'E':
1531  subd = HcalDcsEndcap;
1532  break;
1533  case 'F':
1534  subd = HcalDcsForward;
1535  break;
1536  case 'O':
1537  subd = HcalDcsOuter;
1538  break;
1539  default:
1540  continue;
1541  }
1542  //from_string<int>(subd, items[0], std::dec);
1543  from_string<int>(sidering, items[1], std::dec);
1544  from_string<unsigned int>(slice, items[2], std::dec);
1545  //from_string<int>(ty, items[3], std::dec);
1546  from_string<unsigned int>(subchan, items[4], std::dec);
1547 
1548  HcalDcsDetId newId(subd, sidering, slice,
1549  HcalDcsDetId::DcsTypeFromString(items[3]), subchan);
1550 
1551  int LS;
1552  float val,upper,lower;
1553  from_string<int>(LS, items[5], std::dec);
1554  from_string<float>(val, items[6], std::dec);
1555  from_string<float>(upper, items[7], std::dec);
1556  from_string<float>(lower, items[8], std::dec);
1557 
1558  HcalDcsValue newVal(newId.rawId(),LS,val,upper,lower);
1559 // std::cout << buffer << '\n';
1560 // std::cout << subd << ' ' << sidering << ' ' << slice << ' '
1561 // << ty << ' ' << subchan << ' ' << LS << ' '
1562 // << val << ' ' << upper << ' ' << lower << '\n';
1563 // std::cout << newId ;
1564  if (!(fObject->addValue(newVal))) {
1565  edm::LogWarning("Data Error") << "Data from line " << buffer
1566  << "\nwas not added to the HcalDcsValues object." << std::endl;
1567  }
1568 // std::cout << std::endl;
1569  }
1570  fObject->sortAll();
1571  return true;
1572 }
1573 
1574 bool HcalDbASCIIIO::dumpObject(std::ostream& fOutput,
1575  HcalDcsValues const& fObject) {
1576  fOutput << "# subDet side_ring slice type subChan LS Value UpperLimit LowerLimit DcsId\n";
1577  for(int subd = HcalDcsValues::HcalHB;
1578  subd <= HcalDcsValues::HcalHF; ++subd) {
1579 // std::cout << "subd: " << subd << '\n';
1580  HcalDcsValues::DcsSet const & vals=
1582  for (HcalDcsValues::DcsSet::const_iterator val = vals.begin();
1583  val != vals.end(); ++val) {
1584  HcalDcsDetId valId(val->DcsId());
1585 
1586  switch (valId.subdet()) {
1587  case HcalDcsBarrel:
1588  fOutput << "HB ";
1589  break;
1590  case HcalDcsEndcap:
1591  fOutput << "HE ";
1592  break;
1593  case HcalDcsOuter:
1594  fOutput << "HO ";
1595  break;
1596  case HcalDcsForward:
1597  fOutput << "HF ";
1598  break;
1599  default :
1600  fOutput << valId.subdet() << ' ';
1601  }
1602 
1603  if (valId.subdet() == HcalDcsOuter)
1604  fOutput << valId.ring() << ' ';
1605  else
1606  fOutput << valId.zside() << ' ';
1607 
1608  fOutput << valId.slice() << ' '
1609  << valId.typeString(valId.type()) << ' '
1610  << valId.subchannel() << ' ';
1611  fOutput << val->LS() << ' '
1612  << val->getValue() << ' '
1613  << val->getUpperLimit() << ' '
1614  << val->getLowerLimit() << ' ';
1615  fOutput << std::hex << val->DcsId() << std::dec << '\n';
1616 
1617 // std::cout << valId << ' '
1618 // << valId.subdet() << ' '
1619 // << val->LS() << ' ' << val->getValue() << ' '
1620 // << val->getUpperLimit() << ' ' << val->getLowerLimit()
1621 // << std::endl;
1622  }
1623  }
1624 
1625  return true;
1626 }
1627 
1628 
1629 // Format of the ASCII file:
1630 // line# Ring Slice Subchannel Subdetector Eta Phi Depth
1631 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1632 namespace HcalDbASCIIIO {
1633 template <> std::unique_ptr<HcalDcsMap> createObject<HcalDcsMap>(std::istream& fInput) {
1634  char buffer [1024];
1635  HcalDcsMapAddons::Helper fObjectHelper;
1636  while (fInput.getline(buffer, 1024)) {
1637  if (buffer [0] == '#') continue; //ignore comment
1638  std::vector <std::string> items = splitString (std::string (buffer));
1639  if (items.size () < 8) {
1640  if (items.size()==0) continue; // no warning here
1641  else {
1642  edm::LogError("MapFormat") << "HcalDcsMap-> Bad line: " << buffer
1643  << "\n line must contain 8 items: line side_ring slice subchannel subdet ieta iphi depth";
1644  continue;
1645  }
1646  }
1647  int ring = atoi(items[1].c_str());
1648  unsigned int slice = atoi (items [2].c_str());
1649  unsigned int subchannel = atoi (items [3].c_str());
1652  if (items[4].find("CALIB")!=std::string::npos){
1653  subdet = HcalCalibration;
1654  }
1655  else if (items[4].find("HB")!=std::string::npos){
1656  subdet = HcalDcsBarrel;
1657  }
1658  else if (items[4].find("HE")!=std::string::npos){
1659  subdet = HcalDcsEndcap;
1660  }
1661  else if (items[4].find("HO")!=std::string::npos){
1662  subdet = HcalDcsOuter;
1663  }
1664  else if (items[4].find("HF")!=std::string::npos){
1665  subdet = HcalDcsForward;
1666  }
1667  else{
1668  edm::LogError("MapFormat") << "HcalDcsMap-> Unknown subdetector, line is not accepted: " << items[5];
1669  continue;
1670  }
1671  HcalDcsDetId dcsId(subdet, ring, slice, type, subchannel);
1672  HcalText2DetIdConverter converter (items [4], items [5], items [6], items [7]);
1673  HcalDetId id(0);
1674  if (converter.isHcalDetId()){
1675  id = converter.getId();
1676  }
1677  else{
1678  edm::LogWarning("Invalid HCAL channel") << "HcalDcsMap-> invalid channel: "
1679  << items [4] << '/'
1680  << items [5] << '/'
1681  << items [6] << '/'
1682  << items [7] << std::endl;
1683  continue;
1684  }
1685  fObjectHelper.mapGeomId2DcsId(id, dcsId);
1686  }
1687  auto fObject = std::make_unique<HcalDcsMap>(fObjectHelper);
1688  return fObject;
1689 }
1690 }
1691 
1692 // Format of the ASCII file:
1693 // line# Ring Slice Subchannel Subdetector Eta Phi Depth
1694 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1695 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalDcsMap& fObject) {
1696  char buf [1024];
1697  sprintf (buf, "# %7s %10s %6s %8s %7s %5s %5s %6s",
1698  "i", "side_ring", "slice", "subchan", "subdet", "ieta", "iphi", "depth");
1699  fOutput << buf << std::endl;
1701  unsigned int line_counter = 0;
1702  for (_line = fObject.beginById();
1703  _line != fObject.endById();
1704  ++_line) {
1705  HcalDcsDetId dcsId = _line.getHcalDcsDetId();
1706  //std::string _dcs_type = "DCSUNKNOWN";
1707  HcalText2DetIdConverter _converter(_line.getHcalDetId());
1708  sprintf (buf, " %8X %10d %6d %8d %7s %5s %5s %6s",
1709  line_counter,
1710  dcsId.ring(), // contains zside() already
1711  dcsId.slice(),
1712  dcsId.subchannel(),
1713  _converter.getFlavor().c_str(),
1714  _converter.getField1().c_str(),
1715  _converter.getField2().c_str(),
1716  _converter.getField3().c_str()
1717  );
1718  fOutput << buf << std::endl;
1719  ++line_counter;
1720  }
1721  return true;
1722 }
1723 
1724 
1725 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalFlagHFDigiTimeParams* fObject)
1726 {
1727 
1728  if (!fObject) return false; //fObject = new HcalFlagHFDigiTimeParams();
1729  char buffer [1024];
1730  while (fInput.getline(buffer, 1024)) {
1731  if (buffer [0] == '#') continue; //ignore comment
1732  std::vector <std::string> items = splitString (std::string (buffer));
1733  if (items.size()==0) continue; // blank line
1734  if (items.size () != 9) {
1735  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain at 9 least items: eta, phi, depth, subdet, firstSample, samplesToAdd, ExpectedPeak, MinEnergy, and a set of comma-separated coefficients" << std::endl;
1736  continue;
1737  }
1738  // expects (ieta, iphi, depth, subdet) as first four arguments
1739  DetId id = HcalDbASCIIIO::getId (items);
1740  std::vector<double> coef= splitStringToDoubleByComma(items[8].c_str());
1741 
1742  HcalFlagHFDigiTimeParam* fCondObject = new HcalFlagHFDigiTimeParam(id,
1743  atoi (items [4].c_str()), //firstSample
1744  atoi (items [5].c_str()), //samplesToAdd
1745  atoi (items [6].c_str()), //expectedPeak
1746  atof (items [7].c_str()), // minEThreshold
1747  coef // coefficients
1748  );
1749  fObject->addValues(*fCondObject);
1750  delete fCondObject;
1751  }
1752  return true;
1753 } // getObject (HcalFlagHFDigiTime)
1754 
1755 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalFlagHFDigiTimeParams& fObject)
1756 {
1757  char buffer [1024];
1758  sprintf (buffer, "# %15s %15s %15s %15s %15s %15s %15s %15s %30s\n", "eta", "phi", "dep", "det", "FirstSample", "SamplesToAdd", "ExpectedPeak","MinEnergy","Coefficients");
1759  fOutput << buffer;
1760  std::vector<DetId> channels = fObject.getAllChannels ();
1761  std::sort (channels.begin(), channels.end(), DetIdLess ());
1762  for (std::vector<DetId>::iterator channel = channels.begin ();
1763  channel != channels.end ();
1764  ++channel) {
1765  // Dump out channel (ieta,iphi,depth,subdet) info
1766  HcalDbASCIIIO::dumpId (fOutput, *channel);
1767  // Dump out values for channel
1768  sprintf (buffer, " %15u %15u %15u %15f",
1769  fObject.getValues (*channel)->HFdigiflagFirstSample(),
1770  fObject.getValues (*channel)->HFdigiflagSamplesToAdd(),
1771  fObject.getValues (*channel)->HFdigiflagExpectedPeak(),
1772  fObject.getValues (*channel)->HFdigiflagMinEThreshold()
1773  );
1774 
1775  fOutput<<buffer; // dump flag reco values to buffer
1776  fOutput<<" "; // simple spacer
1777 
1778  std::vector<double> coef=fObject.getValues(*channel)->HFdigiflagCoefficients();
1779  for (std::vector<double>::size_type x=0;x<coef.size();++x)
1780  {
1781  // dump comma-separated list of coefficients
1782  fOutput<<coef[x];
1783  if (x<coef.size()-1) // add commas where necessary
1784  fOutput<<",";
1785  }
1786  sprintf(buffer,"\n");
1787  fOutput << buffer;
1788  }
1789  return true;
1790 }
1791 
1792 
1793 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1794 namespace HcalDbASCIIIO {
1795 template<> std::unique_ptr<HcalFrontEndMap> createObject<HcalFrontEndMap>(std::istream& fInput) {
1796  char buffer [1024];
1797  HcalFrontEndMapAddons::Helper fObjectHelper;
1798  unsigned int all(0), good(0);
1799  while (fInput.getline(buffer, 1024)) {
1800  ++all;
1801  if (buffer [0] == '#') continue; //ignore comment
1802  std::vector <std::string> items = splitString (std::string (buffer));
1803  if (items.size () != 6) {
1804  edm::LogError("Format Error") << "HcalFrontEndMap-> line ignored: " << buffer;
1805  continue;
1806  }
1807  ++good;
1808  DetId id = HcalDbASCIIIO::getId (items);
1809  int rm = atoi (items [5].c_str());
1810  fObjectHelper.loadObject (id, rm, items[4]);
1811  }
1812  edm::LogInfo("MapFormat") << "HcalFrontEndMap:: processed " << good << " records in " << all << " record" << std::endl;
1813  auto fObject = std::make_unique<HcalFrontEndMap>(fObjectHelper);
1814  return fObject;
1815 }
1816 }
1817 
1818 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalFrontEndMap& fObject) {
1819 
1820  char buffer [1024];
1821  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s\n", "eta", "phi", "dep", "det", "rbx", "rm");
1822  fOutput << buffer;
1823 
1824  std::vector<DetId> channels = fObject.allDetIds();
1825  std::sort (channels.begin(), channels.end(), DetIdLess ());
1826  for (std::vector<DetId>::iterator channel = channels.begin ();
1827  channel != channels.end (); ++channel) {
1828  const std::string rbx = fObject.lookupRBX(*channel);
1829  const int rm = fObject.lookupRM(*channel);
1830  dumpId (fOutput, *channel);
1831  sprintf (buffer, " %8s %8d \n", rbx.c_str(), rm);
1832  fOutput << buffer;
1833  }
1834  return true;
1835 }
1836 
1837 
1838 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1839 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalSiPMParameters* fObject) {
1840  if (!fObject) return false;
1841  char buffer [1024];
1842  while (fInput.getline(buffer, 1024)) {
1843  if (buffer [0] == '#') continue; //ignore comment
1844  std::vector <std::string> items = splitString (std::string (buffer));
1845  if (items.size()==0) continue; // blank line
1846  if (items.size () < 9) {
1847  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 9 items: eta, phi, depth, subdet, 5x values" << std::endl;
1848  continue;
1849  }
1850  DetId id = HcalDbASCIIIO::getId (items);
1851 
1852  HcalSiPMParameter* obj = new HcalSiPMParameter(id, atoi(items[4].c_str()),
1853  atof(items[5].c_str()),
1854  atof(items[6].c_str()),
1855  atoi(items[7].c_str()),
1856  atof(items[8].c_str()));
1857  fObject->addValues(*obj);
1858  delete obj;
1859  }
1860  return true;
1861 }
1862 
1863 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalSiPMParameters& fObject) {
1864 
1865  char buffer [1024];
1866  sprintf (buffer, "# %15s %15s %15s %15s %8s %15s %15s %8s %15s\n",
1867  "eta", "phi", "dep", "det", "type", "fcByPE", "darkCurrent",
1868  "auxi1", "auxi2");
1869  fOutput << buffer;
1870  std::vector<DetId> channels = fObject.getAllChannels ();
1871  std::sort (channels.begin(), channels.end(), DetIdLess ());
1872  for (std::vector<DetId>::iterator channel = channels.begin ();
1873  channel != channels.end ();
1874  ++channel) {
1875  const int type = fObject.getValues(*channel)->getType();
1876  const float fcByPE = fObject.getValues(*channel)->getFCByPE();
1877  const float darkC = fObject.getValues(*channel)->getDarkCurrent();
1878  const int auxi1 = fObject.getValues(*channel)->getauxi1();
1879  const float auxi2 = fObject.getValues(*channel)->getauxi2();
1880  HcalDbASCIIIO::dumpId (fOutput, *channel);
1881  sprintf (buffer, " %8d %15.6f %15.6f %8d %15.6f\n", type, fcByPE,
1882  darkC, auxi1, auxi2);
1883  fOutput << buffer;
1884  }
1885  return true;
1886 }
1887 
1888 
1889 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1890 namespace HcalDbASCIIIO {
1891 template<> std::unique_ptr<HcalSiPMCharacteristics> createObject<HcalSiPMCharacteristics>(std::istream& fInput) {
1892  char buffer [1024];
1894  unsigned int all(0), good(0);
1895  while (fInput.getline(buffer, 1024)) {
1896  ++all;
1897  if (buffer [0] == '#') continue; //ignore comment
1898  std::vector <std::string> items = splitString (std::string (buffer));
1899  if (items.size () != 8) {
1900  edm::LogError("MapFormat") << "HcalSiPMCharacteristics-> line ignored: " << buffer;
1901  continue;
1902  }
1903  ++good;
1904  // std::cout << "HcalSiPMCharacteristics-> processing line: " << buffer << std::endl;
1905  int type = atoi (items [0].c_str());
1906  int pixels = atoi (items [1].c_str());
1907  float parL0 = atof (items [2].c_str());
1908  float parL1 = atof (items [3].c_str());
1909  float parL2 = atof (items [4].c_str());
1910  float cTalk = atof (items [5].c_str());
1911  int auxi1 = atoi (items [6].c_str());
1912  float auxi2 = atof (items [7].c_str());
1913  fObjectHelper.loadObject (type, pixels, parL0, parL1, parL2, cTalk, auxi1, auxi2);
1914  }
1915  edm::LogInfo("MapFormat") << "HcalSiPMCharacteristics:: processed " << good << " records in " << all << " record" << std::endl;
1916  auto fObject = std::make_unique<HcalSiPMCharacteristics>(fObjectHelper);
1917  return fObject;
1918 }
1919 }
1920 
1921 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalSiPMCharacteristics& fObject) {
1922 
1923  char buffer [1024];
1924  sprintf (buffer, "# %8s %8s %15s %15s %15s %15s %8s %15s\n", "type",
1925  "pixels", "parLin1", "parLin2", "parLin3", "crossTalk", "auxi1",
1926  "auxi2");
1927  fOutput << buffer;
1928 
1929  unsigned int size = fObject.getTypes();
1930  for (unsigned int k=0; k<size; ++k) {
1931  const int type = fObject.getType(k);
1932  const int pixels = fObject.getPixels(type);
1933  const std::vector<float> pars = fObject.getNonLinearities(type);
1934  const float cTalk = fObject.getCrossTalk(type);
1935  const int auxi1 = fObject.getAuxi1(type);
1936  const float auxi2 = fObject.getAuxi2(type);
1937  const float par0 = (pars.size() > 0) ? pars[0] : 0;
1938  const float par1 = (pars.size() > 1) ? pars[1] : 0;
1939  const float par2 = (pars.size() > 2) ? pars[2] : 0;
1940  sprintf (buffer, " %8d %8d %15.6e %15.6e %15.6e %15.6f %8d %15.6f\n",
1941  type, pixels, par0, par1, par2, cTalk, auxi1, auxi2);
1942  fOutput << buffer;
1943  }
1944  return true;
1945 }
1946 
1947 
1948 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1949 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalTPChannelParameters* fObject) {
1950  if (!fObject) return false;
1951  char buffer [1024];
1952  while (fInput.getline(buffer, 1024)) {
1953  if (buffer [0] == '#') continue; //ignore comment
1954  std::vector <std::string> items = splitString (std::string (buffer));
1955  if (items.size()==0) continue; // blank line
1956  if (items.size () < 8) {
1957  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
1958  continue;
1959  }
1960  DetId id = HcalDbASCIIIO::getId (items);
1961 
1963  atoi(items[4].c_str()),
1964  atoi(items[5].c_str()),
1965  atoi(items[6].c_str()),
1966  atoi(items[7].c_str()));
1967  fObject->addValues(*obj);
1968  delete obj;
1969  }
1970  return true;
1971 }
1972 
1973 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalTPChannelParameters& fObject) {
1974 
1975  char buffer [1024];
1976  sprintf (buffer, "# %15s %15s %15s %15s %15s %15s %15s %15s\n",
1977  "eta", "phi", "dep", "det", "Mask", "FGBitInfo", "auxi1", "auxi2");
1978  fOutput << buffer;
1979  std::vector<DetId> channels = fObject.getAllChannels ();
1980  std::sort (channels.begin(), channels.end(), DetIdLess ());
1981  for (std::vector<DetId>::iterator channel = channels.begin ();
1982  channel != channels.end ();
1983  ++channel) {
1984  const uint32_t mask = fObject.getValues(*channel)->getMask();
1985  const uint32_t fgBitInfo = fObject.getValues(*channel)->getFGBitInfo();
1986  const int auxi1 = fObject.getValues(*channel)->getauxi1();
1987  const int auxi2 = fObject.getValues(*channel)->getauxi2();
1988  HcalDbASCIIIO::dumpId (fOutput, *channel);
1989  sprintf (buffer, " %15d %15d %15d %15d \n", mask, fgBitInfo, auxi1, auxi2);
1990  fOutput << buffer;
1991  }
1992  return true;
1993 }
1994 
1995 
1996 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1997 bool HcalDbASCIIIO::getObject (std::istream& fInput, HcalTPParameters* fObject) {
1998  char buffer [1024];
1999  unsigned int all(0), good(0);
2000  while (fInput.getline(buffer, 1024)) {
2001  ++all;
2002  if (buffer [0] == '#') continue; //ignore comment
2003  std::vector <std::string> items = splitString (std::string (buffer));
2004  if (items.size () != 6) {
2005  edm::LogError("Format Error") << "HcalTPParameters-> line ignored: " << buffer;
2006  continue;
2007  }
2008  ++good;
2009  // std::cout << "HcalTPParameters-> processing line: " << buffer << std::endl;
2010  int version = atoi (items [0].c_str());
2011  int adcCut = atoi (items [1].c_str());
2012  uint64_t tdcMask = strtoull(items [2].c_str(),NULL,16);
2013  uint32_t tbits = atoi (items [3].c_str());
2014  int auxi1 = atoi (items [4].c_str());
2015  int auxi2 = atoi (items [5].c_str());
2016  fObject->loadObject (version, adcCut, tdcMask, tbits, auxi1, auxi2);
2017  break;
2018  }
2019  edm::LogInfo("MapFormat") << "HcalTPParameters:: processed " << good << " records in " << all << " record" << std::endl;
2020  return true;
2021 }
2022 
2023 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalTPParameters& fObject) {
2024 
2025  char buffer [1024];
2026  sprintf (buffer, "# %15s %15s %16s %15s %15s %15s\n", "FGAlgo_HBHE",
2027  "ADCThrHF", "TDCMaskHF", "STBitsHF", "auxi1", "auxi2");
2028  fOutput << buffer;
2029 
2030  const int version = fObject.getFGVersionHBHE();
2031  const int adcCut = fObject.getADCThresholdHF();
2032  const uint64_t tdcMask = fObject.getTDCMaskHF();
2033  const uint32_t tbits = fObject.getHFTriggerInfo();
2034  const int auxi1 = fObject.getAuxi1();
2035  const int auxi2 = fObject.getAuxi2();
2036 
2037  sprintf (buffer, " %15d %15d %16jx %15x %15d %15d\n", version, adcCut, tdcMask, tbits, auxi1, auxi2);
2038  fOutput << buffer;
2039 
2040  return true;
2041 }
2042 
2043 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2044 
2045 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalCalibrationsSet& fObject) {
2046  char buffer [1024];
2047  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
2048  "eta", "phi", "dep", "det", "pedcap0", "pedcap1", "pedcap2", "pedcap3", "gaincap0", "gaincap1", "gaincap2", "gaincap3", "DetId");
2049  fOutput << buffer;
2050 
2051  std::vector<DetId> channels = fObject.getAllChannels ();
2052  std::sort (channels.begin(), channels.end(), DetIdLess ());
2053  for (std::vector<DetId>::iterator channel = channels.begin (); channel != channels.end (); ++channel) {
2054  dumpId (fOutput, *channel);
2055  const HcalCalibrations& values = fObject.getCalibrations(*channel);
2056  sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
2057  values.pedestal(0), values.pedestal(1), values.pedestal(2), values.pedestal(3),
2058  values.respcorrgain(0), values.respcorrgain(1), values.respcorrgain(2), values.respcorrgain(3), channel->rawId ());
2059  fOutput << buffer;
2060  }
2061  return true;
2062 }
2063 
2064 bool HcalDbASCIIIO::dumpObject (std::ostream& fOutput, const HcalCalibrationWidthsSet& fObject) {
2065  char buffer [1024];
2066  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %9s %9s %9s %9s %10s\n",
2067  "eta", "phi", "dep", "det", "pedwcap0", "pedwcap1", "pedwcap2", "pedwcap3", "gainwcap0", "gainwcap1", "gainwcap2", "gainwcap3", "DetId");
2068  fOutput << buffer;
2069 
2070  std::vector<DetId> channels = fObject.getAllChannels ();
2071  std::sort (channels.begin(), channels.end(), DetIdLess ());
2072  for (std::vector<DetId>::iterator channel = channels.begin (); channel != channels.end (); ++channel) {
2073  dumpId (fOutput, *channel);
2074  const HcalCalibrationWidths& values = fObject.getCalibrationWidths(*channel);
2075  sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
2076  values.pedestal(0), values.pedestal(1), values.pedestal(2), values.pedestal(3),
2077  values.gain(0), values.gain(1), values.gain(2), values.gain(3), channel->rawId ());
2078  fOutput << buffer;
2079  }
2080  return true;
2081 }
2082 
const std::string & getField1() const
void dumpIdShort(std::ostream &fOutput, DetId id)
size
Write out results.
std::unique_ptr< HcalFrontEndMap > createObject< HcalFrontEndMap >(std::istream &fInput)
uint32_t getFlag() const
Definition: start.py:1
type
Definition: HCALResponse.h:21
float getPedestal() const
unsigned int firstSample() const
Definition: HcalRecoParam.h:32
static const HcalDetId Undefined
Definition: HcalDetId.h:85
void setAlgoString(std::string fAlgo)
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
float timePhase() const
Definition: HcalMCParam.h:43
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
void setUnitADC(bool isADC)
Definition: HcalPedestals.h:30
double gain(int fCapId) const
get gain width for capid=0..3
float slope(unsigned fCapId, unsigned fRange) const
Definition: HcalQIECoder.cc:54
int getAuxi1() const
get Axiliary words
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
unsigned int param2() const
Definition: HcalRecoParam.h:27
std::vector< DetId > getAllChannels() const
bool getHcalSingleIntObject(std::istream &fInput, T *fObject, S *fCondObject)
uint64_t getTDCMaskHF() const
get TDC mask for HF
std::vector< unsigned int > signalTS() const
bool from_string(T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
bool isADC() const
Definition: HcalPedestals.h:28
bool isHcalZDCDetId() const
int subchannel() const
Definition: HcalDcsDetId.h:49
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
bool getHcalSingleFloatObject(std::istream &fInput, T *fObject, S *fCondObject)
static int slb(const HcalTriggerPrimitiveSample &theSample)
unsigned int pileupCleaningID() const
Definition: HcalRecoParam.h:44
const HcalQIECoder * getCoder(DetId fId) const
get QIE parameters
Definition: HcalQIEData.h:39
bool timeSmearing() const
Definition: HcalMCParam.h:44
uint8_t getOutputLutThreshold() const
float getauxi2() const
unsigned int packingScheme() const
Definition: HcalMCParam.h:45
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
uint32_t HFdigiflagSamplesToAdd() const
bool getHcalMatrixObject(std::istream &fInput, T *fObject, S *fCondObject)
std::vector< float > splitStringToFloatByComma(const std::string &fLine)
DcsSet const & getAllSubdetValues(DcsSubDet subd) const
static unsigned int getId(void)
bool correctForPhaseContainment() const
Definition: HcalRecoParam.h:29
int getType() const
get SiPM type
int htrSlot() const
get the htr slot
#define NULL
Definition: scimark2.h:8
std::vector< unsigned int > splitStringToIntByComma(const std::string &fLine)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
void setOffset(unsigned fCapId, unsigned fRange, float fValue)
Definition: HcalQIECoder.cc:58
bool dumpHcalSingleFloatObject(std::ostream &fOutput, const T &fObject)
unsigned int noiseFlaggingID() const
Definition: HcalRecoParam.h:43
void dumpId(std::ostream &fOutput, DetId id)
uint8_t getLutGranularity() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const HcalCalibrationQIECoder * getCoder(DetId fId) const
get QIE parameters
std::vector< std::string > splitString(const std::string &fLine)
std::vector< DetId > getAllChannels() const
uint16_t size_type
unsigned int leakCorrectionID() const
Definition: HcalRecoParam.h:37
bool addCoder(const HcalQIECoder &fCoder)
Definition: HcalQIEData.h:43
int crateId() const
get the readout VME crate number
bool setRctLsb(float rctlsb)
int readoutVMECrateId() const
get the readout VME crate number
void dumpId(std::ostream &fOutput, DetId id)
float getCrossTalk(int type) const
get cross talk
unsigned int param1() const
Definition: HcalMCParam.h:39
float phase() const
unsigned int specialCaseID() const
Definition: HcalRecoParam.h:42
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
U second(std::pair< T, U > const &p)
const_iterator endById(void) const
Definition: HcalDcsMap.cc:61
bool syncPhase() const
Definition: HcalMCParam.h:41
const std::string & getField3() const
std::unique_ptr< HcalSiPMCharacteristics > createObject< HcalSiPMCharacteristics >(std::istream &fInput)
std::vector< HcalDcsValue > DcsSet
Definition: HcalDcsValues.h:27
void setUnitADC(bool isADC)
float getRespGain() const
double pedestal(int fCapId) const
get pedestal width for capid=0..3
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
float offset(unsigned fCapId, unsigned fRange) const
Definition: HcalQIECoder.cc:50
const_iterator beginById(void) const
Definition: HcalDcsMap.cc:49
std::vector< DetId > getAllChannels() const
unsigned int param1() const
Definition: HcalRecoParam.h:26
unsigned int nhits() const
float getNominalGain() const
std::vector< DetId > allDetIds() const
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< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
HcalDetId getHcalDetId(void)
Definition: HcalDcsMap.cc:98
HcalOtherSubdetector
Definition: HcalAssistant.h:32
float getRCalib() const
int getFGVersionHBHE() const
get FineGrain Algorithm Version for HBHE
bool correctForTimeslew() const
Definition: HcalRecoParam.h:38
bool correctTiming() const
Definition: HcalRecoParam.h:40
int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
HcalDcsDetId getHcalDcsDetId(void)
Definition: HcalDcsMap.cc:94
bool dumpHcalMatrixObject(std::ostream &fOutput, const T &fObject)
double f[11][100]
uint32_t HFdigiflagExpectedPeak() const
unsigned int getTypes() const
get # of types
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
Definition: HcalDcsMap.cc:160
Definition: value.py:1
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
float getDarkCurrent() const
get dark current
std::string getTagString() const
unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:33
void setMinCharges(const float fValue[32])
uint32_t getHFTriggerInfo() const
get Self Trigger bits
bool mapEId2tId(HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
float correctionPhaseNS() const
Definition: HcalRecoParam.h:31
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
unsigned int pulseShapeID() const
Definition: HcalRecoParam.h:34
static DcsType DcsTypeFromString(const std::string &str)
Definition: HcalDcsDetId.cc:31
int k[5][pyjets_maxn]
bin
set the eta bin as selection string.
const HcalCalibrationWidths & getCalibrationWidths(const DetId id) const
int slbChannelIndex() const
get the SLB channel index (valid only for VME trigger-chain ids)
std::vector< double > HFdigiflagCoefficients() const
int getauxi1() const
Definition: DetId.h:18
void setHTR(int crate, int slot, int tb)
const std::string & getField2() const
bool isVMEid() const
int getAuxi2() const
int getAuxi1(int type) const
get auxiliary words
std::string getAlgoString() const
std::vector< HcalElectronicsId > allElectronicsId() const
unsigned long long uint64_t
Definition: Time.h:15
int getType(unsigned int k) const
void sort()
Definition: HcalQIEData.h:45
uint32_t HFdigiflagFirstSample() const
const int lookupRM(DetId fId) const
brief lookup the RM associated with the given logical id
const HcalCalibrations & getCalibrations(const DetId id) const
int slot() const
get the htr or uHTR slot
int slice() const
Definition: HcalDcsDetId.h:47
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
std::vector< float > getNonLinearities(int type) const
get nonlinearity constants
float getRctLsb() const
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
bool isTriggerChainId() const
void loadObject(int version, int adcCut, uint64_t tdcMask, uint32_t tbits, int auxi1, int auxi2)
unsigned int signalShape() const
Definition: HcalMCParam.h:40
static const HcalTrigTowerDetId Undefined
bool addValue(HcalDcsValue const &newVal)
bool getHcalObject(std::istream &fInput, T *fObject, S *fCondObject)
bool getObject(std::istream &fInput, HcalPedestals *fObject)
DetId getId(const std::vector< std::string > &items)
unsigned int binOfMaximum() const
Definition: HcalMCParam.h:42
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
int slbSiteNumber() const
get the SLB site number (valid only for VME trigger-chain ids)
uint32_t getFGBitInfo() const
get FG bit information
unsigned int packingScheme() const
Definition: HcalRecoParam.h:45
const float * getValues() const
get value for all capId = 0..3
Definition: HcalPedestal.h:19
bool dumpHcalObject(std::ostream &fOutput, const T &fObject)
std::vector< unsigned int > noiseTS() const
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
float getAuxi2(int type) const
const std::string & getFlavor() const
unsigned int firstAuxTS() const
Definition: HcalRecoParam.h:41
const float * minCharges() const
void setTagString(std::string fTag)
std::unique_ptr< HcalDcsMap > createObject< HcalDcsMap >(std::istream &fInput)
uint32_t getValue() const
bool correctForLeadingEdge() const
Definition: HcalRecoParam.h:30
float rms() const
bool addCoder(const HcalCalibrationQIECoder &fCoder)
def fail(errstr="")
bool addValues(const Item &myItem)
rm
Definition: submit.py:76
long double T
int getPixels(int type) const
get # of pixels
int ring() const
Definition: HcalDcsDetId.h:46
std::unique_ptr< HcalElectronicsMap > createObject< HcalElectronicsMap >(std::istream &fInput)
Readout chain identification for Hcal.
void setSigma(int fCapId1, int fCapId2, float fSigma)
void setSlope(unsigned fCapId, unsigned fRange, float fValue)
Definition: HcalQIECoder.cc:67
const std::string lookupRBX(DetId fId) const
brief lookup the RBX associated with the given logical id
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
int getADCThresholdHF() const
get ADC threshold fof TDC mask of HF
float getFCByPE() const
get fcByPE
bool setNominalGain(float gain)
bool isUTCAid() const
bool dumpHcalSingleIntObject(std::ostream &fOutput, const T &fObject)
unsigned int timeslewCorrectionID() const
Definition: HcalRecoParam.h:39
uint32_t getMask() const
get mask for channel validity and self trigger information
std::vector< double > splitStringToDoubleByComma(const std::string &fLine)
double HFdigiflagMinEThreshold() const
bool useLeakCorrection() const
Definition: HcalRecoParam.h:36