CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/MuonAnalysis/MomentumScaleCalibration/plugins/DBReader.cc

Go to the documentation of this file.
00001 // #include "CondFormats/PhysicsToolsObjects/interface/Histogram2D.h"
00002 #include "CondFormats/RecoMuonObjects/interface/MuScleFitDBobject.h"
00003 #include "CondFormats/DataRecord/interface/MuScleFitDBobjectRcd.h"
00004 
00005 #include "DBReader.h"
00006 
00007 #include <iostream>
00008 #include <stdio.h>
00009 #include <sys/time.h>
00010 #include <string>
00011 
00012 DBReader::DBReader( const edm::ParameterSet& iConfig ) : type_(iConfig.getUntrackedParameter<std::string>("Type"))
00013 {
00014 }
00015 
00016 void DBReader::initialize( const edm::EventSetup& iSetup )
00017 {
00018   edm::ESHandle<MuScleFitDBobject> dbObject;
00019   iSetup.get<MuScleFitDBobjectRcd>().get(dbObject);
00020   edm::LogInfo("DBReader") << "[DBReader::analyze] End Reading MuScleFitDBobjectRcd" << std::endl;
00021 
00022   std::cout << "identifiers size from dbObject = " << dbObject->identifiers.size() << std::endl;
00023   std::cout << "parameters size from dbObject = " << dbObject->parameters.size() << std::endl;;
00024 
00025   // This string is one of: scale, resolution, background.
00026   // Create the corrector and set the parameters
00027   if( type_ == "scale" ) corrector_.reset(new MomentumScaleCorrector( dbObject.product() ) );
00028   else if( type_ == "resolution" ) resolution_.reset(new ResolutionFunction( dbObject.product() ) );
00029   else if( type_ == "background" ) background_.reset(new BackgroundFunction( dbObject.product() ) );
00030   else {
00031     std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
00032     exit(1);
00033   }
00034 
00035   // cout << "pointer = " << corrector_.get() << endl;
00036 }
00037 
00038 //:  printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug",1)){}
00039 
00040 DBReader::~DBReader(){}
00041 
00042 void DBReader::analyze( const edm::Event& e, const edm::EventSetup& iSetup)
00043 {
00044   initialize(iSetup);
00045   if( type_ == "scale" ) printParameters(corrector_);
00046   else if( type_ == "resolution" ) printParameters(resolution_);
00047   else if( type_ == "background" ) printParameters(background_);
00048 }
00049 
00050 #include "FWCore/PluginManager/interface/ModuleDef.h"
00051 #include "FWCore/Framework/interface/MakerMacros.h"
00052 
00053 DEFINE_FWK_MODULE(DBReader);