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 &) override
 
 DBReader (const edm::ParameterSet &)
 
void initialize (const edm::EventSetup &iSetup)
 
 ~DBReader () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

std::shared_ptr< BackgroundFunctionbackground_
 
std::shared_ptr< MomentumScaleCorrectorcorrector_
 
std::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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 24 of file DBReader.h.

Constructor & Destructor Documentation

◆ DBReader()

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

Definition at line 12 of file DBReader.cc.

12 : type_(iConfig.getUntrackedParameter<std::string>("Type")) {}

◆ ~DBReader()

DBReader::~DBReader ( )
override

Definition at line 41 of file DBReader.cc.

41 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 43 of file DBReader.cc.

43  {
44  initialize(iSetup);
45  if (type_ == "scale")
47  else if (type_ == "resolution")
49  else if (type_ == "background")
51 }

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

◆ initialize()

void DBReader::initialize ( const edm::EventSetup iSetup)

Definition at line 14 of file DBReader.cc.

14  {
16  iSetup.get<MuScleFitDBobjectRcd>().get(dbObject);
17  edm::LogInfo("DBReader") << "[DBReader::analyze] End Reading MuScleFitDBobjectRcd" << std::endl;
18 
19  std::cout << "identifiers size from dbObject = " << dbObject->identifiers.size() << std::endl;
20  std::cout << "parameters size from dbObject = " << dbObject->parameters.size() << std::endl;
21  ;
22 
23  // This string is one of: scale, resolution, background.
24  // Create the corrector and set the parameters
25  if (type_ == "scale")
26  corrector_.reset(new MomentumScaleCorrector(dbObject.product()));
27  else if (type_ == "resolution")
28  resolution_.reset(new ResolutionFunction(dbObject.product()));
29  else if (type_ == "background")
30  background_.reset(new BackgroundFunction(dbObject.product()));
31  else {
32  std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
33  exit(1);
34  }
35 
36  // cout << "pointer = " << corrector_.get() << endl;
37 }

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

Referenced by analyze().

◆ printParameters()

template<typename T >
void DBReader::printParameters ( const T functionPtr)
inlineprivate

Definition at line 35 of file DBReader.h.

35  {
36  // Looping directly on it does not work, because it is returned by value
37  // and the iterator gets invalidated on the next line. Save it to a temporary object
38  // and iterate on it.
39  std::vector<double> parVecVec(functionPtr->parameters());
40  std::vector<double>::const_iterator parVec = parVecVec.begin();
41  std::vector<int> functionId(functionPtr->identifiers());
42  std::vector<int>::const_iterator id = functionId.begin();
43  std::cout << "total number of parameters read from database = parVecVec.size() = " << parVecVec.size() << std::endl;
44  int iFunc = 0;
45  for (; id != functionId.end(); ++id, ++iFunc) {
46  int parNum = functionPtr->function(iFunc)->parNum();
47  std::cout << "For function id = " << *id << ", with " << parNum << " parameters: " << std::endl;
48  for (int par = 0; par < parNum; ++par) {
49  std::cout << "par[" << par << "] = " << *parVec << std::endl;
50  ++parVec;
51  }
52  }
53  }

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

Referenced by analyze().

Member Data Documentation

◆ background_

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

Definition at line 60 of file DBReader.h.

Referenced by analyze(), and initialize().

◆ corrector_

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

Definition at line 58 of file DBReader.h.

Referenced by analyze(), and initialize().

◆ resolution_

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

Definition at line 59 of file DBReader.h.

Referenced by analyze(), and initialize().

◆ type_

std::string DBReader::type_
private
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
DBReader::background_
std::shared_ptr< BackgroundFunction > background_
Definition: DBReader.h:60
MomentumScaleCorrector
Definition: MomentumScaleCorrector.h:25
BackgroundFunction
Definition: BackgroundFunction.h:15
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DBReader::resolution_
std::shared_ptr< ResolutionFunction > resolution_
Definition: DBReader.h:59
edm::LogInfo
Definition: MessageLogger.h:254
MuScleFitDBobjectRcd
Definition: MuScleFitDBobjectRcd.h:6
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DBReader::printParameters
void printParameters(const T &functionPtr)
Definition: DBReader.h:35
MuScleFitDBobject::identifiers
std::vector< int > identifiers
Definition: MuScleFitDBobject.h:9
DBReader::type_
std::string type_
Definition: DBReader.h:56
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
MuScleFitDBobject::parameters
std::vector< double > parameters
Definition: MuScleFitDBobject.h:10
edm::ESHandle< MuScleFitDBobject >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ResolutionFunction
Definition: ResolutionFunction.h:15
DBReader::initialize
void initialize(const edm::EventSetup &iSetup)
Definition: DBReader.cc:14
get
#define get
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
DBReader::corrector_
std::shared_ptr< MomentumScaleCorrector > corrector_
Definition: DBReader.h:58