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

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

Definition at line 303 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::dumpId(), mps_fire::i, and funct::m.

303  {
304  char buffer [1024];
305  sprintf (buffer, "# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
306  "eta", "phi", "dep", "det", "capid","c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "DetId");
307  fOutput << buffer;
308  std::vector<DetId> channels = fObject.getAllChannels ();
309  std::sort (channels.begin(), channels.end(), DetIdLess ());
310  for (std::vector<DetId>::iterator channel = channels.begin ();
311  channel != channels.end ();
312  ++channel) {
313  float thisline[10];
314  for(int m = 0; m != 4; m++){
315  for(int i = 0; i != 10; i++){
316  for(int j = 0; j != 10; j++){
317 // std::cout <<"test "<<(fObject.getValues(*channel))->getValue(0,0,0);
318  thisline[j] = fObject.getValues(*channel)->getValue(m,i,j);
319 // thisline[j] = fObject.getValues(*channel)->getValue(1,1,1);
320  }
321  HcalDbASCIIIO::dumpId (fOutput, *channel);
322  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",
323  m, thisline[0], thisline[1], thisline[2], thisline[3], thisline[4], thisline[5], thisline[6], thisline[7],
324  thisline[8], thisline[9], channel->rawId());
325  fOutput << buffer;
326  }
327  }
328  }
329 
330  return true;
331 }
void dumpId(std::ostream &fOutput, DetId id)
template<class T >
bool dumpHcalObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 192 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::dumpId(), and MuonErrorMatrixValues_cff::values.

Referenced by HcalDbASCIIIO::dumpObject().

192  {
193  char buffer [1024];
194  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n", "eta", "phi", "dep", "det", "cap0", "cap1", "cap2", "cap3", "DetId");
195  fOutput << buffer;
196  std::vector<DetId> channels = fObject.getAllChannels ();
197  std::sort (channels.begin(), channels.end(), DetIdLess ());
198  for (std::vector<DetId>::iterator channel = channels.begin ();
199  channel != channels.end ();
200  ++channel) {
201  const float* values = fObject.getValues (*channel)->getValues ();
202  if (values) {
203  HcalDbASCIIIO::dumpId (fOutput, *channel);
204  sprintf (buffer, " %10.7f %10.7f %10.7f %10.7f %10X\n",
205  values[0], values[1], values[2], values[3], channel->rawId ());
206  fOutput << buffer;
207  }
208  }
209  return true;
210 }
void dumpId(std::ostream &fOutput, DetId id)
template<class T >
bool dumpHcalSingleFloatObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 241 of file HcalDbASCIIIO.cc.

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

Referenced by HcalDbASCIIIO::dumpObject().

241  {
242  char buffer [1024];
243  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
244  fOutput << buffer;
245  std::vector<DetId> channels = fObject.getAllChannels ();
246  std::sort (channels.begin(), channels.end(), DetIdLess ());
247  for (std::vector<DetId>::iterator channel = channels.begin ();
248  channel != channels.end ();
249  ++channel) {
250  const float value = fObject.getValues (*channel)->getValue ();
251  HcalDbASCIIIO::dumpId (fOutput, *channel);
252  sprintf (buffer, " %8.5f %10X\n",
253  value, channel->rawId ());
254  fOutput << buffer;
255  }
256  return true;
257 }
void dumpId(std::ostream &fOutput, DetId id)
Definition: value.py:1
template<class T >
bool dumpHcalSingleIntObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 260 of file HcalDbASCIIIO.cc.

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

Referenced by HcalDbASCIIIO::dumpObject().

260  {
261  char buffer [1024];
262  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
263  fOutput << buffer;
264  std::vector<DetId> channels = fObject.getAllChannels ();
265  std::sort (channels.begin(), channels.end(), DetIdLess ());
266  for (std::vector<DetId>::iterator channel = channels.begin ();
267  channel != channels.end ();
268  ++channel) {
269  const int value = fObject.getValues (*channel)->getValue ();
270  HcalDbASCIIIO::dumpId (fOutput, *channel);
271  sprintf (buffer, " %15d %10X\n",
272  value, channel->rawId ());
273  fOutput << buffer;
274  }
275  return true;
276 }
void dumpId(std::ostream &fOutput, DetId id)
Definition: value.py:1
template<class T >
bool from_string ( T t,
const std::string &  s,
std::ios_base &(*)(std::ios_base &)  f 
)

Definition at line 160 of file HcalDbASCIIIO.cc.

References f, cmsPerfPublish::fail(), and lumiQTWidget::t.

160  {
161  std::istringstream iss(s);
162  return !(iss >> f >> t).fail();
163 }
double f[11][100]
def fail(errstr="")
template<class S , class T >
bool getHcalMatrixObject ( std::istream &  fInput,
T fObject,
S fCondObject 
)

Definition at line 279 of file HcalDbASCIIIO.cc.

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

