CMS 3D CMS Logo

CandidateSeededTrackingRegionsProducer.h
Go to the documentation of this file.
1 #ifndef CandidateSeededTrackingRegionsProducer_h
2 #define CandidateSeededTrackingRegionsProducer_h
3 
7 
19 
46 public:
48 
50  edm::ParameterSet regPSet = conf.getParameter<edm::ParameterSet>("RegionPSet");
51 
52  // operation mode
53  std::string modeString = regPSet.getParameter<std::string>("mode");
54  if (modeString == "BeamSpotFixed")
56  else if (modeString == "BeamSpotSigma")
58  else if (modeString == "VerticesFixed")
60  else if (modeString == "VerticesSigma")
62  else
63  edm::LogError("CandidateSeededTrackingRegionsProducer") << "Unknown mode string: " << modeString;
64 
65  // basic inputs
66  token_input = iC.consumes<reco::CandidateView>(regPSet.getParameter<edm::InputTag>("input"));
67  m_maxNRegions = regPSet.getParameter<int>("maxNRegions");
68  token_beamSpot = iC.consumes<reco::BeamSpot>(regPSet.getParameter<edm::InputTag>("beamSpot"));
69  m_maxNVertices = 1;
71  token_vertex = iC.consumes<reco::VertexCollection>(regPSet.getParameter<edm::InputTag>("vertexCollection"));
72  m_maxNVertices = regPSet.getParameter<int>("maxNVertices");
73  }
74 
75  // RectangularEtaPhiTrackingRegion parameters:
76  m_ptMin = regPSet.getParameter<double>("ptMin");
77  m_originRadius = regPSet.getParameter<double>("originRadius");
78  m_zErrorBeamSpot = regPSet.getParameter<double>("zErrorBeamSpot");
79  m_deltaEta = regPSet.getParameter<double>("deltaEta");
80  m_deltaPhi = regPSet.getParameter<double>("deltaPhi");
81  m_precise = regPSet.getParameter<bool>("precise");
83  regPSet.getParameter<std::string>("whereToUseMeasurementTracker"));
86  iC.consumes<MeasurementTrackerEvent>(regPSet.getParameter<edm::InputTag>("measurementTrackerName"));
87  }
88  m_searchOpt = false;
89  if (regPSet.exists("searchOpt"))
90  m_searchOpt = regPSet.getParameter<bool>("searchOpt");
91 
92  // mode-dependent z-halflength of tracking regions
93  if (m_mode == VERTICES_SIGMA)
94  m_nSigmaZVertex = regPSet.getParameter<double>("nSigmaZVertex");
95  if (m_mode == VERTICES_FIXED)
96  m_zErrorVetex = regPSet.getParameter<double>("zErrorVetex");
97  m_nSigmaZBeamSpot = -1.;
98  if (m_mode == BEAM_SPOT_SIGMA) {
99  m_nSigmaZBeamSpot = regPSet.getParameter<double>("nSigmaZBeamSpot");
100  if (m_nSigmaZBeamSpot < 0.)
101  edm::LogError("CandidateSeededTrackingRegionsProducer")
102  << "nSigmaZBeamSpot must be positive for BeamSpotSigma mode!";
103  }
104  }
105 
107 
110 
111  desc.add<std::string>("mode", "BeamSpotFixed");
112 
113  desc.add<edm::InputTag>("input", edm::InputTag(""));
114  desc.add<int>("maxNRegions", 10);
115  desc.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
116  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("hltPixelVertices"));
117  desc.add<int>("maxNVertices", 1);
118 
119  desc.add<double>("ptMin", 0.9);
120  desc.add<double>("originRadius", 0.2);
121  desc.add<double>("zErrorBeamSpot", 24.2);
122  desc.add<double>("deltaEta", 0.5);
123  desc.add<double>("deltaPhi", 0.5);
124  desc.add<bool>("precise", true);
125 
126  desc.add<double>("nSigmaZVertex", 3.);
127  desc.add<double>("zErrorVetex", 0.2);
128  desc.add<double>("nSigmaZBeamSpot", 4.);
129 
130  desc.add<std::string>("whereToUseMeasurementTracker", "ForSiStrips");
131  desc.add<edm::InputTag>("measurementTrackerName", edm::InputTag(""));
132 
133  desc.add<bool>("searchOpt", false);
134 
135  // Only for backwards-compatibility
136  edm::ParameterSetDescription descRegion;
137  descRegion.add<edm::ParameterSetDescription>("RegionPSet", desc);
138 
139  descriptions.add("seededTrackingRegionsFromBeamSpotFixedZLength", descRegion);
140  }
141 
142  std::vector<std::unique_ptr<TrackingRegion> > regions(const edm::Event& e, const edm::EventSetup& es) const override {
143  std::vector<std::unique_ptr<TrackingRegion> > result;
144 
145  // pick up the candidate objects of interest
147  e.getByToken(token_input, objects);
148  size_t n_objects = objects->size();
149  if (n_objects == 0)
150  return result;
151 
152  // always need the beam spot (as a fall back strategy for vertex modes)
154  e.getByToken(token_beamSpot, bs);
155  if (!bs.isValid())
156  return result;
157 
158  // this is a default origin for all modes
159  GlobalPoint default_origin(bs->x0(), bs->y0(), bs->z0());
160 
161  // vector of origin & halfLength pairs:
162  std::vector<std::pair<GlobalPoint, float> > origins;
163 
164  // fill the origins and halfLengths depending on the mode
166  origins.push_back(std::make_pair(
167  default_origin, (m_mode == BEAM_SPOT_FIXED) ? m_zErrorBeamSpot : m_nSigmaZBeamSpot * bs->sigmaZ()));
168  } else if (m_mode == VERTICES_FIXED || m_mode == VERTICES_SIGMA) {
170  e.getByToken(token_vertex, vertices);
171  int n_vert = 0;
172  for (reco::VertexCollection::const_iterator v = vertices->begin();
173  v != vertices->end() && n_vert < m_maxNVertices;
174  ++v) {
175  if (v->isFake() || !v->isValid())
176  continue;
177 
178  origins.push_back(std::make_pair(GlobalPoint(v->x(), v->y(), v->z()),
179  (m_mode == VERTICES_FIXED) ? m_zErrorVetex : m_nSigmaZVertex * v->zError()));
180  ++n_vert;
181  }
182  // no-vertex fall-back case:
183  if (origins.empty()) {
184  origins.push_back(std::make_pair(
185  default_origin, (m_nSigmaZBeamSpot > 0.) ? m_nSigmaZBeamSpot * bs->z0Error() : m_zErrorBeamSpot));
186  }
187  }
188 
192  e.getByToken(token_measurementTracker, hmte);
193  measurementTracker = hmte.product();
194  }
195 
196  // create tracking regions (maximum MaxNRegions of them) in directions of the
197  // objects of interest (we expect that the collection was sorted in decreasing pt order)
198  int n_regions = 0;
199  for (size_t i = 0; i < n_objects && n_regions < m_maxNRegions; ++i) {
200  const reco::Candidate& object = (*objects)[i];
201  GlobalVector direction(object.momentum().x(), object.momentum().y(), object.momentum().z());
202 
203  for (size_t j = 0; j < origins.size() && n_regions < m_maxNRegions; ++j) {
204  result.push_back(std::make_unique<RectangularEtaPhiTrackingRegion>(direction,
205  origins[j].first,
206  m_ptMin,
208  origins[j].second,
209  m_deltaEta,
210  m_deltaPhi,
212  m_precise,
214  m_searchOpt));
215  ++n_regions;
216  }
217  }
218  //std::cout<<"n_seeded_regions = "<<n_regions<<std::endl;
219  edm::LogInfo("CandidateSeededTrackingRegionsProducer") << "produced " << n_regions << " regions";
220 
221  return result;
222  }
223 
224 private:
226 
232 
233  float m_ptMin;
236  float m_deltaEta;
237  float m_deltaPhi;
238  bool m_precise;
242 
246 };
247 
248 #endif
Vector3DBase
Definition: Vector3DBase.h:8
ConfigurationDescriptions.h
DDAxes::y
Handle.h
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
CandidateSeededTrackingRegionsProducer::VERTICES_FIXED
Definition: CandidateSeededTrackingRegionsProducer.h:47
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HLTSiStripMonitoring_cff.measurementTracker
measurementTracker
Definition: HLTSiStripMonitoring_cff.py:178
edm::EDGetTokenT< reco::VertexCollection >
CandidateSeededTrackingRegionsProducer::m_originRadius
float m_originRadius
Definition: CandidateSeededTrackingRegionsProducer.h:234
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
CandidateSeededTrackingRegionsProducer::BEAM_SPOT_SIGMA
Definition: CandidateSeededTrackingRegionsProducer.h:47
objects
Definition: __init__.py:1
CandidateSeededTrackingRegionsProducer::m_zErrorVetex
float m_zErrorVetex
Definition: CandidateSeededTrackingRegionsProducer.h:244
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CandidateSeededTrackingRegionsProducer::m_nSigmaZBeamSpot
float m_nSigmaZBeamSpot
Definition: CandidateSeededTrackingRegionsProducer.h:245
CandidateSeededTrackingRegionsProducer::regions
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &e, const edm::EventSetup &es) const override
Definition: CandidateSeededTrackingRegionsProducer.h:142
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDAxes::x
findQualityFiles.v
v
Definition: findQualityFiles.py:179
CandidateSeededTrackingRegionsProducer::m_mode
Mode m_mode
Definition: CandidateSeededTrackingRegionsProducer.h:225
edm::Handle
Definition: AssociativeIterator.h:50
dqmdumpme.first
first
Definition: dqmdumpme.py:55
CandidateSeededTrackingRegionsProducer
Definition: CandidateSeededTrackingRegionsProducer.h:45
TrackingRegionProducer.h
CandidateSeededTrackingRegionsProducer::token_beamSpot
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
Definition: CandidateSeededTrackingRegionsProducer.h:229
cms::cuda::bs
bs
Definition: HistoContainer.h:127
CandidateSeededTrackingRegionsProducer::m_whereToUseMeasurementTracker
RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker
Definition: CandidateSeededTrackingRegionsProducer.h:240
BeamSpot.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CandidateSeededTrackingRegionsProducer::m_ptMin
float m_ptMin
Definition: CandidateSeededTrackingRegionsProducer.h:233
CandidateSeededTrackingRegionsProducer::Mode
Mode
Definition: CandidateSeededTrackingRegionsProducer.h:47
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
CandidateSeededTrackingRegionsProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CandidateSeededTrackingRegionsProducer.h:108
CandidateSeededTrackingRegionsProducer::m_maxNVertices
int m_maxNVertices
Definition: CandidateSeededTrackingRegionsProducer.h:231
reco::BeamSpot
Definition: BeamSpot.h:21
DDAxes::z
CandidateSeededTrackingRegionsProducer::m_maxNRegions
int m_maxNRegions
Definition: CandidateSeededTrackingRegionsProducer.h:227
CandidateSeededTrackingRegionsProducer::token_measurementTracker
edm::EDGetTokenT< MeasurementTrackerEvent > token_measurementTracker
Definition: CandidateSeededTrackingRegionsProducer.h:239
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
CandidateSeededTrackingRegionsProducer::VERTICES_SIGMA
Definition: CandidateSeededTrackingRegionsProducer.h:47
Point3DBase< float, GlobalTag >
CandidateSeededTrackingRegionsProducer::CandidateSeededTrackingRegionsProducer
CandidateSeededTrackingRegionsProducer(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
Definition: CandidateSeededTrackingRegionsProducer.h:49
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
CandidateSeededTrackingRegionsProducer::m_nSigmaZVertex
float m_nSigmaZVertex
Definition: CandidateSeededTrackingRegionsProducer.h:243
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
CandidateSeededTrackingRegionsProducer::~CandidateSeededTrackingRegionsProducer
~CandidateSeededTrackingRegionsProducer() override
Definition: CandidateSeededTrackingRegionsProducer.h:106
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
edm::LogError
Definition: MessageLogger.h:183
Event.h
CandidateSeededTrackingRegionsProducer::m_deltaEta
float m_deltaEta
Definition: CandidateSeededTrackingRegionsProducer.h:236
CandidateSeededTrackingRegionsProducer::m_deltaPhi
float m_deltaPhi
Definition: CandidateSeededTrackingRegionsProducer.h:237
RectangularEtaPhiTrackingRegion.h
edm::EventSetup
Definition: EventSetup.h:57
RectangularEtaPhiTrackingRegion::UseMeasurementTracker
UseMeasurementTracker
Definition: RectangularEtaPhiTrackingRegion.h:27
CandidateSeededTrackingRegionsProducer::BEAM_SPOT_FIXED
Definition: CandidateSeededTrackingRegionsProducer.h:47
CandidateSeededTrackingRegionsProducer::token_input
edm::EDGetTokenT< reco::CandidateView > token_input
Definition: CandidateSeededTrackingRegionsProducer.h:230
InputTag.h
reco::Candidate
Definition: Candidate.h:27
CandidateSeededTrackingRegionsProducer::m_searchOpt
bool m_searchOpt
Definition: CandidateSeededTrackingRegionsProducer.h:241
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CandidateSeededTrackingRegionsProducer::m_precise
bool m_precise
Definition: CandidateSeededTrackingRegionsProducer.h:238
TrackingRegionProducer
Definition: TrackingRegionProducer.h:12
EventSetup.h
CandidateSeededTrackingRegionsProducer::token_vertex
edm::EDGetTokenT< reco::VertexCollection > token_vertex
Definition: CandidateSeededTrackingRegionsProducer.h:228
mps_fire.result
result
Definition: mps_fire.py:303
ConsumesCollector.h
Candidate.h
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CandidateSeededTrackingRegionsProducer::m_zErrorBeamSpot
float m_zErrorBeamSpot
Definition: CandidateSeededTrackingRegionsProducer.h:235
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
RectangularEtaPhiTrackingRegion::stringToUseMeasurementTracker
static UseMeasurementTracker stringToUseMeasurementTracker(const std::string &name)
Definition: RectangularEtaPhiTrackingRegion.cc:82
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37