CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/MuonAnalysis/MomentumScaleCalibration/plugins/DBReader.h

Go to the documentation of this file.
00001 #ifndef DBReader_H
00002 #define DBReader_H
00003 
00004 // system include files
00005 //#include <memory>
00006 #include <boost/shared_ptr.hpp>
00007 #include <iostream>
00008 #include <vector>
00009 
00010 // user include files
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     // Looping directly on it does not work, because it is returned by value
00040     // and the iterator gets invalidated on the next line. Save it to a temporary object
00041     // and iterate on it.
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   //  uint32_t printdebug_;
00059   std::string type_;
00060   //std::auto_ptr<BaseFunction> corrector_;
00061   boost::shared_ptr<MomentumScaleCorrector> corrector_;
00062   boost::shared_ptr<ResolutionFunction> resolution_;
00063   boost::shared_ptr<BackgroundFunction> background_;
00064 };
00065 #endif