CMS 3D CMS Logo

CandidatePointSeededTrackingRegionsProducer.h
Go to the documentation of this file.
1 #ifndef CandidatePointSeededTrackingRegionsProducer_h
2 #define CandidatePointSeededTrackingRegionsProducer_h
3 
7 
21 
22 #include "VertexBeamspotOrigins.h"
23 
59 public:
61 
63  : m_origins(conf.getParameter<edm::ParameterSet>("RegionPSet"), iC) {
64  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
65 
66  // seeding mode
67  std::string seedingModeString = regPSet.getParameter<std::string>("seedingMode");
68  if (seedingModeString == "Candidate")
70  else if (seedingModeString == "Point")
72  else if (seedingModeString == "CandidatePoint")
74  else
75  throw edm::Exception(edm::errors::Configuration) << "Unknown seeding mode string: " << seedingModeString;
76 
77  // basic inputs
79  m_token_input = iC.consumes<reco::CandidateView>(regPSet.getParameter<edm::InputTag>("input"));
80 
81  // Specific points in the detector
84  std::vector<double> etaPoints = points.getParameter<std::vector<double>>("eta");
85  std::vector<double> phiPoints = points.getParameter<std::vector<double>>("phi");
86 
87  if (!(etaPoints.size() == phiPoints.size()))
88  throw edm::Exception(edm::errors::Configuration) << "The parameters 'eta' and 'phi' must have the same size";
89  if (etaPoints.empty())
91  << "At least one point should be defined for point or candidate+point seeding modes";
92 
93  for (size_t i = 0; i < etaPoints.size(); ++i) {
94  m_etaPhiPoints.push_back(std::make_pair(etaPoints[i], phiPoints[i]));
95 
96  double x = std::cos(phiPoints[i]);
97  double y = std::sin(phiPoints[i]);
98  double theta = 2 * std::atan(std::exp(-etaPoints[i]));
99  double z = 1. / std::tan(theta);
100  GlobalVector direction(x, y, z);
101  m_directionPoints.push_back(direction);
102  }
103  }
104 
105  m_maxNRegions = regPSet.getParameter<unsigned int>("maxNRegions");
106  if (m_maxNRegions == 0)
107  throw edm::Exception(edm::errors::Configuration) << "maxNRegions should be greater than or equal to 1";
108 
109  // RectangularEtaPhiTrackingRegion parameters:
110  m_ptMin = regPSet.getParameter<double>("ptMin");
111  m_originRadius = regPSet.getParameter<double>("originRadius");
112 
114  m_deltaEta_Cand = regPSet.getParameter<double>("deltaEta_Cand");
115  m_deltaPhi_Cand = regPSet.getParameter<double>("deltaPhi_Cand");
116  if (m_deltaEta_Cand < 0 || m_deltaPhi_Cand < 0)
118  << "Delta eta and phi parameters must be set for candidates in candidate seeding mode";
120  m_deltaEta_Point = regPSet.getParameter<double>("deltaEta_Point");
121  m_deltaPhi_Point = regPSet.getParameter<double>("deltaPhi_Point");
122  if (m_deltaEta_Point < 0 || m_deltaPhi_Point < 0)
124  << "Delta eta and phi parameters must be set for points in point seeding mode";
126  m_deltaEta_Cand = regPSet.getParameter<double>("deltaEta_Cand");
127  m_deltaPhi_Cand = regPSet.getParameter<double>("deltaPhi_Cand");
128  m_deltaEta_Point = regPSet.getParameter<double>("deltaEta_Point");
129  m_deltaPhi_Point = regPSet.getParameter<double>("deltaPhi_Point");
131  throw edm::Exception(edm::errors::Configuration) << "Delta eta and phi parameters must be set separately for "
132  "candidates and points in candidate+point seeding mode";
133  }
134 
135  m_precise = regPSet.getParameter<bool>("precise");
137  regPSet.getParameter<std::string>("whereToUseMeasurementTracker"));
140  iC.consumes<MeasurementTrackerEvent>(regPSet.getParameter<edm::InputTag>("measurementTrackerName"));
141  }
142  m_searchOpt = false;
143  if (regPSet.exists("searchOpt"))
144  m_searchOpt = regPSet.getParameter<bool>("searchOpt");
145  }
146 
148 
151 
152  desc.add<std::string>("seedingMode", "Candidate");
153 
154  desc.add<edm::InputTag>("input", edm::InputTag(""));
155  edm::ParameterSetDescription descPoints;
156  descPoints.add<std::vector<double>>("eta", {});
157  descPoints.add<std::vector<double>>("phi", {});
158  desc.add<edm::ParameterSetDescription>("points", descPoints);
159 
160  desc.add<unsigned int>("maxNRegions", 10);
161 
162  VertexBeamspotOrigins::fillDescriptions(desc, "hltOnlineBeamSpot", "hltPixelVertices", 1);
163 
164  desc.add<double>("ptMin", 0.9);
165  desc.add<double>("originRadius", 0.2);
166  desc.add<double>("deltaEta_Cand", -1.);
167  desc.add<double>("deltaPhi_Cand", -1.);
168  desc.add<double>("deltaEta_Point", -1.);
169  desc.add<double>("deltaPhi_Point", -1.);
170  desc.add<bool>("precise", true);
171 
172  desc.add<std::string>("whereToUseMeasurementTracker", "ForSiStrips");
173  desc.add<edm::InputTag>("measurementTrackerName", edm::InputTag(""));
174 
175  desc.add<bool>("searchOpt", false);
176 
177  // Only for backwards-compatibility
178  edm::ParameterSetDescription descRegion;
179  descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
180 
181  descriptions.add("candidatePointSeededTrackingRegionsFromBeamSpot", descRegion);
182  }
183 
184  std::vector<std::unique_ptr<TrackingRegion>> regions(const edm::Event& e, const edm::EventSetup& es) const override {
185  std::vector<std::unique_ptr<TrackingRegion>> result;
186 
187  // pick up the candidate objects of interest
189  size_t n_objects = 0;
190 
192  e.getByToken(m_token_input, objects);
193  n_objects = objects->size();
194  if (n_objects == 0)
195  return result;
196  }
197 
198  const auto& objs = *objects;
199 
200  const auto& origins = m_origins.origins(e);
201  if (origins.empty()) {
202  return result;
203  }
204 
208  e.getByToken(m_token_measurementTracker, hmte);
209  measurementTracker = hmte.product();
210  }
211 
212  // create tracking regions (maximum MaxNRegions of them) in directions of the
213  // objects of interest (we expect that the collection was sorted in decreasing pt order)
214  int n_regions = 0;
215 
217  for (const auto& object : objs) {
218  GlobalVector direction(object.momentum().x(), object.momentum().y(), object.momentum().z());
219 
220  for (const auto& origin : origins) {
221  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(direction,
222  origin.first,
223  m_ptMin,
225  origin.second,
229  m_precise,
231  m_searchOpt));
232  ++n_regions;
233  if (n_regions >= m_maxNRegions)
234  break;
235  }
236 
237  if (n_regions >= m_maxNRegions)
238  break;
239  }
240 
241  }
242 
244  for (const auto& direction : m_directionPoints) {
245  for (const auto& origin : origins) {
246  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(direction, // GlobalVector
247  origin.first, // GlobalPoint
248  m_ptMin,
250  origin.second,
254  m_precise,
256  m_searchOpt));
257  ++n_regions;
258  if (n_regions >= m_maxNRegions)
259  break;
260  }
261 
262  if (n_regions >= m_maxNRegions)
263  break;
264  }
265 
266  }
267 
269  for (const auto& object : objs) {
270  double eta_Cand = object.eta();
271  double phi_Cand = object.phi();
272 
273  for (const auto& etaPhiPoint : m_etaPhiPoints) {
274  double eta_Point = etaPhiPoint.first;
275  double phi_Point = etaPhiPoint.second;
276  double dEta_Cand_Point = std::abs(eta_Cand - eta_Point);
277  double dPhi_Cand_Point = std::abs(deltaPhi(phi_Cand, phi_Point));
278 
279  //Check if there is an overlap between Candidate- and Point-based regions of interest
280  if (dEta_Cand_Point > (m_deltaEta_Cand + m_deltaEta_Point) ||
281  dPhi_Cand_Point > (m_deltaPhi_Cand + m_deltaPhi_Point))
282  continue;
283 
284  //Determines boundaries of intersection of RoIs
285  double etaMin_RoI = std::max(eta_Cand - m_deltaEta_Cand, eta_Point - m_deltaEta_Point);
286  double etaMax_RoI = std::min(eta_Cand + m_deltaEta_Cand, eta_Point + m_deltaEta_Point);
287 
288  double phi_Cand_minus = normalizedPhi(phi_Cand - m_deltaPhi_Cand);
289  double phi_Point_minus = normalizedPhi(phi_Point - m_deltaPhi_Point);
290  double phi_Cand_plus = normalizedPhi(phi_Cand + m_deltaPhi_Cand);
291  double phi_Point_plus = normalizedPhi(phi_Point + m_deltaPhi_Point);
292 
293  double phiMin_RoI = deltaPhi(phi_Cand_minus, phi_Point_minus) > 0. ? phi_Cand_minus : phi_Point_minus;
294  double phiMax_RoI = deltaPhi(phi_Cand_plus, phi_Point_plus) < 0. ? phi_Cand_plus : phi_Point_plus;
295 
296  //Determines position and width of new RoI
297  double eta_RoI = 0.5 * (etaMax_RoI + etaMin_RoI);
298  double deltaEta_RoI = etaMax_RoI - eta_RoI;
299 
300  double phi_RoI = 0.5 * (phiMax_RoI + phiMin_RoI);
301  if (phiMax_RoI < phiMin_RoI)
302  phi_RoI -= M_PI;
303  phi_RoI = normalizedPhi(phi_RoI);
304  double deltaPhi_RoI = deltaPhi(phiMax_RoI, phi_RoI);
305 
306  double x = std::cos(phi_RoI);
307  double y = std::sin(phi_RoI);
308  double theta = 2 * std::atan(std::exp(-eta_RoI));
309  double z = 1. / std::tan(theta);
310 
311  GlobalVector direction(x, y, z);
312 
313  for (const auto& origin : origins) {
314  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(direction,
315  origin.first,
316  m_ptMin,
318  origin.second,
319  deltaEta_RoI,
320  deltaPhi_RoI,
322  m_precise,
324  m_searchOpt));
325  ++n_regions;
326  if (n_regions >= m_maxNRegions)
327  break;
328  }
329 
330  if (n_regions >= m_maxNRegions)
331  break;
332  }
333 
334  if (n_regions >= m_maxNRegions)
335  break;
336  }
337  }
338 
339  edm::LogInfo("CandidatePointSeededTrackingRegionsProducer") << "produced " << n_regions << " regions";
340 
341  return result;
342  }
343 
344 private:
347 
350 
351  std::vector<std::pair<double, double>> m_etaPhiPoints;
352  std::vector<GlobalVector> m_directionPoints;
353 
354  float m_ptMin;
360  bool m_precise;
364 };
365 
366 #endif
Vector3DBase
Definition: Vector3DBase.h:8
ConfigurationDescriptions.h
HLT_2018_cff.points
points
Definition: HLT_2018_cff.py:20125
DDAxes::y
Handle.h
CandidatePointSeededTrackingRegionsProducer::m_deltaPhi_Cand
float m_deltaPhi_Cand
Definition: CandidatePointSeededTrackingRegionsProducer.h:357
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MeasurementTrackerEvent.h
VertexBeamspotOrigins::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &desc, const std::string &defaultBeamSpot="offlineBeamSpot", const std::string &defaultVertex="firstStepPrimaryVertices", int defaultMaxVertices=-1)
Definition: VertexBeamspotOrigins.cc:38
CandidatePointSeededTrackingRegionsProducer::m_seedingMode
SeedingMode m_seedingMode
Definition: CandidatePointSeededTrackingRegionsProducer.h:346
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HLTSiStripMonitoring_cff.measurementTracker
measurementTracker
Definition: HLTSiStripMonitoring_cff.py:178
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT
Definition: EDGetToken.h:33
CandidatePointSeededTrackingRegionsProducer::m_whereToUseMeasurementTracker
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
Definition: CandidatePointSeededTrackingRegionsProducer.h:362
edm
HLT enums.
Definition: AlignableModifier.h:19
CandidatePointSeededTrackingRegionsProducer::m_deltaEta_Point
float m_deltaEta_Point
Definition: CandidatePointSeededTrackingRegionsProducer.h:358
objects
Definition: __init__.py:1
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CandidatePointSeededTrackingRegionsProducer::m_searchOpt
bool m_searchOpt
Definition: CandidatePointSeededTrackingRegionsProducer.h:363
CandidatePointSeededTrackingRegionsProducer::m_ptMin
float m_ptMin
Definition: CandidatePointSeededTrackingRegionsProducer.h:354
DDAxes::x
CandidatePointSeededTrackingRegionsProducer
Definition: CandidatePointSeededTrackingRegionsProducer.h:58
CandidatePointSeededTrackingRegionsProducer::m_deltaPhi_Point
float m_deltaPhi_Point
Definition: CandidatePointSeededTrackingRegionsProducer.h:359
VertexBeamspotOrigins.h
edm::Handle
Definition: AssociativeIterator.h:50
CandidatePointSeededTrackingRegionsProducer::m_maxNRegions
int m_maxNRegions
Definition: CandidatePointSeededTrackingRegionsProducer.h:348
edm::Exception
Definition: EDMException.h:77
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TrackingRegionProducer.h
CandidatePointSeededTrackingRegionsProducer::SeedingMode
SeedingMode
Definition: CandidatePointSeededTrackingRegionsProducer.h:60
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
BeamSpot.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
CandidatePointSeededTrackingRegionsProducer::m_directionPoints
std::vector< GlobalVector > m_directionPoints
Definition: CandidatePointSeededTrackingRegionsProducer.h:352
CandidatePointSeededTrackingRegionsProducer::SeedingMode::POINT_SEEDED
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
DDAxes::z
normalizedPhi
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
CandidatePointSeededTrackingRegionsProducer::m_etaPhiPoints
std::vector< std::pair< double, double > > m_etaPhiPoints
Definition: CandidatePointSeededTrackingRegionsProducer.h:351
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
edm::View
Definition: CaloClusterFwd.h:14
RectangularEtaPhiTrackingRegion::UseMeasurementTracker::kNever
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
MeasurementTrackerEvent
Definition: MeasurementTrackerEvent.h:15
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
ParameterSet
Definition: Functions.h:16
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
CandidatePointSeededTrackingRegionsProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CandidatePointSeededTrackingRegionsProducer.h:149
CandidatePointSeededTrackingRegionsProducer::m_token_input
edm::EDGetTokenT< reco::CandidateView > m_token_input
Definition: CandidatePointSeededTrackingRegionsProducer.h:349
CandidatePointSeededTrackingRegionsProducer::SeedingMode::CANDIDATE_POINT_SEEDED
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
normalizedPhi.h
RectangularEtaPhiTrackingRegion.h
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
edm::EventSetup
Definition: EventSetup.h:57
RectangularEtaPhiTrackingRegion::UseMeasurementTracker
UseMeasurementTracker
Definition: RectangularEtaPhiTrackingRegion.h:27
CandidatePointSeededTrackingRegionsProducer::SeedingMode::CANDIDATE_SEEDED
InputTag.h
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CandidatePointSeededTrackingRegionsProducer::m_originRadius
float m_originRadius
Definition: CandidatePointSeededTrackingRegionsProducer.h:355
CandidatePointSeededTrackingRegionsProducer::m_origins
VertexBeamspotOrigins m_origins
Definition: CandidatePointSeededTrackingRegionsProducer.h:345
Exception
Definition: hltDiff.cc:246
TrackingRegionProducer
Definition: TrackingRegionProducer.h:12
CandidatePointSeededTrackingRegionsProducer::m_precise
bool m_precise
Definition: CandidatePointSeededTrackingRegionsProducer.h:360
CandidatePointSeededTrackingRegionsProducer::m_deltaEta_Cand
float m_deltaEta_Cand
Definition: CandidatePointSeededTrackingRegionsProducer.h:356
VertexBeamspotOrigins
Definition: VertexBeamspotOrigins.h:15
EventSetup.h
HLTEGTnPMonitor_cfi.objs
objs
Definition: HLTEGTnPMonitor_cfi.py:1018
mps_fire.result
result
Definition: mps_fire.py:303
CandidatePointSeededTrackingRegionsProducer::m_token_measurementTracker
edm::EDGetTokenT< MeasurementTrackerEvent > m_token_measurementTracker
Definition: CandidatePointSeededTrackingRegionsProducer.h:361
ConsumesCollector.h
Candidate.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::Event
Definition: Event.h:73
edm::errors::Configuration
Definition: EDMException.h:36
edm::InputTag
Definition: InputTag.h:15
CandidatePointSeededTrackingRegionsProducer::regions
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &e, const edm::EventSetup &es) const override
Definition: CandidatePointSeededTrackingRegionsProducer.h:184
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
RectangularEtaPhiTrackingRegion::stringToUseMeasurementTracker
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
Definition: RectangularEtaPhiTrackingRegion.cc:82
CandidatePointSeededTrackingRegionsProducer::CandidatePointSeededTrackingRegionsProducer
CandidatePointSeededTrackingRegionsProducer(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
Definition: CandidatePointSeededTrackingRegionsProducer.h:62
deltaPhi.h
VertexBeamspotOrigins::origins
Origins origins(const edm::Event &iEvent) const
Definition: VertexBeamspotOrigins.cc:53
CandidatePointSeededTrackingRegionsProducer::~CandidatePointSeededTrackingRegionsProducer
~CandidatePointSeededTrackingRegionsProducer() override
Definition: CandidatePointSeededTrackingRegionsProducer.h:147
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37