CMS 3D CMS Logo

Static Public Member Functions

EcalTimeOffsetXMLTranslator Class Reference

#include <EcalTimeOffsetXMLTranslator.h>

List of all members.

Static Public Member Functions

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

Detailed Description

Definition at line 25 of file EcalTimeOffsetXMLTranslator.h.


Member Function Documentation

std::string EcalTimeOffsetXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalTimeOffsetConstant record 
) [static]

Definition at line 81 of file EcalTimeOffsetXMLTranslator.cc.

References xuti::Barrel_tag(), asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::Endcap_tag(), xuti::fromNative(), EcalTimeOffsetConstant::getEBValue(), EcalTimeOffsetConstant::getEEValue(), dbtoconf::root, xuti::TimeOffsetConstant_tag(), xuti::toNative(), 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 );
  DOMDocument *    doc = 
    impl->createDocument( 0, fromNative(TimeOffsetConstant_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);
   
  xuti::WriteNodeWithValue(root,Barrel_tag,record.getEBValue());
  xuti::WriteNodeWithValue(root,Endcap_tag,record.getEEValue());

  std::string dump= toNative(writer->writeToString(*root)); 
  doc->release();

  //   XMLPlatformUtils::Terminate();

  return dump;
}
int EcalTimeOffsetXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalTimeOffsetConstant record 
) [static]

Definition at line 23 of file EcalTimeOffsetXMLTranslator.cc.

References xuti::Barrel_tag(), gather_cfg::cout, xuti::Endcap_tag(), xuti::getChildNode(), xuti::GetNodeData(), geometryXMLtoCSV::parser, xuti::readHeader(), EcalTimeOffsetConstant::setEBValue(), and EcalTimeOffsetConstant::setEEValue().

                                                                       {

 
  XMLPlatformUtils::Initialize();

  XercesDOMParser* parser = new XercesDOMParser;
  parser->setValidationScheme( XercesDOMParser::Val_Never );
  parser->setDoNamespaces( false );
  parser->setDoSchema( false );
  
  parser->parse(filename.c_str());

  DOMDocument* xmlDoc = parser->getDocument();
  if (!xmlDoc) {
    std::cout << "EcalTimeOffsetXMLTranslator::Error parsing document" << std::endl;
    return -1;
  }
  
  // Get the top-level element
  DOMElement* elementRoot = xmlDoc->getDocumentElement();

  xuti::readHeader(elementRoot, header);

  
  DOMNode * barrelnode = xuti::getChildNode(elementRoot,Barrel_tag);
  DOMNode * endcapnode = xuti::getChildNode(elementRoot,Endcap_tag);
  
  double barrelvalue=0;
  double endcapvalue=0;

  xuti::GetNodeData(barrelnode,barrelvalue);
  xuti::GetNodeData(endcapnode,endcapvalue);

  record.setEBValue(barrelvalue); 
  record.setEEValue(endcapvalue);


  delete parser;
  XMLPlatformUtils::Terminate();
  return 0;

}
int EcalTimeOffsetXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTimeOffsetConstant record 
) [static]

Definition at line 72 of file EcalTimeOffsetXMLTranslator.cc.

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

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