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 
13 namespace {
14  template <class T> inline T sqr( T t) {return t*t;}
15  template <class T>
16  inline T cropped_asin(T x) {
17  return std::abs(x) <= 1 ? std::asin(x) : (x > 0 ? T(M_PI/2) : -T(M_PI/2));
18  }
19 }
20 
21 namespace {
22  inline 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 
30 InnerDeltaPhi:: InnerDeltaPhi( const DetLayer& outlayer, const DetLayer& layer,
31  const TrackingRegion & region,
32  const edm::EventSetup& iSetup,
33  bool precise, float extraTolerance)
34  : thePrecise(precise),
35  ol( outlayer.seqNum()),
36  theROrigin(region.originRBound()),
37  theRLayer(0),
38  theThickness(0),
39  theExtraTolerance(extraTolerance),
40  theA(0),
41  theB(0),
42  theVtxZ(region.origin().z()),
43  thePtMin(region.ptMin()),
44  theVtx(region.origin().x(),region.origin().y()),
45  sigma(&layer,iSetup)
46 {
47  float zMinOrigin = theVtxZ-region.originZBound();
48  float zMaxOrigin = theVtxZ+region.originZBound();
50 
51 
52  if (layer.isBarrel()) initBarrelLayer( layer);
53  else initForwardLayer( layer, zMinOrigin, zMaxOrigin);
54 
55 }
56 
57 
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);
74  theRLayer = fl.specificSurface().innerRadius();
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  float rLayer = theRLayer;
88  bool checkCrossing = true;
89  Point2D crossing;
90 
91  Point2D dHit = hitXY-theVtx;
92  auto dHitmag = dHit.mag();
93  float dLayer = 0.;
94  float dL = 0.;
95  //
96  // compute crossing of stright track with inner layer
97  //
98  if (!theRDefined) {
99  auto t = theA/(hitZ-theB); auto 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 = (vect(rVTX) + vect(dHit).unit * dLayer)^2 and we have square eqation for dLayer
118  //
119  // barrel case
120  //
121 
122  if (checkCrossing) {
123  auto vtxmag2 = theVtx.mag2();
124  if (vtxmag2 < 1.e-10f) {
125  dLayer = rLayer;
126  }
127  else {
128  // there are cancellation here....
129  double var_c = vtxmag2-sqr(rLayer);
130  double var_b = theVtx.dot(dHit.unit());
131  double var_delta = sqr(var_b)-var_c;
132  if (var_delta <=0.) var_delta = 0;
133  dLayer = -var_b + std::sqrt(var_delta); //only the value along vector is OK.
134  }
135  crossing = theVtx+ dHit.unit() * dLayer;
136  float cosCross = std::abs( dHit.unit().dot(crossing.unit()));
137  dL = theThickness/cosCross;
138  }
139 
140 
141  // track is crossing layer with angle such as:
142  // this factor should be taken in computation of eror projection
143  auto cosCross = std::abs( dHit.unit().dot(crossing.unit()));
144 
145  auto alphaHit = cropped_asin( dHitmag/(2*theRCurvature));
146  auto deltaPhi = std::abs( alphaHit - cropped_asin( dLayer/(2*theRCurvature)));
147  deltaPhi *= dLayer/(rLayer*cosCross);
148 
149  // additinal angle due to not perpendicular stright line crossing (for displaced beam)
150  // double dPhiCrossing = (cosCross > 0.9999) ? 0 : dL * sqrt(1-sqr(cosCross))/ rLayer;
151  Point2D crossing2 = theVtx + dHit.unit()* (dLayer+dL);
152  auto phicross2 = crossing2.barePhi();
153  auto phicross1 = crossing.barePhi();
154  auto dphicross = phicross2-phicross1;
155  if (dphicross < -float(M_PI)) dphicross += float(2*M_PI);
156  if (dphicross > float(M_PI)) dphicross -= float(2*M_PI);
157  if (dphicross > float(M_PI/2)) dphicross = 0.; // something wrong?
158  phicross2 = phicross1 + dphicross;
159 
160 
161  // compute additional delta phi due to origin radius
162  auto deltaPhiOrig = cropped_asin( theROrigin * (dHitmag-dLayer) / (dHitmag*dLayer));
163  deltaPhiOrig *= dLayer/(rLayer*cosCross);
164 
165  // inner hit error taken as constant
166  auto deltaPhiHit = theExtraTolerance / rLayer;
167 
168  // outer hit error
169 // double deltaPhiHitOuter = errRPhi/rLayer;
170  auto deltaPhiHitOuter = errRPhi/hitXY.mag();
171 
172  auto margin = deltaPhi+deltaPhiOrig+deltaPhiHit+deltaPhiHitOuter ;
173 
174  if (thePrecise) {
175  // add multiple scattering correction
176  PixelRecoPointRZ zero(0., theVtxZ);
177  PixelRecoPointRZ point(hitXY.mag(), hitZ);
178  auto scatt = 3.f*sigma(thePtMin,zero, point, ol) / rLayer;
179 
180  margin += scatt ;
181  }
182 
183  return PixelRecoRange<float>( std::min(phicross1,phicross2)-margin,
184  std::max(phicross1,phicross2)+margin);
185 }
186 
187 
188 
189 
190 float InnerDeltaPhi::minRadius( float hitR, float hitZ) const
191 {
192  if (theRDefined) return theRLayer;
193  else {
194  float rmin = (theA*hitR)/(hitZ-theB);
195  return ( rmin> 0) ? std::max( rmin, theRLayer) : theRLayer;
196  }
197 }
198 
199 
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