CMS 3D CMS Logo

Namespaces | Functions
HcalDbASCIIIO.cc File Reference
#include <vector>
#include <string>
#include <cstdio>
#include <sstream>
#include <memory>
#include <iostream>
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
#include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
#include "DataFormats/HcalDetId/interface/HcalDcsDetId.h"
#include "CalibFormats/HcalObjects/interface/HcalText2DetIdConverter.h"
#include "CondFormats/HcalObjects/interface/AllObjects.h"
#include "CalibCalorimetry/HcalAlgos/interface/HcalDbASCIIIO.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Namespaces

 HcalDbASCIIIO
 

Functions

template<>
std::unique_ptr< HcalDcsMapHcalDbASCIIIO::createObject< HcalDcsMap > (std::istream &fInput)
 
template<>
std::unique_ptr< HcalElectronicsMapHcalDbASCIIIO::createObject< HcalElectronicsMap > (std::istream &fInput)
 
template<>
std::unique_ptr< HcalFrontEndMapHcalDbASCIIIO::createObject< HcalFrontEndMap > (std::istream &fInput)
 
template<>
std::unique_ptr< HcalSiPMCharacteristicsHcalDbASCIIIO::createObject< HcalSiPMCharacteristics > (std::istream &fInput)
 
template<class T >
bool dumpHcalDoubleFloatObject (std::ostream &fOutput, const T &fObject)
 
template<class T >
bool dumpHcalMatrixObject (std::ostream &fOutput, const T &fObject)
 
template<class T >
bool dumpHcalObject (std::ostream &fOutput, const T &fObject)
 
template<class T >
bool dumpHcalSingleFloatObject (std::ostream &fOutput, const T &fObject)
 
template<class T >
bool dumpHcalSingleIntObject (std::ostream &fOutput, const T &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalGains &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalGainWidths &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalPFCuts &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalQIETypes &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalRespCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalLUTCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalPFCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalTimeCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalZSThresholds &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalValidationCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalZDCLowGainFractions &fObject)
 
template<class T >
bool from_string (T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
 
template<class S , class T >
bool getHcalDoubleFloatObject (std::istream &fInput, T *fObject)
 
template<class S , class T >
bool getHcalMatrixObject (std::istream &fInput, T *fObject, S *fCondObject)
 
template<class S , class T >
bool getHcalObject (std::istream &fInput, T *fObject)
 
template<class ObjectPrimitiveType , class S , class T >
bool getHcalSingleObject (std::istream &fInput, T *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalGains *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalGainWidths *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalPFCuts *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalQIETypes *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalRespCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalLUTCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalPFCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalTimeCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalZSThresholds *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalValidationCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalZDCLowGainFractions *fObject)
 
std::vector< std::string > splitString (const std::string &fLine)
 
std::vector< double > splitStringToDoubleByComma (const std::string &fLine)
 
std::vector< float > splitStringToFloatByComma (const std::string &fLine)
 
std::vector< unsigned int > splitStringToIntByComma (const std::string &fLine)
 

Function Documentation

◆ dumpHcalDoubleFloatObject()

template<class T >
bool dumpHcalDoubleFloatObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 265 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, ewkTauDQM_cfi::channels, HcalDbASCIIIO::dumpId(), jetUpdater_cfi::sort, and HLT_2024v14_cff::value1.

Referenced by HcalDbASCIIIO::dumpObject().

265  {
266  char buffer[1024];
267  sprintf(buffer, "# %15s %15s %15s %15s %10s %10s %10s\n", "eta", "phi", "dep", "det", "value0", "value1", "DetId");
268  fOutput << buffer;
269  std::vector<DetId> channels = fObject.getAllChannels();
270  std::sort(channels.begin(), channels.end(), DetIdLess());
271  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
272  const float value0 = fObject.getValues(*channel)->getValue0();
273  const float value1 = fObject.getValues(*channel)->getValue1();
274  HcalDbASCIIIO::dumpId(fOutput, *channel);
275  sprintf(buffer, " %10.7f %10.7f %10X\n", value0, value1, channel->rawId());
276  fOutput << buffer;
277  }
278  return true;
279 }
void dumpId(std::ostream &fOutput, DetId id)

◆ dumpHcalMatrixObject()

template<class T >
bool dumpHcalMatrixObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 369 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, ewkTauDQM_cfi::channels, HcalDbASCIIIO::dumpId(), mps_fire::i, dqmiolumiharvest::j, visualization-live-secondInstance_cfg::m, and jetUpdater_cfi::sort.

