CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrajectoryAtInvalidHit.cc
Go to the documentation of this file.
14 // #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)
24 {
25  if ( tm.backwardPredictedState().isValid() )
26  theCombinedPredictedState = TrajectoryStateCombiner().combine( tm.forwardPredictedState(),
28  else
29  theCombinedPredictedState = tm.forwardPredictedState();
30 
31  if (!theCombinedPredictedState.isValid()) {
32  return;
33  }
34  theHit = tm.recHit();
35  iidd = theHit->geographicalId().rawId();
37  unsigned int subid=strip.subdetId();
38  // xB and yB are for absolute borders on the trajectories included in the study, sigmaX sigmaY are
39  // significance cuts on the distance from the detector surface
40  float xB = 0.; float sigmaX = 5.0;
41  float yB = 0.; 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  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matched_id);
57 
58  // get the sensor det indicated by mono
59  if (mono == 1) monodet=gdet->stereoDet();
60  else monodet=gdet->monoDet(); // this should only be mono == 2
61 
62  // set theCombinedPredictedState to be on the sensor surface, not the matched surface
63  DetId mono_id = monodet->geographicalId();
64  const Surface &surface = tracker->idToDet(mono_id)->surface();
65  theCombinedPredictedState = propagator.propagate(theCombinedPredictedState,
66  surface);
67 
68  if (!theCombinedPredictedState.isValid()) {
69  cout << "found invalid combinedpredictedstate after propagation"<< endl;
70  return;
71  }
72 
73  //check if hit on trajectory is valid for this sensor
74  if ((iidd & 0x3)==0) {
75  // passed id is on matched surface (ie neither rphi, nor stereo surface)
76  // so the rechits on both sensors should be invalid
77  hasValidHit = theHit->isValid();
78  //cout << "should always be invalid = " << theHit->isValid() << endl;
79  } else {
80  if (iidd==mono_id) {
81  //mono sensor for this TrajAtInvalidHit is same as originally passed in from trajectory
82  //normally should only happen for valid hits, but sometimes is invalid
83  hasValidHit = theHit->isValid();
84  //cout << "check always true = " << theHit->isValid() << endl;
85  } else {
86  // mono sensor for this TrajAtInvalidHit is not as originally passed in from trajectory
87  // so this is a partner missing from the trajectory and is thus invalid
88  hasValidHit = false;
89  //cout << "setting invalid by fiat" << endl;
90  }
91  }
92 
93  //set module id to be mono det
94  iidd = monodet->geographicalId().rawId();
95  } else {
96  monodet = (GeomDetUnit*)theHit->det();
97  hasValidHit = theHit->isValid();
98  }
99 
100  locX = theCombinedPredictedState.localPosition().x();
101  locY = theCombinedPredictedState.localPosition().y();
102  locZ = theCombinedPredictedState.localPosition().z();
103  locXError = sqrt(theCombinedPredictedState.localError().positionError().xx());
104  locYError = sqrt(theCombinedPredictedState.localError().positionError().yy());
105  locDxDz = theCombinedPredictedState.localParameters().vector()[1];
106  locDyDz = theCombinedPredictedState.localParameters().vector()[2];
107  globX = theCombinedPredictedState.globalPosition().x();
108  globY = theCombinedPredictedState.globalPosition().y();
109  globZ = theCombinedPredictedState.globalPosition().z();
110 
111  // this should never be a glued det, only rphi or stero
112  //cout << "From TrajAtValidHit module " << iidd << " matched/stereo/rphi = " << ((iidd & 0x3)==0) << "/" << ((iidd & 0x3)==1) << "/" << ((iidd & 0x3)==2) << endl;
113 
114  // Restrict the bound regions for better understanding of the modul assignment.
115 
116  LocalPoint BoundedPoint;
117  float xx, yy ,zz;
118 
119  // Insert the bounded values
120  if (locX < 0. ) xx = min(locX - xB,locX - sigmaX*locXError);
121  else xx = max(locX + xB, locX + sigmaX*locXError);
122 
123  if (locY < 0. ) yy = min(locY - yB,locY - sigmaY*locYError);
124  else yy = max(locY + yB, locY + sigmaY*locYError);
125 
126  zz = theCombinedPredictedState.localPosition().z();
127 
128  BoundedPoint = LocalPoint(xx,yy,zz);
129 
130  if ( monodet->surface().bounds().inside(BoundedPoint) && abs(locY) > sigmaYBond*locYError ){
131  acceptance = true;
132  }
133  else {
134  // hit is within xB, yB from the edge of the detector, so throw it out
135  acceptance = false;
136  }
137 }
138 
140 {
141  return locX;
142 }
144 {
145  return locY;
146 }
148 {
149  return locZ;
150 }
152 {
153  return locXError;
154 }
156 {
157  return locYError;
158 }
160  return locDxDz;
161 }
163  return locDyDz;
164 }
166 {
167  return globX;
168 }
170 {
171  return globY;
172 }
174 {
175  return globZ;
176 }
177 
179 {
180  return iidd;
181 }
182 
184 {
185  return acceptance;
186 }
187 
189 {
190  return hasValidHit;
191 }
192 
193 bool TrajectoryAtInvalidHit::isDoubleSided(unsigned int iidd, const TrackerTopology* tTopo) const {
195  unsigned int subid=strip.subdetId();
196  unsigned int layer = 0;
197  if (subid == StripSubdetector::TIB) {
198 
199  layer = tTopo->tibLayer(iidd);
200  if (layer == 1 || layer == 2) return true;
201  else return false;
202  }
203  else if (subid == StripSubdetector::TOB) {
204 
205  layer = tTopo->tobLayer(iidd) + 4 ;
206  if (layer == 5 || layer == 6) return true;
207  else return false;
208  }
209  else if (subid == StripSubdetector::TID) {
210 
211  layer = tTopo->tidRing(iidd) + 10;
212  if (layer == 11 || layer == 12) return true;
213  else return false;
214  }
215  else if (subid == StripSubdetector::TEC) {
216 
217  layer = tTopo->tecRing(iidd) + 13 ;
218  if (layer == 14 || layer == 15 || layer == 18) return true;
219  else return false;
220  }
221  else
222  return false;
223 }
224 
226  return theCombinedPredictedState;
227 }
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:20
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
#define abs(x)
Definition: mlp_lapack.h:159
const Bounds & bounds() const
Definition: Surface.h:128
#define min(a, b)
Definition: mlp_lapack.h:161
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
virtual const GeomDet * idToDet(DetId) const
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)
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
Definition: DetId.h:20
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface tsos() const
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
unsigned int tobLayer(const DetId &id) const
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)