CMS 3D CMS Logo

Namespaces | Functions
HcalDbASCIIIO.cc File Reference
#include <vector>
#include <string>
#include <cstdio>
#include <sstream>
#include <memory>
#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)
 
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 328 of file HcalDbASCIIIO.cc.

References HcalCalibrationQIEData::addCoder(), HcalQIEData::addCoder(), HcalCondObjectContainer< Item >::addValues(), stringResolutionProvider_cfi::bin, HcalMCParam::binOfMaximum(), edmScanValgrind::buffer, HcalRecoParam::correctForLeadingEdge(), HcalRecoParam::correctForPhaseContainment(), HcalRecoParam::correctForTimeslew(), HcalRecoParam::correctionPhaseNS(), HcalRecoParam::correctTiming(), dumpHcalObject(), dumpHcalSingleFloatObject(), dumpHcalSingleIntObject(), CastorDbASCIIIO::dumpId(), HcalDbASCIIIO::dumpId(), HcalDbASCIIIO::dumpIdShort(), HcalDbASCIIIO::dumpObject(), HcalRecoParam::firstAuxTS(), HcalRecoParam::firstSample(), HcalL1TriggerObjects::getAlgoString(), HcalCondObjectContainer< Item >::getAllChannels(), HcalCalibrationQIEData::getCoder(), HcalQIEData::getCoder(), HcalL1TriggerObject::getFlag(), getHcalObject(), getHcalSingleFloatObject(), getHcalSingleIntObject(), getId(), HcalDbASCIIIO::getId(), HcalDbASCIIIO::getObject(), HcalL1TriggerObject::getPedestal(), HcalL1TriggerObject::getRespGain(), HcalPedestalWidth::getSigma(), HcalL1TriggerObjects::getTagString(), HcalChannelStatus::getValue(), HcalPedestal::getValues(), HcalCondObjectContainer< Item >::getValues(), mps_fire::i, diffTreeTool::index, HcalPedestalWidths::isADC(), HcalPedestals::isADC(), HcalGenericDetId::isHcalZDCDetId(), HcalRecoParam::leakCorrectionID(), funct::m, HcalCalibrationQIECoder::minCharges(), HcalTimingParam::nhits(), HcalRecoParam::noiseFlaggingID(), HcalLongRecoParam::noiseTS(), HcalQIECoder::offset(), HcalRecoParam::packingScheme(), HcalMCParam::packingScheme(), HcalRecoParam::param1(), HcalMCParam::param1(), HcalRecoParam::param2(), HcalTimingParam::phase(), hcalRecAlgoESProd_cfi::phase, HcalRecoParam::pileupCleaningID(), HcalRecoParam::pulseShapeID(), HcalTimingParam::rms(), HcalRecoParam::samplesToAdd(), HcalL1TriggerObjects::setAlgoString(), HcalCalibrationQIECoder::setMinCharges(), HcalQIECoder::setOffset(), HcalPedestalWidth::setSigma(), HcalQIECoder::setSlope(), HcalL1TriggerObjects::setTagString(), HcalPedestalWidths::setUnitADC(), HcalPedestals::setUnitADC(), HcalMCParam::signalShape(), HcalLongRecoParam::signalTS(), HcalQIECoder::slope(), HcalCalibrationQIEData::sort(), HcalQIEData::sort(), HcalRecoParam::specialCaseID(), splitString(), splitStringToIntByComma(), AlCaHLTBitMon_QueryRunRegistry::string, HcalMCParam::syncPhase(), HcalMCParam::timePhase(), HcalRecoParam::timeslewCorrectionID(), HcalMCParam::timeSmearing(), HcalRecoParam::useLeakCorrection(), and MuonErrorMatrixValues_cff::values.

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

Definition at line 193 of file HcalDbASCIIIO.cc.

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

Referenced by dumpHcalMatrixObject().

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

Definition at line 240 of file HcalDbASCIIIO.cc.

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

Referenced by dumpHcalMatrixObject().

240  {
241  char buffer [1024];
242  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
243  fOutput << buffer;
244  std::vector<DetId> channels = fObject.getAllChannels ();
245  std::sort (channels.begin(), channels.end(), DetIdLess ());
246  for (std::vector<DetId>::iterator channel = channels.begin ();
247  channel != channels.end ();
248  ++channel) {
249  const float value = fObject.getValues (*channel)->getValue ();
250  HcalDbASCIIIO::dumpId (fOutput, *channel);
251  sprintf (buffer, " %8.5f %10X\n",
252  value, channel->rawId ());
253  fOutput << buffer;
254  }
255  return true;
256 }
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 285 of file HcalDbASCIIIO.cc.

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

Referenced by dumpHcalMatrixObject().

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

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

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

Definition at line 304 of file HcalDbASCIIIO.cc.

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

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

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

Referenced by dumpHcalMatrixObject().

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

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

Referenced by dumpHcalMatrixObject().

214  {
215  if (!fObject) return false; //fObject = new T;
216  char buffer [1024];
217  while (fInput.getline(buffer, 1024)) {
218  if (buffer [0] == '#') continue; //ignore comment
219  std::vector <std::string> items = splitString (std::string (buffer));
220  if (items.empty()) continue; // blank line
221  if (items.size () < 5) {
222  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, value" << std::endl;
223  continue;
224  }
225  DetId id = HcalDbASCIIIO::getId (items);
226 
227 // if (fObject->exists(id) )
228 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
229 // else
230 // {
231  fCondObject = new S(id, atof (items [4].c_str()) );
232  fObject->addValues(*fCondObject);
233  delete fCondObject;
234  // }
235  }
236  return true;
237 }
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 259 of file HcalDbASCIIIO.cc.

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

Referenced by dumpHcalMatrixObject().

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

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

Referenced by EgHLTOfflineClient::createLooseTightTrigEff(), HcalDbASCIIIO::createObject< HcalDcsMap >(), HcalDbASCIIIO::createObject< HcalElectronicsMap >(), HcalDbASCIIIO::createObject< HcalFrontEndMap >(), HcalDbASCIIIO::createObject< HcalSiPMCharacteristics >(), dumpHcalMatrixObject(), ElectronEnergyCalibrator::ElectronEnergyCalibrator(), getHcalMatrixObject(), getHcalObject(), getHcalSingleFloatObject(), getHcalSingleIntObject(), HcalQIEManager::getHfQieTable(), HcalQIEManager::getQIETableFromFile(), egHLT::MonElemFuncs::initTightLooseDiObjTrigHistsTrigCuts(), egHLT::MonElemFuncs::initTightLooseTrigHists(), and egHLT::MonElemFuncs::initTightLooseTrigHistsTrigCuts().

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

Definition at line 114 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 >().

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

Definition at line 94 of file HcalDbASCIIIO.cc.

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

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

Definition at line 74 of file HcalDbASCIIIO.cc.

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

Referenced by dumpHcalMatrixObject().

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