test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalTrackingRegionWithVerticesProducer.h
Go to the documentation of this file.
1 #ifndef RecoTracker_TkTrackingRegions_GlobalTrackingRegionWithVerticesProducer_H
2 #define RecoTracker_TkTrackingRegions_GlobalTrackingRegionWithVerticesProducer_H
3 
8 
14 
16 {
17 public:
18 
21  {
22  edm::ParameterSet regionPSet = cfg.getParameter<edm::ParameterSet>("RegionPSet");
23 
24  thePtMin = regionPSet.getParameter<double>("ptMin");
25  theOriginRadius = regionPSet.getParameter<double>("originRadius");
26  theNSigmaZ = regionPSet.getParameter<double>("nSigmaZ");
27  token_beamSpot = iC.consumes<reco::BeamSpot>(regionPSet.getParameter<edm::InputTag>("beamSpot"));
28  thePrecise = regionPSet.getParameter<bool>("precise");
29  theUseMS = regionPSet.getParameter<bool>("useMultipleScattering");
30 
31  theSigmaZVertex = regionPSet.getParameter<double>("sigmaZVertex");
32  theFixedError = regionPSet.getParameter<double>("fixedError");
33 
34  theUseFoundVertices = regionPSet.getParameter<bool>("useFoundVertices");
35  theUseFakeVertices = regionPSet.getParameter<bool>("useFakeVertices");
36  theUseFixedError = regionPSet.getParameter<bool>("useFixedError");
37  token_vertex = iC.consumes<reco::VertexCollection>(regionPSet.getParameter<edm::InputTag>("VertexCollection"));
38  }
39 
41 
42  virtual std::vector<std::unique_ptr<TrackingRegion> > regions
43  (const edm::Event& ev, const edm::EventSetup&) const override
44  {
45  std::vector<std::unique_ptr<TrackingRegion> > result;
46 
47  GlobalPoint theOrigin;
49  ev.getByToken( token_beamSpot, bsHandle);
50  double bsSigmaZ;
51  if(bsHandle.isValid()) {
52  const reco::BeamSpot & bs = *bsHandle;
53  bsSigmaZ = theNSigmaZ*bs.sigmaZ();
54  theOrigin = GlobalPoint(bs.x0(), bs.y0(), bs.z0());
55  }else{
56  throw cms::Exception("Seeding") << "ERROR: input beamSpot is not valid in GlobalTrackingRegionWithVertices";
57  }
58 
60  {
62  ev.getByToken(token_vertex,vertexCollection);
63 
64  for(reco::VertexCollection::const_iterator iV=vertexCollection->begin(); iV != vertexCollection->end() ; iV++) {
65  if (!iV->isValid()) continue;
66  if (iV->isFake() && !(theUseFakeVertices && theUseFixedError)) continue;
67  GlobalPoint theOrigin_ = GlobalPoint(iV->x(),iV->y(),iV->z());
68  double theOriginHalfLength_ = (theUseFixedError ? theFixedError : (iV->zError())*theSigmaZVertex);
69  result.push_back( std::make_unique<GlobalTrackingRegion>(thePtMin, theOrigin_, theOriginRadius, theOriginHalfLength_, thePrecise, theUseMS) );
70  }
71 
72  if (result.empty()) {
73  result.push_back( std::make_unique<GlobalTrackingRegion>(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS) );
74  }
75  }
76  else
77  {
78  result.push_back(
79  std::make_unique<GlobalTrackingRegion>(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS) );
80  }
81 
82  return result;
83  }
84 
85 private:
86  double thePtMin;
87  double theOriginRadius;
88  double theNSigmaZ;
90 
92  double theFixedError;
93  bool thePrecise;
94  bool theUseMS;
95 
101 
102 
103 };
104 
105 #endif
T getParameter(std::string const &) const
double z0() const
z coordinate
Definition: BeamSpot.h:68
tuple cfg
Definition: looper.py:293
virtual std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &ev, const edm::EventSetup &) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
edm::EDGetTokenT< reco::VertexCollection > token_vertex
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool ev
tuple vertexCollection
tuple result
Definition: mps_fire.py:84
bool isValid() const
Definition: HandleBase.h:75
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
GlobalTrackingRegionWithVerticesProducer(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
double y0() const
y coordinate
Definition: BeamSpot.h:66
double x0() const
x coordinate
Definition: BeamSpot.h:64