CMS 3D CMS Logo

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  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
44 
45  desc.add<bool>("precise", true);
46  desc.add<bool>("useMultipleScattering", false);
47  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
48  desc.add<bool>("useFixedError", true);
49  desc.add<double>("originRadius", 0.2);
50  desc.add<double>("sigmaZVertex", 3.0);
51  desc.add<double>("fixedError", 0.2);
52  desc.add<edm::InputTag>("VertexCollection", edm::InputTag("firstStepPrimaryVertices"));
53  desc.add<double>("ptMin", 0.9);
54  desc.add<bool>("useFoundVertices", true);
55  desc.add<bool>("useFakeVertices", false);
56  desc.add<double>("nSigmaZ", 4.0);
57 
58  // Only for backwards-compatibility
60  descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
61 
62  descriptions.add("globalTrackingRegionWithVertices", descRegion);
63  }
64 
65  virtual std::vector<std::unique_ptr<TrackingRegion> > regions
66  (const edm::Event& ev, const edm::EventSetup&) const override
67  {
68  std::vector<std::unique_ptr<TrackingRegion> > result;
69 
70  GlobalPoint theOrigin;
72  ev.getByToken( token_beamSpot, bsHandle);
73  double bsSigmaZ;
74  if(bsHandle.isValid()) {
75  const reco::BeamSpot & bs = *bsHandle;
76  bsSigmaZ = theNSigmaZ*bs.sigmaZ();
77  theOrigin = GlobalPoint(bs.x0(), bs.y0(), bs.z0());
78  }else{
79  throw cms::Exception("Seeding") << "ERROR: input beamSpot is not valid in GlobalTrackingRegionWithVertices";
80  }
81 
83  {
85  ev.getByToken(token_vertex,vertexCollection);
86 
87  for(reco::VertexCollection::const_iterator iV=vertexCollection->begin(); iV != vertexCollection->end() ; iV++) {
88  if (!iV->isValid()) continue;
89  if (iV->isFake() && !(theUseFakeVertices && theUseFixedError)) continue;
90  GlobalPoint theOrigin_ = GlobalPoint(iV->x(),iV->y(),iV->z());
91  double theOriginHalfLength_ = (theUseFixedError ? theFixedError : (iV->zError())*theSigmaZVertex);
92  result.push_back( std::make_unique<GlobalTrackingRegion>(thePtMin, theOrigin_, theOriginRadius, theOriginHalfLength_, thePrecise, theUseMS) );
93  }
94 
95  if (result.empty()) {
96  result.push_back( std::make_unique<GlobalTrackingRegion>(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS) );
97  }
98  }
99  else
100  {
101  result.push_back(
102  std::make_unique<GlobalTrackingRegion>(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS) );
103  }
104 
105  return result;
106  }
107 
108 private:
109  double thePtMin;
111  double theNSigmaZ;
113 
117  bool theUseMS;
118 
124 
125 
126 };
127 
128 #endif
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double z0() const
z coordinate
Definition: BeamSpot.h:68
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
void add(std::string const &label, ParameterSetDescription const &psetDescription)
GlobalTrackingRegionWithVerticesProducer(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
double y0() const
y coordinate
Definition: BeamSpot.h:66
virtual std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &ev, const edm::EventSetup &) const override
double x0() const
x coordinate
Definition: BeamSpot.h:64