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 HcalLUTCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalPFCorrs &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 HcalTimeCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalValidationCorrs &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalZDCLowGainFractions &fObject)
 
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalZSThresholds &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, HcalLUTCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalPFCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalQIETypes *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalRespCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalTimeCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalValidationCorrs *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalZDCLowGainFractions *fObject)
 
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalZSThresholds *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 330 of file HcalDbASCIIIO.cc.

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

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

◆ dumpHcalObject()

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

Definition at line 207 of file HcalDbASCIIIO.cc.

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

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

Referenced by HcalDbASCIIIO::dumpObject().

◆ dumpHcalSingleFloatObject()

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

Definition at line 268 of file HcalDbASCIIIO.cc.

268  {
269  char buffer[1024];
270  sprintf(buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
271  fOutput << buffer;
272  std::vector<DetId> channels = fObject.getAllChannels();
273  std::sort(channels.begin(), channels.end(), DetIdLess());
274  for (std::vector<DetId>::iterator channel = channels.begin(); channel != channels.end(); ++channel) {
275  const float value = fObject.getValues(*channel)->getValue();
276  HcalDbASCIIIO::dumpId(fOutput, *channel);
277  sprintf(buffer, " %8.5f %10X\n", value, channel->rawId());
278  fOutput << buffer;
279  }
280  return true;
281 }

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

Referenced by HcalDbASCIIIO::dumpObject().

◆ dumpHcalSingleIntObject()

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

Definition at line 284 of file HcalDbASCIIIO.cc.

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

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

Referenced by HcalDbASCIIIO::dumpObject().

◆ from_string()

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

Definition at line 170 of file HcalDbASCIIIO.cc.

170  {
171  std::istringstream iss(s);
172  return !(iss >> f >> t).fail();
173 }

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

◆ getHcalMatrixObject()

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

Definition at line 300 of file HcalDbASCIIIO.cc.

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

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

◆ getHcalObject()

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

Definition at line 176 of file HcalDbASCIIIO.cc.

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

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

◆ getHcalSingleObject()

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

Definition at line 236 of file HcalDbASCIIIO.cc.

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

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

◆ splitString()

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

◆ splitStringToDoubleByComma()

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

Definition at line 118 of file HcalDbASCIIIO.cc.

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

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

◆ splitStringToFloatByComma()

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

Definition at line 98 of file HcalDbASCIIIO.cc.

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

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

◆ splitStringToIntByComma()

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

Definition at line 78 of file HcalDbASCIIIO.cc.

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

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

mps_fire.i
i
Definition: mps_fire.py:355
start
Definition: start.py:1
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
splitString
std::vector< std::string > splitString(const std::string &fLine)
Definition: HcalDbASCIIIO.cc:58
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HcalDbASCIIIO::dumpId
void dumpId(std::ostream &fOutput, DetId id)
Definition: CastorDbASCIIIO.cc:76
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
vertices_cff.x
x
Definition: vertices_cff.py:29
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
edm::LogWarning
Definition: MessageLogger.h:141
value
Definition: value.py:1
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HcalDbASCIIIO::getId
DetId getId(const std::vector< std::string > &items)
Definition: CastorDbASCIIIO.cc:71
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
S
Definition: CSCDBL1TPParametersExtended.h:16
mps_fire.result
result
Definition: mps_fire.py:303
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66