279  {
280  if (!fObject) return false; //fObject = new T;
281  char buffer [1024];
282  while (fInput.getline(buffer, 1024)) {
283  if (buffer [0] == '#') continue; //ignore comment
284  std::vector <std::string> items = splitString (std::string (buffer));
285  if (items.empty()) continue; // blank line
286  DetId firstid = HcalDbASCIIIO::getId (items);
287  fCondObject = new S(firstid.rawId());
288  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), 0, j, atof(items[j+5].c_str()));
289  for(int i = 1; i != 40; i++){
290  fInput.getline(buffer, 1024);
291  items = splitString (std::string (buffer));
292  DetId id = HcalDbASCIIIO::getId (items);
293  if(id.rawId() != firstid.rawId()) break;//throw cms::Exception("Wrong number of elements");
294  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), i%10, j, atof(items[j+5].c_str()));
295  }
296  fObject->addValues(*fCondObject);
297  delete fCondObject;
298  }
299  return true;
300 }
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:18
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
DetId getId(const std::vector< std::string > &items)
template<class S , class T >
bool getHcalObject ( std::istream &  fInput,
T fObject 
)

Definition at line 166 of file HcalDbASCIIIO.cc.

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

166  {
167  if (!fObject) return false; //fObject = new T;
168  char buffer [1024];
169  while (fInput.getline(buffer, 1024)) {
170  if (buffer [0] == '#') continue; //ignore comment
171  std::vector <std::string> items = splitString (std::string (buffer));
172  if (items.empty()) continue; // blank line
173  if (items.size () < 8) {
174  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
175  continue;
176  }
177  DetId id = HcalDbASCIIIO::getId (items);
178 
179 // if (fObject->exists(id) )
180 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
181 // else
182 // {
183  S fCondObject(id, atof (items [4].c_str()), atof (items [5].c_str()), atof (items [6].c_str()), atof (items [7].c_str()));
184  fObject->addValues(fCondObject);
185  // }
186  }
187 
188  return true;
189 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:18
DetId getId(const std::vector< std::string > &items)
template<class ObjectPrimitiveType , class S , class T >
bool getHcalSingleObject ( std::istream &  fInput,
T fObject 
)

Definition at line 213 of file HcalDbASCIIIO.cc.

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

213  {
214  if (!fObject) return false; //fObject = new T;
215  char buffer [1024];
216  while (fInput.getline(buffer, 1024)) {
217  if (buffer [0] == '#') continue; //ignore comment
218  std::vector <std::string> items = splitString (std::string (buffer));
219  if (items.empty()) continue; // blank line
220  if (items.size () < 5) {
221  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
222  continue;
223  }
224  DetId id = HcalDbASCIIIO::getId (items);
225 
226 // if (fObject->exists(id) )
227 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
228 // else
229 // {
230  std::stringstream ss(items[4]);
231  ObjectPrimitiveType x = 0; // usually int or float
232  ss >> x;
233  S fCondObject(id, x );
234  fObject->addValues(fCondObject);
235  // }
236  }
237  return true;
238 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:18
DetId getId(const std::vector< std::string > &items)
std::vector<std::string> splitString ( const std::string &  fLine)

Definition at line 55 of file HcalDbASCIIIO.cc.

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

Referenced by HcalDbASCIIIO::createObject< HcalDcsMap >(), HcalDbASCIIIO::createObject< HcalElectronicsMap >(), HcalDbASCIIIO::createObject< HcalFrontEndMap >(), HcalDbASCIIIO::createObject< HcalSiPMCharacteristics >(), HcalDbASCIIIO::dumpObject(), getHcalMatrixObject(), getHcalObject(), and getHcalSingleObject().

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  }
68  else {
69  if (empty) empty = false;
70  }
71  }
72  return result;
73 }
Definition: start.py:1
std::vector<double> splitStringToDoubleByComma ( const std::string &  fLine)

Definition at line 115 of file HcalDbASCIIIO.cc.

References edmScanValgrind::buffer, HcalDbASCIIIO::dumpId(), HcalDbASCIIIO::dumpIdShort(), relativeConstraints::empty, HcalText2DetIdConverter::getField1(), HcalText2DetIdConverter::getField2(), HcalText2DetIdConverter::getField3(), HcalText2DetIdConverter::getFlavor(), HcalText2DetIdConverter::getId(), HcalDbASCIIIO::getId(), mps_fire::i, mps_monitormerge::items, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HcalDbASCIIIO::createObject< HcalDcsMap >().

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  }
128  else {
129  if (empty) empty = false;
130  }
131  }
132  return result;
133 }
Definition: start.py:1
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  }
108  else {
109  if (empty) empty = false;
110  }
111  }
112  return result;
113 }
Definition: start.py:1
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.

Referenced by HcalDbASCIIIO::dumpObject().

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  }
88  else {
89  if (empty) empty = false;
90  }
91  }
92  return result;
93 }
Definition: start.py:1