CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

std::auto_ptr< BaseFunctioncorrector_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 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
tuple cout
Definition: gather_cfg.py:121
std::auto_ptr< BaseFunction > corrector_
Definition: DBWriter.h:21
DBWriter::~DBWriter ( )

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 
)
privatevirtual

Implements edm::EDAnalyzer.

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(), 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::auto_ptr< BaseFunction > corrector_
Definition: DBWriter.h:21
std::vector< double > parameters
virtual void DBWriter::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 21 of file DBWriter.h.

21 {};

Member Data Documentation

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

Definition at line 21 of file DBWriter.h.

Referenced by analyze(), and DBWriter().