CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DBWriter Class Reference

#include <DBWriter.h>

Inheritance diagram for DBWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

 DBWriter (const edm::ParameterSet &)
 ~DBWriter ()

Private Member Functions

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

Private Attributes

std::auto_ptr< BaseFunctioncorrector_

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, and edm::ParameterSet::getUntrackedParameter().

{
  // This string is one of: scale, resolution, background.
  std::string type( ps.getUntrackedParameter<std::string>("Type") );
  // Create the corrector and set the parameters
  if( type == "scale" ) corrector_.reset(new MomentumScaleCorrector( ps.getUntrackedParameter<std::string>("CorrectionsIdentifier") ) );
  else if( type == "resolution" ) corrector_.reset(new ResolutionFunction( ps.getUntrackedParameter<std::string>("CorrectionsIdentifier") ) );
  else if( type == "background" ) corrector_.reset(new BackgroundFunction( ps.getUntrackedParameter<std::string>("CorrectionsIdentifier") ) );
  else {
    std::cout << "Error: unrecognized type. Use one of those: 'scale', 'resolution', 'background'" << std::endl;
    exit(1);
  }
}
DBWriter::~DBWriter ( )

Definition at line 32 of file DBWriter.cc.

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

Member Function Documentation

void DBWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 40 of file DBWriter.cc.

References corrector_, MuScleFitDBobject::identifiers, edm::Service< T >::isAvailable(), and MuScleFitDBobject::parameters.

{
  MuScleFitDBobject * dbObject = new MuScleFitDBobject;

  dbObject->identifiers = corrector_->identifiers();
  dbObject->parameters = corrector_->parameters();

//   if( dbObject->identifiers.size() != dbObject->parameters.size() ) {
//     std::cout << "Error: size of parameters("<<dbObject->parameters.size()<<") and identifiers("<<dbObject->identifiers.size()<<") don't match" << std::endl;
//     exit(1);
//   }

//   std::vector<std::vector<double> >::const_iterator parVec = dbObject->parameters.begin();
//   std::vector<int>::const_iterator id = dbObject->identifiers.begin();
//   for( ; id != dbObject->identifiers.end(); ++id, ++parVec ) {
//     std::cout << "id = " << *id << std::endl;
//     std::vector<double>::const_iterator par = parVec->begin();
//     int i=0;
//     for( ; par != parVec->end(); ++par, ++i ) {
//       std::cout << "par["<<i<<"] = " << *par << std::endl;
//     }
//   }

  // Save the parameters to the db.
  edm::Service<cond::service::PoolDBOutputService> mydbservice;
  if( mydbservice.isAvailable() ){
    if( mydbservice->isNewTagRequest("MuScleFitDBobjectRcd") ){
      mydbservice->createNewIOV<MuScleFitDBobject>(dbObject,mydbservice->beginOfTime(),mydbservice->endOfTime(),"MuScleFitDBobjectRcd");
    } else {
      mydbservice->appendSinceTime<MuScleFitDBobject>(dbObject,mydbservice->currentTime(),"MuScleFitDBobjectRcd");      
    }
  } else {
    edm::LogError("DBWriter")<<"Service is unavailable"<<std::endl;
  }

}
virtual void DBWriter::endJob ( void  ) [inline, private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 21 of file DBWriter.h.

{};

Member Data Documentation

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

Definition at line 21 of file DBWriter.h.

Referenced by analyze(), and DBWriter().