CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DBReader Class Reference
Inheritance diagram for DBReader:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase 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::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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_
 
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcdmuToken_
 
std::shared_ptr< ResolutionFunctionresolution_
 
const std::string type_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 23 of file DBReader.cc.

Constructor & Destructor Documentation

◆ DBReader()

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

Definition at line 62 of file DBReader.cc.

63  : muToken_(esConsumes()), type_(iConfig.getUntrackedParameter<std::string>("Type")) {}
const std::string type_
Definition: DBReader.cc:55
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcd > muToken_
Definition: DBReader.cc:54
T getUntrackedParameter(std::string const &, T const &) const

◆ ~DBReader()

DBReader::~DBReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 91 of file DBReader.cc.

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

91  {
92  initialize(iSetup);
93  if (type_ == "scale")
95  else if (type_ == "resolution")
97  else if (type_ == "background")
99 }
std::shared_ptr< MomentumScaleCorrector > corrector_
Definition: DBReader.cc:57
std::shared_ptr< BackgroundFunction > background_
Definition: DBReader.cc:59
const std::string type_
Definition: DBReader.cc:55
void initialize(const edm::EventSetup &iSetup)
Definition: DBReader.cc:65
void printParameters(const T &functionPtr)
Definition: DBReader.cc:32
std::shared_ptr< ResolutionFunction > resolution_
Definition: DBReader.cc:58

◆ initialize()

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

Definition at line 65 of file DBReader.cc.

References background_, corrector_, beamvalidation::exit(), edm::EventSetup::getData(), MuScleFitDBobject::identifiers, muToken_, MuScleFitDBobject::parameters, resolution_, and type_.

Referenced by analyze().

65  {
66  const MuScleFitDBobject* dbObject = &iSetup.getData(muToken_);
67  edm::LogInfo("DBReader") << "[DBReader::analyze] End Reading MuScleFitDBobjectRcd" << std::endl;
68  edm::LogPrint("DBReader") << "identifiers size from dbObject = " << dbObject->identifiers.size() << std::endl;
69  edm::LogPrint("DBReader") << "parameters size from dbObject = " << dbObject->parameters.size() << std::endl;
70 
71  // This string is one of: scale, resolution, background.
72  // Create the corrector and set the parameters
73  if (type_ == "scale")
74  corrector_.reset(new MomentumScaleCorrector(dbObject));
75  else if (type_ == "resolution")
76  resolution_.reset(new ResolutionFunction(dbObject));
77  else if (type_ == "background")
78  background_.reset(new BackgroundFunction(dbObject));
79  else {
80  edm::LogPrint("DBReader") << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'"
81  << std::endl;
82  exit(1);
83  }
84  // cout << "pointer = " << corrector_.get() << endl;
85 }
std::shared_ptr< MomentumScaleCorrector > corrector_
Definition: DBReader.cc:57
std::shared_ptr< BackgroundFunction > background_
Definition: DBReader.cc:59
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const std::string type_
Definition: DBReader.cc:55
const edm::ESGetToken< MuScleFitDBobject, MuScleFitDBobjectRcd > muToken_
Definition: DBReader.cc:54
std::vector< int > identifiers
Log< level::Warning, true > LogPrint
std::shared_ptr< ResolutionFunction > resolution_
Definition: DBReader.cc:58
Log< level::Info, false > LogInfo
def exit(msg="")
std::vector< double > parameters

◆ printParameters()

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

Definition at line 32 of file DBReader.cc.

References l1ctLayer2EG_cff::id.

Referenced by analyze().

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

Member Data Documentation

◆ background_

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

Definition at line 59 of file DBReader.cc.

Referenced by analyze(), and initialize().

◆ corrector_

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

Definition at line 57 of file DBReader.cc.

Referenced by analyze(), and initialize().

◆ muToken_

const edm::ESGetToken<MuScleFitDBobject, MuScleFitDBobjectRcd> DBReader::muToken_
private

Definition at line 54 of file DBReader.cc.

Referenced by initialize().

◆ resolution_

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

Definition at line 58 of file DBReader.cc.

Referenced by analyze(), and initialize().

◆ type_

const std::string DBReader::type_
private