CMS 3D CMS Logo

DBReader.cc
Go to the documentation of this file.
1 // #include "CondFormats/PhysicsToolsObjects/interface/Histogram2D.h"
4 
5 #include "DBReader.h"
6 
7 #include <iostream>
8 #include <cstdio>
9 #include <sys/time.h>
10 #include <string>
11 
12 DBReader::DBReader( const edm::ParameterSet& iConfig ) : type_(iConfig.getUntrackedParameter<std::string>("Type"))
13 {
14 }
15 
17 {
19  iSetup.get<MuScleFitDBobjectRcd>().get(dbObject);
20  edm::LogInfo("DBReader") << "[DBReader::analyze] End Reading MuScleFitDBobjectRcd" << std::endl;
21 
22  std::cout << "identifiers size from dbObject = " << dbObject->identifiers.size() << std::endl;
23  std::cout << "parameters size from dbObject = " << dbObject->parameters.size() << std::endl;;
24 
25  // This string is one of: scale, resolution, background.
26  // Create the corrector and set the parameters
27  if( type_ == "scale" ) corrector_.reset(new MomentumScaleCorrector( dbObject.product() ) );
28  else if( type_ == "resolution" ) resolution_.reset(new ResolutionFunction( dbObject.product() ) );
29  else if( type_ == "background" ) background_.reset(new BackgroundFunction( dbObject.product() ) );
30  else {
31  std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
32  exit(1);
33  }
34 
35  // cout << "pointer = " << corrector_.get() << endl;
36 }
37 
38 //: printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug",1)){}
39 
41 
42 void DBReader::analyze( const edm::Event& e, const edm::EventSetup& iSetup)
43 {
44  initialize(iSetup);
45  if( type_ == "scale" ) printParameters(corrector_);
46  else if( type_ == "resolution" ) printParameters(resolution_);
47  else if( type_ == "background" ) printParameters(background_);
48 }
49 
52 
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DBReader.cc:42
void initialize(const edm::EventSetup &iSetup)
Definition: DBReader.cc:16
std::string type_
Definition: DBReader.h:59
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< int > identifiers
DBReader(const edm::ParameterSet &)
Definition: DBReader.cc:12
boost::shared_ptr< MomentumScaleCorrector > corrector_
Definition: DBReader.h:61
void printParameters(const T &functionPtr)
Definition: DBReader.h:37
boost::shared_ptr< ResolutionFunction > resolution_
Definition: DBReader.h:62
T get() const
Definition: EventSetup.h:71
boost::shared_ptr< BackgroundFunction > background_
Definition: DBReader.h:63
T const * product() const
Definition: ESHandle.h:86
~DBReader() override
Definition: DBReader.cc:40
std::vector< double > parameters