CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
HcalDbASCIIIO.cc File Reference
#include <vector>
#include <string>
#include <cstdio>
#include <sstream>
#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.

Functions

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)
 
template<class T >
bool from_string (T &t, const std::string &s, std::ios_base &(*f)(std::ios_base &))
 
template<class T , class S >
bool getHcalMatrixObject (std::istream &fInput, T *fObject, S *fCondObject)
 
template<class T , class S >
bool getHcalObject (std::istream &fInput, T *fObject, S *fCondObject)
 
template<class T , class S >
bool getHcalSingleFloatObject (std::istream &fInput, T *fObject, S *fCondObject)
 
template<class T , class S >
bool getHcalSingleIntObject (std::istream &fInput, T *fObject, S *fCondObject)
 
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 327 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::dumpId(), i, j, visualization-live-secondInstance_cfg::m, and python.multivaluedict::sort().

327  {
328  char buffer [1024];
329  sprintf (buffer, "# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
330  "eta", "phi", "dep", "det", "capid","c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "DetId");
331  fOutput << buffer;
332  std::vector<DetId> channels = fObject.getAllChannels ();
333  std::sort (channels.begin(), channels.end(), DetIdLess ());
334  for (std::vector<DetId>::iterator channel = channels.begin ();
335  channel != channels.end ();
336  ++channel) {
337  float thisline[10];
338  for(int m = 0; m != 4; m++){
339  for(int i = 0; i != 10; i++){
340  for(int j = 0; j != 10; j++){
341 // std::cout <<"test "<<(fObject.getValues(*channel))->getValue(0,0,0);
342  thisline[j] = fObject.getValues(*channel)->getValue(m,i,j);
343 // thisline[j] = fObject.getValues(*channel)->getValue(1,1,1);
344  }
345  HcalDbASCIIIO::dumpId (fOutput, *channel);
346  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",
347  m, thisline[0], thisline[1], thisline[2], thisline[3], thisline[4], thisline[5], thisline[6], thisline[7],
348  thisline[8], thisline[9], channel->rawId());
349  fOutput << buffer;
350  }
351  }
352  }
353 
354  return true;
355 }
int i
Definition: DBlmapReader.cc:9
void dumpId(std::ostream &fOutput, DetId id)
int j
Definition: DBlmapReader.cc:9
template<class T >
bool dumpHcalObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 192 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::dumpId(), python.multivaluedict::sort(), and makeHLTPrescaleTable::values.

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, " %8.5f %8.5f %8.5f %8.5f %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 239 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::dumpId(), python.multivaluedict::sort(), and relativeConstraints::value.

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

Definition at line 284 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::dumpId(), python.multivaluedict::sort(), and relativeConstraints::value.

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 ();
291  channel != channels.end ();
292  ++channel) {
293  const int value = fObject.getValues (*channel)->getValue ();
294  HcalDbASCIIIO::dumpId (fOutput, *channel);
295  sprintf (buffer, " %15d %10X\n",
296  value, channel->rawId ());
297  fOutput << buffer;
298  }
299  return true;
300 }
void dumpId(std::ostream &fOutput, DetId id)
template<class T >
bool HcalDbOmds::from_string ( T t,
const std::string &  s,
std::ios_base &(*)(std::ios_base &)  f 
)

Definition at line 158 of file HcalDbASCIIIO.cc.

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

Definition at line 303 of file HcalDbASCIIIO.cc.

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

303  {
304  if (!fObject) return false; //fObject = new T;
305  char buffer [1024];
306  while (fInput.getline(buffer, 1024)) {
307  if (buffer [0] == '#') continue; //ignore comment
308  std::vector <std::string> items = splitString (std::string (buffer));
309  if (items.size()==0) continue; // blank line
310  DetId firstid = HcalDbASCIIIO::getId (items);
311  fCondObject = new S(firstid.rawId());
312  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), 0, j, atof(items[j+5].c_str()));
313  for(int i = 1; i != 40; i++){
314  fInput.getline(buffer, 1024);
315  items = splitString (std::string (buffer));
316  DetId id = HcalDbASCIIIO::getId (items);
317  if(id.rawId() != firstid.rawId()) break;//throw cms::Exception("Wrong number of elements");
318  for(int j = 0; j != 10; j++) 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 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > splitString(const std::string &fLine)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int j
Definition: DBlmapReader.cc:9
Definition: DetId.h:18
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
DetId getId(const std::vector< std::string > &items)
template<class T , class S >
bool getHcalObject ( std::istream &  fInput,
T fObject,
S fCondObject 
)

Definition at line 164 of file HcalDbASCIIIO.cc.

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

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

Definition at line 213 of file HcalDbASCIIIO.cc.

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

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.size()==0) 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  fCondObject = new S(id, atof (items [4].c_str()) );
231  fObject->addValues(*fCondObject);
232  delete fCondObject;
233  // }
234  }
235  return true;
236 }
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 T , class S >
bool getHcalSingleIntObject ( std::istream &  fInput,
T fObject,
S fCondObject 
)