369  {
370  char buffer[1024];
371  sprintf(buffer,
372  "# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
373  "eta",
374  "phi",
375  "dep",
376  "det",
377  "capid",
378  "c0",
379  "c1",
380  "c2",
381  "c3",
382  "c4",
383  "c5",
384  "c6",
385  "c7",
386  "c8",
387  "c9",
388  "DetId");
389  fOutput << buffer;
390  std::vector<DetId> channels = fObject.getAllChannels();
391  std::sort(channels.begin(), channels.end(), DetIdLess());
392  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
393  float thisline[10];
394  for (int m = 0; m != 4; m++) {
395  for (int i = 0; i != 10; i++) {
396  for (int j = 0; j != 10; j++) {
397  // std::cout <<"test "<<(fObject.getValues(*channel))->getValue(0,0,0);
398  thisline[j] = fObject.getValues(*channel)->getValue(m, i, j);
399  // thisline[j] = fObject.getValues(*channel)->getValue(1,1,1);
400  }
401  HcalDbASCIIIO::dumpId(fOutput, *channel);
402  sprintf(buffer,
403  " %5i %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
404  m,
405  thisline[0],
406  thisline[1],
407  thisline[2],
408  thisline[3],
409  thisline[4],
410  thisline[5],
411  thisline[6],
412  thisline[7],
413  thisline[8],
414  thisline[9],
415  channel->rawId());
416  fOutput << buffer;
417  }
418  }
419  }
420 
421  return true;
422 }
void dumpId(std::ostream &fOutput, DetId id)

◆ dumpHcalObject()

template<class T >
bool dumpHcalObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 204 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, ewkTauDQM_cfi::channels, HcalDbASCIIIO::dumpId(), jetUpdater_cfi::sort, and contentValuesCheck::values.

Referenced by HcalDbASCIIIO::dumpObject().

204  {
205  char buffer[1024];
206  sprintf(buffer,
207  "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n",
208  "eta",
209  "phi",
210  "dep",
211  "det",
212  "cap0",
213  "cap1",
214  "cap2",
215  "cap3",
216  "DetId");
217  fOutput << buffer;
218  std::vector<DetId> channels = fObject.getAllChannels();
219  std::sort(channels.begin(), channels.end(), DetIdLess());
220  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
221  const float* values = fObject.getValues(*channel)->getValues();
222  if (values) {
223  HcalDbASCIIIO::dumpId(fOutput, *channel);
224  sprintf(
225  buffer, " %10.7f %10.7f %10.7f %10.7f %10X\n", values[0], values[1], values[2], values[3], channel->rawId());
226  fOutput << buffer;
227  }
228  }
229  return true;
230 }
void dumpId(std::ostream &fOutput, DetId id)

◆ dumpHcalSingleFloatObject()

template<class T >
bool dumpHcalSingleFloatObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 307 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, ewkTauDQM_cfi::channels, HcalDbASCIIIO::dumpId(), and jetUpdater_cfi::sort.

Referenced by HcalDbASCIIIO::dumpObject().

307  {
308  char buffer[1024];
309  sprintf(buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
310  fOutput << buffer;
311  std::vector<DetId> channels = fObject.getAllChannels();
312  std::sort(channels.begin(), channels.end(), DetIdLess());
313  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
314  const float value = fObject.getValues(*channel)->getValue();
315  HcalDbASCIIIO::dumpId(fOutput, *channel);
316  sprintf(buffer, " %8.5f %10X\n", value, channel->rawId());
317  fOutput << buffer;
318  }
319  return true;
320 }
void dumpId(std::ostream &fOutput, DetId id)
Definition: value.py:1

◆ dumpHcalSingleIntObject()

template<class T >
bool dumpHcalSingleIntObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 323 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, ewkTauDQM_cfi::channels, HcalDbASCIIIO::dumpId(), and jetUpdater_cfi::sort.

Referenced by HcalDbASCIIIO::dumpObject().

323  {
324  char buffer[1024];
325  sprintf(buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
326  fOutput << buffer;
327  std::vector<DetId> channels = fObject.getAllChannels();
328  std::sort(channels.begin(), channels.end(), DetIdLess());
329  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
330  const int value = fObject.getValues(*channel)->getValue();
331  HcalDbASCIIIO::dumpId(fOutput, *channel);
332  sprintf(buffer, " %15d %10X\n", value, channel->rawId());
333  fOutput << buffer;
334  }
335  return true;
336 }
void dumpId(std::ostream &fOutput, DetId id)
Definition: value.py:1

◆ from_string()

