CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTT0Correction Class Reference

#include <DTT0Correction.h>

Inheritance diagram for DTT0Correction:
edm::EDAnalyzer edm::EDConsumerBase

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)
 DTT0Correction (const edm::ParameterSet &pset)
 Constructor.
virtual void endJob ()
virtual ~DTT0Correction ()
 Destructor.

Private Attributes

dtCalibration::DTT0BaseCorrectioncorrectionAlgo_
edm::ESHandle< DTGeometrymuonGeom_
const DTT0t0Map_

Detailed Description

Class that reads and corrects t0 DB

Date:
2012/03/02 19:47:32
Revision:
1.1
Author:
A. Vilela Pereira

Definition at line 24 of file DTT0Correction.h.


Constructor & Destructor Documentation

DTT0Correction::DTT0Correction ( const edm::ParameterSet pset)

Constructor.

Definition at line 36 of file DTT0Correction.cc.

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

                                                      { 

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

  // Get the concrete algo from the factory
  string theAlgoName = pset.getParameter<string>("correctionAlgo");
  correctionAlgo_ = DTT0CorrectionFactory::get()->create(theAlgoName,pset.getParameter<ParameterSet>("correctionAlgoConfig"));
}
DTT0Correction::~DTT0Correction ( ) [virtual]

Destructor.

Definition at line 45 of file DTT0Correction.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 36 of file DTT0Correction.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 34 of file DTT0Correction.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file DTT0Correction.cc.

References edm::EventSetup::get().

                                                                             {
  // Get t0 record from DB
  ESHandle<DTT0> t0H;
  setup.get<DTT0Rcd>().get(t0H);
  t0Map_ = &*t0H;
  LogVerbatim("Calibration") << "[DTT0Correction]: T0 version: " << t0H->version() << endl;

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 64 of file DTT0Correction.cc.

References DTTimeUnits::counts, alignCSCRings::e, cms::Exception::explainSelf(), DTTopology::firstChannel(), DTTopology::lastChannel(), dtCalibration::DTT0Data::mean, record, dtCalibration::DTT0Data::rms, DTT0::set(), and ntuplemaker::status.

                            {
  // Create the object to be written to DB
  DTT0* t0NewMap = new DTT0();  

  // Loop over all channels
  for(vector<DTSuperLayer*>::const_iterator sl = muonGeom_->superLayers().begin();
                                            sl != muonGeom_->superLayers().end(); ++sl) {
     for(vector<const DTLayer*>::const_iterator layer = (*sl)->layers().begin();
                                                layer != (*sl)->layers().end(); ++layer) {
        // Access layer topology
        const DTTopology& dtTopo = (*layer)->specificTopology();
        const int firstWire = dtTopo.firstChannel();
        const int lastWire = dtTopo.lastChannel();
        //const int nWires = dtTopo.channels();

        //Loop on wires
        for(int wire = firstWire; wire <= lastWire; ++wire){
           DTWireId wireId((*layer)->id(),wire);

           // Get old value from DB
           float t0Mean,t0RMS;
           int status = t0Map_->get(wireId,t0Mean,t0RMS,DTTimeUnits::counts);

           // Compute new t0 for this wire
           try{
              dtCalibration::DTT0Data t0Corr = correctionAlgo_->correction( wireId );
              float t0MeanNew = t0Corr.mean;
              float t0RMSNew = t0Corr.rms; 
              t0NewMap->set(wireId,t0MeanNew,t0RMSNew,DTTimeUnits::counts);

              LogVerbatim("Calibration") << "New t0 for: " << wireId
                                         << " mean from " << t0Mean << " to " << t0MeanNew
                                         << " rms from " << t0RMS << " to " << t0RMSNew << 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){
                 t0NewMap->set(wireId,t0Mean,t0RMS,DTTimeUnits::counts);
                 LogVerbatim("Calibration") << "Keep old t0 for: " << wireId
                                            << " mean " << t0Mean
                                            << " rms " << t0RMS << endl;
              } 
              continue;
           }
        } // End of loop on wires 
     } // End of loop on layers 
  } // End of loop on superlayers 
  
  //Write object to DB
  LogVerbatim("Calibration") << "[DTT0Correction]: Writing t0 object to DB!" << endl;
  string record = "DTT0Rcd";
  DTCalibDBUtils::writeToDB<DTT0>(record, t0NewMap);
} 

Member Data Documentation

Definition at line 46 of file DTT0Correction.h.

Definition at line 44 of file DTT0Correction.h.

const DTT0* DTT0Correction::t0Map_ [private]

Definition at line 43 of file DTT0Correction.h.