CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
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 }
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
const MSLayersKeeper * allLayers
Definition: MSLayer.h:33
virtual float length() const =0
T max() const
const BoundSurface & surface() const final
GeometricSearchDet interface.
WorkSpace int float eps
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:144
float theHalfThickness
Definition: MSLayer.h:71
Range theRange
Definition: MSLayer.h:70
#define LIKELY(x)
Definition: Likely.h:20
const Bounds & bounds() const
Definition: Surface.h:87
float x0(float cotTheta) const
Definition: MSLayer.cc:131
T min() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
int sqr(const T &t)
constexpr std::array< uint8_t, layerIndexSize > layer
const uint16_t range(const Frame &aFrame)
virtual float thickness() const =0
float zAtR(float r) const
tuple d
Definition: ztail.py:151
const Range & range() const
Definition: MSLayer.h:50
bool hasFSlope
Definition: MSLayer.h:31
const GeomDetEnumerators::Location & face() const
Definition: MSLayer.h:52
float position() const
Definition: MSLayer.h:53
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool operator<(const MSLayer &o) const
Definition: MSLayer.cc:72
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DataX0 theX0Data
Definition: MSLayer.h:74
MSLayer()
Definition: MSLayer.h:38
bool operator==(const MSLayer &o) const
Definition: MSLayer.cc:68
virtual const MSLayersAtAngle & layers(float cotTheta) const =0
float cotTheta
Definition: MSLayer.h:32
std::pair< PixelRecoPointRZ, bool > crossing(const PixelRecoLineRZ &line) const
Definition: MSLayer.cc:84
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:69
float rAtZ(float z) const
static int position[264][3]
Definition: ReadPGInfo.cc:289
float rAtZ(float z) const
virtual const BoundDisk & specificSurface() const final
tuple cout
Definition: gather_cfg.py:144
float distance2(const PixelRecoPointRZ &point) const
Definition: MSLayer.cc:118
float slopeSumX0D
Definition: MSLayer.h:32
float zAtR(float r) const
GeomDetEnumerators::Location theFace
Definition: MSLayer.h:68
long double T
PixelRecoRange< float > Range
Definition: MSLayer.h:15
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:32