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< unsigned int > splitStringToIntByComma (const std::string &fLine)
 

Function Documentation

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

Definition at line 280 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::dumpId(), i, j, m, and python.multivaluedict::sort().

280  {
281  char buffer [1024];
282  sprintf (buffer, "# %5s %5s %5s %5s %5s %8s %8s %8s %8s %8s %8s %8s %8s %8s %8s %10s\n",
283  "eta", "phi", "dep", "det", "capid","c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "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 ();
288  channel != channels.end ();
289  channel++) {
290  float thisline[10];
291  for(int m = 0; m != 4; m++){
292  for(int i = 0; i != 10; i++){
293  for(int j = 0; j != 10; j++){
294 // std::cout <<"test "<<(fObject.getValues(*channel))->getValue(0,0,0);
295  thisline[j] = fObject.getValues(*channel)->getValue(m,i,j);
296 // thisline[j] = fObject.getValues(*channel)->getValue(1,1,1);
297  }
298  HcalDbASCIIIO::dumpId (fOutput, *channel);
299  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",
300  m, thisline[0], thisline[1], thisline[2], thisline[3], thisline[4], thisline[5], thisline[6], thisline[7],
301  thisline[8], thisline[9], channel->rawId());
302  fOutput << buffer;
303  }
304  }
305  }
306 
307  return true;
308 }
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 145 of file HcalDbASCIIIO.cc.

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

145  {
146  char buffer [1024];
147  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n", "eta", "phi", "dep", "det", "cap0", "cap1", "cap2", "cap3", "DetId");
148  fOutput << buffer;
149  std::vector<DetId> channels = fObject.getAllChannels ();
150  std::sort (channels.begin(), channels.end(), DetIdLess ());
151  for (std::vector<DetId>::iterator channel = channels.begin ();
152  channel != channels.end ();
153  channel++) {
154  const float* values = fObject.getValues (*channel)->getValues ();
155  if (values) {
156  HcalDbASCIIIO::dumpId (fOutput, *channel);
157  sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %10X\n",
158  values[0], values[1], values[2], values[3], channel->rawId ());
159  fOutput << buffer;
160  }
161  }
162  return true;
163 }
void dumpId(std::ostream &fOutput, DetId id)
template<class T >
bool dumpHcalSingleFloatObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 192 of file HcalDbASCIIIO.cc.

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

192  {
193  char buffer [1024];
194  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "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 value = fObject.getValues (*channel)->getValue ();
202  HcalDbASCIIIO::dumpId (fOutput, *channel);
203  sprintf (buffer, " %8.5f %10X\n",
204  value, channel->rawId ());
205  fOutput << buffer;
206  }
207  return true;
208 }
void dumpId(std::ostream &fOutput, DetId id)
template<class T >
bool dumpHcalSingleIntObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 237 of file HcalDbASCIIIO.cc.

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

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

111  {
112  std::istringstream iss(s);
113  return !(iss >> f >> t).fail();
114 }
double f[11][100]
string s
Definition: asciidump.py:422
template<class T , class S >
bool getHcalMatrixObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 256 of file HcalDbASCIIIO.cc.

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

256  {
257  if (!fObject) fObject = new T;
258  char buffer [1024];
259  while (fInput.getline(buffer, 1024)) {
260  if (buffer [0] == '#') continue; //ignore comment
261  std::vector <std::string> items = splitString (std::string (buffer));
262  if (items.size()==0) continue; // blank line
263  DetId firstid = HcalDbASCIIIO::getId (items);
264  fCondObject = new S(firstid.rawId());
265  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), 0, j, atof(items[j+5].c_str()));
266  for(int i = 1; i != 40; i++){
267  fInput.getline(buffer, 1024);
268  items = splitString (std::string (buffer));
269  DetId id = HcalDbASCIIIO::getId (items);
270  if(id.rawId() != firstid.rawId()) break;//throw cms::Exception("Wrong number of elements");
271  for(int j = 0; j != 10; j++) fCondObject->setValue(atoi(items[4].c_str()), i%10, j, atof(items[j+5].c_str()));
272  }
273  fObject->addValues(*fCondObject);
274  delete fCondObject;
275  }
276  return true;
277 }
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:45
int j
Definition: DBlmapReader.cc:9
Definition: DetId.h:20
DetId getId(const std::vector< std::string > &items)
long double T
template<class T , class S >
bool getHcalObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 117 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::getId(), and splitString().

117  {
118  if (!fObject) fObject = new T;
119  char buffer [1024];
120  while (fInput.getline(buffer, 1024)) {
121  if (buffer [0] == '#') continue; //ignore comment
122  std::vector <std::string> items = splitString (std::string (buffer));
123  if (items.size()==0) continue; // blank line
124  if (items.size () < 8) {
125  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
126  continue;
127  }
128  DetId id = HcalDbASCIIIO::getId (items);
129 
130 // if (fObject->exists(id) )
131 // edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
132 // else
133 // {
134  fCondObject = new S(id, atof (items [4].c_str()), atof (items [5].c_str()),
135  atof (items [6].c_str()), atof (items [7].c_str()));
136  fObject->addValues(*fCondObject);
137  delete fCondObject;
138  // }
139  }
140 
141  return true;
142 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:20
DetId getId(const std::vector< std::string > &items)
long double T
template<class T , class S >
bool getHcalSingleFloatObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 166 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::getId(), and splitString().

166  {
167  if (!fObject) 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.size()==0) continue; // blank line
173  if (items.size () < 5) {
174  edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 5 items: eta, phi, depth, subdet, value" << 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  fCondObject = new S(id, atof (items [4].c_str()) );
184  fObject->addValues(*fCondObject);
185  delete fCondObject;
186  // }
187  }
188  return true;
189 }
std::vector< std::string > splitString(const std::string &fLine)
Definition: DetId.h:20
DetId getId(const std::vector< std::string > &items)
long double T
template<class T , class S >
bool getHcalSingleIntObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 211 of file HcalDbASCIIIO.cc.

References HcalDbASCIIIO::getId(), and splitString().

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

Definition at line 55 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, i, and query::result.

Referenced by EgHLTOfflineClient::createLooseTightTrigEff(), getHcalMatrixObject(), getHcalObject(), getHcalSingleFloatObject(), getHcalSingleIntObject(), HcalQIEManager::getHfQieTable(), HcalQIEManager::getQIETableFromFile(), 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  }
68  else {
69  if (empty) empty = false;
70  }
71  }
72  return result;
73 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
std::vector<unsigned int> splitStringToIntByComma ( const std::string &  fLine)

Definition at line 75 of file HcalDbASCIIIO.cc.

References relativeConstraints::empty, i, and query::result.

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 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137