CMS 3D CMS Logo

HcalDbASCIIIO.cc File Reference

#include <vector>
#include <string>
#include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
#include "DataFormats/HcalDetId/interface/HcalElectronicsId.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 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)
void dumpId (std::ostream &fOutput, DetId id)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalElectronicsMap &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalCalibrationQIEData &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalQIEData &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalPedestalWidths &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalChannelQuality &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalRespCorrs &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalGainWidths &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalGains &fObject)
bool HcalDbASCIIIO::dumpObject (std::ostream &fOutput, const HcalPedestals &fObject)
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)
DetId getId (const std::vector< std::string > &items)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalElectronicsMap *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalCalibrationQIEData *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalQIEData *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalPedestalWidths *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalChannelQuality *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalRespCorrs *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalGainWidths *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalGains *fObject)
bool HcalDbASCIIIO::getObject (std::istream &fInput, HcalPedestals *fObject)
std::vector< std::string > splitString (const std::string &fLine)


Function Documentation

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

Definition at line 112 of file HcalDbASCIIIO.cc.

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

00112                                                             {
00113   char buffer [1024];
00114   sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n", "eta", "phi", "dep", "det", "cap0", "cap1", "cap2", "cap3", "DetId");
00115   fOutput << buffer;
00116   std::vector<DetId> channels = fObject.getAllChannels ();
00117   std::sort (channels.begin(), channels.end(), DetIdLess ());
00118   for (std::vector<DetId>::iterator channel = channels.begin ();
00119        channel !=  channels.end ();
00120        channel++) {
00121     const float* values = fObject.getValues (*channel)->getValues ();
00122     if (values) {
00123       dumpId (fOutput, *channel);
00124       sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %10X\n",
00125                values[0], values[1], values[2], values[3], channel->rawId ());
00126       fOutput << buffer;
00127     }
00128   }
00129   return true;
00130 }

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

Definition at line 159 of file HcalDbASCIIIO.cc.

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

00159                                                                        {
00160   char buffer [1024];
00161   sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
00162   fOutput << buffer;
00163   std::vector<DetId> channels = fObject.getAllChannels ();
00164   std::sort (channels.begin(), channels.end(), DetIdLess ());
00165   for (std::vector<DetId>::iterator channel = channels.begin ();
00166        channel !=  channels.end ();
00167        channel++) {
00168     const float value = fObject.getValues (*channel)->getValue ();
00169     dumpId (fOutput, *channel);
00170     sprintf (buffer, " %8.5f %10X\n",
00171              value, channel->rawId ());
00172     fOutput << buffer;
00173   }
00174   return true;
00175 }

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

Definition at line 204 of file HcalDbASCIIIO.cc.

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

00204                                                                      {
00205   char buffer [1024];
00206   sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
00207   fOutput << buffer;
00208   std::vector<DetId> channels = fObject.getAllChannels ();
00209   std::sort (channels.begin(), channels.end(), DetIdLess ());
00210   for (std::vector<DetId>::iterator channel = channels.begin ();
00211        channel !=  channels.end ();
00212        channel++) {
00213     const int value = fObject.getValues (*channel)->getValue ();
00214     dumpId (fOutput, *channel);
00215     sprintf (buffer, " %15d %10X\n",
00216              value, channel->rawId ());
00217     fOutput << buffer;
00218   }
00219   return true;
00220 }

void dumpId ( std::ostream &  fOutput,
DetId  id 
)

Definition at line 75 of file HcalDbASCIIIO.cc.

References HcalText2DetIdConverter::getField1(), HcalText2DetIdConverter::getField2(), HcalText2DetIdConverter::getField3(), and HcalText2DetIdConverter::getFlavor().

00075                                             {
00076   HcalText2DetIdConverter converter (id);
00077   char buffer [1024];
00078   sprintf (buffer, "  %15s %15s %15s %15s",
00079            converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());  
00080   fOutput << buffer;
00081 }

template<class T, class S>
bool getHcalObject ( std::istream &  fInput,
T *  fObject,
S *  fCondObject 
) [inline]

Definition at line 84 of file HcalDbASCIIIO.cc.

References lat::endl(), getId(), and splitString().

