test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PointSeededTrackingRegionsProducer.h
Go to the documentation of this file.
1 #ifndef PointSeededTrackingRegionsProducer_h
2 #define PointSeededTrackingRegionsProducer_h
3 
4 
7 
18 
19 #include <TMath.h>
20 #include <TLorentzVector.h>
21 
47 {
48 public:
49 
51 
54  {
55  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
56 
57  // operation mode
58  std::string modeString = regPSet.getParameter<std::string>("mode");
59  if (modeString == "BeamSpotFixed") m_mode = BEAM_SPOT_FIXED;
60  else if (modeString == "BeamSpotSigma") m_mode = BEAM_SPOT_SIGMA;
61  else if (modeString == "VerticesFixed") m_mode = VERTICES_FIXED;
62  else if (modeString == "VerticesSigma") m_mode = VERTICES_SIGMA;
63  else edm::LogError ("PointSeededTrackingRegionsProducer")<<"Unknown mode string: "<<modeString;
64 
65  // basic inputs
66  edm::ParameterSet point_input = regPSet.getParameter<edm::ParameterSet>("point_input");
67  eta_input = point_input.getParameter<double>("eta");
68  phi_input = point_input.getParameter<double>("phi");
69  m_maxNRegions = regPSet.getParameter<int>("maxNRegions");
70  token_beamSpot = iC.consumes<reco::BeamSpot>(regPSet.getParameter<edm::InputTag>("beamSpot"));
71  m_maxNVertices = 1;
73  {
74  token_vertex = iC.consumes<reco::VertexCollection>(regPSet.getParameter<edm::InputTag>("vertexCollection"));
75  m_maxNVertices = regPSet.getParameter<int>("maxNVertices");
76  }
77 
78  // RectangularEtaPhiTrackingRegion parameters:
79  m_ptMin = regPSet.getParameter<double>("ptMin");
80  m_originRadius = regPSet.getParameter<double>("originRadius");
81  m_zErrorBeamSpot = regPSet.getParameter<double>("zErrorBeamSpot");
82  m_deltaEta = regPSet.getParameter<double>("deltaEta");
83  m_deltaPhi = regPSet.getParameter<double>("deltaPhi");
84  m_precise = regPSet.getParameter<bool>("precise");
86  if(m_whereToUseMeasurementTracker != RectangularEtaPhiTrackingRegion::UseMeasurementTracker::kNever) {
87  token_measurementTracker = iC.consumes<MeasurementTrackerEvent>(regPSet.getParameter<edm::InputTag>("measurementTrackerName"));
88  }
89  m_searchOpt = false;
90  if (regPSet.exists("searchOpt")) m_searchOpt = regPSet.getParameter<bool>("searchOpt");
91 
92  // mode-dependent z-halflength of tracking regions
93  if (m_mode == VERTICES_SIGMA) m_nSigmaZVertex = regPSet.getParameter<double>("nSigmaZVertex");
94  if (m_mode == VERTICES_FIXED) m_zErrorVetex = regPSet.getParameter<double>("zErrorVetex");
95  m_nSigmaZBeamSpot = -1.;
96  if (m_mode == BEAM_SPOT_SIGMA)
97  {
98  m_nSigmaZBeamSpot = regPSet.getParameter<double>("nSigmaZBeamSpot");
99  if (m_nSigmaZBeamSpot < 0.)
100  edm::LogError ("PointSeededTrackingRegionsProducer")<<"nSigmaZBeamSpot must be positive for BeamSpotSigma mode!";
101  }
102  }
103 
105 
106 
107  virtual std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& e, const edm::EventSetup& es) const override
108  {
109  std::vector<std::unique_ptr<TrackingRegion> > result;
110 
111  // always need the beam spot (as a fall back strategy for vertex modes)
113  e.getByToken( token_beamSpot, bs );
114  if( !bs.isValid() ) return result;
115 
116  // this is a default origin for all modes
117  GlobalPoint default_origin( bs->x0(), bs->y0(), bs->z0() );
118 
119  // vector of origin & halfLength pairs:
120  std::vector< std::pair< GlobalPoint, float > > origins;
121 
122  // fill the origins and halfLengths depending on the mode
124  origins.push_back( std::make_pair( default_origin,
126  ));
127  } else if (m_mode == VERTICES_FIXED || m_mode == VERTICES_SIGMA) {
129  e.getByToken( token_vertex, vertices );
130  int n_vert = 0;
131  for (reco::VertexCollection::const_iterator iv = vertices->begin(), ev = vertices->end();
132  iv != ev && n_vert < m_maxNVertices; ++iv) {
133  if ( iv->isFake() || !iv->isValid() ) continue;
134 
135  origins.push_back( std::make_pair( GlobalPoint( iv->x(), iv->y(), iv->z() ),
136  (m_mode == VERTICES_FIXED) ? m_zErrorVetex : m_nSigmaZVertex*iv->zError()
137  ));
138  ++n_vert;
139  }
140  // no-vertex fall-back case:
141  if ( origins.empty() ) {
142  origins.push_back( std::make_pair( default_origin,
143  (m_nSigmaZBeamSpot > 0.) ? m_nSigmaZBeamSpot*bs->z0Error() : m_zErrorBeamSpot
144  ));
145  }
146  }
147 
152  measurementTracker = hmte.product();
153  }
154 
155  // create tracking regions (maximum MaxNRegions of them) in directions of the
156  // points of interest
157  size_t n_points = 1;
158  int n_regions = 0;
159  for(size_t i = 0; i < n_points && n_regions < m_maxNRegions; ++i ) {
160 
161  double x = TMath::Cos(phi_input);
162  double y = TMath::Sin(phi_input);
163  double theta = 2*TMath::ATan(TMath::Exp(-eta_input));
164  double z = (x*x+y*y)/TMath::Tan(theta);
165 
166  GlobalVector direction( x,y,z );
167 
168  for (size_t j=0; j<origins.size() && n_regions < m_maxNRegions; ++j) {
169 
170  result.push_back( std::make_unique<RectangularEtaPhiTrackingRegion>(
171  direction, // GlobalVector
172  origins[j].first, // GlobalPoint
173  m_ptMin,
175  origins[j].second,
176  m_deltaEta,
177  m_deltaPhi,
179  m_precise,
180  measurementTracker,
182  ));
183  ++n_regions;
184  }
185  }
186  //std::cout<<"n_seeded_regions = "<<n_regions<<std::endl;
187  edm::LogInfo ("PointSeededTrackingRegionsProducer") << "produced "<<n_regions<<" regions";
188 
189  return result;
190  }
191 
192 private:
193 
195 
201 
202  float m_ptMin;
205  float m_deltaEta;
206  float m_deltaPhi;
207  bool m_precise;
211 
215 };
216 
217 #endif
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
PointSeededTrackingRegionsProducer(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
virtual std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &e, const edm::EventSetup &es) const override
bool ev
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
edm::EDGetTokenT< MeasurementTrackerEvent > token_measurementTracker
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
tuple result
Definition: mps_fire.py:83
U second(std::pair< T, U > const &p)
int j
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::VertexCollection > token_vertex
bool isValid() const
Definition: HandleBase.h:75
T const * product() const
Definition: Handle.h:81
bool isUninitialized() const
Definition: EDGetToken.h:73