CMS 3D CMS Logo

Static Public Member Functions

EcalClusterEnergyCorrectionXMLTranslator Class Reference

#include <EcalClusterEnergyCorrectionXMLTranslator.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 EcalClusterEnergyCorrection record to XML and vice versa

Author:
Version:
Id:
EcalClusterEnergyCorrectionXMLTranslator.h,v 1.1 2011/11/10 17:53:11 fay Exp
Date:
October 2011

Definition at line 21 of file EcalClusterEnergyCorrectionXMLTranslator.h.


Member Function Documentation

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

Definition at line 56 of file EcalClusterEnergyCorrectionXMLTranslator.cc.

References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EcalFunParams::params(), dbtoconf::root, 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 EcalClusterEnergyCorrection_tag("EcalClusterEnergyCorrection");
  DOMDocument *    doc = 
    impl->createDocument( 0, fromNative(EcalClusterEnergyCorrection_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 ECEC_tag("ClusterEnergy");
  for ( EcalFunctionParameters::const_iterator it = record.params().begin(); it != record.params().end(); ++it ) {
    DOMElement* ECEC = 
      root->getOwnerDocument()->createElement( fromNative(ECEC_tag).c_str());
    root->appendChild(ECEC);

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

Definition at line 99 of file EcalClusterEnergyCorrectionXMLTranslator.cc.

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

                                           {

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