Definition at line 258 of file HcalDbASCIIIO.cc.

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

258  {
259  if (!fObject) return false; //fObject = new T;
260  char buffer [1024];
261  while (fInput.getline(buffer, 1024)) {
262  if (buffer [0] == '#') continue; //ignore comment
263  std::vector <std::string> items = splitString (std::string (buffer));
264  if (items.size()==0) continue; // blank line
265  if (items.size () < 5) {
266  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
267  continue;
268  }
269  DetId id = HcalDbASCIIIO::getId (items);
270 
271 // if (fObject->exists(id) )
272 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
273 // else
274 // {
275  fCondObject = new S(id, atoi (items [4].c_str()) );
276  fObject->addValues(*fCondObject);
277  delete fCondObject;
278  // }
279  }
280  return true;
281 }
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)
std::vector<std::string> splitString ( const std::string &  fLine)

Definition at line 53 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, i, query::result, dqm_diff::start, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EgHLTOfflineClient::createLooseTightTrigEff(), getHcalMatrixObject(), getHcalObject(), getHcalSingleFloatObject(), getHcalSingleIntObject(), HcalQIEManager::getHfQieTable(), HcalQIEManager::getQIETableFromFile(), ElectronEnergyCalibrator::init(), egHLT::MonElemFuncs::initTightLooseDiObjTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTightLooseTrigHists(), and egHLT::MonElemFuncs::initTightLooseTrigHistsTrigCuts().

53  {
54  std::vector <std::string> result;
55  int start = 0;
56  bool empty = true;
57  for (unsigned i = 0; i <= fLine.size (); i++) {
58  if (fLine [i] == ' ' || i == fLine.size ()) {
59  if (!empty) {
60  std::string item (fLine, start, i-start);
61  result.push_back (item);
62  empty = true;
63  }
64  start = i+1;
65  }
66  else {
67  if (empty) empty = false;
68  }
69  }
70  return result;
71 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
tuple result
Definition: query.py:137
std::vector<double> splitStringToDoubleByComma ( const std::string &  fLine)

Definition at line 113 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, i, query::result, dqm_diff::start, and AlCaHLTBitMon_QueryRunRegistry::string.

113  {
114  std::vector <double> result;
115  int start = 0;
116  bool empty = true;
117  for (unsigned i = 0; i <= fLine.size (); i++) {
118  if (fLine [i] == ',' || i == fLine.size ()) {
119  if (!empty) {
120  std::string itemString (fLine, start, i-start);
121  result.push_back (atof (itemString.c_str()) );
122  empty = true;
123  }
124  start = i+1;
125  }
126  else {
127  if (empty) empty = false;
128  }
129  }
130  return result;
131 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
tuple result
Definition: query.py:137
std::vector<float> splitStringToFloatByComma ( const std::string &  fLine)

Definition at line 93 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, i, query::result, dqm_diff::start, and AlCaHLTBitMon_QueryRunRegistry::string.

93  {
94  std::vector <float> result;
95  int start = 0;
96  bool empty = true;
97  for (unsigned i = 0; i <= fLine.size (); i++) {
98  if (fLine [i] == ',' || i == fLine.size ()) {
99  if (!empty) {
100  std::string itemString (fLine, start, i-start);
101  result.push_back (atof (itemString.c_str()) );
102  empty = true;
103  }
104  start = i+1;
105  }
106  else {
107  if (empty) empty = false;
108  }
109  }
110  return result;
111 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
tuple result
Definition: query.py:137
std::vector<unsigned int> splitStringToIntByComma ( const std::string &  fLine)

Definition at line 73 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, i, query::result, dqm_diff::start, and AlCaHLTBitMon_QueryRunRegistry::string.

73  {
74  std::vector <unsigned int> result;
75  int start = 0;
76  bool empty = true;
77  for (unsigned i = 0; i <= fLine.size (); i++) {
78  if (fLine [i] == ',' || i == fLine.size ()) {
79  if (!empty) {
80  std::string itemString (fLine, start, i-start);
81  result.push_back (atoi (itemString.c_str()) );
82  empty = true;
83  }
84  start = i+1;
85  }
86  else {
87  if (empty) empty = false;
88  }
89  }
90  return result;
91 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
tuple result
Definition: query.py:137