CMS 3D CMS Logo

Classes | Functions

CastorDbASCIIIO Namespace Reference

Classes

class  CastorElectronicsIdLess
class  DetIdLess

Functions

template<class T >
bool dumpCastorObject (std::ostream &fOutput, const T &fObject)
template<class T >
bool dumpCastorSingleFloatObject (std::ostream &fOutput, const T &fObject)
template<class T >
bool dumpCastorSingleIntObject (std::ostream &fOutput, const T &fObject)
void dumpId (std::ostream &fOutput, DetId id)
bool dumpObject (std::ostream &fOutput, const CastorPedestalWidths &fObject)
bool dumpObject (std::ostream &fOutput, const CastorChannelQuality &fObject)
bool dumpObject (std::ostream &fOutput, const CastorGainWidths &fObject)
bool dumpObject (std::ostream &fOutput, const CastorQIEData &fObject)
bool dumpObject (std::ostream &fOutput, const CastorPedestals &fObject)
bool dumpObject (std::ostream &fOutput, const CastorGains &fObject)
bool dumpObject (std::ostream &fOutput, const CastorCalibrationQIEData &fObject)
bool dumpObject (std::ostream &fOutput, const CastorElectronicsMap &fObject)
template<class T , class S >
bool getCastorObject (std::istream &fInput, T *fObject, S *fCondObject)
template<class T , class S >
bool getCastorSingleFloatObject (std::istream &fInput, T *fObject, S *fCondObject)
template<class T , class S >
bool getCastorSingleIntObject (std::istream &fInput, T *fObject, S *fCondObject)
DetId getId (const std::vector< std::string > &items)
bool getObject (std::istream &fInput, CastorCalibrationQIEData *fObject)
bool getObject (std::istream &fInput, CastorElectronicsMap *fObject)
bool getObject (std::istream &fInput, CastorGains *fObject)
bool getObject (std::istream &fInput, CastorPedestals *fObject)
bool getObject (std::istream &fInput, CastorPedestalWidths *fObject)
bool getObject (std::istream &fInput, CastorQIEData *fObject)
bool getObject (std::istream &fInput, CastorGainWidths *fObject)
bool getObject (std::istream &fInput, CastorChannelQuality *fObject)
std::vector< std::string > splitString (const std::string &fLine)

Function Documentation

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

Definition at line 111 of file CastorDbASCIIIO.cc.

References dumpId(), and makeHLTPrescaleTable::values.

                                                              {
  char buffer [1024];
  sprintf (buffer, "# %15s %15s %15s %15s %8s %8s %8s %8s %10s\n", "eta", "phi", "dep", "det", "cap0", "cap1", "cap2", "cap3", "DetId");
  fOutput << buffer;
  std::vector<DetId> channels = fObject.getAllChannels ();
  //std::sort (channels.begin(), channels.end(), DetIdLess ());
  for (std::vector<DetId>::iterator channel = channels.begin ();
       channel !=  channels.end ();
       channel++) {
    const float* values = fObject.getValues (*channel)->getValues ();
    if (values) {
      dumpId (fOutput, *channel);
      sprintf (buffer, " %8.5f %8.5f %8.5f %8.5f %10X\n",
               values[0], values[1], values[2], values[3], channel->rawId ());
      fOutput << buffer;
    }
  }
  return true;
}
template<class T >
bool CastorDbASCIIIO::dumpCastorSingleFloatObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 158 of file CastorDbASCIIIO.cc.

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

                                                                         {
  char buffer [1024];
  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
  fOutput << buffer;
  std::vector<DetId> channels = fObject.getAllChannels ();
  std::sort (channels.begin(), channels.end(), DetIdLess ());
  for (std::vector<DetId>::iterator channel = channels.begin ();
       channel !=  channels.end ();
       channel++) {
    const float value = fObject.getValues (*channel)->getValue ();
    dumpId (fOutput, *channel);
    sprintf (buffer, " %8.5f %10X\n",
             value, channel->rawId ());
    fOutput << buffer;
  }
  return true;
}
template<class T >
bool CastorDbASCIIIO::dumpCastorSingleIntObject ( std::ostream &  fOutput,
const T fObject 
)

Definition at line 203 of file CastorDbASCIIIO.cc.

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

                                                                       {
  char buffer [1024];
  sprintf (buffer, "# %15s %15s %15s %15s %8s %10s\n", "eta", "phi", "dep", "det", "value", "DetId");
  fOutput << buffer;
  std::vector<DetId> channels = fObject.getAllChannels ();
  std::sort (channels.begin(), channels.end(), DetIdLess ());
  for (std::vector<DetId>::iterator channel = channels.begin ();
       channel !=  channels.end ();
       channel++) {
    const int value = fObject.getValues (*channel)->getValue ();
    dumpId (fOutput, *channel);
    sprintf (buffer, " %15d %10X\n",
             value, channel->rawId ());
    fOutput << buffer;
  }
  return true;
}
void CastorDbASCIIIO::dumpId ( std::ostream &  fOutput,
DetId  id 
)

Definition at line 74 of file CastorDbASCIIIO.cc.

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

