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 }
Likely.h
MSLayer::sumX0D
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:144
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
DetLayer
Definition: DetLayer.h:21
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
BarrelDetLayer::surface
const BoundSurface & surface() const final
GeometricSearchDet interface.
Definition: BarrelDetLayer.h:29
gpuVertexFinder::eps
WorkSpace int float eps
Definition: gpuClusterTracksDBSCAN.h:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MSLayer::DataX0::cotTheta
float cotTheta
Definition: MSLayer.h:32
MSLayer::theX0Data
DataX0 theX0Data
Definition: MSLayer.h:74
MSLayer::theHalfThickness
float theHalfThickness
Definition: MSLayer.h:71
findQualityFiles.v
v
Definition: findQualityFiles.py:179
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
GeometricSearchDet::position
virtual const Surface::PositionType & position() const
Returns position of the surface.
Definition: GeometricSearchDet.h:31
MSLayer.h
sqr
T sqr(T t)
Definition: MSLayer.cc:13
PixelRecoRange::min
T min() const
Definition: PixelRecoRange.h:25
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
MSLayer::crossing
std::pair< PixelRecoPointRZ, bool > crossing(const PixelRecoLineRZ &line) const
Definition: MSLayer.cc:84
Bounds::length
virtual float length() const =0
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
MSLayersAtAngle::findLayer
const MSLayer * findLayer(const MSLayer &layer) const
Definition: MSLayersAtAngle.cc:34
operator<<
ostream & operator<<(ostream &s, const MSLayer &l)
Definition: MSLayer.cc:18
MSLayersKeeper.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
part
part
Definition: HCALResponse.h:20
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
MSLayer::DataX0::allLayers
const MSLayersKeeper * allLayers
Definition: MSLayer.h:33
MSLayer::Range
PixelRecoRange< float > Range
Definition: MSLayer.h:15
PixelRecoRange::max
T max() const
Definition: PixelRecoRange.h:26
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
DDAxes::z
MSLayer::operator<
bool operator<(const MSLayer &o) const
Definition: MSLayer.cc:72
MSLayer::DataX0
Definition: MSLayer.h:17
MSLayer::DataX0::hasX0
bool hasX0
Definition: MSLayer.h:31
MSLayer::distance2
float distance2(const PixelRecoPointRZ &point) const
Definition: MSLayer.cc:118
MSLayer::DataX0::sumX0D
float sumX0D
Definition: MSLayer.h:32
MSLayer
Definition: MSLayer.h:13
MSLayer::DataX0::slopeSumX0D
float slopeSumX0D
Definition: MSLayer.h:32
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
GeomDetEnumerators::invalidLoc
Definition: GeomDetEnumerators.h:9
PixelRecoRange< float >
MSLayer::thePosition
float thePosition
Definition: MSLayer.h:69
MSLayer::DataX0::x0
float x0
Definition: MSLayer.h:32
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
MSLayersKeeper::layers
virtual const MSLayersAtAngle & layers(float cotTheta) const =0
PixelRecoLineRZ
Definition: PixelRecoLineRZ.h:12
MSLayer::range
const Range & range() const
Definition: MSLayer.h:50
value
Definition: value.py:1
BarrelDetLayer.h
MSLayer::x0
float x0(float cotTheta) const
Definition: MSLayer.cc:131
MSLayer::theRange
Range theRange
Definition: MSLayer.h:70
BarrelDetLayer
Definition: BarrelDetLayer.h:22
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
PixelRecoPointRZ
Definition: PixelRecoPointRZ.h:6
SimpleLineRZ
Definition: PixelRecoLineRZ.h:63
GeomDetEnumerators
Definition: GeomDetEnumerators.h:8
GeomDetEnumerators::Location
Location
Definition: GeomDetEnumerators.h:9
std
Definition: JetResolutionObject.h:76
ForwardDetLayer
Definition: ForwardDetLayer.h:22
T
long double T
Definition: Basic3DVectorLD.h:48
MSLayer::DataX0::hasFSlope
bool hasFSlope
Definition: MSLayer.h:31
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
MSLayer::operator==
bool operator==(const MSLayer &o) const
Definition: MSLayer.cc:68
ForwardDetLayer.h
DetLayer.h
MSLayer::theFace
GeomDetEnumerators::Location theFace
Definition: MSLayer.h:68
EcalCondDBWriter_cfi.location
location
Definition: EcalCondDBWriter_cfi.py:63
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PixelRecoRange::inside
bool inside(const T &value) const
Definition: PixelRecoRange.h:36
point
*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
mps_splice.line
line
Definition: mps_splice.py:76
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MSLayer::MSLayer
MSLayer()
Definition: MSLayer.h:38
BarrelDetLayer::specificSurface
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
Definition: BarrelDetLayer.h:39
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39