CMS 3D CMS Logo

Static Public Member Functions

EcalFloatCondObjectContainerXMLTranslator Class Reference

#include <EcalFloatCondObjectContainerXMLTranslator.h>

List of all members.

Static Public Member Functions

static std::vector< float > barrelfromXML (const std::string &filename)
static std::string dumpXML (const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)
static std::vector< float > endcapfromXML (const std::string &filename)
static int readXML (const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalFloatCondObjectContainer &record)

Detailed Description

Translates a EcalFloatCondObjectContainer record to XML and vice versa

Author:
Stefano ARGIRO
Version:
Id:
EcalFloatCondObjectContainerXMLTranslator.h,v 1.3 2009/07/09 22:56:14 argiro Exp
Date:
20 Jun 2008

Definition at line 21 of file EcalFloatCondObjectContainerXMLTranslator.h.


Member Function Documentation

std::vector< float > EcalFloatCondObjectContainerXMLTranslator::barrelfromXML ( const std::string &  filename) [static]
std::string EcalFloatCondObjectContainerXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalFloatCondObjectContainer record 
) [static]

Definition at line 108 of file EcalFloatCondObjectContainerXMLTranslator.cc.

References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::EcalFloatCondObjectContainer_tag(), EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), xuti::fromNative(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, dbtoconf::root, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), xuti::Value_tag(), xuti::writeCell(), 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(EcalFloatCondObjectContainer_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);

  for (int cellid = EBDetId::MIN_HASH; 
       cellid < EBDetId::kSizeForDenseIndexing; 
       ++cellid){// loop on EB cells
    
    uint32_t rawid= EBDetId::unhashIndex(cellid);
    EcalFloatCondObjectContainer::const_iterator value_ptr=
      record.find(rawid);
    if (value_ptr==record.end()) continue; // cell absent from original record
    
    DOMElement* cellnode=writeCell(root,rawid);

    WriteNodeWithValue(cellnode,Value_tag,*value_ptr);
 

  } // loop on EB cells
  
  
  
  for (int cellid = 0; 
       cellid < EEDetId::kSizeForDenseIndexing; 
       ++cellid){// loop on EE cells
    
    if (!EEDetId::validHashIndex(cellid)) continue;

    uint32_t rawid= EEDetId::unhashIndex(cellid);
    EcalFloatCondObjectContainer::const_iterator value_ptr=
      record.find(rawid);
    if (value_ptr==record.end()) continue; // cell absent from original record
    

    DOMElement* cellnode= writeCell(root,rawid);
    WriteNodeWithValue(cellnode,Value_tag,*value_ptr);

    
  } // loop on EE cells
  
  
  std::string dump= toNative(writer->writeToString(*root));
  doc->release();
  return dump;
}
std::vector< float > EcalFloatCondObjectContainerXMLTranslator::endcapfromXML ( const std::string &  filename) [static]
static int EcalFloatCondObjectContainerXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalFloatCondObjectContainer record 
) [static]
int EcalFloatCondObjectContainerXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalFloatCondObjectContainer record 
) [static]

Definition at line 183 of file EcalFloatCondObjectContainerXMLTranslator.cc.

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

Referenced by PhiSymmetryCalibration_step2_SM::endJob(), PhiSymmetryCalibration_step2::endJob(), and main().

                                                                                          {

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