CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTVDriftWriter Class Reference

#include <DTVDriftWriter.h>

Inheritance diagram for DTVDriftWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
virtual void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 DTVDriftWriter (const edm::ParameterSet &pset)
virtual void endJob ()
virtual ~DTVDriftWriter ()

Private Attributes

edm::ESHandle< DTGeometrydtGeom_
std::string granularity_
const DTMtimemTimeMap_
DTVDriftBaseAlgovDriftAlgo_

Detailed Description

Definition at line 24 of file DTVDriftWriter.h.


Constructor & Destructor Documentation

DTVDriftWriter::DTVDriftWriter ( const edm::ParameterSet pset)

Definition at line 35 of file DTVDriftWriter.cc.

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

                                                      :
  granularity_( pset.getUntrackedParameter<string>("calibGranularity","bySL") ) {

  LogVerbatim("Calibration") << "[DTVDriftWriter]Constructor called!";

  if(granularity_ != "bySL")
     throw cms::Exception("Configuration") << "[DTVDriftWriter] Check parameter calibGranularity: " << granularity_ << " option not available.";

  // Get the concrete algo from the factory
  string algoName = pset.getParameter<string>("vDriftAlgo");
  ParameterSet algoPSet = pset.getParameter<ParameterSet>("vDriftAlgoConfig");
  vDriftAlgo_ = DTVDriftPluginFactory::get()->create(algoName,algoPSet);
}
DTVDriftWriter::~DTVDriftWriter ( ) [virtual]

Definition at line 49 of file DTVDriftWriter.cc.

References vDriftAlgo_.

                               {
  LogVerbatim("Calibration") << "[DTVDriftWriter]Destructor called!";
  delete vDriftAlgo_;
}

Member Function Documentation

virtual void DTVDriftWriter::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
) [inline, virtual]

Implements edm::EDAnalyzer.

Definition at line 31 of file DTVDriftWriter.h.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file DTVDriftWriter.cc.

References dtGeom_, edm::EventSetup::get(), mTimeMap_, DTVDriftBaseAlgo::setES(), and vDriftAlgo_.

                                                                           {
  // Get the map of ttrig from the Setup
  ESHandle<DTMtime> mTime;
  setup.get<DTMtimeRcd>().get(mTime);
  mTimeMap_ = &*mTime;

  // Get geometry from Event Setup
  setup.get<MuonGeometryRecord>().get(dtGeom_);
  // Pass EventSetup to concrete implementation
  vDriftAlgo_->setES(setup); 
}
void DTVDriftWriter::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 66 of file DTVDriftWriter.cc.

References DTVelocityUnits::cm_per_ns, DTVDriftBaseAlgo::compute(), dtGeom_, alignCSCRings::e, cms::Exception::explainSelf(), DTMtime::get(), granularity_, mTimeMap_, record, dtDQMClient_cfg::resolution, DTVDriftData::resolution, DTMtime::set(), ntuplemaker::status, DTVDriftData::vdrift, and vDriftAlgo_.

                            {
  // Create the object to be written to DB
  DTMtime* mTimeNewMap = new DTMtime();

  if(granularity_ == "bySL") {    
     // Get all the sls from the geometry
     const vector<DTSuperLayer*>& superLayers = dtGeom_->superLayers(); 
     vector<DTSuperLayer*>::const_iterator sl = superLayers.begin();
     vector<DTSuperLayer*>::const_iterator sl_end = superLayers.end();
     for(; sl != sl_end; ++sl){
        DTSuperLayerId slId = (*sl)->id();
        // Get original value from DB
        float vDrift = 0., resolution = 0.;
        // vdrift is cm/ns , resolution is cm
        int status = mTimeMap_->get(slId,vDrift,resolution,DTVelocityUnits::cm_per_ns);

        // Compute vDrift
        try{
           DTVDriftData vDriftData = vDriftAlgo_->compute(slId);
           float vDriftNew = vDriftData.vdrift;
           float resolutionNew = vDriftData.resolution; 
           // vdrift is cm/ns , resolution is cm
           mTimeNewMap->set(slId,
                            vDriftNew,
                            resolutionNew,
                            DTVelocityUnits::cm_per_ns);
           LogVerbatim("Calibration") << "vDrift for: " << slId
                                      << " Mean " << vDriftNew
                                      << " Resolution " << resolutionNew;
        } catch(cms::Exception& e){
           LogError("Calibration") << e.explainSelf();
           // Go back to original value in case of error
           if(!status){  
              mTimeNewMap->set(slId,
                               vDrift,
                               resolution,
                               DTVelocityUnits::cm_per_ns);
              LogVerbatim("Calibration") << "Keep original vDrift for: " << slId
                                         << " Mean " << vDrift
                                         << " Resolution " << resolution;
           }
        }
     } // End of loop on superlayers
  }

  // Write the vDrift object to DB
  LogVerbatim("Calibration") << "[DTVDriftWriter]Writing vdrift object to DB!";
  string record = "DTMtimeRcd";
  DTCalibDBUtils::writeToDB<DTMtime>(record, mTimeNewMap);
}

Member Data Documentation

Definition at line 38 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

std::string DTVDriftWriter::granularity_ [private]

Definition at line 35 of file DTVDriftWriter.h.

Referenced by DTVDriftWriter(), and endJob().

Definition at line 37 of file DTVDriftWriter.h.

Referenced by beginRun(), and endJob().

Definition at line 40 of file DTVDriftWriter.h.

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