CMS 3D CMS Logo

DBReader.h
Go to the documentation of this file.
1 #ifndef DBReader_H
2 #define DBReader_H
3 
4 // system include files
5 //#include <memory>
6 #include <boost/shared_ptr.hpp>
7 #include <iostream>
8 #include <vector>
9 
10 // user include files
19 
23 
24 class DBReader : public edm::EDAnalyzer
25 {
26  public:
27  explicit DBReader( const edm::ParameterSet& );
28  ~DBReader() override;
29 
30  void initialize( const edm::EventSetup& iSetup );
31 
32  void analyze( const edm::Event&, const edm::EventSetup& ) override;
33 
34  private:
35 
36  template <typename T>
37  void printParameters(const T & functionPtr)
38  {
39  // Looping directly on it does not work, because it is returned by value
40  // and the iterator gets invalidated on the next line. Save it to a temporary object
41  // and iterate on it.
42  std::vector<double> parVecVec(functionPtr->parameters());
43  std::vector<double>::const_iterator parVec = parVecVec.begin();
44  std::vector<int> functionId(functionPtr->identifiers());
45  std::vector<int>::const_iterator id = functionId.begin();
46  std::cout << "total number of parameters read from database = parVecVec.size() = " << parVecVec.size() << std::endl;
47  int iFunc = 0;
48  for( ; id != functionId.end(); ++id, ++iFunc ) {
49  int parNum = functionPtr->function(iFunc)->parNum();
50  std::cout << "For function id = " << *id << ", with "<<parNum<< " parameters: " << std::endl;
51  for( int par=0; par<parNum; ++par ) {
52  std::cout << "par["<<par<<"] = " << *parVec << std::endl;
53  ++parVec;
54  }
55  }
56  }
57 
58  // uint32_t printdebug_;
60  //std::unique_ptr<BaseFunction> corrector_;
61  boost::shared_ptr<MomentumScaleCorrector> corrector_;
62  boost::shared_ptr<ResolutionFunction> resolution_;
63  boost::shared_ptr<BackgroundFunction> background_;
64 };
65 #endif
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
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
boost::shared_ptr< BackgroundFunction > background_
Definition: DBReader.h:63
long double T
~DBReader() override
Definition: DBReader.cc:40