CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Static Private Member Functions

EcalWeightSetXMLTranslator Class Reference

#include <EcalWeightSetXMLTranslator.h>

List of all members.

Public Member Functions

 EcalWeightSetXMLTranslator ()

Static Public Member Functions

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

Static Private Member Functions

static void write10x10 (xercesc::DOMElement *node, const EcalWeightSet &record)
static void write3x10 (xercesc::DOMElement *node, const EcalWeightSet &record)

Detailed Description

Definition at line 27 of file EcalWeightSetXMLTranslator.h.


Constructor & Destructor Documentation

EcalWeightSetXMLTranslator::EcalWeightSetXMLTranslator ( ) [inline]

Definition at line 31 of file EcalWeightSetXMLTranslator.h.

{};

Member Function Documentation

std::string EcalWeightSetXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalWeightSet record 
) [static]

Definition at line 315 of file EcalWeightSetXMLTranslator.cc.

References asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::EcalWeightSet_tag(), xuti::fromNative(), dbtoconf::root, AlCaHLTBitMon_QueryRunRegistry::string, xuti::toNative(), xuti::wgtAfterSwitch_tag(), xuti::wgtBeforeSwitch_tag(), xuti::wgtChi2AfterSwitch_tag(), xuti::wgtChi2BeforeSwitch_tag(), and xuti::writeHeader().

                                                                             {

  
  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(EcalWeightSet_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);

  DOMElement* wgtBS = doc->createElement(fromNative(wgtBeforeSwitch_tag).c_str());
  root->appendChild(wgtBS);
  
  DOMElement* wgtAS = doc->createElement(fromNative(wgtAfterSwitch_tag).c_str());
  root->appendChild(wgtAS);
  
  DOMElement* wgtChi2BS = doc->createElement(fromNative(wgtChi2BeforeSwitch_tag).c_str());
  root->appendChild(wgtChi2BS);
  
  DOMElement* wgtChi2AS = doc->createElement(fromNative(wgtChi2AfterSwitch_tag).c_str());
  root->appendChild(wgtChi2AS);
  
  write3x10(wgtBS,record);
  write3x10(wgtAS,record);
  
  write10x10(wgtChi2BS,record);
  write10x10(wgtChi2AS,record);
  
  std::string dump= toNative(writer->writeToString(*root)); 
  doc->release(); 
  
  return dump;  


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

Definition at line 22 of file EcalClusterCrackCorrXMLTranslator.cc.

References gather_cfg::cout, geometryXMLtoCSV::parser, 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 << "EcalClusterCrackCorrXMLTranslator::Error parsing document" << std::endl;
    return -1;
  }

  DOMElement* elementRoot = xmlDoc->getDocumentElement();

  xuti::readHeader(elementRoot, header);

  // need some extra code here

  delete parser;
  XMLPlatformUtils::Terminate();
  return 0;
}
void EcalWeightSetXMLTranslator::write10x10 ( xercesc::DOMElement *  node,
const EcalWeightSet record 
) [static, private]

Definition at line 216 of file EcalWeightSetXMLTranslator.cc.

References xuti::fromNative(), EcalWeightSet::getChi2WeightsAfterGainSwitch(), EcalWeightSet::getChi2WeightsBeforeGainSwitch(), i, xuti::id_tag(), gen::k, xuti::row_tag(), xuti::toNative(), xuti::wgtChi2AfterSwitch_tag(), and xuti::wgtChi2BeforeSwitch_tag().

                                                                        {

  DOMElement* row[10];
  DOMAttr* rowid[10];
  DOMText* rowvalue[10];
  EcalWeightSet::EcalChi2WeightMatrix echi2wmatrix;


  if(toNative(node->getNodeName()) == wgtChi2BeforeSwitch_tag)
    {
      echi2wmatrix = record.getChi2WeightsBeforeGainSwitch();

    }
  if(toNative(node->getNodeName()) == wgtChi2AfterSwitch_tag)
    {
      echi2wmatrix = record.getChi2WeightsAfterGainSwitch();

    }

  for(int i=0;i<10;++i)
    {


      row[i] = node->getOwnerDocument()->createElement(fromNative(row_tag).c_str());
      node->appendChild(row[i]);

      stringstream value_s;
      value_s << i; 

      rowid[i] = node->getOwnerDocument()->createAttribute(fromNative(id_tag).c_str());
      rowid[i]->setValue(fromNative(value_s.str()).c_str());
      row[i]->setAttributeNode(rowid[i]);

      stringstream row_s;

      for(int k=0;k<10;++k)
        {
          row_s << " ";
          row_s << echi2wmatrix(k,i);
          row_s << " ";
        }//for loop on element


      rowvalue[i] = node->getOwnerDocument()->createTextNode(fromNative(row_s.str()).c_str());
      row[i]->appendChild(rowvalue[i]);
    }//for loop on row
}
void EcalWeightSetXMLTranslator::write3x10 ( xercesc::DOMElement *  node,
const EcalWeightSet record 
) [static, private]

Definition at line 267 of file EcalWeightSetXMLTranslator.cc.

References xuti::fromNative(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), i, xuti::id_tag(), gen::k, xuti::row_tag(), xuti::toNative(), xuti::wgtAfterSwitch_tag(), and xuti::wgtBeforeSwitch_tag().

                                                                       {

  DOMElement* row[10];
  DOMAttr* rowid[10];
  DOMText* rowvalue[10];
  EcalWeightSet::EcalWeightMatrix ewmatrix;


  if(toNative(node->getNodeName()) == wgtBeforeSwitch_tag)
    ewmatrix = record.getWeightsBeforeGainSwitch();
  
  if(toNative(node->getNodeName()) == wgtAfterSwitch_tag)
    ewmatrix = record.getWeightsAfterGainSwitch();
  
  
  for(int i=0;i<10;++i)
    {

      row[i] = node->getOwnerDocument()->createElement(fromNative(row_tag).c_str());
      node->appendChild(row[i]);

      stringstream value_s;
      value_s << i; 

      rowid[i] = node->getOwnerDocument()->createAttribute(fromNative(id_tag).c_str());

      rowid[i]->setValue(fromNative(value_s.str()).c_str());

      row[i]->setAttributeNode(rowid[i]);


      stringstream row_s;

      for(int k=0;k<3;++k)
        {
          row_s << " ";
          row_s << ewmatrix(k,i);
          row_s << " ";
        }//for loop on element


      rowvalue[i] = node->getOwnerDocument()->createTextNode(fromNative(row_s.str()).c_str());
      row[i]->appendChild(rowvalue[i]);
    }//for loop on row
}
int EcalWeightSetXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalWeightSet record 
) [static]

Definition at line 203 of file EcalWeightSetXMLTranslator.cc.

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

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

}