-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
DBReader.h
65 lines (56 loc) · 2.32 KB
/
DBReader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef DBReader_H
#define DBReader_H
// system include files
//#include <memory>
#include <boost/shared_ptr.hpp>
#include <iostream>
#include <vector>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "MuonAnalysis/MomentumScaleCalibration/interface/MomentumScaleCorrector.h"
#include "MuonAnalysis/MomentumScaleCalibration/interface/ResolutionFunction.h"
#include "MuonAnalysis/MomentumScaleCalibration/interface/BackgroundFunction.h"
class DBReader : public edm::EDAnalyzer
{
public:
explicit DBReader( const edm::ParameterSet& );
~DBReader() override;
void initialize( const edm::EventSetup& iSetup );
void analyze( const edm::Event&, const edm::EventSetup& ) override;
private:
template <typename T>
void printParameters(const T & functionPtr)
{
// 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;
}
}
}
// uint32_t printdebug_;
std::string type_;
//std::unique_ptr<BaseFunction> corrector_;
boost::shared_ptr<MomentumScaleCorrector> corrector_;
boost::shared_ptr<ResolutionFunction> resolution_;
boost::shared_ptr<BackgroundFunction> background_;
};
#endif