CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

MiscalibReaderFromXML Class Reference

#include <MiscalibReaderFromXML.h>

Inheritance diagram for MiscalibReaderFromXML:
MiscalibReaderFromXMLEcalBarrel MiscalibReaderFromXMLEcalEndcap MiscalibReaderFromXMLHcal

List of all members.

Public Member Functions

double getFloatAttribute (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute, const std::string &attribute_name)
int getIntAttribute (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute, const std::string &attribute_name)
double getScalingFactor (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)
 MiscalibReaderFromXML (CaloMiscalibMap &)
virtual DetId parseCellEntry (XERCES_CPP_NAMESPACE::DOMNamedNodeMap *attribute)=0
bool parseXMLMiscalibFile (std::string configFile)
virtual ~MiscalibReaderFromXML ()

Private Attributes

CaloMiscalibMapcaloMap_

Static Private Attributes

static int s_numberOfInstances = 0

Detailed Description

* Parses the xml file to get miscalibration constants

Date:
2010/08/07 14:55:53
Revision:
1.2
Author:
Lorenzo Agostino

Definition at line 30 of file MiscalibReaderFromXML.h.


Constructor & Destructor Documentation

MiscalibReaderFromXML::MiscalibReaderFromXML ( CaloMiscalibMap caloMap)

Definition at line 25 of file MiscalibReaderXML.cc.

References _toString(), gather_cfg::cout, alignCSCRings::e, and s_numberOfInstances.

                                                                     :caloMap_(caloMap){
      
             
        try { 
                //std::cout << "Xerces-c initialization Number "
                //<< s_numberOfInstances<<std::endl;
                if (s_numberOfInstances==0) 
                XMLPlatformUtils::Initialize();  
        }
        catch (const XMLException& e) {
                std::cout << "Xerces-c error in initialization \n"
                << "Exception message is:  \n"
                << _toString(e.getMessage()) <<std::endl;
                // throw an exception here
        }
 
        ++s_numberOfInstances;
        
        
        
        
}
virtual MiscalibReaderFromXML::~MiscalibReaderFromXML ( ) [inline, virtual]

Definition at line 34 of file MiscalibReaderFromXML.h.

{}

Member Function Documentation

double MiscalibReaderFromXML::getFloatAttribute ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute,
const std::string &  attribute_name 
)
int MiscalibReaderFromXML::getIntAttribute ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute,
const std::string &  attribute_name 
)
double MiscalibReaderFromXML::getScalingFactor ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute)

Definition at line 61 of file MiscalibReaderXML.cc.

References getFloatAttribute().

Referenced by parseXMLMiscalibFile().

{
return MiscalibReaderFromXML::getFloatAttribute(attribute,"scale_factor");
}
virtual DetId MiscalibReaderFromXML::parseCellEntry ( XERCES_CPP_NAMESPACE::DOMNamedNodeMap *  attribute) [pure virtual]
bool MiscalibReaderFromXML::parseXMLMiscalibFile ( std::string  configFile)

Get ME name

Definition at line 79 of file MiscalibReaderXML.cc.

References _toDOMS(), CaloMiscalibMap::addCell(), asciidump::attributes, caloMap_, prof2calltree::count, gather_cfg::cout, asciidump::doc, getScalingFactor(), i, parseCellEntry(), and geometryXMLtoCSV::parser.

Referenced by InvRingCalib::duringLoop(), ZeeCalibration::duringLoop(), HcalRecHitRecalib::HcalRecHitRecalib(), HcalRecHitsMaker::init(), CaloMiscalibToolsMC::produce(), and CaloMiscalibTools::produce().

                                                                    {

        XercesDOMParser* parser = new XercesDOMParser;     
        parser->setValidationScheme(XercesDOMParser::Val_Auto);
        parser->setDoNamespaces(false);
        parser->parse(configFile.c_str()); 
        DOMDocument* doc = parser->getDocument();
        assert(doc);

        unsigned int linkTagsNum = doc->getElementsByTagName(_toDOMS("Cell"))->getLength();
        // The following should be on LogInfo
        //std::cout << "Read number of Cells = " << linkTagsNum << std::endl;

        if(linkTagsNum==0) std::cout <<"Number of Cells in file is 0 - probably bad file format"<<std::endl;

        int count=0;    
        for (unsigned int i=0; i<linkTagsNum; i++){
                        
                
                DOMNode* linkNode = doc->getElementsByTagName(_toDOMS("Cell"))->item(i);
                if (! linkNode){
                        std::cout<<"Node LINK does not exist, i="<<i<<std::endl;
                        return true;
                }
                DOMElement* linkElement = static_cast<DOMElement *>(linkNode);          
                if (! linkElement){
                        std::cout<<"Element LINK does not exist, i="<<i<<std::endl;
                        return true;             
                }


                DOMNamedNodeMap *attributes = linkNode->getAttributes();
                double scalingfactor= getScalingFactor(attributes);
                
                
                
                DetId cell = parseCellEntry(attributes);
                
                if(cell!= DetId(0)) 
                { 
                count++;
                caloMap_.addCell(cell,scalingfactor);
                } else  
                {
                  //            std::cout << "Null received" << std::endl;
                }
                
        }
 
        // The following should be on LogInfo
        // std::cout << "Number of good Cells = " << count << std::endl;
        return false;

}

Member Data Documentation

Definition at line 45 of file MiscalibReaderFromXML.h.

Referenced by parseXMLMiscalibFile().

int MiscalibReaderFromXML::s_numberOfInstances = 0 [static, private]

Definition at line 44 of file MiscalibReaderFromXML.h.

Referenced by MiscalibReaderFromXML().