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.
16 // #include "RecoTracker/MeasurementDet/interface/RecHitPropagator.h"
19 
20 using namespace std;
22  const TrackerGeometry* tracker,
23  const Propagator& propagator,
24  const unsigned int mono)
25 {
26  if ( tm.backwardPredictedState().isValid() )
27  theCombinedPredictedState = TrajectoryStateCombiner().combine( tm.forwardPredictedState(),
29  else
30  theCombinedPredictedState = tm.forwardPredictedState();
31 
32  if (!theCombinedPredictedState.isValid()) {
33  return;
34  }
35  theHit = tm.recHit();
36  iidd = theHit->geographicalId().rawId();
38  unsigned int subid=strip.subdetId();
39  // xB and yB are for absolute borders on the trajectories included in the study, sigmaX sigmaY are
40  // significance cuts on the distance from the detector surface
41  float xB = 0.; float sigmaX = 5.0;
42  float yB = 0.; 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) ) {
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  GluedGeomDet * gdet=(GluedGeomDet *)tracker->idToDet(matched_id);
58 
59  // get the sensor det indicated by mono
60  if (mono == 1) monodet=gdet->stereoDet();
61  else monodet=gdet->monoDet(); // this should only be mono == 2
62 
63  // set theCombinedPredictedState to be on the sensor surface, not the matched surface
64  DetId mono_id = monodet->geographicalId();
65  const Surface &surface = tracker->idToDet(mono_id)->surface();
66  theCombinedPredictedState = propagator.propagate(theCombinedPredictedState,
67  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 = (GeomDetUnit*)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. ) xx = min(locX - xB,locX - sigmaX*locXError);
122  else xx = max(locX + xB, locX + sigmaX*locXError);
123 
124  if (locY < 0. ) yy = min(locY - yB,locY - sigmaY*locYError);
125  else yy = max(locY + yB, locY + sigmaY*locYError);
126 
127  zz = theCombinedPredictedState.localPosition().z();
128 
129  BoundedPoint = LocalPoint(xx,yy,zz);
130 
131  if ( monodet->surface().bounds().inside(BoundedPoint) && abs(locY) > sigmaYBond*locYError ){
132  acceptance = true;
133  }
134  else {
135  // hit is within xB, yB from the edge of the detector, so throw it out
136  acceptance = false;
137  }
138 }
139 
141 {
142  return locX;
143 }
145 {
146  return locY;
147 }
149 {
150  return locZ;
151 }
153 {
154  return locXError;
155 }
157 {
158  return locYError;
159 }
161  return locDxDz;
162 }
164  return locDyDz;
165 }
167 {
168  return globX;
169 }
171 {
172  return globY;
173 }
175 {
176  return globZ;
177 }
178 
180 {
181  return iidd;
182 }
183 
185 {
186  return acceptance;
187 }
188 
190 {
191  return hasValidHit;
192 }
193 
194 bool TrajectoryAtInvalidHit::isDoubleSided(unsigned int iidd) const {
196  unsigned int subid=strip.subdetId();
197  unsigned int layer = 0;
198  if (subid == StripSubdetector::TIB) {
199  TIBDetId tibid(iidd);
200  layer = tibid.layer();
201  if (layer == 1 || layer == 2) return true;
202  else return false;
203  }
204  else if (subid == StripSubdetector::TOB) {
205  TOBDetId tobid(iidd);
206  layer = tobid.layer() + 4 ;
207  if (layer == 5 || layer == 6) return true;
208  else return false;
209  }
210  else if (subid == StripSubdetector::TID) {
211  TIDDetId tidid(iidd);
212  layer = tidid.ring() + 10;
213  if (layer == 11 || layer == 12) return true;
214  else return false;
215  }
216  else if (subid == StripSubdetector::TEC) {
217  TECDetId tecid(iidd);
218  layer = tecid.ring() + 13 ;
219  if (layer == 14 || layer == 15 || layer == 18) return true;
220  else return false;
221  }
222  else
223  return false;
224 }
225 
227  return theCombinedPredictedState;
228 }
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
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
TrajectoryStateOnSurface forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
#define abs(x)
Definition: mlp_lapack.h:159
ConstRecHitPointer recHit() const
#define min(a, b)
Definition: mlp_lapack.h:161
TrajectoryAtInvalidHit(const TrajectoryMeasurement &, const TrackerGeometry *tracker, const Propagator &propagator, const unsigned int mono=0)
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:46
bool isDoubleSided(unsigned int iidd) const
unsigned int ring() const
ring id
Definition: TIDDetId.h:55
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
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
Definition: DetId.h:20
const Bounds & bounds() const
Definition: BoundSurface.h:89
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
unsigned int ring() const
ring id
Definition: TECDetId.h:71
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:121
TrajectoryStateOnSurface tsos() const
TrajectoryStateOnSurface backwardPredictedState() const
Access to backward predicted state (from smoother)
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21