CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTTTrigCorrection Class Reference

#include <DTTTrigCorrection.h>

Inheritance diagram for DTTTrigCorrection:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &setup)
virtual void beginJob ()
virtual void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 DTTTrigCorrection (const edm::ParameterSet &pset)
 Constructor.
virtual void endJob ()
virtual ~DTTTrigCorrection ()
 Destructor.

Private Attributes

DTTTrigBaseCorrectioncorrectionAlgo_
std::string dbLabel
edm::ESHandle< DTGeometrymuonGeom_
const DTTtrigtTrigMap_

Detailed Description

Class which read a ttrig DB and correct it with the near SL (or the global average)

Date:
2010/02/16 10:03:23
Revision:
1.7
Author:
S. Maselli - INFN Torino

Class which read a ttrig DB and correct it with the near SL (or the global average)

Date:
2010/02/16 10:03:23
Revision:
1.3
Author:
S. Maselli - INFN Torino

Definition at line 23 of file DTTTrigCorrection.h.


Constructor & Destructor Documentation

DTTTrigCorrection::DTTTrigCorrection ( const edm::ParameterSet pset)

Constructor.

Definition at line 36 of file DTTTrigCorrection.cc.

References reco::get(), edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

                                                             {
  LogVerbatim("Calibration") << "[DTTTrigCorrection] Constructor called" << endl;

  // Get the concrete algo from the factory
  string theAlgoName = pset.getParameter<string>("correctionAlgo");
  correctionAlgo_ = DTTTrigCorrectionFactory::get()->create(theAlgoName,pset.getParameter<ParameterSet>("correctionAlgoConfig"));

  dbLabel  = pset.getUntrackedParameter<string>("dbLabel", "");
}
DTTTrigCorrection::~DTTTrigCorrection ( ) [virtual]

Destructor.

Definition at line 46 of file DTTTrigCorrection.cc.

                                     {
  LogVerbatim("Calibration") << "[DTTTrigCorrection] Destructor called" << endl;
  delete correctionAlgo_;
}

Member Function Documentation

virtual void DTTTrigCorrection::analyze ( const edm::Event event,
const edm::EventSetup setup 
) [inline, virtual]

Implements edm::EDAnalyzer.

Definition at line 35 of file DTTTrigCorrection.h.

{}
virtual void DTTTrigCorrection::beginJob ( void  ) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file DTTTrigCorrection.h.

{}
void DTTTrigCorrection::beginRun ( const edm::Run run,
const edm::EventSetup setup 
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file DTTTrigCorrection.cc.

References edm::EventSetup::get().

                                                                                {
  // Get tTrig record from DB
  ESHandle<DTTtrig> tTrig;
  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
  tTrigMap_ = &*tTrig;
  LogVerbatim("Calibration") << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl;

  // Get geometry from Event Setup
  setup.get<MuonGeometryRecord>().get(muonGeom_);

  // Pass EventSetup to correction Algo
  correctionAlgo_->setES(setup);
}
void DTTTrigCorrection::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 65 of file DTTTrigCorrection.cc.

References ExpressReco_HICollisions_FallBack::e, cms::Exception::explainSelf(), DTTTrigData::kFactor, DTTTrigData::mean, DTTimeUnits::ns, record, DTTtrig::set(), DTTTrigData::sigma, and ntuplemaker::status.

                               {
  // Create the object to be written to DB
  DTTtrig* tTrigNewMap = new DTTtrig();  
  //Get the superlayers list
  vector<DTSuperLayer*> dtSupLylist = muonGeom_->superLayers();

  for(vector<DTSuperLayer*>::const_iterator sl = muonGeom_->superLayers().begin();
                                            sl != muonGeom_->superLayers().end(); ++sl) {
    // Get old value from DB
    float tTrigMean,tTrigSigma,kFactor;
    int status = tTrigMap_->get((*sl)->id(),tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);

    //Compute new ttrig
    try{
      DTTTrigData tTrigCorr = correctionAlgo_->correction((*sl)->id());
      float tTrigMeanNew = tTrigCorr.mean;
      float tTrigSigmaNew = tTrigCorr.sigma; 
      float kFactorNew = tTrigCorr.kFactor;
      tTrigNewMap->set((*sl)->id(),tTrigMeanNew,tTrigSigmaNew,kFactorNew,DTTimeUnits::ns);

      LogVerbatim("Calibration") << "New tTrig for : " << (*sl)->id()
                                 << " mean from " << tTrigMean << " to " << tTrigMeanNew
                                 << " sigma from " << tTrigSigma << " to " << tTrigSigmaNew
                                 << " kFactor from " << kFactor << " to " << kFactorNew << endl;
    } catch(cms::Exception& e){
      LogError("Calibration") << e.explainSelf();
      // Set db to the old value, if it was there in the first place
      if(!status){
         tTrigNewMap->set((*sl)->id(),tTrigMean,tTrigSigma,kFactor,DTTimeUnits::ns);
         LogVerbatim("Calibration") << "Keep old tTrig for : " << (*sl)->id()
                                    << " mean " << tTrigMean
                                    << " sigma " << tTrigSigma
                                    << " kFactor " << kFactor << endl;
      } 
      continue;
    }
  }//End of loop on superlayers 

  //Write object to DB
  LogVerbatim("Calibration") << "[DTTTrigCorrection]: Writing ttrig object to DB!" << endl;
  string record = "DTTtrigRcd";
  DTCalibDBUtils::writeToDB<DTTtrig>(record, tTrigNewMap);
} 

Member Data Documentation

Definition at line 46 of file DTTTrigCorrection.h.

std::string DTTTrigCorrection::dbLabel [private]

Definition at line 44 of file DTTTrigCorrection.h.

Definition at line 42 of file DTTTrigCorrection.h.

Definition at line 41 of file DTTTrigCorrection.h.