CMS 3D CMS Logo

Static Public Member Functions

EcalTPGCrystalStatusXMLTranslator Class Reference

#include <EcalTPGCrystalStatusXMLTranslator.h>

List of all members.

Static Public Member Functions

static std::string dumpXML (const EcalCondHeader &header, const EcalTPGCrystalStatus &record)
static void plot (std::string, const EcalTPGCrystalStatus &record)
static int writeXML (const std::string &filename, const EcalCondHeader &header, const EcalTPGCrystalStatus &record)

Detailed Description

Definition at line 23 of file EcalTPGCrystalStatusXMLTranslator.h.


Member Function Documentation

std::string EcalTPGCrystalStatusXMLTranslator::dumpXML ( const EcalCondHeader header,
const EcalTPGCrystalStatus record 
) [static]

Definition at line 34 of file EcalTPGCrystalStatusXMLTranslator.cc.

References gather_cfg::cout, asciidump::doc, hcal_timing_source_file_cfg::dump, xuti::fromNative(), errorMatrix2Lands_multiChannel::id, EEDetId::IX_MAX, EEDetId::IY_MAX, kBarlRings, kBarlWedges, kEndcWedgesX, kEndcWedgesY, kSides, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, dbtoconf::root, xuti::toNative(), xuti::TPGCrystalStatus_tag(), EEDetId::validDetId(), 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(TPGCrystalStatus_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);

  const int kSides       = 2;
  const int kBarlRings   = EBDetId::MAX_IETA;
  const int kBarlWedges  = EBDetId::MAX_IPHI;
  const int kEndcWedgesX = EEDetId::IX_MAX;
  const int kEndcWedgesY = EEDetId::IY_MAX;

  std::cout << "EcalTPGCrystalStatusXMLTranslator::dumpXML" << std::endl;
  for (int sign=0; sign < kSides; sign++) {
    int thesign = sign==1 ? 1:-1;

    for (int ieta=0; ieta<kBarlRings; ieta++) {
      for (int iphi=0; iphi<kBarlWedges; iphi++) {
        EBDetId id((ieta+1)*thesign, iphi+1);
        if(record[id.rawId()].getStatusCode() > 0) {
          DOMElement* cellnode=writeCell(root, id);
          WriteNodeWithValue(cellnode, TPGCrystalStatus_tag, record[id.rawId()].getStatusCode());
        }
      }  // iphi
    }   // ieta

    for (int ix=0; ix<kEndcWedgesX; ix++) {
      for (int iy=0; iy<kEndcWedgesY; iy++) {
        if (! EEDetId::validDetId(ix+1,iy+1,thesign)) continue;
        EEDetId id(ix+1,iy+1,thesign);
        if(record[id.rawId()].getStatusCode() > 0) {
          DOMElement* cellnode=writeCell(root, id);
          WriteNodeWithValue(cellnode, TPGCrystalStatus_tag, record[id.rawId()].getStatusCode());
        }
      }  // iy
    }   // ix
  }    // side

  std::string dump = toNative(writer->writeToString(*root)); 
  doc->release(); 
  return dump;
}
static void EcalTPGCrystalStatusXMLTranslator::plot ( std::string  ,
const EcalTPGCrystalStatus record 
) [static]
int EcalTPGCrystalStatusXMLTranslator::writeXML ( const std::string &  filename,
const EcalCondHeader header,
const EcalTPGCrystalStatus record 
) [static]

Definition at line 26 of file EcalTPGCrystalStatusXMLTranslator.cc.

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

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