00084                                                                     {
00085   if (!fObject) fObject = new T;
00086   char buffer [1024];
00087   while (fInput.getline(buffer, 1024)) {
00088     if (buffer [0] == '#') continue; //ignore comment
00089     std::vector <std::string> items = splitString (std::string (buffer));
00090     if (items.size()==0) continue; // blank line
00091     if (items.size () < 8) {
00092       edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
00093       continue;
00094     }
00095     DetId id = getId (items);
00096     
00097 //    if (fObject->exists(id) )
00098 //      edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
00099 //    else
00100 //      {
00101         fCondObject = new S(id, atof (items [4].c_str()), atof (items [5].c_str()), 
00102                            atof (items [6].c_str()), atof (items [7].c_str()));
00103         fObject->addValues(*fCondObject);
00104         delete fCondObject;
00105         //      }
00106   }
00107 
00108   return true;
00109 }

template<class T, class S>
bool getHcalSingleFloatObject ( std::istream &  fInput,
T *  fObject,
S *  fCondObject 
) [inline]

Definition at line 133 of file HcalDbASCIIIO.cc.

References lat::endl(), getId(), and splitString().

00133                                                                                {
00134   if (!fObject) fObject = new T;
00135   char buffer [1024];
00136   while (fInput.getline(buffer, 1024)) {
00137     if (buffer [0] == '#') continue; //ignore comment
00138     std::vector <std::string> items = splitString (std::string (buffer));
00139     if (items.size()==0) continue; // blank line
00140     if (items.size () < 5) {
00141       edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, value" << std::endl;
00142       continue;
00143     }
00144     DetId id = getId (items);
00145     
00146 //    if (fObject->exists(id) )
00147 //      edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
00148 //    else
00149 //      {
00150         fCondObject = new S(id, atof (items [4].c_str()) );
00151         fObject->addValues(*fCondObject);
00152         delete fCondObject;
00153         //      }
00154   }
00155   return true;
00156 }

template<class T, class S>
bool getHcalSingleIntObject ( std::istream &  fInput,
T *  fObject,
S *  fCondObject 
) [inline]

Definition at line 178 of file HcalDbASCIIIO.cc.

References lat::endl(), getId(), and splitString().

00178                                                                              {
00179   if (!fObject) fObject = new T;
00180   char buffer [1024];
00181   while (fInput.getline(buffer, 1024)) {
00182     if (buffer [0] == '#') continue; //ignore comment
00183     std::vector <std::string> items = splitString (std::string (buffer));
00184     if (items.size()==0) continue; // blank line
00185     if (items.size () < 5) {
00186       edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, value" << std::endl;
00187       continue;
00188     }
00189     DetId id = getId (items);
00190     
00191 //    if (fObject->exists(id) )
00192 //      edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
00193 //    else
00194 //      {
00195         fCondObject = new S(id, atoi (items [4].c_str()) );
00196         fObject->addValues(*fCondObject);
00197         delete fCondObject;
00198         //      }
00199   }
00200   return true;
00201 }

DetId getId ( const std::vector< std::string > &  items  ) 

Definition at line 70 of file HcalDbASCIIIO.cc.

References HcalText2DetIdConverter::getId().

00070                                                   {
00071   HcalText2DetIdConverter converter (items [3], items [0], items [1], items [2]);
00072   return converter.getId ();
00073 }

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

Definition at line 50 of file HcalDbASCIIIO.cc.

References empty, i, and HLT_VtxMuL3::result.

00050                                                            {
00051   std::vector <std::string> result;
00052   int start = 0;
00053   bool empty = true;
00054   for (unsigned i = 0; i <= fLine.size (); i++) {
00055     if (fLine [i] == ' ' || i == fLine.size ()) {
00056       if (!empty) {
00057         std::string item (fLine, start, i-start);
00058         result.push_back (item);
00059         empty = true;
00060       }
00061       start = i+1;
00062     }
00063     else {
00064       if (empty) empty = false;
00065     }
00066   }
00067   return result;
00068 }


Generated on Tue Jun 9 17:51:03 2009 for CMSSW by  doxygen 1.5.4