CMS 3D CMS Logo

Static Public Member Functions

EcalChannelStatusXMLTranslator Class Reference

#include <EcalChannelStatusXMLTranslator.h>

List of all members.

Static Public Member Functions

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

Detailed Description

Definition at line 25 of file EcalChannelStatusXMLTranslator.h.


Member Function Documentation

std::string EcalChannelStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalChannelStatus record 
) [static]

Definition at line 94 of file EcalChannelStatusXMLTranslator.cc.

References xuti::ChannelStatus_tag(), xuti::ChannelStatusCode_tag(), asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), EBDetId::kSizeForDenseIndexing, EEDetId::kSizeForDenseIndexing, EBDetId::MIN_HASH, dbtoconf::root, xuti::toNative(), EBDetId::unhashIndex(), EEDetId::unhashIndex(), EEDetId::validHashIndex(), 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(ChannelStatus_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)
      {

        uint32_t rawid = EBDetId::unhashIndex(cellid);

        if(!record[rawid].getStatusCode()) continue;
      

        DOMElement* cellnode = writeCell(root,rawid);     

        WriteNodeWithValue(cellnode,ChannelStatusCode_tag,record[rawid].getStatusCode());

                          
      }



   
    for(int cellid = 0;
        cellid < EEDetId::kSizeForDenseIndexing;
        ++cellid)
      {
          
        if(!EEDetId::validHashIndex(cellid)) continue;
          
        uint32_t rawid = EEDetId::unhashIndex(cellid); 

        if(!record[rawid].getStatusCode()) continue;

        DOMElement* cellnode = writeCell(root,rawid);
        WriteNodeWithValue(cellnode,ChannelStatusCode_tag,record[rawid].getStatusCode());
          
      }
    

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

    return dump;

}
int EcalChannelStatusXMLTranslator::readXML ( const std::string &  filename,
EcalCondHeader header,
EcalChannelStatus record 
) [static]

Definition at line 27 of file EcalChannelStatusXMLTranslator.cc.

References xuti::Cell_tag(), xuti::ChannelStatusCode_tag(), gather_cfg::cout, cond::rpcobgas::detid, xuti::getChildNode(), xuti::GetNodeData(), geometryXMLtoCSV::parser, xuti::readCellId(), and xuti::readHeader().

                                                                       {



  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 << "EcalChannelStatusXMLTranslator::Error parsing document" << std::endl;
    return -1;
  }

  DOMElement* elementRoot = xmlDoc->getDocumentElement();

  xuti::readHeader(elementRoot,header);

  DOMNode * cellnode = getChildNode(elementRoot,Cell_tag);

  while(cellnode)
    {
      uint16_t csc = 0;

      DetId detid = readCellId(dynamic_cast<DOMElement*>(cellnode));

      DOMNode* c_node = getChildNode(cellnode,ChannelStatusCode_tag);
      GetNodeData(c_node,csc);

      EcalChannelStatusCode ecalCSC = EcalChannelStatusCode(csc);
      record[detid] = ecalCSC;

      cellnode = cellnode->getNextSibling();

      while(cellnode && cellnode->getNodeType() != DOMNode::ELEMENT_NODE)
        cellnode = cellnode->getNextSibling();

 
    }  

  delete parser;
  XMLPlatformUtils::Terminate();
  return 0;
  
  
}
int EcalChannelStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalChannelStatus record 
) [static]

Definition at line 85 of file EcalChannelStatusXMLTranslator.cc.

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

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