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.
5 #include "MSLayersKeeper.h"
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, const DataX0& dataX0)
34  : theFace(layer->location()), theSeqNum(layer->seqNum()), 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);
42  thePosition = bl->specificSurface().radius();
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();
49  theRange = Range(fl->specificSurface().innerRadius(),
50  fl->specificSurface().outerRadius());
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  const DataX0& dataX0)
61  : theFace(part),
62  thePosition(position),
63  theRange(range),
64  theHalfThickness(halfThickness),
65  theSeqNum(-1),
66  theX0Data(dataX0)
67  { }
68 
69 
70 //----------------------------------------------------------------------
71 bool MSLayer::operator== (const MSLayer &o) const
72 {
73  return theFace == o.theFace && std::abs(thePosition-o.thePosition) < 1.e-3f;
74 }
75 //----------------------------------------------------------------------
76 bool MSLayer::operator< (const MSLayer & o) const
77 {
78 
79  if (theFace==barrel && o.theFace==barrel)
80  return thePosition < o.thePosition;
81  else if (theFace==barrel && o.theFace==endcap)
82  return thePosition < o.range().max();
83  else if (theFace==endcap && o.theFace==endcap )
85  else
86  return range().max() < o.thePosition;
87 }
88 
89 //----------------------------------------------------------------------
90 pair<PixelRecoPointRZ,bool> MSLayer::crossing( const PixelRecoLineRZ & line) const {
91  const float eps = 1.e-5;
92  bool inLayer = true;
93  float value = (theFace==barrel) ? line.zAtR(thePosition) : line.rAtZ(thePosition);
94  if (value > theRange.max()) {
95  value = theRange.max()-eps;
96  inLayer = false;
97  } else if (value < theRange.min() ) {
98  value = theRange.min()+eps;
99  inLayer = false;
100  }
101  float z = thePosition;
102  if (theFace==barrel) std::swap(z,value); // if barrel value is z
103  return make_pair( PixelRecoPointRZ( value, z), inLayer);
104 }
105 pair<PixelRecoPointRZ,bool> MSLayer::crossing( const SimpleLineRZ & line) const {
106  const float eps = 1.e-5;
107  bool inLayer = true;
108  float value = (theFace==barrel) ? line.zAtR(thePosition) : line.rAtZ(thePosition);
109  if (value > theRange.max()) {
110  value = theRange.max()-eps;
111  inLayer = false;
112  } else if (value < theRange.min() ) {
113  value = theRange.min()+eps;
114  inLayer = false;
115  }
116  float z = thePosition;
117  if (theFace==barrel) std::swap(z,value); // if barrel value is z
118  return make_pair( PixelRecoPointRZ( value, z), inLayer);
119 }
120 
121 //----------------------------------------------------------------------
123 {
124  float u = (theFace==barrel) ? point.r() : point.z();
125  float v = (theFace==barrel) ? point.z() : point.r();
126 
127  float du = std::abs(u-thePosition);
128  if (theRange.inside(v)) return (du < theHalfThickness) ? 0.f : du*du;
129 
130  float dv = (v > theRange.max()) ?
131  v-theRange.max() : theRange.min() - v;
132  return sqr(du)+sqr(dv);
133 }
134 
135 
136 //----------------------------------------------------------------------
137 float MSLayer::x0(float cotTheta) const
138 {
139  if likely(theX0Data.hasX0) {
140  float OverSinTheta = std::sqrt(1.f+cotTheta*cotTheta);
141  return (theFace==barrel) ? theX0Data.x0*OverSinTheta :
142  theX0Data.x0*OverSinTheta/std::abs(cotTheta);
143  } else if (theX0Data.allLayers) {
144  const MSLayer * dataLayer =
145  theX0Data.allLayers->layers(cotTheta).findLayer(*this);
146  if (dataLayer) return dataLayer->x0(cotTheta);
147  }
148  return 0.;
149 }
150 
151 //----------------------------------------------------------------------
152 float MSLayer::sumX0D(float cotTheta) const
153 {
154 if likely(theX0Data.hasX0) {
155  switch(theFace) {
156  case barrel:
157  return theX0Data.sumX0D
158  *std::sqrt( std::sqrt( (1.f+cotTheta*cotTheta)
160  )
161  );
162  case endcap:
163  return (theX0Data.hasFSlope) ?
165  + theX0Data.slopeSumX0D * (1.f/cotTheta-1.f/theX0Data.cotTheta)
166  : theX0Data.sumX0D;
167  case invalidLoc: break;// make gcc happy
168  }
169  } else if (theX0Data.allLayers) {
170  const MSLayer* dataLayer =
171  theX0Data.allLayers->layers(cotTheta).findLayer(*this);
172  if (dataLayer) return dataLayer->sumX0D(cotTheta);
173  }
174  return 0.;
175 
176 }
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
const MSLayersKeeper * allLayers
Definition: MSLayer.h:28
virtual float length() const =0
T max() const
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:152
virtual const BoundSurface & surface() const final
GeometricSearchDet interface.
float theHalfThickness
Definition: MSLayer.h:69
Range theRange
Definition: MSLayer.h:68
const Bounds & bounds() const
Definition: Surface.h:120
float x0(float cotTheta) const
Definition: MSLayer.cc:137
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
tuple d
Definition: ztail.py:151
#define likely(x)
const Range & range() const
Definition: MSLayer.h:45
bool hasFSlope
Definition: MSLayer.h:26
const GeomDetEnumerators::Location & face() const
Definition: MSLayer.h:47
float position() const
Definition: MSLayer.h:48
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
bool operator<(const MSLayer &o) const
Definition: MSLayer.cc:76
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DataX0 theX0Data
Definition: MSLayer.h:72
double f[11][100]
MSLayer()
Definition: MSLayer.h:33
bool operator==(const MSLayer &o) const
Definition: MSLayer.cc:71
virtual const MSLayersAtAngle & layers(float cotTheta) const =0
float cotTheta
Definition: MSLayer.h:27
std::pair< PixelRecoPointRZ, bool > crossing(const PixelRecoLineRZ &line) const
Definition: MSLayer.cc:90
float z() const
virtual const Surface::PositionType & position() const
Returns position of the surface.
part
Definition: HCALResponse.h:20
bool inside(const T &value) const
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
float r() const
float thePosition
Definition: MSLayer.h:67
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 rAtZ(float z) const
virtual const BoundDisk & specificSurface() const final
tuple cout
Definition: gather_cfg.py:145
float distance2(const PixelRecoPointRZ &point) const
Definition: MSLayer.cc:122
float slopeSumX0D
Definition: MSLayer.h:27
float zAtR(float r) const
GeomDetEnumerators::Location theFace
Definition: MSLayer.h:66
long double T
PixelRecoRange< float > Range
Definition: MSLayer.h:16
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:27