1 |
#include "TrackingAnalysis/Cosmics/interface/TrajectoryAtValidHit.h"
|
2 |
#include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
|
3 |
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
|
4 |
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
|
5 |
#include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
|
6 |
#include "Geometry/CommonTopologies/interface/StripTopology.h"
|
7 |
#include "Geometry/CommonTopologies/interface/PixelTopology.h"
|
8 |
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementError.h"
|
9 |
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementVector.h"
|
10 |
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
|
11 |
#include "DataFormats/SiStripDetId/interface/TIBDetId.h"
|
12 |
#include "DataFormats/SiStripDetId/interface/TIDDetId.h"
|
13 |
#include "DataFormats/SiStripDetId/interface/TOBDetId.h"
|
14 |
#include "DataFormats/SiStripDetId/interface/TECDetId.h"
|
15 |
#include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
|
16 |
#include "RecoTracker/MeasurementDet/interface/RecHitPropagator.h"
|
17 |
#include "TrackingTools/TransientTrackingRecHit/interface/TrackingRecHitProjector.h"
|
18 |
#include "RecoTracker/TransientTrackingRecHit/interface/ProjectedRecHit2D.h"
|
19 |
|
20 |
using namespace std;
|
21 |
TrajectoryAtValidHit::TrajectoryAtValidHit( const TrajectoryMeasurement& tm,
|
22 |
const TrackerGeometry* tracker,
|
23 |
const Propagator& propagator,
|
24 |
const uint mono)
|
25 |
{
|
26 |
theCombinedPredictedState = TrajectoryStateCombiner().combine( tm.forwardPredictedState(),
|
27 |
tm.backwardPredictedState());
|
28 |
|
29 |
if (!theCombinedPredictedState.isValid()) {
|
30 |
cout << "found invalid combinedpredictedstate"<< endl;
|
31 |
return;
|
32 |
}
|
33 |
|
34 |
theHit = tm.recHit();
|
35 |
iidd = theHit->geographicalId().rawId();
|
36 |
StripSubdetector strip=StripSubdetector(iidd);
|
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) ) {
|
52 |
// find matched det id, that is the matched hit surface between the two sensors
|
53 |
uint 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 |
//set module id to be mono det
|
74 |
iidd = monodet->geographicalId().rawId();
|
75 |
} else {
|
76 |
monodet = (GeomDetUnit*)theHit->det();
|
77 |
}
|
78 |
|
79 |
locX = theCombinedPredictedState.localPosition().x();
|
80 |
locY = theCombinedPredictedState.localPosition().y();
|
81 |
locZ = theCombinedPredictedState.localPosition().z();
|
82 |
locXError = sqrt(theCombinedPredictedState.localError().positionError().xx());
|
83 |
locYError = sqrt(theCombinedPredictedState.localError().positionError().yy());
|
84 |
locDxDz = theCombinedPredictedState.localParameters().vector()[1];
|
85 |
locDyDz = theCombinedPredictedState.localParameters().vector()[2];
|
86 |
globX = theCombinedPredictedState.globalPosition().x();
|
87 |
globY = theCombinedPredictedState.globalPosition().y();
|
88 |
globZ = theCombinedPredictedState.globalPosition().z();
|
89 |
|
90 |
// this should never be a glued det, only rphi or stero
|
91 |
//cout << "From TrajAtValidHit module " << iidd << " matched/stereo/rphi = " << ((iidd & 0x3)==0) << "/" << ((iidd & 0x3)==1) << "/" << ((iidd & 0x3)==2) << endl;
|
92 |
|
93 |
// Restrict the bound regions for better understanding of the modul assignment.
|
94 |
|
95 |
LocalPoint BoundedPoint;
|
96 |
float xx, yy ,zz;
|
97 |
|
98 |
// Insert the bounded values
|
99 |
if (locX < 0. ) xx = min(locX - xB,locX - sigmaX*locXError);
|
100 |
else xx = max(locX + xB, locX + sigmaX*locXError);
|
101 |
|
102 |
if (locY < 0. ) yy = min(locY - yB,locY - sigmaY*locYError);
|
103 |
else yy = max(locY + yB, locY + sigmaY*locYError);
|
104 |
|
105 |
zz = theCombinedPredictedState.localPosition().z();
|
106 |
|
107 |
BoundedPoint = LocalPoint(xx,yy,zz);
|
108 |
|
109 |
if ( monodet->surface().bounds().inside(BoundedPoint) && abs(locY) > sigmaYBond*locYError ){
|
110 |
acceptance = true;
|
111 |
}
|
112 |
else {
|
113 |
// hit is within xB, yB from the edge of the detector, so throw it out
|
114 |
acceptance = false;
|
115 |
}
|
116 |
}
|
117 |
|
118 |
double TrajectoryAtValidHit::localX() const
|
119 |
{
|
120 |
return locX;
|
121 |
}
|
122 |
double TrajectoryAtValidHit::localY() const
|
123 |
{
|
124 |
return locY;
|
125 |
}
|
126 |
double TrajectoryAtValidHit::localZ() const
|
127 |
{
|
128 |
return locZ;
|
129 |
}
|
130 |
double TrajectoryAtValidHit::localErrorX() const
|
131 |
{
|
132 |
return locXError;
|
133 |
}
|
134 |
double TrajectoryAtValidHit::localErrorY() const
|
135 |
{
|
136 |
return locYError;
|
137 |
}
|
138 |
double TrajectoryAtValidHit::localDxDz() const {
|
139 |
return locDxDz;
|
140 |
}
|
141 |
double TrajectoryAtValidHit::localDyDz() const {
|
142 |
return locDyDz;
|
143 |
}
|
144 |
double TrajectoryAtValidHit::globalX() const
|
145 |
{
|
146 |
return globX;
|
147 |
}
|
148 |
double TrajectoryAtValidHit::globalY() const
|
149 |
{
|
150 |
return globY;
|
151 |
}
|
152 |
double TrajectoryAtValidHit::globalZ() const
|
153 |
{
|
154 |
return globZ;
|
155 |
}
|
156 |
|
157 |
uint TrajectoryAtValidHit::monodet_id() const
|
158 |
{
|
159 |
return iidd;
|
160 |
}
|
161 |
|
162 |
bool TrajectoryAtValidHit::withinAcceptance() const
|
163 |
{
|
164 |
return acceptance;
|
165 |
}
|
166 |
|
167 |
bool TrajectoryAtValidHit::isDoubleSided(uint iidd) const {
|
168 |
StripSubdetector strip=StripSubdetector(iidd);
|
169 |
unsigned int subid=strip.subdetId();
|
170 |
uint layer = 0;
|
171 |
if (subid == StripSubdetector::TIB) {
|
172 |
TIBDetId tibid(iidd);
|
173 |
layer = tibid.layer();
|
174 |
if (layer == 1 || layer == 2) return true;
|
175 |
else return false;
|
176 |
}
|
177 |
else if (subid == StripSubdetector::TOB) {
|
178 |
TOBDetId tobid(iidd);
|
179 |
layer = tobid.layer() + 4 ;
|
180 |
if (layer == 5 || layer == 6) return true;
|
181 |
else return false;
|
182 |
}
|
183 |
else if (subid == StripSubdetector::TID) {
|
184 |
TIDDetId tidid(iidd);
|
185 |
layer = tidid.ring() + 10;
|
186 |
if (layer == 11 || layer == 12) return true;
|
187 |
else return false;
|
188 |
}
|
189 |
else if (subid == StripSubdetector::TEC) {
|
190 |
TECDetId tecid(iidd);
|
191 |
layer = tecid.ring() + 13 ;
|
192 |
if (layer == 14 || layer == 15 || layer == 18) return true;
|
193 |
else return false;
|
194 |
}
|
195 |
else
|
196 |
return false;
|
197 |
}
|
198 |
|
199 |
TrajectoryStateOnSurface TrajectoryAtValidHit::tsos() const {
|
200 |
return theCombinedPredictedState;
|
201 |
}
|