CMS 3D CMS Logo

GlobalTrackingRegion.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <sstream>
8 
13 
14 template <class T>
15 T sqr(T t) {
16  return t * t;
17 }
18 
19 using namespace GeomDetEnumerators;
20 
22  std::ostringstream str;
23  str << TrackingRegionBase::print() << "precise: " << thePrecise;
24  return str.str();
25 }
26 
28  return layer.hits();
29 }
30 
31 std::unique_ptr<HitRZCompatibility> GlobalTrackingRegion::checkRZ(const DetLayer* layer,
32  const Hit& outerHit,
33  const DetLayer* outerlayer,
34  float lr,
35  float gz,
36  float dr,
37  float dz) const {
38  bool isBarrel = layer->isBarrel();
39  bool isPixel = (layer->subDetector() == PixelBarrel || layer->subDetector() == PixelEndcap);
40 
41  if UNLIKELY (!outerlayer) {
42  GlobalPoint ohit = outerHit->globalPosition();
43  lr = std::sqrt(sqr(ohit.x() - origin().x()) + sqr(ohit.y() - origin().y()));
44  gz = ohit.z();
45  dr = outerHit->errorGlobalR();
46  dz = outerHit->errorGlobalZ();
47  }
48 
49  PixelRecoPointRZ outerred(lr, gz);
50 
51  PixelRecoPointRZ vtxR = (gz > origin().z() + originZBound())
52  ? PixelRecoPointRZ(-originRBound(), origin().z() + originZBound())
53  : PixelRecoPointRZ(originRBound(), origin().z() + originZBound());
54  PixelRecoPointRZ vtxL = (gz < origin().z() - originZBound())
55  ? PixelRecoPointRZ(-originRBound(), origin().z() - originZBound())
56  : PixelRecoPointRZ(originRBound(), origin().z() - originZBound());
57 
58  if UNLIKELY ((!thePrecise) && (isPixel)) {
59  auto VcotMin = PixelRecoLineRZ(vtxR, outerred).cotLine();
60  auto VcotMax = PixelRecoLineRZ(vtxL, outerred).cotLine();
61  return std::make_unique<HitEtaCheck>(isBarrel, outerred, VcotMax, VcotMin);
62  }
63 
64  constexpr float nSigmaPhi = 3.;
65 
66  dr *= nSigmaPhi;
67  dz *= nSigmaPhi;
68 
69  PixelRecoPointRZ outerL, outerR;
70  if (isBarrel) {
71  outerL = PixelRecoPointRZ(lr, gz - dz);
72  outerR = PixelRecoPointRZ(lr, gz + dz);
73  } else if (gz > 0) {
74  outerL = PixelRecoPointRZ(lr + dr, gz);
75  outerR = PixelRecoPointRZ(lr - dr, gz);
76  } else {
77  outerL = PixelRecoPointRZ(lr - dr, gz);
78  outerR = PixelRecoPointRZ(lr + dr, gz);
79  }
80 
81  auto corr = isBarrel ? dz : dr;
82 
83  SimpleLineRZ leftLine(vtxL, outerL);
84  SimpleLineRZ rightLine(vtxR, outerR);
85  HitRZConstraint rzConstraint(leftLine, rightLine);
86 
87  if UNLIKELY (theUseMS) {
88  MultipleScatteringParametrisation iSigma = theMSMaker->parametrisation(layer);
89  PixelRecoPointRZ vtxMean(0., origin().z());
90 
91  float innerScatt = 3.f * (outerlayer ? iSigma(ptMin(), vtxMean, outerred, outerlayer->seqNum())
92  : iSigma(ptMin(), vtxMean, outerred));
93 
94  float cotTheta = SimpleLineRZ(vtxMean, outerred).cotLine();
95 
96  if (isBarrel) {
97  float sinTheta = 1 / std::sqrt(1 + sqr(cotTheta));
98  corr = innerScatt / sinTheta + dz;
99  } else {
100  float cosTheta = 1 / std::sqrt(1 + sqr(1 / cotTheta));
101  corr = innerScatt / cosTheta + dr;
102  }
103  }
104 
105  if (isBarrel) {
106  return std::make_unique<HitZCheck>(rzConstraint, HitZCheck::Margin(corr, corr));
107  } else {
108  return std::make_unique<HitRCheck>(rzConstraint, HitRCheck::Margin(corr, corr));
109  }
110 }
111 
112 void GlobalTrackingRegion::checkTracks(reco::TrackCollection const& tracks, std::vector<bool>& mask) const {
113  const math::XYZPoint regOrigin(origin().x(), origin().y(), origin().z());
114 
115  assert(mask.size() == tracks.size());
116  int i = -1;
117  for (auto const& track : tracks) {
118  i++;
119  if (mask[i])
120  continue;
121 
122  if (track.pt() < ptMin()) {
123  continue;
124  }
125  if (std::abs(track.dxy(regOrigin)) > originRBound()) {
126  continue;
127  }
128  if (std::abs(track.dz(regOrigin)) > originZBound()) {
129  continue;
130  }
131 
132  mask[i] = true;
133  }
134 }
TkTrackingRegionsMargin< float > Margin
Definition: HitRCheck.h:14
TkTrackingRegionsMargin< float > Margin
Definition: HitZCheck.h:14
float cotLine() const
T z() const
Definition: PV3DBase.h:61
bool isBarrel(GeomDetEnumerators::SubDetector m)
constexpr float ptMin
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
assert(be >=bs)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer &layer) const override
get hits from layer compatible with region constraints
dictionary corr
T sqrt(T t)
Definition: SSEVec.h:19
void checkTracks(reco::TrackCollection const &tracks, std::vector< bool > &mask) const override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static GlobalPoint vtxMean(const GlobalPoint &p1, const GlobalError &e1, const GlobalPoint &p2, const GlobalError &e2)
virtual std::string print() const
int seqNum() const
Definition: DetLayer.h:35
constexpr float nSigmaPhi
T sqr(T t)
SeedingLayerSetsHits::Hits Hits
float cotLine() const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::unique_ptr< HitRZCompatibility > checkRZ(const DetLayer *layer, const Hit &outerHit, const DetLayer *outerlayer=nullptr, float lr=0, float gz=0, float dr=0, float dz=0) const override
bool isPixel(HitType hitType)
float x
#define UNLIKELY(x)
Definition: Likely.h:21
std::string print() const override
#define str(s)
long double T