Referenced by dumpCastorObject(), dumpCastorSingleFloatObject(), dumpCastorSingleIntObject(), dumpHcalMatrixObject(), dumpHcalObject(), dumpHcalSingleFloatObject(), and dumpHcalSingleIntObject().

                                            {
  CastorText2DetIdConverter converter (id);
  char buffer [1024];
  sprintf (buffer, "  %15s %15s %15s %15s",
           converter.getField1 ().c_str (), converter.getField2 ().c_str (), converter.getField3 ().c_str (),converter.getFlavor ().c_str ());  
  fOutput << buffer;
}
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorPedestalWidths fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorChannelQuality fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorGainWidths fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorQIEData fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorPedestals fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorGains fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorCalibrationQIEData fObject 
)
bool CastorDbASCIIIO::dumpObject ( std::ostream &  fOutput,
const CastorElectronicsMap fObject 
)
template<class T , class S >
bool CastorDbASCIIIO::getCastorObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 83 of file CastorDbASCIIIO.cc.

References getId(), and splitString().

                                                                      {
  if (!fObject) fObject = new T;
  char buffer [1024];
  while (fInput.getline(buffer, 1024)) {
    if (buffer [0] == '#') continue; //ignore comment
    std::vector <std::string> items = splitString (std::string (buffer));
    if (items.size()==0) continue; // blank line
    if (items.size () < 8) {
      edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, 4x values" << std::endl;
      continue;
    }
    DetId id = getId (items);
    
//    if (fObject->exists(id) )
//      edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
//    else
//      {
        fCondObject = new S(id, atof (items [4].c_str()), atof (items [5].c_str()), 
                           atof (items [6].c_str()), atof (items [7].c_str()));
        fObject->addValues(*fCondObject);
        delete fCondObject;
        //      }
  }

  return true;
}
template<class T , class S >
bool CastorDbASCIIIO::getCastorSingleFloatObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 132 of file CastorDbASCIIIO.cc.

References getId(), and splitString().

                                                                                 {
  if (!fObject) fObject = new T;
  char buffer [1024];
  while (fInput.getline(buffer, 1024)) {
    if (buffer [0] == '#') continue; //ignore comment
    std::vector <std::string> items = splitString (std::string (buffer));
    if (items.size()==0) continue; // blank line
    if (items.size () < 5) {
      edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, value" << std::endl;
      continue;
    }
    DetId id = getId (items);
    
//    if (fObject->exists(id) )
//      edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
//    else
//      {
        fCondObject = new S(id, atof (items [4].c_str()) );
        fObject->addValues(*fCondObject);
        delete fCondObject;
        //      }
  }
  return true;
}
template<class T , class S >
bool CastorDbASCIIIO::getCastorSingleIntObject ( std::istream &  fInput,
T fObject,
S *  fCondObject 
)

Definition at line 177 of file CastorDbASCIIIO.cc.

References getId(), and splitString().

                                                                               {
  if (!fObject) fObject = new T;
  char buffer [1024];
  while (fInput.getline(buffer, 1024)) {
    if (buffer [0] == '#') continue; //ignore comment
    std::vector <std::string> items = splitString (std::string (buffer));
    if (items.size()==0) continue; // blank line
    if (items.size () < 5) {
      edm::LogWarning("Format Error") << "Bad line: " << buffer << "\n line must contain 8 items: eta, phi, depth, subdet, value" << std::endl;
      continue;
    }
    DetId id = getId (items);
    
//    if (fObject->exists(id) )
//      edm::LogWarning("Redefining Channel") << "line: " << buffer << "\n attempts to redefine data. Ignored" << std::endl;
//    else
//      {
        fCondObject = new S(id, atoi (items [4].c_str()) );
        fObject->addValues(*fCondObject);
        delete fCondObject;
        //      }
  }
  return true;
}
DetId CastorDbASCIIIO::getId ( const std::vector< std::string > &  items)

Definition at line 69 of file CastorDbASCIIIO.cc.

References CastorText2DetIdConverter::getId().

Referenced by getCastorObject(), getCastorSingleFloatObject(), getCastorSingleIntObject(), getHcalMatrixObject(), getHcalObject(), getHcalSingleFloatObject(), and getHcalSingleIntObject().

                                                  {
  CastorText2DetIdConverter converter (items [3], items [0], items [1], items [2]);
  return converter.getId ();
}
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorCalibrationQIEData fObject 
)
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorElectronicsMap fObject 
)
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorGains fObject 
)
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorPedestals fObject 
)

Referenced by produce_impl().

bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorPedestalWidths fObject 
)
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorQIEData fObject 
)
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorGainWidths fObject 
)
bool CastorDbASCIIIO::getObject ( std::istream &  fInput,
CastorChannelQuality fObject 
)
std::vector<std::string> CastorDbASCIIIO::splitString ( const std::string &  fLine)

Definition at line 49 of file CastorDbASCIIIO.cc.

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

Referenced by getCastorObject(), getCastorSingleFloatObject(), and getCastorSingleIntObject().

                                                           {
  std::vector <std::string> result;
  int start = 0;
  bool empty = true;
  for (unsigned i = 0; i <= fLine.size (); i++) {
    if (fLine [i] == ' ' || i == fLine.size ()) {
      if (!empty) {
        std::string item (fLine, start, i-start);
        result.push_back (item);
        empty = true;
      }
      start = i+1;
    }
    else {
      if (empty) empty = false;
    }
  }
  return result;
}