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 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 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 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, 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

◆ dumpHcalMatrixObject()

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

Definition at line 327 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.

327  {
328  char buffer[1024];
329  sprintf(buffer,
330  "# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
331  "eta",
332  "phi",
333  "dep",
334  "det",
335  "capid",
336  "c0",
337  "c1",
338  "c2",
339  "c3",
340  "c4",
341  "c5",
342  "c6",
343  "c7",
344  "c8",
345  "c9",
346  "DetId");
347  fOutput << buffer;
348  std::vector<DetId> channels = fObject.getAllChannels();
349  std::sort(channels.begin(), channels.end(), DetIdLess());
350  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
351  float thisline[10];
352  for (int m = 0; m != 4; m++) {
353  for (int i = 0; i != 10; i++) {
354  for (int j = 0; j != 10; j++) {
355  // std::cout <<"test "<<(fObject.getValues(*channel))->getValue(0,0,0);
356  thisline[j] = fObject.getValues(*channel)->getValue(m, i, j);
357  // thisline[j] = fObject.getValues(*channel)->getValue(1,1,1);
358  }
359  HcalDbASCIIIO::dumpId(fOutput, *channel);
360  sprintf(buffer,
361  " %5i %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %10X\n",
362  m,
363  thisline[0],
364  thisline[1],
365  thisline[2],
366  thisline[3],
367  thisline[4],
368  thisline[5],
369  thisline[6],
370  thisline[7],
371  thisline[8],
372  thisline[9],
373  channel->rawId());
374  fOutput << buffer;
375  }
376  }
377  }
378 
379  return true;
380 }
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 265 of file HcalDbASCIIIO.cc.

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

Referenced by HcalDbASCIIIO::dumpObject().

265  {
266  char buffer[1024];
267  sprintf(buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "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 value = fObject.getValues(*channel)->getValue();
273  HcalDbASCIIIO::dumpId(fOutput, *channel);
274  sprintf(buffer, " %8.5f %10X\n", value, channel->rawId());
275  fOutput << buffer;
276  }
277  return true;
278 }
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 281 of file HcalDbASCIIIO.cc.

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

Referenced by HcalDbASCIIIO::dumpObject().

281  {
282  char buffer[1024];
283  sprintf(buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
284  fOutput << buffer;
285  std::vector<DetId> channels = fObject.getAllChannels();
286  std::sort(channels.begin(), channels.end(), DetIdLess());
287  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
288  const int value = fObject.getValues(*channel)->getValue();
289  HcalDbASCIIIO::dumpId(fOutput, *channel);
290  sprintf(buffer, " %15d %10X\n", value, channel->rawId());
291  fOutput << buffer;
292  }
293  return true;
294 }
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]

◆ getHcalMatrixObject()

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

Definition at line 297 of file HcalDbASCIIIO.cc.

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

297  {
298  if (!fObject)
299  return false; //fObject = new T;
300  char buffer[1024];
301  while (fInput.getline(buffer, 1024)) {
302  if (buffer[0] == '#')
303  continue; //ignore comment
304  std::vector<std::string> items = splitString(std::string(buffer));
305  if (items.empty())
306  continue; // blank line
307  DetId firstid = HcalDbASCIIIO::getId(items);
308  fCondObject = new S(firstid.rawId());
309  for (int j = 0; j != 10; j++)
310  fCondObject->setValue(atoi(items[4].c_str()), 0, j, atof(items[j + 5].c_str()));
311  for (int i = 1; i != 40; i++) {
312  fInput.getline(buffer, 1024);
315  if (id.rawId() != firstid.rawId())
316  break; //throw cms::Exception("Wrong number of elements");
317  for (int j = 0; j != 10; j++)
318  fCondObject->setValue(atoi(items[4].c_str()), i % 10, j, atof(items[j + 5].c_str()));
319  }
320  fObject->addValues(*fCondObject);
321  delete fCondObject;
322  }
323  return true;
324 }
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 >(), 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