template<class T >
bool from_string ( T t,
const std::string &  s,
std::ios_base &(*)(std::ios_base &)  f 
)

Definition at line 167 of file HcalDbASCIIIO.cc.

References f, alignCSCRings::s, and submitPVValidationJobs::t.

167  {
168  std::istringstream iss(s);
169  return !(iss >> f >> t).fail();
170 }
double f[11][100]

◆ getHcalDoubleFloatObject()

template<class S , class T >
bool getHcalDoubleFloatObject ( std::istream &  fInput,
T fObject 
)

Definition at line 282 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::getId(), mps_monitormerge::items, splitString(), and AlCaHLTBitMon_QueryRunRegistry::string.

282  {
283  if (!fObject)
284  return false; //fObject = new T;
285  char buffer[1024];
286  while (fInput.getline(buffer, 1024)) {
287  if (buffer[0] == '#')
288  continue; //ignore comment
289  std::vector<std::string> items = splitString(std::string(buffer));
290  if (items.empty())
291  continue; // blank line
292  if (items.size() < 6) {
293  edm::LogWarning("Format Error") << "Bad line: " << buffer
294  << "\n line must contain 6 items: eta, phi, depth, subdet, value0, value1"
295  << std::endl;
296  continue;
297  }
299  S fCondObject(id, atof(items[4].c_str()), atof(items[5].c_str()));
300  fObject->addValues(fCondObject);
301  }
302 
303  return true;
304 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:17
DetId getId(const std::vector< std::string > &items)
Log< level::Warning, false > LogWarning

◆ getHcalMatrixObject()

template<class S , class T >
bool getHcalMatrixObject ( std::istream &  fInput,
T fObject,
S fCondObject 
)

Definition at line 339 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::getId(), mps_fire::i, mps_monitormerge::items, dqmiolumiharvest::j, DetId::rawId(), nano_mu_digi_cff::rawId, splitString(), and AlCaHLTBitMon_QueryRunRegistry::string.

339  {
340  if (!fObject)
341  return false; //fObject = new T;
342  char buffer[1024];
343  while (fInput.getline(buffer, 1024)) {
344  if (buffer[0] == '#')
345  continue; //ignore comment
346  std::vector<std::string> items = splitString(std::string(buffer));
347  if (items.empty())
348  continue; // blank line
349  DetId firstid = HcalDbASCIIIO::getId(items);
350  fCondObject = new S(firstid.rawId());
351  for (int j = 0; j != 10; j++)
352  fCondObject->setValue(atoi(items[4].c_str()), 0, j, atof(items[j + 5].c_str()));
353  for (int i = 1; i != 40; i++) {
354  fInput.getline(buffer, 1024);
357  if (id.rawId() != firstid.rawId())
358  break; //throw cms::Exception("Wrong number of elements");
359  for (int j = 0; j != 10; j++)
360  fCondObject->setValue(atoi(items[4].c_str()), i % 10, j, atof(items[j + 5].c_str()));
361  }
362  fObject->addValues(*fCondObject);
363  delete fCondObject;
364  }
365  return true;
366 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
DetId getId(const std::vector< std::string > &items)

◆ getHcalObject()

template<class S , class T >
bool getHcalObject ( std::istream &  fInput,
T fObject 
)

Definition at line 173 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::getId(), mps_monitormerge::items, splitString(), and AlCaHLTBitMon_QueryRunRegistry::string.

173  {
174  if (!fObject)
175  return false; //fObject = new T;
176  char buffer[1024];
177  while (fInput.getline(buffer, 1024)) {
178  if (buffer[0] == '#')
179  continue; //ignore comment
180  std::vector<std::string> items = splitString(std::string(buffer));
181  if (items.empty())
182  continue; // blank line
183  if (items.size() < 8) {
184  edm::LogWarning("Format Error") << "Bad line: " << buffer
185  << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values"
186  << std::endl;
187  continue;
188  }
190 
191  // if (fObject->exists(id) )
192  // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
193  // else
194  // {
195  S fCondObject(id, atof(items[4].c_str()), atof(items[5].c_str()), atof(items[6].c_str()), atof(items[7].c_str()));
196  fObject->addValues(fCondObject);
197  // }
198  }
199 
200  return true;
201 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:17
DetId getId(const std::vector< std::string > &items)
Log< level::Warning, false > LogWarning

◆ getHcalSingleObject()

template<class ObjectPrimitiveType , class S , class T >
bool getHcalSingleObject ( std::istream &  fInput,
T fObject 
)

Definition at line 233 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::getId(), mps_monitormerge::items, splitString(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and x.

233  {
234  if (!fObject)
235  return false; //fObject = new T;
236  char buffer[1024];
237  while (fInput.getline(buffer, 1024)) {
238  if (buffer[0] == '#')
239  continue; //ignore comment
240  std::vector<std::string> items = splitString(std::string(buffer));
241  if (items.empty())
242  continue; // blank line
243  if (items.size() < 5) {
244  edm::LogWarning("Format Error") << "Bad line: " << buffer
245  << "\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
246  continue;
247  }
249 
250  // if (fObject->exists(id) )
251  // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
252  // else
253  // {
254  std::stringstream ss(items[4]);
255  ObjectPrimitiveType x = 0; // usually int or float
256  ss >> x;
257  S fCondObject(id, x);
258  fObject->addValues(fCondObject);
259  // }
260  }
261  return true;
262 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:17
DetId getId(const std::vector< std::string > &items)
float x
Log< level::Warning, false > LogWarning

◆ splitString()

std::vector<std::string> splitString ( const std::string &  fLine)

Definition at line 55 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, mps_fire::i, B2GTnPMonitor_cfi::item, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EgHLTOfflineClient::createLooseTightTrigEff(), HcalDbASCIIIO::createObject< HcalDcsMap >(), HcalDbASCIIIO::createObject< HcalElectronicsMap >(), HcalDbASCIIIO::createObject< HcalFrontEndMap >(), HcalDbASCIIIO::createObject< HcalSiPMCharacteristics >(), getHcalDoubleFloatObject(), getHcalMatrixObject(), getHcalObject(), getHcalSingleObject(), HcalQIEManager::getHfQieTable(), HcalQIEManager::getQIETableFromFile(), HGCalNumberingScheme::HGCalNumberingScheme(), HGCScintSD::HGCScintSD(), egHLT::MonElemFuncs::initTightLooseDiObjTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTightLooseTrigHists(), and egHLT::MonElemFuncs::initTightLooseTrigHistsTrigCuts().

55  {
56  std::vector<std::string> result;
57  int start = 0;
58  bool empty = true;
59  for (unsigned i = 0; i <= fLine.size(); i++) {
60  if (fLine[i] == ' ' || i == fLine.size()) {
61  if (!empty) {
62  std::string item(fLine, start, i - start);
63  result.push_back(item);
64  empty = true;
65  }
66  start = i + 1;
67  } else {
68  if (empty)
69  empty = false;
70  }
71  }
72  return result;
73 }
Definition: start.py:1

◆ splitStringToDoubleByComma()

std::vector<double> splitStringToDoubleByComma ( const std::string &  fLine)

Definition at line 115 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, mps_fire::i, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

115  {
116  std::vector<double> result;
117  int start = 0;
118  bool empty = true;
119  for (unsigned i = 0; i <= fLine.size(); i++) {
120  if (fLine[i] == ',' || i == fLine.size()) {
121  if (!empty) {
122  std::string itemString(fLine, start, i - start);
123  result.push_back(atof(itemString.c_str()));
124  empty = true;
125  }
126  start = i + 1;
127  } else {
128  if (empty)
129  empty = false;
130  }
131  }
132  return result;
133 }
Definition: start.py:1

◆ splitStringToFloatByComma()

std::vector<float> splitStringToFloatByComma ( const std::string &  fLine)

Definition at line 95 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, mps_fire::i, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

95  {
96  std::vector<float> result;
97  int start = 0;
98  bool empty = true;
99  for (unsigned i = 0; i <= fLine.size(); i++) {
100  if (fLine[i] == ',' || i == fLine.size()) {
101  if (!empty) {
102  std::string itemString(fLine, start, i - start);
103  result.push_back(atof(itemString.c_str()));
104  empty = true;
105  }
106  start = i + 1;
107  } else {
108  if (empty)
109  empty = false;
110  }
111  }
112  return result;
113 }
Definition: start.py:1

◆ splitStringToIntByComma()

std::vector<unsigned int> splitStringToIntByComma ( const std::string &  fLine)

Definition at line 75 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, mps_fire::i, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

75  {
76  std::vector<unsigned int> result;
77  int start = 0;
78  bool empty = true;
79  for (unsigned i = 0; i <= fLine.size(); i++) {
80  if (fLine[i] == ',' || i == fLine.size()) {
81  if (!empty) {
82  std::string itemString(fLine, start, i - start);
83  result.push_back(atoi(itemString.c_str()));
84  empty = true;
85  }
86  start = i + 1;
87  } else {
88  if (empty)
89  empty = false;
90  }
91  }
92  return result;
93 }
Definition: start.py:1