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::string dumpXML (const EcalCondHeader &header, const std::vector< float > &eb, const std::vector< float > &ee)
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.4 2011/05/04 12:38:10 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 156 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::string EcalFloatCondObjectContainerXMLTranslator::dumpXML ( const EcalCondHeader header,
const std::vector< float > &  eb,
const std::vector< float > &  ee 
) [static]

Definition at line 109 of file EcalFloatCondObjectContainerXMLTranslator.cc.

References dtNoiseDBValidation_cfg::cerr, EcalCondTools::dumpXML(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, record, EBDetId::unhashIndex(), EEDetId::unhashIndex(), and EEDetId::validHashIndex().

                                                             {


  if (eb.size() != EBDetId::kSizeForDenseIndexing){
    std::cerr<<"Error in EcalFloatCondObjectContainerXMLTranslator::dumpXML, invalid Barrel array size: "
             <<eb.size() << " should be "<<  EBDetId::kSizeForDenseIndexing<< std::endl;
    return std::string("");
  }

  if (ee.size() != EEDetId::kSizeForDenseIndexing){
    std::cerr<<"Error in EcalFloatCondObjectContainerXMLTranslator::dumpXML, invalid Endcap array size: "
             <<ee.size() << " should be "<<  EEDetId::kSizeForDenseIndexing<< std::endl;
    return std::string("");
  }

  EcalFloatCondObjectContainer record;
  
  for (int cellid = 0; 
       cellid < EBDetId::kSizeForDenseIndexing; 
       ++cellid){// loop on EB cells
        
    uint32_t rawid = EBDetId::unhashIndex(cellid);
    record[rawid]   = eb[cellid];
  } 
  
  for (int cellid = 0; 
       cellid < EEDetId::kSizeForDenseIndexing; 
       ++cellid){// loop on EE cells
    
    
    
    if (EEDetId::validHashIndex(cellid)){  
      uint32_t rawid = EEDetId::unhashIndex(cellid);
   
      record[rawid]=ee[cellid];
    } // if
  }
  
  return dumpXML(header,record);


}
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 231 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;  
}