CMS 3D CMS Logo

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

#include <DBWriter.h>

Inheritance diagram for DBWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DBWriter (const edm::ParameterSet &)
 
 ~DBWriter () 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
 
std::vector< ESProxyIndex > 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
 
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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 

Private Attributes

std::unique_ptr< BaseFunctioncorrector_
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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 13 of file DBWriter.h.

Constructor & Destructor Documentation

◆ DBWriter()

DBWriter::DBWriter ( const edm::ParameterSet ps)
explicit

Definition at line 18 of file DBWriter.cc.

18  {
19  // This string is one of: scale, resolution, background.
21  // Create the corrector and set the parameters
22  if (type == "scale")
23  corrector_ =
24  std::make_unique<MomentumScaleCorrector>(ps.getUntrackedParameter<std::string>("CorrectionsIdentifier"));
25  else if (type == "resolution")
26  corrector_ = std::make_unique<ResolutionFunction>(ps.getUntrackedParameter<std::string>("CorrectionsIdentifier"));
27  else if (type == "background")
28  corrector_ = std::make_unique<BackgroundFunction>(ps.getUntrackedParameter<std::string>("CorrectionsIdentifier"));
29  else {
30  std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
31  exit(1);
32  }
33 }

References corrector_, gather_cfg::cout, beamvalidation::exit(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~DBWriter()

DBWriter::~DBWriter ( )
override

Definition at line 35 of file DBWriter.cc.

35  {
36  // do anything here that needs to be done at desctruction time
37  // (e.g. close files, deallocate resources etc.)
38 }

Member Function Documentation

◆ analyze()

void DBWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 41 of file DBWriter.cc.

41  {
42  MuScleFitDBobject* dbObject = new MuScleFitDBobject;
43 
44  dbObject->identifiers = corrector_->identifiers();
45  dbObject->parameters = corrector_->parameters();
46 
47  // if( dbObject->identifiers.size() != dbObject->parameters.size() ) {
48  // std::cout << "Error: size of parameters("<<dbObject->parameters.size()<<") and identifiers("<<dbObject->identifiers.size()<<") don't match" << std::endl;
49  // exit(1);
50  // }
51 
52  // std::vector<std::vector<double> >::const_iterator parVec = dbObject->parameters.begin();
53  // std::vector<int>::const_iterator id = dbObject->identifiers.begin();
54  // for( ; id != dbObject->identifiers.end(); ++id, ++parVec ) {
55  // std::cout << "id = " << *id << std::endl;
56  // std::vector<double>::const_iterator par = parVec->begin();
57  // int i=0;
58  // for( ; par != parVec->end(); ++par, ++i ) {
59  // std::cout << "par["<<i<<"] = " << *par << std::endl;
60  // }
61  // }
62 
63  // Save the parameters to the db.
65  if (mydbservice.isAvailable()) {
66  if (mydbservice->isNewTagRequest("MuScleFitDBobjectRcd")) {
67  mydbservice->createNewIOV<MuScleFitDBobject>(
68  dbObject, mydbservice->beginOfTime(), mydbservice->endOfTime(), "MuScleFitDBobjectRcd");
69  } else {
70  mydbservice->appendSinceTime<MuScleFitDBobject>(dbObject, mydbservice->currentTime(), "MuScleFitDBobjectRcd");
71  }
72  } else {
73  edm::LogError("DBWriter") << "Service is unavailable" << std::endl;
74  }
75 }

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), corrector_, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), cond::service::PoolDBOutputService::endOfTime(), MuScleFitDBobject::identifiers, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), and MuScleFitDBobject::parameters.

◆ endJob()

void DBWriter::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 20 of file DBWriter.h.

20 {};

Member Data Documentation

◆ corrector_

std::unique_ptr<BaseFunction> DBWriter::corrector_
private

Definition at line 20 of file DBWriter.h.

Referenced by analyze(), and DBWriter().

cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:141
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
MuScleFitDBobject
Definition: MuScleFitDBobject.h:8
MuScleFitDBobject::identifiers
std::vector< int > identifiers
Definition: MuScleFitDBobject.h:9
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
MuScleFitDBobject::parameters
std::vector< double > parameters
Definition: MuScleFitDBobject.h:10
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:116
DBWriter::corrector_
std::unique_ptr< BaseFunction > corrector_
Definition: DBWriter.h:20
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
edm::Service< cond::service::PoolDBOutputService >
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:213
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:128
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217