CMS 3D CMS Logo

MSLayer.cc
Go to the documentation of this file.
5 #include "MSLayersKeeper.h"
6 
7 #include <iostream>
8 
9 using namespace GeomDetEnumerators;
10 using namespace std;
11 template <class T>
12 T sqr(T t) {
13  return t * t;
14 }
15 
16 //----------------------------------------------------------------------
17 ostream& operator<<(ostream& s, const MSLayer& l) {
18  s << " face: " << l.face() << " pos:" << l.position() << ", "
19  << " range:" << l.range() << ", " << l.theX0Data;
20  return s;
21 }
22 //----------------------------------------------------------------------
23 ostream& operator<<(ostream& s, const MSLayer::DataX0& d) {
24  if (d.hasX0)
25  s << "x0=" << d.x0 << " sumX0D=" << d.sumX0D;
26  else if (d.allLayers)
27  s << "x0 by MSLayersKeeper";
28  else
29  s << "empty DataX0";
30  return s;
31 }
32 //----------------------------------------------------------------------
33 //MP
34 MSLayer::MSLayer(const DetLayer* layer, const DataX0& dataX0)
35  : theFace(layer->location()), theSeqNum(layer->seqNum()), theX0Data(dataX0) {
36  const BarrelDetLayer* bl;
37  const ForwardDetLayer* fl;
38  theHalfThickness = layer->surface().bounds().thickness() / 2;
39 
40  switch (theFace) {
41  case barrel:
42  bl = static_cast<const BarrelDetLayer*>(layer);
43  thePosition = bl->specificSurface().radius();
44  theRange = Range(-bl->surface().bounds().length() / 2, bl->surface().bounds().length() / 2);
45  break;
46  case endcap:
47  fl = static_cast<const ForwardDetLayer*>(layer);
48  thePosition = fl->position().z();
49  theRange = Range(fl->specificSurface().innerRadius(), fl->specificSurface().outerRadius());
50  break;
51  default:
52  // should throw or simimal
53  cout << " ** MSLayer ** unknown part - will not work!" << endl;
54  break;
55  }
56 }
57 //----------------------------------------------------------------------
59  : theFace(part),
60  thePosition(position),
61  theRange(range),
62  theHalfThickness(halfThickness),
63  theSeqNum(-1),
64  theX0Data(dataX0) {}
65 
66 //----------------------------------------------------------------------
67 bool MSLayer::operator==(const MSLayer& o) const {
68  return theFace == o.theFace && std::abs(thePosition - o.thePosition) < 1.e-3f;
69 }
70 //----------------------------------------------------------------------
71 bool MSLayer::operator<(const MSLayer& o) const {
72  if (theFace == barrel && o.theFace == barrel)
73  return thePosition < o.thePosition;
74  else if (theFace == barrel && o.theFace == endcap)
75  return thePosition < o.range().max();
76  else if (theFace == endcap && o.theFace == endcap)
78  else
79  return range().max() < o.thePosition;
80 }
81 
82 //----------------------------------------------------------------------
83 pair<PixelRecoPointRZ, bool> MSLayer::crossing(const PixelRecoLineRZ& line) const {
84  const float eps = 1.e-5;
85  bool inLayer = true;
86  float value = (theFace == barrel) ? line.zAtR(thePosition) : line.rAtZ(thePosition);
87  if (value > theRange.max()) {
88  value = theRange.max() - eps;
89  inLayer = false;
90  } else if (value < theRange.min()) {
91  value = theRange.min() + eps;
92  inLayer = false;
93  }
94  float z = thePosition;
95  if (theFace == barrel)
96  std::swap(z, value); // if barrel value is z
97  return make_pair(PixelRecoPointRZ(value, z), inLayer);
98 }
99 pair<PixelRecoPointRZ, bool> MSLayer::crossing(const SimpleLineRZ& line) const {
100  const float eps = 1.e-5;
101  bool inLayer = true;
102  float value = (theFace == barrel) ? line.zAtR(thePosition) : line.rAtZ(thePosition);
103  if (value > theRange.max()) {
104  value = theRange.max() - eps;
105  inLayer = false;
106  } else if (value < theRange.min()) {
107  value = theRange.min() + eps;
108  inLayer = false;
109  }
110  float z = thePosition;
111  if (theFace == barrel)
112  std::swap(z, value); // if barrel value is z
113  return make_pair(PixelRecoPointRZ(value, z), inLayer);
114 }
115 
116 //----------------------------------------------------------------------
118  float u = (theFace == barrel) ? point.r() : point.z();
119  float v = (theFace == barrel) ? point.z() : point.r();
120 
121  float du = std::abs(u - thePosition);
122  if (theRange.inside(v))
123  return (du < theHalfThickness) ? 0.f : du * du;
124 
125  float dv = (v > theRange.max()) ? v - theRange.max() : theRange.min() - v;
126  return sqr(du) + sqr(dv);
127 }
128 
129 //----------------------------------------------------------------------
130 float MSLayer::x0(float cotTheta) const {
131  if
133  float OverSinTheta = std::sqrt(1.f + cotTheta * cotTheta);
134  return (theFace == barrel) ? theX0Data.x0 * OverSinTheta : theX0Data.x0 * OverSinTheta / std::abs(cotTheta);
135  }
136  else if (theX0Data.allLayers) {
137  const MSLayer* dataLayer = theX0Data.allLayers->layers(cotTheta).findLayer(*this);
138  if (dataLayer)
139  return dataLayer->x0(cotTheta);
140  }
141  return 0.;
142 }
143 
144 //----------------------------------------------------------------------
145 float MSLayer::sumX0D(float cotTheta) const {
146  if
148  switch (theFace) {
149  case barrel:
150  return theX0Data.sumX0D *
151  std::sqrt(std::sqrt((1.f + cotTheta * cotTheta) / (1.f + theX0Data.cotTheta * theX0Data.cotTheta)));
152  case endcap:
153  return (theX0Data.hasFSlope)
154  ? theX0Data.sumX0D + theX0Data.slopeSumX0D * (1.f / cotTheta - 1.f / theX0Data.cotTheta)
155  : theX0Data.sumX0D;
156  case invalidLoc:
157  break; // make gcc happy
158  }
159  }
160  else if (theX0Data.allLayers) {
161  const MSLayer* dataLayer = theX0Data.allLayers->layers(cotTheta).findLayer(*this);
162  if (dataLayer)
163  return dataLayer->sumX0D(cotTheta);
164  }
165  return 0.;
166 }
virtual float length() const =0
const MSLayersKeeper * allLayers
Definition: MSLayer.h:34
T max() const
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:145
T sqr(T t)
Definition: MSLayer.cc:12
float theHalfThickness
Definition: MSLayer.h:72
Range theRange
Definition: MSLayer.h:71
#define LIKELY(x)
Definition: Likely.h:20
const Bounds & bounds() const
Definition: Surface.h:89
float x0(float cotTheta) const
Definition: MSLayer.cc:130
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
T min() const
float zAtR(float r) const
virtual const MSLayersAtAngle & layers(float cotTheta) const =0
const Range & range() const
Definition: MSLayer.h:51
bool hasFSlope
Definition: MSLayer.h:32
const GeomDetEnumerators::Location & face() const
Definition: MSLayer.h:53
float position() const
Definition: MSLayer.h:54
int theSeqNum
Definition: MSLayer.h:73
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
float halfThickness() const
Definition: MSLayer.h:55
bool operator<(const MSLayer &o) const
Definition: MSLayer.cc:71
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DataX0 theX0Data
Definition: MSLayer.h:75
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
double f[11][100]
Definition: value.py:1
MSLayer()
Definition: MSLayer.h:39
bool operator==(const MSLayer &o) const
Definition: MSLayer.cc:67
d
Definition: ztail.py:151
float cotTheta
Definition: MSLayer.h:33
std::pair< PixelRecoPointRZ, bool > crossing(const PixelRecoLineRZ &line) const
Definition: MSLayer.cc:83
virtual const BoundDisk & specificSurface() const final
float z() const
virtual float thickness() const =0
virtual const Surface::PositionType & position() const
Returns position of the surface.
part
Definition: HCALResponse.h:20
ostream & operator<<(ostream &s, const MSLayer &l)
Definition: MSLayer.cc:17
bool inside(const T &value) const
float r() const
float thePosition
Definition: MSLayer.h:70
float rAtZ(float z) const
float rAtZ(float z) const
float distance2(const PixelRecoPointRZ &point) const
Definition: MSLayer.cc:117
float slopeSumX0D
Definition: MSLayer.h:33
float zAtR(float r) const
GeomDetEnumerators::Location theFace
Definition: MSLayer.h:69
long double T
PixelRecoRange< float > Range
Definition: MSLayer.h:16
const MSLayer * findLayer(const MSLayer &layer) const
const BoundSurface & surface() const final
GeometricSearchDet interface.
*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
float sumX0D
Definition: MSLayer.h:33