CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MSLayer.cc
Go to the documentation of this file.
6 
7 #include<iostream>
8 
9 
10 using namespace GeomDetEnumerators;
11 using namespace std;
12 template <class T> T sqr( T t) {return t*t;}
13 
14 //----------------------------------------------------------------------
15 ostream& operator<<( ostream& s, const MSLayer & l)
16 {
17  s <<" face: "<<l.face()
18  <<" pos:"<<l.position()<<", "
19  <<" range:"<<l.range()<<", "
20  <<l.theX0Data;
21  return s;
22 }
23 //----------------------------------------------------------------------
24 ostream& operator<<( ostream& s, const MSLayer::DataX0 & d)
25 {
26  if (d.hasX0) s << "x0="<<d.x0 <<" sumX0D="<<d.sumX0D;
27  else if (d.allLayers) s << "x0 by MSLayersKeeper";
28  else s <<"empty DataX0";
29  return s;
30 }
31 //----------------------------------------------------------------------
32 //MP
33 MSLayer::MSLayer(const DetLayer* layer, DataX0 dataX0)
34  : theFace(layer->location()), theX0Data(dataX0)
35 {
36  const BarrelDetLayer* bl; const ForwardDetLayer * fl;
37  theHalfThickness = layer->surface().bounds().thickness()/2;
38 
39  switch (theFace) {
40  case barrel :
41  bl = static_cast<const BarrelDetLayer* >(layer);
43  theRange = Range(-bl->surface().bounds().length()/2,
44  bl->surface().bounds().length()/2);
45  break;
46  case endcap :
47  fl = static_cast<const ForwardDetLayer* >(layer);
48  thePosition = fl->position().z();
51  break;
52  default:
53  // should throw or simimal
54  cout << " ** MSLayer ** unknown part - will not work!" <<endl;
55  break;
56  }
57 }
58 //----------------------------------------------------------------------
59 MSLayer::MSLayer(Location part, float position, Range range, float halfThickness,
60  DataX0 dataX0)
61  : theFace(part),
62  thePosition(position),
63  theRange(range),
64  theHalfThickness(halfThickness),
65  theX0Data(dataX0)
66  { }
67 
68 
69 //----------------------------------------------------------------------
70 bool MSLayer::operator== (const MSLayer &o) const
71 {
72  return theFace == o.theFace && std::abs(thePosition-o.thePosition) < 1.e-3f;
73 }
74 
75 //----------------------------------------------------------------------
76 pair<PixelRecoPointRZ,bool> MSLayer::crossing(
77  const PixelRecoLineRZ & line) const
78 {
79  const float eps = 1.e-5;
80  bool inLayer = true;
81  if (theFace==barrel) {
82  float value = line.zAtR(thePosition);
83  if (value > theRange.max()) {
84  value = theRange.max()-eps;
85  inLayer = false;
86  }
87  else if (value < theRange.min() ) {
88  value = theRange.min()+eps;
89  inLayer = false;
90  }
91  return make_pair( PixelRecoPointRZ(thePosition, value), inLayer) ;
92  }
93  else {
94  float value = line.rAtZ(thePosition);
95  if (value > theRange.max()) {
96  value = theRange.max()-eps;
97  inLayer = false;
98  }
99  else if (value < theRange.min() ) {
100  value = theRange.min()+eps;
101  inLayer = false;
102  }
103  return make_pair( PixelRecoPointRZ( value, thePosition), inLayer);
104  }
105 }
106 //----------------------------------------------------------------------
108 {
109  float dr = 0;
110  float dz = 0;
111  switch(theFace) {
112  case barrel:
113  dr = std::abs(point.r()-thePosition);
114  if (theRange.inside(point.z())) {
115  return (dr < theHalfThickness) ? 0.f : dr;
116  }
117  else {
118  dz = point.z() > theRange.max() ?
119  point.z()-theRange.max() : theRange.min() - point.z();
120  }
121  break;
122  case endcap:
123  dz = std::abs(point.z()-thePosition);
124  if (theRange.inside(point.r())) {
125  return (dz < theHalfThickness) ? 0. : dz;
126  }
127  else {
128  dr = point.r() > theRange.max() ?
129  point.r()-theRange.max() : theRange.min()-point.r();
130  }
131  break;
132  case invalidLoc: break; // make gcc happy
133  }
134  return std::sqrt(sqr(dr)+sqr(dz));
135 }
136 
137 //----------------------------------------------------------------------
138 bool MSLayer::operator< (const MSLayer & o) const
139 {
140 
141  if (theFace==barrel && o.theFace==barrel)
142  return thePosition < o.thePosition;
143  else if (theFace==barrel && o.theFace==endcap)
144  return thePosition < o.range().max();
145  else if (theFace==endcap && o.theFace==endcap )
147  else
148  return range().max() < o.thePosition;
149 }
150 //----------------------------------------------------------------------
151 float MSLayer::x0(float cotTheta) const
152 {
153  if (theX0Data.hasX0) {
154  float OverSinTheta = std::sqrt(1.f+cotTheta*cotTheta);
155  switch(theFace) {
156  case barrel: return theX0Data.x0*OverSinTheta;
157  case endcap: return theX0Data.x0*std::abs(OverSinTheta/cotTheta);
158  case invalidLoc: return 0.;// make gcc happy
159  }
160  } else if (theX0Data.allLayers) {
161  const MSLayer * dataLayer =
162  theX0Data.allLayers->layers(cotTheta).findLayer(*this);
163  if (dataLayer) return dataLayer->x0(cotTheta);
164  }
165  return 0.;
166 }
167 
168 //----------------------------------------------------------------------
169 float MSLayer::sumX0D(float cotTheta) const
170 {
171 if (theX0Data.hasX0) {
172  switch(theFace) {
173  case barrel:
174  return theX0Data.sumX0D
175  *std::sqrt( std::sqrt( (1.f+cotTheta*cotTheta)
177  )
178  );
179  case endcap:
180  return (theX0Data.hasFSlope) ?
182  + theX0Data.slopeSumX0D * (1.f/cotTheta-1.f/theX0Data.cotTheta)
183  : theX0Data.sumX0D;
184  case invalidLoc: break;// make gcc happy
185  }
186  } else if (theX0Data.allLayers) {
187  const MSLayer* dataLayer =
188  theX0Data.allLayers->layers(cotTheta).findLayer(*this);
189  if (dataLayer) return dataLayer->sumX0D(cotTheta);
190  }
191  return 0.;
192 
193 }
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
const MSLayersKeeper * allLayers
Definition: MSLayer.h:26
virtual float length() const =0
T max() const
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:169
float theHalfThickness
Definition: MSLayer.h:57
Range theRange
Definition: MSLayer.h:56
#define abs(x)
Definition: mlp_lapack.h:159
float x0(float cotTheta) const
Definition: MSLayer.cc:151
T min() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
virtual float thickness() const =0
float zAtR(float r) const
const Range & range() const
Definition: MSLayer.h:37
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:55
bool hasFSlope
Definition: MSLayer.h:24
const GeomDetEnumerators::Location & face() const
Definition: MSLayer.h:39
float position() const
Definition: MSLayer.h:40
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
virtual const BoundDisk & specificSurface() const
bool operator<(const MSLayer &o) const
Definition: MSLayer.cc:138
DataX0 theX0Data
Definition: MSLayer.h:58
float distance(const PixelRecoPointRZ &point) const
Definition: MSLayer.cc:107
double f[11][100]
MSLayer()
Definition: MSLayer.h:31
bool operator==(const MSLayer &o) const
Definition: MSLayer.cc:70
virtual const MSLayersAtAngle & layers(float cotTheta) const =0
float cotTheta
Definition: MSLayer.h:25
const Bounds & bounds() const
Definition: BoundSurface.h:89
std::pair< PixelRecoPointRZ, bool > crossing(const PixelRecoLineRZ &line) const
Definition: MSLayer.cc:76
float z() const
virtual const BoundSurface & surface() const
GeometricSearchDet interface.
virtual const Surface::PositionType & position() const
Returns position of the surface.
part
Definition: HCALResponse.h:21
bool inside(const T &value) const
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
float r() const
float thePosition
Definition: MSLayer.h:55
float rAtZ(float z) const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
static int position[264][3]
Definition: ReadPGInfo.cc:509
float outerRadius() const
The outer radius of the disk.
Definition: BoundDisk.h:75
float innerRadius() const
The inner radius of the disk.
Definition: BoundDisk.h:72
tuple cout
Definition: gather_cfg.py:121
float slopeSumX0D
Definition: MSLayer.h:25
GeomDetEnumerators::Location theFace
Definition: MSLayer.h:54
long double T
PixelRecoRange< float > Range
Definition: MSLayer.h:14
const MSLayer * findLayer(const MSLayer &layer) const
*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:25