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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 13 of file DBWriter.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file DBWriter.cc.

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

18  {
19  // This string is one of: scale, resolution, background.
21  // Create the corrector and set the parameters
22  if (type == "scale")
23  corrector_.reset(new MomentumScaleCorrector(ps.getUntrackedParameter<std::string>("CorrectionsIdentifier")));
24  else if (type == "resolution")
25  corrector_.reset(new ResolutionFunction(ps.getUntrackedParameter<std::string>("CorrectionsIdentifier")));
26  else if (type == "background")
27  corrector_.reset(new BackgroundFunction(ps.getUntrackedParameter<std::string>("CorrectionsIdentifier")));
28  else {
29  std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
30  exit(1);
31  }
32 }
type
Definition: HCALResponse.h:21
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< BaseFunction > corrector_
Definition: DBWriter.h:20
def exit(msg="")
DBWriter::~DBWriter ( )
override

Definition at line 34 of file DBWriter.cc.

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

Member Function Documentation

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

Definition at line 40 of file DBWriter.cc.

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

40  {
41  MuScleFitDBobject* dbObject = new MuScleFitDBobject;
42 
43  dbObject->identifiers = corrector_->identifiers();
44  dbObject->parameters = corrector_->parameters();
45 
46  // if( dbObject->identifiers.size() != dbObject->parameters.size() ) {
47  // std::cout << "Error: size of parameters("<<dbObject->parameters.size()<<") and identifiers("<<dbObject->identifiers.size()<<") don't match" << std::endl;
48  // exit(1);
49  // }
50 
51  // std::vector<std::vector<double> >::const_iterator parVec = dbObject->parameters.begin();
52  // std::vector<int>::const_iterator id = dbObject->identifiers.begin();
53  // for( ; id != dbObject->identifiers.end(); ++id, ++parVec ) {
54  // std::cout << "id = " << *id << std::endl;
55  // std::vector<double>::const_iterator par = parVec->begin();
56  // int i=0;
57  // for( ; par != parVec->end(); ++par, ++i ) {
58  // std::cout << "par["<<i<<"] = " << *par << std::endl;
59  // }
60  // }
61 
62  // Save the parameters to the db.
64  if (mydbservice.isAvailable()) {
65  if (mydbservice->isNewTagRequest("MuScleFitDBobjectRcd")) {
66  mydbservice->createNewIOV<MuScleFitDBobject>(
67  dbObject, mydbservice->beginOfTime(), mydbservice->endOfTime(), "MuScleFitDBobjectRcd");
68  } else {
69  mydbservice->appendSinceTime<MuScleFitDBobject>(dbObject, mydbservice->currentTime(), "MuScleFitDBobjectRcd");
70  }
71  } else {
72  edm::LogError("DBWriter") << "Service is unavailable" << std::endl;
73  }
74 }
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
std::vector< int > identifiers
bool isAvailable() const
Definition: Service.h:40
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
std::unique_ptr< BaseFunction > corrector_
Definition: DBWriter.h:20
std::vector< double > parameters
void DBWriter::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 20 of file DBWriter.h.

References corrector_.

20 {};

Member Data Documentation

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

Definition at line 20 of file DBWriter.h.

Referenced by analyze(), DBWriter(), and endJob().