CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DBReader Class Reference

#include <DBReader.h>

Inheritance diagram for DBReader:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 DBReader (const edm::ParameterSet &)
void initialize (const edm::EventSetup &iSetup)
 ~DBReader ()

Private Member Functions

template<typename T >
void printParameters (const T &functionPtr)

Private Attributes

boost::shared_ptr
< BackgroundFunction
background_
boost::shared_ptr
< MomentumScaleCorrector
corrector_
boost::shared_ptr
< ResolutionFunction
resolution_
std::string type_

Detailed Description

Definition at line 24 of file DBReader.h.


Constructor & Destructor Documentation

DBReader::DBReader ( const edm::ParameterSet iConfig) [explicit]

Definition at line 12 of file DBReader.cc.

                                                   : type_(iConfig.getUntrackedParameter<std::string>("Type"))
{
}
DBReader::~DBReader ( )

Definition at line 40 of file DBReader.cc.

{}

Member Function Documentation

void DBReader::analyze ( const edm::Event e,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 42 of file DBReader.cc.

References background_, corrector_, initialize(), printParameters(), resolution_, and type_.

{
  initialize(iSetup);
  if( type_ == "scale" ) printParameters(corrector_);
  else if( type_ == "resolution" ) printParameters(resolution_);
  else if( type_ == "background" ) printParameters(background_);
}
void DBReader::initialize ( const edm::EventSetup iSetup)

Definition at line 16 of file DBReader.cc.

References background_, corrector_, gather_cfg::cout, cmsRelvalreport::exit, edm::EventSetup::get(), edm::ESHandle< T >::product(), resolution_, and type_.

Referenced by analyze().

{
  edm::ESHandle<MuScleFitDBobject> dbObject;
  iSetup.get<MuScleFitDBobjectRcd>().get(dbObject);
  edm::LogInfo("DBReader") << "[DBReader::analyze] End Reading MuScleFitDBobjectRcd" << std::endl;

  std::cout << "identifiers size from dbObject = " << dbObject->identifiers.size() << std::endl;
  std::cout << "parameters size from dbObject = " << dbObject->parameters.size() << std::endl;;

  // This string is one of: scale, resolution, background.
  // Create the corrector and set the parameters
  if( type_ == "scale" ) corrector_.reset(new MomentumScaleCorrector( dbObject.product() ) );
  else if( type_ == "resolution" ) resolution_.reset(new ResolutionFunction( dbObject.product() ) );
  else if( type_ == "background" ) background_.reset(new BackgroundFunction( dbObject.product() ) );
  else {
    std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
    exit(1);
  }

  // cout << "pointer = " << corrector_.get() << endl;
}
template<typename T >
void DBReader::printParameters ( const T functionPtr) [inline, private]

Definition at line 37 of file DBReader.h.

References gather_cfg::cout, and Gflash::par.

Referenced by analyze().

  {
    // Looping directly on it does not work, because it is returned by value
    // and the iterator gets invalidated on the next line. Save it to a temporary object
    // and iterate on it.
    std::vector<double> parVecVec(functionPtr->parameters());
    std::vector<double>::const_iterator parVec = parVecVec.begin();
    std::vector<int> functionId(functionPtr->identifiers());
    std::vector<int>::const_iterator id = functionId.begin();
    std::cout << "total number of parameters read from database = parVecVec.size() = " << parVecVec.size() << std::endl;
    int iFunc = 0;
    for( ; id != functionId.end(); ++id, ++iFunc ) {
      int parNum = functionPtr->function(iFunc)->parNum();
      std::cout << "For function id = " << *id << ", with "<<parNum<< " parameters: " << std::endl;
      for( int par=0; par<parNum; ++par ) {
        std::cout << "par["<<par<<"] = " << *parVec << std::endl;
        ++parVec;
      }
    }
  }

Member Data Documentation

boost::shared_ptr<BackgroundFunction> DBReader::background_ [private]

Definition at line 63 of file DBReader.h.

Referenced by analyze(), and initialize().

boost::shared_ptr<MomentumScaleCorrector> DBReader::corrector_ [private]

Definition at line 61 of file DBReader.h.

Referenced by analyze(), and initialize().

boost::shared_ptr<ResolutionFunction> DBReader::resolution_ [private]

Definition at line 62 of file DBReader.h.

Referenced by analyze(), and initialize().

std::string DBReader::type_ [private]

Definition at line 59 of file DBReader.h.

Referenced by analyze(), and initialize().