CMS 3D CMS Logo

TrajectoryAtInvalidHit.cc
Go to the documentation of this file.
16 // #include "RecoTracker/MeasurementDet/interface/RecHitPropagator.h"
17 
18 using namespace std;
20  const TrackerTopology* tTopo,
21  const TrackerGeometry* tracker,
22  const Propagator& propagator,
23  const unsigned int mono) {
25  theCombinedPredictedState =
27  else
28  theCombinedPredictedState = tm.forwardPredictedState();
29 
30  if (!theCombinedPredictedState.isValid()) {
31  return;
32  }
33  theHit = tm.recHit();
34  iidd = theHit->geographicalId().rawId();
36  unsigned int subid = strip.subdetId();
37  // xB and yB are for absolute borders on the trajectories included in the study, sigmaX sigmaY are
38  // significance cuts on the distance from the detector surface
39  float xB = 0.;
40  float sigmaX = 5.0;
41  float yB = 0.;
42  float sigmaY = 5.0;
43  float sigmaYBond = 0.;
44  //set bounds for point to be within to be counted in the study
45  if (subid == StripSubdetector::TOB) {
46  sigmaYBond = 5.0;
47  }
48  const GeomDetUnit* monodet;
49 
50  // if module is from a double sided layer, write out info for either the
51  // rphi surface (mono = 1) or the stereo surface (mono = 2)--not the matched hit surface
52  if ((mono > 0) && isDoubleSided(iidd, tTopo)) {
53  // find matched det id, that is the matched hit surface between the two sensors
54  unsigned int matched_iidd = iidd - (iidd & 0x3);
55  DetId matched_id(matched_iidd);
56 
57  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(tracker->idToDet(matched_id));
58 
59  // get the sensor det indicated by mono
60  if (mono == 1)
61  monodet = gdet->stereoDet();
62  else
63  monodet = gdet->monoDet(); // this should only be mono == 2
64 
65  // set theCombinedPredictedState to be on the sensor surface, not the matched surface
66  DetId mono_id = monodet->geographicalId();
67  const Surface& surface = tracker->idToDet(mono_id)->surface();
68  theCombinedPredictedState = propagator.propagate(theCombinedPredictedState, surface);
69 
70  if (!theCombinedPredictedState.isValid()) {
71  edm::LogWarning("TrajectoryAtInvalidHit") << "found invalid combinedpredictedstate after propagation" << endl;
72  return;
73  }
74 
75  //check if hit on trajectory is valid for this sensor
76  if ((iidd & 0x3) == 0) {
77  // passed id is on matched surface (ie neither rphi, nor stereo surface)
78  // so the rechits on both sensors should be invalid
79  hasValidHit = theHit->isValid();
80  //cout << "should always be invalid = " << theHit->isValid() << endl;
81  } else {
82  if (iidd == mono_id) {
83  //mono sensor for this TrajAtInvalidHit is same as originally passed in from trajectory
84  //normally should only happen for valid hits, but sometimes is invalid
85  hasValidHit = theHit->isValid();
86  //cout << "check always true = " << theHit->isValid() << endl;
87  } else {
88  // mono sensor for this TrajAtInvalidHit is not as originally passed in from trajectory
89  // so this is a partner missing from the trajectory and is thus invalid
90  hasValidHit = false;
91  //cout << "setting invalid by fiat" << endl;
92  }
93  }
94 
95  //set module id to be mono det
96  iidd = monodet->geographicalId().rawId();
97  } else {
98  monodet = theHit->det();
99  hasValidHit = theHit->isValid();
100  }
101 
102  locX = theCombinedPredictedState.localPosition().x();
103  locY = theCombinedPredictedState.localPosition().y();
104  locZ = theCombinedPredictedState.localPosition().z();
105  locXError = sqrt(theCombinedPredictedState.localError().positionError().xx());
106  locYError = sqrt(theCombinedPredictedState.localError().positionError().yy());
107  locDxDz = theCombinedPredictedState.localParameters().vector()[1];
108  locDyDz = theCombinedPredictedState.localParameters().vector()[2];
109  globX = theCombinedPredictedState.globalPosition().x();
110  globY = theCombinedPredictedState.globalPosition().y();
111  globZ = theCombinedPredictedState.globalPosition().z();
112 
113  // this should never be a glued det, only rphi or stero
114  //cout << "From TrajAtValidHit module " << iidd << " matched/stereo/rphi = " << ((iidd & 0x3)==0) << "/" << ((iidd & 0x3)==1) << "/" << ((iidd & 0x3)==2) << endl;
115 
116  // Restrict the bound regions for better understanding of the modul assignment.
117 
118  LocalPoint BoundedPoint;
119  float xx, yy, zz;
120 
121  // Insert the bounded values
122  if (locX < 0.)
123  xx = min(locX - xB, locX - sigmaX * locXError);
124  else
125  xx = max(locX + xB, locX + sigmaX * locXError);
126 
127  if (locY < 0.)
128  yy = min(locY - yB, locY - sigmaY * locYError);
129  else
130  yy = max(locY + yB, locY + sigmaY * locYError);
131 
132  zz = theCombinedPredictedState.localPosition().z();
133 
134  BoundedPoint = LocalPoint(xx, yy, zz);
135 
136  if (monodet->surface().bounds().inside(BoundedPoint) && abs(locY) > sigmaYBond * locYError) {
137  acceptance = true;
138  } else {
139  // hit is within xB, yB from the edge of the detector, so throw it out
140  acceptance = false;
141  }
142 }
143 
144 double TrajectoryAtInvalidHit::localX() const { return locX; }
145 double TrajectoryAtInvalidHit::localY() const { return locY; }
146 double TrajectoryAtInvalidHit::localZ() const { return locZ; }
147 double TrajectoryAtInvalidHit::localErrorX() const { return locXError; }
148 double TrajectoryAtInvalidHit::localErrorY() const { return locYError; }
149 double TrajectoryAtInvalidHit::localDxDz() const { return locDxDz; }
150 double TrajectoryAtInvalidHit::localDyDz() const { return locDyDz; }
151 double TrajectoryAtInvalidHit::globalX() const { return globX; }
152 double TrajectoryAtInvalidHit::globalY() const { return globY; }
153 double TrajectoryAtInvalidHit::globalZ() const { return globZ; }
154 
155 unsigned int TrajectoryAtInvalidHit::monodet_id() const { return iidd; }
156 
157 bool TrajectoryAtInvalidHit::withinAcceptance() const { return acceptance; }
158 
159 bool TrajectoryAtInvalidHit::validHit() const { return hasValidHit; }
160 
161 bool TrajectoryAtInvalidHit::isDoubleSided(unsigned int iidd, const TrackerTopology* tTopo) const {
163  unsigned int subid = strip.subdetId();
164  unsigned int layer = 0;
165  if (subid == StripSubdetector::TIB) {
166  layer = tTopo->tibLayer(iidd);
167  if (layer == 1 || layer == 2)
168  return true;
169  else
170  return false;
171  } else if (subid == StripSubdetector::TOB) {
172  layer = tTopo->tobLayer(iidd) + 4;
173  if (layer == 5 || layer == 6)
174  return true;
175  else
176  return false;
177  } else if (subid == StripSubdetector::TID) {
178  layer = tTopo->tidRing(iidd) + 10;
179  if (layer == 11 || layer == 12)
180  return true;
181  else
182  return false;
183  } else if (subid == StripSubdetector::TEC) {
184  layer = tTopo->tecRing(iidd) + 13;
185  if (layer == 14 || layer == 15 || layer == 18)
186  return true;
187  else
188  return false;
189  } else
190  return false;
191 }
192 
193 TrajectoryStateOnSurface TrajectoryAtInvalidHit::tsos() const { return theCombinedPredictedState; }
static constexpr auto TEC
unsigned int tobLayer(const DetId &id) const
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
TrajectoryStateOnSurface tsos() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
unsigned int monodet_id() const
unsigned int tecRing(const DetId &id) const
ring id
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
static constexpr auto TOB
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
TrajectoryAtInvalidHit(const TrajectoryMeasurement &, const TrackerTopology *tTopo, const TrackerGeometry *tracker, const Propagator &propagator, const unsigned int mono=0)
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:19
bool isDoubleSided(unsigned int iidd, const TrackerTopology *tTopo) const
Definition: DetId.h:17
static constexpr auto TIB
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:20
unsigned int tidRing(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
Log< level::Warning, false > LogWarning
static constexpr auto TID
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
ConstRecHitPointer const & recHit() const
const Bounds & bounds() const
Definition: Surface.h:87