CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InnerDeltaPhi.cc
Go to the documentation of this file.
9 
10 
11 using namespace std;
12 
14 
15 template <class T> inline T sqr( T t) {return t*t;}
16 
17 inline double cropped_asin(double x) {
18  return abs(x) <= 1 ? asin(x) : (x > 0 ? M_PI/2 : -M_PI/2);
19 }
20 
21 namespace {
22  double checked_asin(double x, const char *expr, const char *file, int line) {
23  if (fabs(x) >= 1.0) throw cms::Exception("CorruptData") << "asin(x) called with x = " << expr << " = " << x << "\n\tat " << file << ":" << line << "\n";
24  return asin(x);
25  }
26 }
27 
28 //#define asin(X) checked_asin(X, #X, __FILE__, __LINE__)
29 
31  const TrackingRegion & region,
32  const edm::EventSetup& iSetup,
33  bool precise, float extraTolerance)
34  : thePrecise(precise),
35  theROrigin(region.originRBound()),
36  theRLayer(0),
37  theThickness(0),
38  theExtraTolerance(extraTolerance),
39  theA(0),
40  theB(0),
41  theVtxZ(region.origin().z()),
42  thePtMin(region.ptMin()),
43  theVtx(region.origin().x(),region.origin().y()),
44  sigma(&layer,iSetup)
45 {
46  float zMinOrigin = theVtxZ-region.originZBound();
47  float zMaxOrigin = theVtxZ+region.originZBound();
49 
50 
51  if (layer.location() == GeomDetEnumerators::barrel) initBarrelLayer( layer);
52  else initForwardLayer( layer, zMinOrigin, zMaxOrigin);
53 
54 }
55 
56 
58 
60 {
61  const BarrelDetLayer& bl = static_cast<const BarrelDetLayer&>(layer);
62  float rLayer = bl.specificSurface().radius();
63 
64  // the maximal delta phi will be for the innermost hits
65  theThickness = layer.surface().bounds().thickness();
66  theRLayer = rLayer - 0.5f*theThickness;
67  theRDefined = true;
68 }
69 
71  float zMinOrigin, float zMaxOrigin)
72 {
73  const ForwardDetLayer &fl = static_cast<const ForwardDetLayer&>(layer);
75  float layerZ = layer.position().z();
76  theThickness = layer.surface().bounds().thickness();
77  float layerZmin = layerZ > 0 ? layerZ-0.5f*theThickness: layerZ+0.5f*theThickness;
78  theB = layerZ > 0 ? zMaxOrigin : zMinOrigin;
79  theA = layerZmin - theB;
80  theRDefined = false;
81 }
82 
83 
84 
85 PixelRecoRange<float> InnerDeltaPhi::phiRange(const Point2D& hitXY,float hitZ,float errRPhi) const
86 {
87  double rLayer = theRLayer;
88  bool checkCrossing = true;
89  Point2D crossing;
90 
91  Point2D dHit = hitXY-theVtx;
92  double dHitmag = dHit.mag();
93  double dLayer = 0.;
94  double dL = 0.;
95  //
96  // compute crossing of stright track with inner layer
97  //
98  if (!theRDefined) {
99  double t = theA/(hitZ-theB); double dt = std::abs(theThickness/(hitZ-theB));
100  crossing = theVtx + t*dHit;
101  rLayer = crossing.mag();
102  dLayer = t*dHitmag; dL = dt * dHitmag;
103  checkCrossing = false;
104  if (rLayer < theRLayer) {
105  checkCrossing = true;
106  rLayer = theRLayer;
107  dL = 0.;
108  }
109  }
110 
111  //
112  // compute crossing of track with layer
113  // dHit - from VTX to outer hit
114  // rLayer - layer radius
115  // dLayer - distance from VTX to inner layer in direction of dHit
116  // vect(rLayer) = vect(rVTX) + vect(dHit).unit * dLayer
117  // rLayer^2 = (ect(rVTX) + vect(dHit).unit * dLayer)^2 and we have square eqation for dLayer
118  //
119  // barrel case
120  //
121 
122  if (checkCrossing) {
123  double vtxmag2 = theVtx.mag2();
124  if (vtxmag2 < 1.e-10) {
125  dLayer = rLayer;
126  }
127  else {
128  double var_c = theVtx.mag2()-sqr(rLayer);
129  double var_b = 2*theVtx.dot(dHit.unit());
130  double var_delta = sqr(var_b)-4*var_c;
131  if (var_delta <=0.) var_delta = 0;
132  dLayer = 0.5*(-var_b + std::sqrt(var_delta)); //only the value along vector is OK.
133  }
134  crossing = theVtx+ dHit.unit() * dLayer;
135  double cosCross = std::abs( dHit.unit().dot(crossing.unit()));
136  dL = theThickness/cosCross;
137  }
138 
139 
140  // track is crossing layer with angle such as:
141  // this factor should be taken in computation of eror projection
142  double cosCross = std::abs( dHit.unit().dot(crossing.unit()));
143 
144  double alphaHit = cropped_asin( dHitmag/(2*theRCurvature));
145  double deltaPhi = fabs( alphaHit - cropped_asin( dLayer/(2*theRCurvature)));
146  deltaPhi *= dLayer/(rLayer*cosCross);
147 
148  // additinal angle due to not perpendicular stright line crossing (for displaced beam)
149  // double dPhiCrossing = (cosCross > 0.9999) ? 0 : dL * sqrt(1-sqr(cosCross))/ rLayer;
150  Point2D crossing2 = theVtx + dHit.unit()* (dLayer+dL);
151  double phicross2 = crossing2.phi();
152  double phicross1 = crossing.phi();
153  double dphicross = phicross2-phicross1;
154  if (dphicross < -M_PI) dphicross += 2*M_PI;
155  if (dphicross > M_PI) dphicross -= 2*M_PI;
156  if (dphicross > M_PI/2) dphicross = 0.; // something wrong?
157  phicross2 = phicross1 + dphicross;
158 
159 
160  // compute additional delta phi due to origin radius
161  double deltaPhiOrig = cropped_asin( theROrigin * (dHitmag-dLayer) / (dHitmag*dLayer));
162  deltaPhiOrig *= dLayer/(rLayer*cosCross);
163 
164  // inner hit error taken as constant
165  double deltaPhiHit = theExtraTolerance / rLayer;
166 
167  // outer hit error
168 // double deltaPhiHitOuter = errRPhi/rLayer;
169  double deltaPhiHitOuter = errRPhi/hitXY.mag();
170 
171  double margin = deltaPhi+deltaPhiOrig+deltaPhiHit+deltaPhiHitOuter ;
172 
173  if (thePrecise) {
174  // add multiple scattering correction
176  PixelRecoPointRZ point(hitXY.mag(), hitZ);
177  double scatt = 3.f*sigma(thePtMin,zero, point) / rLayer;
178 
179  margin += scatt ;
180  }
181 
182  return PixelRecoRange<float>( std::min(phicross1,phicross2)-margin,
183  std::max(phicross1,phicross2)+margin);
184 }
185 
186 float InnerDeltaPhi::operator()( float rHit, float zHit, float errRPhi) const
187 {
188  // alpha - angle between particle direction at vertex and position of hit.
189  // (pi/2 - alpha) - angle hit-vertex-cernter_of_curvature
190  // cos (pi/2 - alpha) = (hRhi/2) / theRCurvature
191  // so:
192 
193  float alphaHit = std::asin( rHit/(2*theRCurvature));
194 
195 
196  float rMin = minRadius( rHit, zHit);
197  float deltaPhi = std::abs( alphaHit - std::asin( rMin/(2*theRCurvature)));
198 
199  // compute additional delta phi due to origin radius
200  float deltaPhiOrig = asin( theROrigin * (rHit-rMin) / (rHit*rMin));
201 
202  // hit error taken as constant
203  float deltaPhiHit = theExtraTolerance / rMin;
204 
205  if (!thePrecise) {
206  return deltaPhi+deltaPhiOrig+deltaPhiHit;
207  } else {
208  // add multiple scattering correction
210  PixelRecoPointRZ point(rHit, zHit);
211  float scatt = 3.f*sigma(thePtMin,zero, point) / rMin;
212  float deltaPhiHitOuter = errRPhi/rMin;
213 
214  return deltaPhi+deltaPhiOrig+deltaPhiHit + scatt + deltaPhiHitOuter;
215  }
216 
217 }
218 
220  float rHit, float phiHit, float zHit, float errRPhi) const
221 {
222 // float phiM = operator()( rHit,zHit,errRPhi);
223 // return PixelRecoRange<float>(phiHit-phiM,phiHit+phiM);
224 
225  Point2D hitXY( rHit*std::cos(phiHit), rHit*std::sin(phiHit));
226  return phiRange(hitXY,zHit,errRPhi);
227 }
228 
229 float InnerDeltaPhi::minRadius( float hitR, float hitZ) const
230 {
231  if (theRDefined) return theRLayer;
232  else {
233  float rmin = (theA*hitR)/(hitZ-theB);
234  return ( rmin> 0) ? std::max( rmin, theRLayer) : theRLayer;
235  }
236 }
237 
238 
float dt
Definition: AMPTWrapper.h:126
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
virtual Location location() const =0
Which part of the detector (barrel, endcap)
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T dot(const Basic2DVector &lh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
#define abs(x)
Definition: mlp_lapack.h:159
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define min(a, b)
Definition: mlp_lapack.h:161
PixelRecoRange< float > phiRange(const Point2D &hitXY, float zHit, float errRPhi) const
float operator()(float rHit, float zHit, float errRPhi) const
Point2D theVtx
Definition: InnerDeltaPhi.h:51
double double double z
double cropped_asin(double x)
Basic2DVector unit() const
virtual float thickness() const =0
float minRadius(float hitR, float hitZ) const
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
virtual const BoundDisk & specificSurface() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const Bounds & bounds() const
Definition: BoundSurface.h:89
#define M_PI
Definition: BFit3D.cc:3
float theThickness
Definition: InnerDeltaPhi.h:41
virtual const Surface::PositionType & position() const
Returns position of the surface.
void initBarrelLayer(const DetLayer &layer)
float theRCurvature
Definition: InnerDeltaPhi.h:43
void initForwardLayer(const DetLayer &layer, float zMinOrigin, float zMaxOrigin)
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
T bendingRadius(T pt, const edm::EventSetup &iSetup)
virtual float originZBound() const =0
bounds the particle vertex in the longitudinal plane
Square< F >::type sqr(const F &f)
Definition: Square.h:13
float innerRadius() const
The inner radius of the disk.
Definition: BoundDisk.cc:6
Definition: DDAxes.h:10
float theExtraTolerance
Definition: InnerDeltaPhi.h:44
Geom::Phi< T > phi() const
long double T
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
MultipleScatteringParametrisation sigma
Definition: InnerDeltaPhi.h:54
InnerDeltaPhi(const DetLayer &layer, const TrackingRegion &region, const edm::EventSetup &iSetup, bool precise=true, float extraTolerance=0.f)