CMS 3D CMS Logo

MuonTrackingRegionBuilder.cc
Go to the documentation of this file.
1 
11 
12 //-------------------------------
13 // Collaborating Class Headers --
14 //-------------------------------
15 
17 
21 
24 
28 
29 //
30 // constructor
31 //
33  // Adjust errors on Eta, Phi, Z
34  theNsigmaEta = par.getParameter<double>("Rescale_eta");
35  theNsigmaPhi = par.getParameter<double>("Rescale_phi");
36  theNsigmaDz = par.getParameter<double>("Rescale_Dz");
37 
38  // Upper limits parameters
39  theEtaRegionPar1 = par.getParameter<double>("EtaR_UpperLimit_Par1");
40  theEtaRegionPar2 = par.getParameter<double>("EtaR_UpperLimit_Par2");
41  thePhiRegionPar1 = par.getParameter<double>("PhiR_UpperLimit_Par1");
42  thePhiRegionPar2 = par.getParameter<double>("PhiR_UpperLimit_Par2");
43 
44  // Flag to switch to use Vertices instead of BeamSpot
45  useVertex = par.getParameter<bool>("UseVertex");
46 
47  // Flag to use fixed limits for Eta, Phi, Z, pT
48  useFixedZ = par.getParameter<bool>("Z_fixed");
49  useFixedPt = par.getParameter<bool>("Pt_fixed");
50  useFixedPhi = par.getParameter<bool>("Phi_fixed");
51  useFixedEta = par.getParameter<bool>("Eta_fixed");
52 
53  // Minimum value for pT
54  thePtMin = par.getParameter<double>("Pt_min");
55 
56  // Minimum value for Phi
57  thePhiMin = par.getParameter<double>("Phi_min");
58 
59  // Minimum value for Eta
60  theEtaMin = par.getParameter<double>("Eta_min");
61 
62  // The static region size along the Z direction
63  theHalfZ = par.getParameter<double>("DeltaZ");
64 
65  // The transverse distance of the region from the BS/PV
66  theDeltaR = par.getParameter<double>("DeltaR");
67 
68  // The static region size in Eta
69  theDeltaEta = par.getParameter<double>("DeltaEta");
70 
71  // The static region size in Phi
72  theDeltaPhi = par.getParameter<double>("DeltaPhi");
73 
74  // Maximum number of regions to build when looping over Muons
75  theMaxRegions = par.getParameter<int>("maxRegions");
76 
77  // Flag to use precise??
78  thePrecise = par.getParameter<bool>("precise");
79 
80  // perigee reference point ToDo: Check this
84  iC.consumes<MeasurementTrackerEvent>(par.getParameter<edm::InputTag>("MeasurementTrackerName"));
85  }
86 
87  // Vertex collection and Beam Spot
90 
91  // Input muon collection
93 }
94 
95 //
96 // Member function to be compatible with TrackingRegionProducerFactory: create many ROI for many tracks
97 //
98 std::vector<std::unique_ptr<TrackingRegion>> MuonTrackingRegionBuilder::regions(const edm::Event& ev,
99  const edm::EventSetup& es) const {
100  std::vector<std::unique_ptr<TrackingRegion>> result;
101 
103  ev.getByToken(inputCollectionToken, tracks);
104 
105  int nRegions = 0;
106  for (auto it = tracks->cbegin(), ed = tracks->cend(); it != ed && nRegions < theMaxRegions; ++it) {
107  result.push_back(region(*it, ev));
108  nRegions++;
109  }
110 
111  return result;
112 }
113 
114 //
115 // Call region on Track from TrackRef
116 //
117 std::unique_ptr<RectangularEtaPhiTrackingRegion> MuonTrackingRegionBuilder::region(const reco::TrackRef& track) const {
118  return region(*track);
119 }
120 
121 //
122 // ToDo: Not sure if this is needed?
123 //
125 
126 //
127 // Main member function called to create the ROI
128 //
129 std::unique_ptr<RectangularEtaPhiTrackingRegion> MuonTrackingRegionBuilder::region(const reco::Track& staTrack,
130  const edm::Event& ev) const {
131  // get track momentum/direction at vertex
132  const math::XYZVector& mom = staTrack.momentum();
133  GlobalVector dirVector(mom.x(), mom.y(), mom.z());
134  double pt = staTrack.pt();
135 
136  // Fix for StandAlone tracks with low momentum
137  const math::XYZVector& innerMomentum = staTrack.innerMomentum();
138  GlobalVector forSmallMomentum(innerMomentum.x(), innerMomentum.y(), innerMomentum.z());
139  if (staTrack.p() <= 1.5) {
140  pt = std::abs(forSmallMomentum.perp());
141  }
142 
143  // initial vertex position - in the following it is replaced with beamspot/vertexing
144  GlobalPoint vertexPos(0.0, 0.0, 0.0);
145  // standard 15.9, if useVertex than use error from vertex
146  double deltaZ = theHalfZ;
147 
148  // retrieve beam spot information
150  bool bsHandleFlag = ev.getByToken(beamSpotToken, bs);
151 
152  // check the validity, otherwise vertexing
153  if (bsHandleFlag && bs.isValid() && !useVertex) {
154  vertexPos = GlobalPoint(bs->x0(), bs->y0(), bs->z0());
155  deltaZ = useFixedZ ? theHalfZ : bs->sigmaZ() * theNsigmaDz;
156  } else {
157  // get originZPos from list of reconstructed vertices (first or all)
159  bool vtxHandleFlag = ev.getByToken(vertexCollectionToken, vertexCollection);
160  // check if there exists at least one reconstructed vertex
161  if (vtxHandleFlag && !vertexCollection->empty()) {
162  // use the first vertex in the collection and assume it is the primary event vertex
163  reco::VertexCollection::const_iterator vtx = vertexCollection->begin();
164  if (!vtx->isFake() && vtx->isValid()) {
165  vertexPos = GlobalPoint(vtx->x(), vtx->y(), vtx->z());
166  deltaZ = useFixedZ ? theHalfZ : vtx->zError() * theNsigmaDz;
167  }
168  }
169  }
170 
171  // inizialize to the maximum possible value
172  double deta = 0.4;
173  double dphi = 0.6;
174 
175  // evaluate the dynamical region if possible
176  deta = theNsigmaEta * (staTrack.etaError());
177  dphi = theNsigmaPhi * (staTrack.phiError());
178 
179  // Region_Parametrizations to take into account possible L2 error matrix inconsistencies
180  double region_dEta = 0;
181  double region_dPhi = 0;
182  double eta = 0;
183  double phi = 0;
184 
185  // eta, pt parametrization from MC study (circa 2009?)
186  if (pt <= 10.) {
187  // angular coefficients
188  float acoeff_Phi = (thePhiRegionPar2 - thePhiRegionPar1) / 5;
189  float acoeff_Eta = (theEtaRegionPar2 - theEtaRegionPar1) / 5;
190 
191  eta = theEtaRegionPar1 + (acoeff_Eta) * (pt - 5.);
192  phi = thePhiRegionPar1 + (acoeff_Phi) * (pt - 5.);
193  }
194  // parametrization 2nd bin in pt from MC study
195  if (pt > 10. && pt < 100.) {
198  }
199  // parametrization 3rd bin in pt from MC study
200  if (pt >= 100.) {
201  // angular coefficients
202  float acoeff_Phi = (thePhiRegionPar1 - thePhiRegionPar2) / 900;
203  float acoeff_Eta = (theEtaRegionPar1 - theEtaRegionPar2) / 900;
204 
205  eta = theEtaRegionPar2 + (acoeff_Eta) * (pt - 100.);
206  phi = thePhiRegionPar2 + (acoeff_Phi) * (pt - 100.);
207  }
208 
209  double region_dPhi1 = std::min(phi, dphi);
210  double region_dEta1 = std::min(eta, deta);
211 
212  // decide to use either a parametrization or a dynamical region
213  region_dPhi = useFixedPhi ? theDeltaPhi : std::max(thePhiMin, region_dPhi1);
214  region_dEta = useFixedEta ? theDeltaEta : std::max(theEtaMin, region_dEta1);
215 
216  float deltaR = theDeltaR;
217  double minPt = useFixedPt ? thePtMin : std::max(thePtMin, pt * 0.6);
218 
222  ev.getByToken(theMeasurementTrackerToken, hmte);
223  measurementTracker = hmte.product();
224  }
225 
226  auto region = std::make_unique<RectangularEtaPhiTrackingRegion>(
227  dirVector, vertexPos, minPt, deltaR, deltaZ, region_dEta, region_dPhi, theOnDemand, thePrecise, measurementTracker);
228 
229  LogDebug("MuonTrackingRegionBuilder") << "the region parameters are:\n"
230  << "\n dirVector: " << dirVector << "\n vertexPos: " << vertexPos
231  << "\n minPt: " << minPt << "\n deltaR:" << deltaR << "\n deltaZ:" << deltaZ
232  << "\n region_dEta:" << region_dEta << "\n region_dPhi:" << region_dPhi
233  << "\n on demand parameter: " << static_cast<int>(theOnDemand);
234 
235  return region;
236 }
237 
239  {
242  descriptions.add("MuonTrackingRegionBuilder", desc);
243  }
244  {
247  descriptions.add("MuonTrackingRegionBuilderHLT", desc);
248  }
249  descriptions.setComment(
250  "Build a TrackingRegion around a standalone muon. Options to define region around beamspot or primary vertex and "
251  "dynamic regions are included.");
252 }
254  desc.add<double>("EtaR_UpperLimit_Par1", 0.25);
255  desc.add<double>("DeltaR", 0.2);
256  desc.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
257  desc.add<int>("OnDemand", -1);
258  desc.add<edm::InputTag>("vertexCollection", edm::InputTag("pixelVertices"));
259  desc.add<double>("Rescale_phi", 3.0);
260  desc.add<bool>("Eta_fixed", false);
261  desc.add<double>("Rescale_eta", 3.0);
262  desc.add<double>("PhiR_UpperLimit_Par2", 0.2);
263  desc.add<double>("Eta_min", 0.05);
264  desc.add<bool>("Phi_fixed", false);
265  desc.add<double>("Phi_min", 0.05);
266  desc.add<double>("PhiR_UpperLimit_Par1", 0.6);
267  desc.add<double>("EtaR_UpperLimit_Par2", 0.15);
268  desc.add<edm::InputTag>("MeasurementTrackerName", edm::InputTag("hltESPMeasurementTracker"));
269  desc.add<bool>("UseVertex", false);
270  desc.add<double>("Rescale_Dz", 3.0);
271  desc.add<bool>("Pt_fixed", false);
272  desc.add<bool>("Z_fixed", true);
273  desc.add<double>("Pt_min", 1.5);
274  desc.add<double>("DeltaZ", 15.9);
275  desc.add<double>("DeltaEta", 0.2);
276  desc.add<double>("DeltaPhi", 0.2);
277  desc.add<int>("maxRegions", 1);
278  desc.add<bool>("precise", true);
279  desc.add<edm::InputTag>("input", edm::InputTag("hltL2Muons", "UpdatedAtVtx"));
280 }
281 
283  desc.add<double>("EtaR_UpperLimit_Par1", 0.25);
284  desc.add<double>("DeltaR", 0.2);
285  desc.add<edm::InputTag>("beamSpot", edm::InputTag(""));
286  desc.add<int>("OnDemand", -1);
287  desc.add<edm::InputTag>("vertexCollection", edm::InputTag(""));
288  desc.add<double>("Rescale_phi", 3.0);
289  desc.add<bool>("Eta_fixed", false);
290  desc.add<double>("Rescale_eta", 3.0);
291  desc.add<double>("PhiR_UpperLimit_Par2", 0.2);
292  desc.add<double>("Eta_min", 0.05);
293  desc.add<bool>("Phi_fixed", false);
294  desc.add<double>("Phi_min", 0.05);
295  desc.add<double>("PhiR_UpperLimit_Par1", 0.6);
296  desc.add<double>("EtaR_UpperLimit_Par2", 0.15);
297  desc.add<edm::InputTag>("MeasurementTrackerName", edm::InputTag(""));
298  desc.add<bool>("UseVertex", false);
299  desc.add<double>("Rescale_Dz", 3.0);
300  desc.add<bool>("Pt_fixed", false);
301  desc.add<bool>("Z_fixed", true);
302  desc.add<double>("Pt_min", 1.5);
303  desc.add<double>("DeltaZ", 15.9);
304  desc.add<double>("DeltaEta", 0.2);
305  desc.add<double>("DeltaPhi", 0.2);
306  desc.add<int>("maxRegions", 1);
307  desc.add<bool>("precise", true);
308  desc.add<edm::InputTag>("input", edm::InputTag(""));
309 }
Vector3DBase
Definition: Vector3DBase.h:8
MuonTrackingRegionBuilder::build
void build(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: MuonTrackingRegionBuilder.cc:32
MuonTrackingRegionBuilder::theMaxRegions
int theMaxRegions
Definition: MuonTrackingRegionBuilder.h:80
TSCBLBuilderNoMaterial.h
MuonTrackingRegionBuilder::theDeltaR
double theDeltaR
Definition: MuonTrackingRegionBuilder.h:94
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
MeasurementTrackerEvent.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11776
MuonTrackingRegionBuilder::fillDescriptionsHLT
static void fillDescriptionsHLT(edm::ParameterSetDescription &descriptions)
Definition: MuonTrackingRegionBuilder.cc:253
MuonTrackingRegionBuilder::thePhiRegionPar1
double thePhiRegionPar1
Definition: MuonTrackingRegionBuilder.h:88
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
reco::TrackBase::etaError
double etaError() const
error on eta
Definition: TrackBase.h:763
HLTSiStripMonitoring_cff.measurementTracker
measurementTracker
Definition: HLTSiStripMonitoring_cff.py:178
MuonTrackingRegionBuilder::beamSpotToken
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
Definition: MuonTrackingRegionBuilder.h:101
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
reco::TrackBase::p
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
min
T min(T a, T b)
Definition: MathUtil.h:58
MuonTrackingRegionBuilder::thePhiMin
double thePhiMin
Definition: MuonTrackingRegionBuilder.h:92
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MuonTrackingRegionBuilder::useFixedPhi
bool useFixedPhi
Definition: MuonTrackingRegionBuilder.h:76
MuonTrackingRegionBuilder::region
std::unique_ptr< RectangularEtaPhiTrackingRegion > region(const reco::TrackRef &) const
Define tracking region.
Definition: MuonTrackingRegionBuilder.cc:117
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
MuonTrackingRegionBuilder::theOnDemand
RectangularEtaPhiTrackingRegion::UseMeasurementTracker theOnDemand
Definition: MuonTrackingRegionBuilder.h:99
MuonTrackingRegionBuilder.h
MuonTrackingRegionBuilder::useFixedEta
bool useFixedEta
Definition: MuonTrackingRegionBuilder.h:77
edm::Handle< reco::TrackCollection >
MuonTrackingRegionBuilder::theEtaRegionPar1
double theEtaRegionPar1
Definition: MuonTrackingRegionBuilder.h:86
edm::Ref< TrackCollection >
MuonTrackingRegionBuilder::theEtaMin
double theEtaMin
Definition: MuonTrackingRegionBuilder.h:93
MuonTrackingRegionBuilder::theHalfZ
double theHalfZ
Definition: MuonTrackingRegionBuilder.h:95
MuonTrackingRegionBuilder::theEtaRegionPar2
double theEtaRegionPar2
Definition: MuonTrackingRegionBuilder.h:87
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:637
MuonTrackingRegionBuilder::setEvent
virtual void setEvent(const edm::Event &)
Pass the Event to the algo at each event.
Definition: MuonTrackingRegionBuilder.cc:124
cms::cuda::bs
bs
Definition: HistoContainer.h:127
reco::Track::innerMomentum
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
RectangularEtaPhiTrackingRegion::intToUseMeasurementTracker
static UseMeasurementTracker intToUseMeasurementTracker(int value)
Definition: RectangularEtaPhiTrackingRegion.h:29
MuonTrackingRegionBuilder::theNsigmaEta
double theNsigmaEta
Definition: MuonTrackingRegionBuilder.h:82
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
PVValHelper::eta
Definition: PVValidationHelpers.h:69
reco::BeamSpot
Definition: BeamSpot.h:21
reco::Track
Definition: Track.h:27
MuonTrackingRegionBuilder::thePrecise
bool thePrecise
Definition: MuonTrackingRegionBuilder.h:78
MuonTrackingRegionBuilder::thePtMin
double thePtMin
Definition: MuonTrackingRegionBuilder.h:91
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
MuonTrackingRegionBuilder::inputCollectionToken
edm::EDGetTokenT< reco::TrackCollection > inputCollectionToken
Definition: MuonTrackingRegionBuilder.h:103
MuonTrackingRegionBuilder::theDeltaEta
double theDeltaEta
Definition: MuonTrackingRegionBuilder.h:97
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
MuonTrackingRegionBuilder::theDeltaPhi
double theDeltaPhi
Definition: MuonTrackingRegionBuilder.h:96
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
MuonTrackingRegionBuilder::useFixedZ
bool useFixedZ
Definition: MuonTrackingRegionBuilder.h:74
MuonTrackingRegionBuilder::theNsigmaDz
double theNsigmaDz
Definition: MuonTrackingRegionBuilder.h:84
RectangularEtaPhiTrackingRegion::UseMeasurementTracker::kNever
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
MeasurementTrackerEvent
Definition: MeasurementTrackerEvent.h:16
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MuonTrackingRegionBuilder::useFixedPt
bool useFixedPt
Definition: MuonTrackingRegionBuilder.h:75
MuonTrackingRegionBuilder::thePhiRegionPar2
double thePhiRegionPar2
Definition: MuonTrackingRegionBuilder.h:89
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edmPickEvents.event
event
Definition: edmPickEvents.py:273
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
RectangularEtaPhiTrackingRegion.h
MuonTrackingRegionBuilder::regions
std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &, const edm::EventSetup &) const override
Create Region of Interest.
Definition: MuonTrackingRegionBuilder.cc:98
edm::EventSetup
Definition: EventSetup.h:57
beam_dqm_sourceclient-live_cfg.minPt
minPt
Definition: beam_dqm_sourceclient-live_cfg.py:321
TSCPBuilderNoMaterial.h
MuonTrackingRegionBuilder::theNsigmaPhi
double theNsigmaPhi
Definition: MuonTrackingRegionBuilder.h:83
DDAxes::phi
MuonTrackingRegionBuilder::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Add Fill Descriptions.
Definition: MuonTrackingRegionBuilder.cc:238
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
spclusmultinvestigator_cfi.vertexCollection
vertexCollection
Definition: spclusmultinvestigator_cfi.py:4
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateTransform.h
reco::TrackBase::phiError
double phiError() const
error on phi
Definition: TrackBase.h:766
MuonTrackingRegionBuilder::vertexCollectionToken
edm::EDGetTokenT< reco::VertexCollection > vertexCollectionToken
Definition: MuonTrackingRegionBuilder.h:102
mps_fire.result
result
Definition: mps_fire.py:311
MuonTrackingRegionBuilder::useVertex
bool useVertex
Definition: MuonTrackingRegionBuilder.h:73
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
MuonTrackingRegionBuilder::theMeasurementTrackerToken
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerToken
Definition: MuonTrackingRegionBuilder.h:100
reco::TrackBase::momentum
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:664
MuonTrackingRegionBuilder::fillDescriptionsOffline
static void fillDescriptionsOffline(edm::ParameterSetDescription &descriptions)
Definition: MuonTrackingRegionBuilder.cc:282
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
MuonTrackingRegionBuilder::theEvent
const edm::Event * theEvent
Definition: MuonTrackingRegionBuilder.h:71
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45