CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoTracker/TkTrackingRegions/plugins/GlobalTrackingRegionProducerFromBeamSpot.h

Go to the documentation of this file.
00001 #ifndef RecoTracker_TkTrackingRegions_GlobalTrackingRegionProducerFromBeamSpot_H
00002 #define RecoTracker_TkTrackingRegions_GlobalTrackingRegionProducerFromBeamSpot_H
00003 
00004 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
00005 #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00008 #include "FWCore/Utilities/interface/InputTag.h"
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 
00011 class GlobalTrackingRegionProducerFromBeamSpot : public TrackingRegionProducer {
00012 
00013 public:
00014 
00015   GlobalTrackingRegionProducerFromBeamSpot(const edm::ParameterSet& cfg) {
00016 
00017     edm::ParameterSet regionPSet = cfg.getParameter<edm::ParameterSet>("RegionPSet");
00018     thePtMin            = regionPSet.getParameter<double>("ptMin");
00019     theOriginRadius     = regionPSet.getParameter<double>("originRadius");
00020     if (!regionPSet.existsAs<double>("nSigmaZ") && !regionPSet.existsAs<double>("originHalfLength")) {
00021         throw cms::Exception("Configuration") << "GlobalTrackingRegionProducerFromBeamSpot: at least one of nSigmaZ, originHalfLength must be present in the cfg.\n";
00022     }
00023     theNSigmaZ          = (regionPSet.existsAs<double>("nSigmaZ")          ? regionPSet.getParameter<double>("nSigmaZ")          : 0.0);
00024     theOriginHalfLength = (regionPSet.existsAs<double>("originHalfLength") ? regionPSet.getParameter<double>("originHalfLength") : 0.0);
00025     theBeamSpotTag      = regionPSet.getParameter<edm::InputTag>("beamSpot");
00026     thePrecise          = regionPSet.getParameter<bool>("precise");
00027   }
00028 
00029   virtual ~GlobalTrackingRegionProducerFromBeamSpot(){}
00030 
00031   virtual std::vector<TrackingRegion* > regions(const edm::Event&ev, const edm::EventSetup&) const {
00032     std::vector<TrackingRegion* > result;
00033     edm::Handle<reco::BeamSpot> bsHandle;
00034     ev.getByLabel( theBeamSpotTag, bsHandle);
00035     if(bsHandle.isValid()) {
00036 
00037       const reco::BeamSpot & bs = *bsHandle; 
00038 
00039       GlobalPoint origin(bs.x0(), bs.y0(), bs.z0()); 
00040 
00041       result.push_back( new GlobalTrackingRegion( 
00042           thePtMin, origin, theOriginRadius, std::max(theNSigmaZ*bs.sigmaZ(), theOriginHalfLength), thePrecise));
00043 
00044     }
00045     return result;
00046   }
00047 
00048 private:
00049   double thePtMin;
00050   double theOriginRadius;
00051   double theOriginHalfLength; 
00052   double theNSigmaZ;
00053   edm::InputTag theBeamSpotTag;
00054   bool thePrecise;
00055 };
00056 
00057 #endif
00058