CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DBReader Class Reference

#include <DBReader.h>

Inheritance diagram for DBReader:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 
 DBReader (const edm::ParameterSet &)
 
void initialize (const edm::EventSetup &iSetup)
 
 ~DBReader ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

template<typename T >
void printParameters (const T &functionPtr)
 

Private Attributes

boost::shared_ptr< BackgroundFunctionbackground_
 
boost::shared_ptr< MomentumScaleCorrectorcorrector_
 
boost::shared_ptr< ResolutionFunctionresolution_
 
std::string type_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 24 of file DBReader.h.

Constructor & Destructor Documentation

DBReader::DBReader ( const edm::ParameterSet iConfig)
explicit

Definition at line 12 of file DBReader.cc.

12  : type_(iConfig.getUntrackedParameter<std::string>("Type"))
13 {
14 }
T getUntrackedParameter(std::string const &, T const &) const
std::string type_
Definition: DBReader.h:59
DBReader::~DBReader ( )

Definition at line 40 of file DBReader.cc.

40 {}

Member Function Documentation

void DBReader::analyze ( const edm::Event e,
const edm::EventSetup iSetup 
)

Definition at line 42 of file DBReader.cc.

References background_, corrector_, DEFINE_FWK_MODULE, initialize(), printParameters(), resolution_, and type_.

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 }
void initialize(const edm::EventSetup &iSetup)
Definition: DBReader.cc:16
std::string type_
Definition: DBReader.h:59
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
void DBReader::initialize ( const edm::EventSetup iSetup)

Definition at line 16 of file DBReader.cc.

References background_, corrector_, gather_cfg::cout, cmsRelvalreport::exit, edm::EventSetup::get(), MuScleFitDBobject::identifiers, MuScleFitDBobject::parameters, edm::ESHandle< T >::product(), resolution_, and type_.

Referenced by analyze().

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 }
std::string type_
Definition: DBReader.h:59
std::vector< int > identifiers
boost::shared_ptr< MomentumScaleCorrector > corrector_
Definition: DBReader.h:61
boost::shared_ptr< ResolutionFunction > resolution_
Definition: DBReader.h:62
const T & get() const
Definition: EventSetup.h:56
boost::shared_ptr< BackgroundFunction > background_
Definition: DBReader.h:63
T const * product() const
Definition: ESHandle.h:86
std::vector< double > parameters
template<typename T >
void DBReader::printParameters ( const T functionPtr)
inlineprivate

Definition at line 37 of file DBReader.h.

References gather_cfg::cout, and hcalTTPDigis_cfi::id.

Referenced by analyze().

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  }

Member Data Documentation

boost::shared_ptr<BackgroundFunction> DBReader::background_
private

Definition at line 63 of file DBReader.h.

Referenced by analyze(), and initialize().

boost::shared_ptr<MomentumScaleCorrector> DBReader::corrector_
private

Definition at line 61 of file DBReader.h.

Referenced by analyze(), and initialize().

boost::shared_ptr<ResolutionFunction> DBReader::resolution_
private

Definition at line 62 of file DBReader.h.

Referenced by analyze(), and initialize().

std::string DBReader::type_
private