00001 #ifndef RecoTracker_TkTrackingRegions_GlobalTrackingRegionWithVerticesProducer_H 00002 #define RecoTracker_TkTrackingRegions_GlobalTrackingRegionWithVerticesProducer_H 00003 00004 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h" 00005 #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h" 00006 #include "FWCore/Framework/interface/Event.h" 00007 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00008 00009 #include "DataFormats/VertexReco/interface/Vertex.h" 00010 #include "DataFormats/VertexReco/interface/VertexFwd.h" 00011 #include "DataFormats/BeamSpot/interface/BeamSpot.h" 00012 #include "FWCore/ParameterSet/interface/InputTag.h" 00013 00014 class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer 00015 { 00016 public: 00017 00018 GlobalTrackingRegionWithVerticesProducer(const edm::ParameterSet& cfg) 00019 { 00020 edm::ParameterSet regionPSet = cfg.getParameter<edm::ParameterSet>("RegionPSet"); 00021 00022 thePtMin = regionPSet.getParameter<double>("ptMin"); 00023 theOriginRadius = regionPSet.getParameter<double>("originRadius"); 00024 theNSigmaZ = regionPSet.getParameter<double>("nSigmaZ"); 00025 theBeamSpotTag = regionPSet.getParameter<edm::InputTag>("beamSpot"); 00026 thePrecise = regionPSet.getParameter<bool>("precise"); 00027 00028 theSigmaZVertex = regionPSet.getParameter<double>("sigmaZVertex"); 00029 theFixedError = regionPSet.getParameter<double>("fixedError"); 00030 00031 theUseFoundVertices = regionPSet.getParameter<bool>("useFoundVertices"); 00032 theUseFixedError = regionPSet.getParameter<bool>("useFixedError"); 00033 vertexCollName = regionPSet.getParameter<edm::InputTag>("VertexCollection"); 00034 } 00035 00036 virtual ~GlobalTrackingRegionWithVerticesProducer(){} 00037 00038 virtual std::vector<TrackingRegion* > regions 00039 (const edm::Event& ev, const edm::EventSetup&) const 00040 { 00041 std::vector<TrackingRegion* > result; 00042 00043 GlobalPoint theOrigin; 00044 edm::Handle<reco::BeamSpot> bsHandle; 00045 ev.getByLabel( theBeamSpotTag, bsHandle); 00046 double bsSigmaZ; 00047 if(bsHandle.isValid()) { 00048 const reco::BeamSpot & bs = *bsHandle; 00049 bsSigmaZ = theNSigmaZ*bs.sigmaZ(); 00050 theOrigin = GlobalPoint(bs.x0(), bs.y0(), bs.z0()); 00051 }else{ 00052 throw cms::Exception("Seeding") << "ERROR: input beamSpot is not valid in GlobalTrackingRegionWithVertices"; 00053 } 00054 00055 if(theUseFoundVertices) 00056 { 00057 edm::Handle<reco::VertexCollection> vertexCollection; 00058 ev.getByLabel(vertexCollName,vertexCollection); 00059 00060 if(vertexCollection->size() > 0) { 00061 for(reco::VertexCollection::const_iterator iV=vertexCollection->begin(); iV != vertexCollection->end() ; iV++) { 00062 GlobalPoint theOrigin_ = GlobalPoint(iV->x(),iV->y(),iV->z()); 00063 double theOriginHalfLength_; 00064 if(!theUseFixedError) { 00065 theOriginHalfLength_ = (iV->zError())*theSigmaZVertex; 00066 } 00067 if(theUseFixedError) { 00068 theOriginHalfLength_ = theFixedError; 00069 } 00070 result.push_back( new GlobalTrackingRegion(thePtMin, theOrigin_, theOriginRadius, theOriginHalfLength_, thePrecise) ); 00071 } 00072 } 00073 00074 else { 00075 result.push_back( new GlobalTrackingRegion(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise) ); 00076 } 00077 } 00078 else 00079 { 00080 result.push_back( 00081 new GlobalTrackingRegion(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise) ); 00082 } 00083 00084 return result; 00085 } 00086 00087 private: 00088 double thePtMin; 00089 double theOriginRadius; 00090 double theNSigmaZ; 00091 edm::InputTag theBeamSpotTag; 00092 00093 double theSigmaZVertex; 00094 double theFixedError; 00095 bool thePrecise; 00096 00097 bool theUseFoundVertices; 00098 bool theUseFixedError; 00099 edm::InputTag vertexCollName; 00100 00101 00102 }; 00103 00104 #endif