CMS 3D CMS Logo

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