Go to the documentation of this file.00001 #ifndef DBReader_H
00002 #define DBReader_H
00003
00004
00005
00006 #include <boost/shared_ptr.hpp>
00007 #include <iostream>
00008 #include <vector>
00009
00010
00011 #include "FWCore/Framework/interface/Frameworkfwd.h"
00012 #include "FWCore/Framework/interface/EDAnalyzer.h"
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019
00020 #include "MuonAnalysis/MomentumScaleCalibration/interface/MomentumScaleCorrector.h"
00021 #include "MuonAnalysis/MomentumScaleCalibration/interface/ResolutionFunction.h"
00022 #include "MuonAnalysis/MomentumScaleCalibration/interface/BackgroundFunction.h"
00023
00024 class DBReader : public edm::EDAnalyzer
00025 {
00026 public:
00027 explicit DBReader( const edm::ParameterSet& );
00028 ~DBReader();
00029
00030 void initialize( const edm::EventSetup& iSetup );
00031
00032 void analyze( const edm::Event&, const edm::EventSetup& );
00033
00034 private:
00035
00036 template <typename T>
00037 void printParameters(const T & functionPtr)
00038 {
00039
00040
00041
00042 std::vector<double> parVecVec(functionPtr->parameters());
00043 std::vector<double>::const_iterator parVec = parVecVec.begin();
00044 std::vector<int> functionId(functionPtr->identifiers());
00045 std::vector<int>::const_iterator id = functionId.begin();
00046 std::cout << "total number of parameters read from database = parVecVec.size() = " << parVecVec.size() << std::endl;
00047 int iFunc = 0;
00048 for( ; id != functionId.end(); ++id, ++iFunc ) {
00049 int parNum = functionPtr->function(iFunc)->parNum();
00050 std::cout << "For function id = " << *id << ", with "<<parNum<< " parameters: " << std::endl;
00051 for( int par=0; par<parNum; ++par ) {
00052 std::cout << "par["<<par<<"] = " << *parVec << std::endl;
00053 ++parVec;
00054 }
00055 }
00056 }
00057
00058
00059 std::string type_;
00060
00061 boost::shared_ptr<MomentumScaleCorrector> corrector_;
00062 boost::shared_ptr<ResolutionFunction> resolution_;
00063 boost::shared_ptr<BackgroundFunction> background_;
00064 };
00065 #endif