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 namespace {
16  template <class T> inline T sqr( T t) {return t*t;}
17  template <class T>
18  inline T cropped_asin(T x) {
19  return std::abs(x) <= 1 ? std::asin(x) : (x > 0 ? T(M_PI/2) : -T(M_PI/2));
20  }
21 }
22 
23 namespace {
24  inline double checked_asin(double x, const char *expr, const char *file, int line) {
25  if (fabs(x) >= 1.0) throw cms::Exception("CorruptData") << "asin(x) called with x = " << expr << " = " << x << "\n\tat " << file << ":" << line << "\n";
26  return asin(x);
27  }
28 }
29 
30 //#define asin(X) checked_asin(X, #X, __FILE__, __LINE__)
31 
32 InnerDeltaPhi:: InnerDeltaPhi( const DetLayer& outlayer, const DetLayer& layer,
33  const TrackingRegion & region,
34  const edm::EventSetup& iSetup,
35  bool precise, float extraTolerance)
36  : thePrecise(precise),
37  ol( outlayer.seqNum()),
38  theROrigin(region.originRBound()),
39  theRLayer(0),
40  theThickness(0),
41  theExtraTolerance(extraTolerance),
42  theA(0),
43  theB(0),
44  theVtxZ(region.origin().z()),
45  thePtMin(region.ptMin()),
46  theVtx(region.origin().x(),region.origin().y()),
47  sigma(&layer,iSetup)
48 {
49  float zMinOrigin = theVtxZ-region.originZBound();
50  float zMaxOrigin = theVtxZ+region.originZBound();
52 
53 
54  if (layer.isBarrel()) initBarrelLayer( layer);
55  else initForwardLayer( layer, zMinOrigin, zMaxOrigin);
56 
57 }
58 
59 
60 
62 {
63  const BarrelDetLayer& bl = static_cast<const BarrelDetLayer&>(layer);
64  float rLayer = bl.specificSurface().radius();
65 
66  // the maximal delta phi will be for the innermost hits
67  theThickness = layer.surface().bounds().thickness();
68  theRLayer = rLayer - 0.5f*theThickness;
69  theRDefined = true;
70 }
71 
73  float zMinOrigin, float zMaxOrigin)
74 {
75  const ForwardDetLayer &fl = static_cast<const ForwardDetLayer&>(layer);
76  theRLayer = fl.specificSurface().innerRadius();
77  float layerZ = layer.position().z();
78  theThickness = layer.surface().bounds().thickness();
79  float layerZmin = layerZ > 0 ? layerZ-0.5f*theThickness: layerZ+0.5f*theThickness;
80  theB = layerZ > 0 ? zMaxOrigin : zMinOrigin;
81  theA = layerZmin - theB;
82  theRDefined = false;
83 }
84 
85 
86 
87 PixelRecoRange<float> InnerDeltaPhi::phiRange(const Point2D& hitXY,float hitZ,float errRPhi) const
88 {
89  float rLayer = theRLayer;
90  bool checkCrossing = true;
91  Point2D crossing;
92 
93  Point2D dHit = hitXY-theVtx;
94  auto dHitmag = dHit.mag();
95  float dLayer = 0.;
96  float dL = 0.;
97  //
98  // compute crossing of stright track with inner layer
99  //
100  if (!theRDefined) {
101  auto t = theA/(hitZ-theB); auto dt = std::abs(theThickness/(hitZ-theB));
102  crossing = theVtx + t*dHit;
103  rLayer = crossing.mag();
104  dLayer = t*dHitmag; dL = dt * dHitmag;
105  checkCrossing = false;
106  if (rLayer < theRLayer) {
107  checkCrossing = true;
108  rLayer = theRLayer;
109  dL = 0.;
110  }
111  }
112 
113  //
114  // compute crossing of track with layer
115  // dHit - from VTX to outer hit
116  // rLayer - layer radius
117  // dLayer - distance from VTX to inner layer in direction of dHit
118  // vect(rLayer) = vect(rVTX) + vect(dHit).unit * dLayer
119  // rLayer^2 = (vect(rVTX) + vect(dHit).unit * dLayer)^2 and we have square eqation for dLayer
120  //
121  // barrel case
122  //
123 
124  if (checkCrossing) {
125  auto vtxmag2 = theVtx.mag2();
126  if (vtxmag2 < 1.e-10f) {
127  dLayer = rLayer;
128  }
129  else {
130  // there are cancellation here....
131  double var_c = vtxmag2-sqr(rLayer);
132  double var_b = theVtx.dot(dHit.unit());
133  double var_delta = sqr(var_b)-var_c;
134  if (var_delta <=0.) var_delta = 0;
135  dLayer = -var_b + std::sqrt(var_delta); //only the value along vector is OK.
136  }
137  crossing = theVtx+ dHit.unit() * dLayer;
138  float cosCross = std::abs( dHit.unit().dot(crossing.unit()));
139  dL = theThickness/cosCross;
140  }
141 
142 
143  // track is crossing layer with angle such as:
144  // this factor should be taken in computation of eror projection
145  auto cosCross = std::abs( dHit.unit().dot(crossing.unit()));
146 
147  auto alphaHit = cropped_asin( dHitmag/(2*theRCurvature));
148  auto deltaPhi = std::abs( alphaHit - cropped_asin( dLayer/(2*theRCurvature)));
149  deltaPhi *= dLayer/(rLayer*cosCross);
150 
151  // additinal angle due to not perpendicular stright line crossing (for displaced beam)
152  // double dPhiCrossing = (cosCross > 0.9999) ? 0 : dL * sqrt(1-sqr(cosCross))/ rLayer;
153  Point2D crossing2 = theVtx + dHit.unit()* (dLayer+dL);
154  auto phicross2 = crossing2.barePhi();
155  auto phicross1 = crossing.barePhi();
156  auto dphicross = phicross2-phicross1;
157  if (dphicross < -float(M_PI)) dphicross += float(2*M_PI);
158  if (dphicross > float(M_PI)) dphicross -= float(2*M_PI);
159  if (dphicross > float(M_PI/2)) dphicross = 0.; // something wrong?
160  phicross2 = phicross1 + dphicross;
161 
162 
163  // compute additional delta phi due to origin radius
164  auto deltaPhiOrig = cropped_asin( theROrigin * (dHitmag-dLayer) / (dHitmag*dLayer));
165  deltaPhiOrig *= dLayer/(rLayer*cosCross);
166 
167  // inner hit error taken as constant
168  auto deltaPhiHit = theExtraTolerance / rLayer;
169 
170  // outer hit error
171 // double deltaPhiHitOuter = errRPhi/rLayer;
172  auto deltaPhiHitOuter = errRPhi/hitXY.mag();
173 
174  auto margin = deltaPhi+deltaPhiOrig+deltaPhiHit+deltaPhiHitOuter ;
175 
176  if (thePrecise) {
177  // add multiple scattering correction
178  PixelRecoPointRZ zero(0., theVtxZ);
179  PixelRecoPointRZ point(hitXY.mag(), hitZ);
180  auto scatt = 3.f*sigma(thePtMin,zero, point, ol) / rLayer;
181 
182  margin += scatt ;
183  }
184 
185  return PixelRecoRange<float>( std::min(phicross1,phicross2)-margin,
186  std::max(phicross1,phicross2)+margin);
187 }
188 
189 
190 
191 
192 float InnerDeltaPhi::minRadius( float hitR, float hitZ) const
193 {
194  if (theRDefined) return theRLayer;
195  else {
196  float rmin = (theA*hitR)/(hitZ-theB);
197  return ( rmin> 0) ? std::max( rmin, theRLayer) : theRLayer;
198  }
199 }
200 
201 
float dt
Definition: AMPTWrapper.h:126
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
T dot(const Basic2DVector &lh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const Bounds & bounds() const
Definition: Surface.h:128
T barePhi() const
PixelRecoRange< float > phiRange(const Point2D &hitXY, float zHit, float errRPhi) const
Point2D theVtx
Definition: InnerDeltaPhi.h:51
float float float z
Basic2DVector unit() const
virtual float thickness() const =0
float minRadius(float hitR, float hitZ) const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
virtual const BoundDisk & specificSurface() const
Double_t margin
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
T min(T a, T b)
Definition: MathUtil.h:58
#define M_PI
float originZBound() const
bounds the particle vertex in the longitudinal plane
bool isBarrel() const
Definition: DetLayer.h:32
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)
Square< F >::type sqr(const F &f)
Definition: Square.h:13
InnerDeltaPhi(const DetLayer &outlayer, const DetLayer &layer, const TrackingRegion &region, const edm::EventSetup &iSetup, bool precise=true, float extraTolerance=0.f)
Definition: DDAxes.h:10
float theExtraTolerance
Definition: InnerDeltaPhi.h:44
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