CMS 3D CMS Logo

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