CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoTracker/MeasurementDet/plugins/MeasurementTrackerSiStripRefGetterProducer.cc

Go to the documentation of this file.
00001 #include "RecoTracker/MeasurementDet/plugins/MeasurementTrackerSiStripRefGetterProducer.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 
00006 #include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"
00007 
00008 //measurement tracker
00009 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
00010 #include "OnDemandMeasurementTracker.h"
00011 
00012 
00013 using namespace std;
00014 //using namespace sistrip;
00015 
00016 // -----------------------------------------------------------------------------
00017 //
00018 MeasurementTrackerSiStripRefGetterProducer::MeasurementTrackerSiStripRefGetterProducer( const edm::ParameterSet& conf ) :
00019   inputModuleLabel_(conf.getParameter<edm::InputTag>("InputModuleLabel")),
00020   cabling_(),
00021   measurementTrackerName_(conf.getParameter<string>("measurementTrackerName"))
00022 {
00023   produces< RefGetter >();
00024 }
00025 
00026 // -----------------------------------------------------------------------------
00027 MeasurementTrackerSiStripRefGetterProducer::~MeasurementTrackerSiStripRefGetterProducer() {}
00028 
00029 // -----------------------------------------------------------------------------
00030 void MeasurementTrackerSiStripRefGetterProducer::beginRun( edm::Run &, const edm::EventSetup& setup) {
00031  //get cabling
00032   setup.get<SiStripRegionCablingRcd>().get(cabling_);
00033 }
00034 
00035 // -----------------------------------------------------------------------------
00036 void MeasurementTrackerSiStripRefGetterProducer::endRun(edm::Run &, const edm::EventSetup&) {;}
00037 
00038 // -----------------------------------------------------------------------------
00040 void MeasurementTrackerSiStripRefGetterProducer::produce( edm::Event& event, 
00041                                             const edm::EventSetup& setup ) {
00042 
00043   // Retrieve unpacking tool from event
00044   edm::Handle< LazyGetter > lazygetter;
00045   event.getByLabel(inputModuleLabel_,lazygetter);
00046   
00047   // Construct default RefGetter object
00048   std::auto_ptr<RefGetter> refgetter(new RefGetter());
00049 
00050   //retreive the measurement tracker.
00051   edm::ESHandle<MeasurementTracker> mtESH;
00052   setup.get<CkfComponentsRecord>().get(measurementTrackerName_,mtESH);
00053   
00054   //cast it to the proper type
00055   const OnDemandMeasurementTracker * tOD = dynamic_cast<const OnDemandMeasurementTracker *>(mtESH.product());
00056   
00057   if (!tOD){
00058     edm::LogError("MeasurementTrackerSiStripRefGetterProducer")<<"casting of MeasurementTracker named: "<<measurementTrackerName_<<" into OnDemandMeasurementTracker does not work.";
00059   }
00060   else{
00061     //define the regions for each individual module
00062     tOD->define(lazygetter, refgetter);
00063   }
00064 
00065   // Add to event
00066   event.put(refgetter);
00067 }
00068