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
 
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)
 
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 ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, 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 14 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, cmsRelvalreport::exit, edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 32 of file DBWriter.cc.

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

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.

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>(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 
75 }
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:46
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:21
std::vector< double > parameters
void DBWriter::endJob ( void  )
inlineoverrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 21 of file DBWriter.h.

References corrector_.

21 {};

Member Data Documentation

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

Definition at line 21 of file DBWriter.h.

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