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/11/17 17:54:23
Revision:
1.8
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 correctionAlgo_, reco::get(), and edm::ParameterSet::getParameter().

                                                            : 
  dbLabel_( pset.getUntrackedParameter<string>("dbLabel", "") ) {

  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"));
}
DTTTrigCorrection::~DTTTrigCorrection ( ) [virtual]

Destructor.

Definition at line 46 of file DTTTrigCorrection.cc.

References correctionAlgo_.

                                     {
  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 correctionAlgo_, dbLabel_, edm::EventSetup::get(), muonGeom_, DTTTrigBaseCorrection::setES(), and tTrigMap_.

                                                                                {
  // 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 DTTTrigBaseCorrection::correction(), correctionAlgo_, alignCSCRings::e, cms::Exception::explainSelf(), DTTtrig::get(), DTTTrigData::kFactor, DTTTrigData::mean, muonGeom_, DTTimeUnits::ns, record, DTTtrig::set(), DTTTrigData::sigma, ntuplemaker::status, and tTrigMap_.

                               {
  // Create the object to be written to DB
  DTTtrig* tTrigNewMap = new DTTtrig();  

  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.

Referenced by beginRun(), DTTTrigCorrection(), endJob(), and ~DTTTrigCorrection().

std::string DTTTrigCorrection::dbLabel_ [private]

Definition at line 41 of file DTTTrigCorrection.h.

Referenced by beginRun().

Definition at line 44 of file DTTTrigCorrection.h.

Referenced by beginRun(), and endJob().

Definition at line 43 of file DTTTrigCorrection.h.

Referenced by beginRun(), and endJob().