CMS 3D CMS Logo

Static Public Member Functions

EcalClusterCrackCorrXMLTranslator Class Reference

#include <EcalClusterCrackCorrXMLTranslator.h>

List of all members.

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalFunParams &record)
static int readXML (const std::string &filename, EcalCondHeader &header, EcalFunParams &record)
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalFunParams &record)

Detailed Description

Translates a EcalFloatClusterCrackCorr record to XML and vice versa

Author:
Version:
Id:
EcalClusterCrackCorrXMLTranslator.h,v 1.1 2011/11/10 17:50:54 fay Exp
Date:
October 2011

Definition at line 20 of file EcalClusterCrackCorrXMLTranslator.h.


Member Function Documentation

std::string EcalClusterCrackCorrXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalFunParams record 
) [static]

Definition at line 56 of file EcalClusterCrackCorrXMLTranslator.cc.

References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), dbtoconf::out, EcalFunParams::params(), dbtoconf::root, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), xuti::Value_tag(), xuti::writeHeader(), and xuti::WriteNodeWithValue().

                                                   {
  
  XMLPlatformUtils::Initialize();
  
  DOMImplementation*  impl =
    DOMImplementationRegistry::getDOMImplementation(fromNative("LS").c_str());
  
  DOMWriter* writer =
    static_cast<DOMImplementationLS*>(impl)->createDOMWriter( );
  writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
  
  DOMDocumentType* doctype = 
    impl->createDocumentType( fromNative("XML").c_str(), 0, 0 );
  const  std::string EcalClusterCrackCorr_tag("EcalClusterCrackCorr");
  DOMDocument *    doc = 
    impl->createDocument( 0, fromNative(EcalClusterCrackCorr_tag).c_str(), doctype );
  
  
  doc->setEncoding(fromNative("UTF-8").c_str() );
  doc->setStandalone(true);
  doc->setVersion(fromNative("1.0").c_str() );
    
  DOMElement* root = doc->getDocumentElement();
  xuti::writeHeader(root, header);

  const std::string ECCC_tag[4] = {"IPCloseEtaSide", "IPFarEtaSide",
                                   "IPClosePhiSide", "IPFarPhiSide"};;
  int num = 0;
  for ( EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it ) {
    int side = num /5;
    int par = num%5;
    std::string s;
    std::stringstream out;
    out << par;
    s = out.str();
    std::string sw = ECCC_tag[side] + "_" + s;
    DOMElement* ECCC = 
      root->getOwnerDocument()->createElement( fromNative(sw).c_str());
    root->appendChild(ECCC);

    WriteNodeWithValue(ECCC,Value_tag,*it);
    num++;
  } 
  
  std::string dump= toNative(writer->writeToString(*root));
  doc->release();
  return dump;
}
static int EcalClusterCrackCorrXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFunParams record 
) [static]
int EcalClusterCrackCorrXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFunParams record 
) [static]

Definition at line 108 of file EcalClusterCrackCorrXMLTranslator.cc.

References EcalCondTools::dumpXML(), and dbtoconf::out.

                                           {

  std::fstream fs(filename.c_str(),ios::out);
  fs<< dumpXML(header,record);
  return 0;  
}