CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
ForwardDiskSectorBuilderFromDet Class Reference

#include <ForwardDiskSectorBuilderFromDet.h>

Public Member Functions

std::pair< DiskSectorBounds *, GlobalVectorcomputeBounds (const std::vector< const GeomDet * > &dets) const
 
BoundDiskSectoroperator() (const std::vector< const GeomDet * > &dets) const
 

Private Member Functions

Surface::RotationType computeRotation (const std::vector< const GeomDet * > &dets, Surface::PositionType pos) const
 
std::vector< GlobalPointcomputeTrapezoidalCorners (const GeomDet *detu) const
 

Detailed Description

As it's name indicates, it's a builder of a BoundDiskSector from a collection of Dets. The disk sector has the minimal size fully containing all Dets.

Definition at line 17 of file ForwardDiskSectorBuilderFromDet.h.

Member Function Documentation

◆ computeBounds()

pair< DiskSectorBounds *, GlobalVector > ForwardDiskSectorBuilderFromDet::computeBounds ( const std::vector< const GeomDet * > &  dets) const

Definition at line 33 of file ForwardDiskSectorBuilderFromDet.cc.

34  {
35  // go over all corners and compute maximum deviations
36  float rmin = (**(dets.begin())).surface().position().perp();
37  float rmax(rmin);
38  float zmin((**(dets.begin())).surface().position().z());
39  float zmax(zmin);
40  float phimin((**(dets.begin())).surface().position().phi());
41  float phimax(phimin);
42 
43  for (vector<const GeomDet*>::const_iterator idet = dets.begin(); idet != dets.end(); idet++) {
44  vector<const GeomDet*> detUnits = (**idet).components();
45  if (!detUnits.empty()) {
46  for (vector<const GeomDet*>::const_iterator detu = detUnits.begin(); detu != detUnits.end(); detu++) {
47  // edm::LogInfo(TkDetLayers) << " Builder: Position of detUnit :"<< (**detu).position() ;
48  vector<GlobalPoint> corners = computeTrapezoidalCorners(*detu);
49  for (vector<GlobalPoint>::const_iterator i = corners.begin(); i != corners.end(); i++) {
50  float r = i->perp();
51  float z = i->z();
52  float phi = i->phi();
53  rmin = min(rmin, r);
54  rmax = max(rmax, r);
55  zmin = min(zmin, z);
56  zmax = max(zmax, z);
57  if (Geom::phiLess(phi, phimin))
58  phimin = phi;
59  if (Geom::phiLess(phimax, phi))
60  phimax = phi;
61  }
62  // in addition to the corners we have to check the middle of the
63  // det +/- length/2, since the min (max) radius for typical fw
64  // dets is reached there
65  float rdet = (**detu).position().perp();
66  float len = (**detu).surface().bounds().length();
67  float width = (**detu).surface().bounds().width();
68 
69  GlobalVector xAxis = (**detu).toGlobal(LocalVector(1, 0, 0));
70  GlobalVector yAxis = (**detu).toGlobal(LocalVector(0, 1, 0));
71  GlobalVector perpDir = GlobalVector((**detu).position() - GlobalPoint(0, 0, (**detu).position().z()));
72 
73  double xAxisCos = xAxis.unit().dot(perpDir.unit());
74  double yAxisCos = yAxis.unit().dot(perpDir.unit());
75 
76  if (std::abs(xAxisCos) > std::abs(yAxisCos)) {
77  rmin = min(rmin, rdet - width / 2.F);
78  rmax = max(rmax, rdet + width / 2.F);
79  } else {
80  rmin = min(rmin, rdet - len / 2.F);
81  rmax = max(rmax, rdet + len / 2.F);
82  }
83  }
84  } else {
85  vector<GlobalPoint> corners = computeTrapezoidalCorners(*idet);
86  for (vector<GlobalPoint>::const_iterator i = corners.begin(); i != corners.end(); i++) {
87  float r = i->perp();
88  float z = i->z();
89  float phi = i->phi();
90  rmin = min(rmin, r);
91  rmax = max(rmax, r);
92  zmin = min(zmin, z);
93  zmax = max(zmax, z);
94  if (Geom::phiLess(phi, phimin))
95  phimin = phi;
96  if (Geom::phiLess(phimax, phi))
97  phimax = phi;
98  }
99  // in addition to the corners we have to check the middle of the
100  // det +/- length/2, since the min (max) radius for typical fw
101  // dets is reached there
102 
103  float rdet = (**idet).position().perp();
104  float len = (**idet).surface().bounds().length();
105  float width = (**idet).surface().bounds().width();
106 
107  GlobalVector xAxis = (**idet).toGlobal(LocalVector(1, 0, 0));
108  GlobalVector yAxis = (**idet).toGlobal(LocalVector(0, 1, 0));
109  GlobalVector perpDir = GlobalVector((**idet).position() - GlobalPoint(0, 0, (**idet).position().z()));
110 
111  double xAxisCos = xAxis.unit().dot(perpDir.unit());
112  double yAxisCos = yAxis.unit().dot(perpDir.unit());
113 
114  if (std::abs(xAxisCos) > std::abs(yAxisCos)) {
115  rmin = min(rmin, rdet - width / 2.F);
116  rmax = max(rmax, rdet + width / 2.F);
117  } else {
118  rmin = min(rmin, rdet - len / 2.F);
119  rmax = max(rmax, rdet + len / 2.F);
120  }
121  }
122  }
123 
124  if (!Geom::phiLess(phimin, phimax))
125  edm::LogError("TkDetLayers") << " ForwardDiskSectorBuilderFromDet : "
126  << "Something went wrong with Phi Sorting !";
127  float zPos = (zmax + zmin) / 2.;
128  float phiWin = phimax - phimin;
129  float phiPos = (phimax + phimin) / 2.;
130  float rmed = (rmin + rmax) / 2.;
131  if (phiWin < 0.) {
132  if ((phimin < Geom::pi() / 2.) || (phimax > -Geom::pi() / 2.)) {
133  edm::LogError("TkDetLayers") << " Debug: something strange going on, please check ";
134  }
135  // edm::LogInfo(TkDetLayers) << " Wedge at pi: phi " << phimin << " " << phimax << " " << phiWin
136  // << " " << 2.*Geom::pi()+phiWin << " " ;
137  phiWin += 2. * Geom::pi();
138  phiPos += Geom::pi();
139  }
140  GlobalVector pos(rmed * cos(phiPos), rmed * sin(phiPos), zPos);
141  return make_pair(new DiskSectorBounds(rmin, rmax, zmin - zPos, zmax - zPos, phiWin), pos);
142 }

References funct::abs(), funct::cos(), F(), mps_fire::i, SiStripPI::max, min(), Geom::phiLess(), phimax, phimin, Geom::pi(), alignCSCRings::r, funct::sin(), Vector3DBase< T, FrameTag >::unit(), ApeEstimator_cff::width, HLT_2018_cff::xAxis, HLT_2018_cff::yAxis, SiStripMonitorCluster_cfi::zmax, and SiStripMonitorCluster_cfi::zmin.

◆ computeRotation()

Surface::RotationType ForwardDiskSectorBuilderFromDet::computeRotation ( const std::vector< const GeomDet * > &  dets,
Surface::PositionType  pos 
) const
private

Definition at line 144 of file ForwardDiskSectorBuilderFromDet.cc.

145  {
146  GlobalVector yAxis = (GlobalVector(pos.x(), pos.y(), 0.)).unit();
147 
148  GlobalVector zAxis(0., 0., 1.);
149  GlobalVector xAxis = yAxis.cross(zAxis);
150 
152 }

References unit(), HLT_2018_cff::xAxis, HLT_2018_cff::yAxis, and HLT_2018_cff::zAxis.

◆ computeTrapezoidalCorners()

vector< GlobalPoint > ForwardDiskSectorBuilderFromDet::computeTrapezoidalCorners ( const GeomDet detu) const
private

Definition at line 154 of file ForwardDiskSectorBuilderFromDet.cc.

154  {
155  const Plane& plane(det->specificSurface());
156 
157  const TrapezoidalPlaneBounds* myBounds(static_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
158 
159  /*
160  if (myBounds == 0) {
161  string errmsg="ForwardDiskSectorBuilderFromDet: problems with dynamic cast to trapezoidal bounds for DetUnits";
162  throw DetLayerException(errmsg);
163  edm::LogError("TkDetLayers") << errmsg ;
164  }
165  */
166 
167  // array<const float, 4>
168  auto const& parameters = (*myBounds).parameters();
169 
170  if (parameters[0] == 0) {
171  edm::LogError("TkDetLayers") << "ForwardDiskSectorBuilder: something weird going on !";
172  edm::LogError("TkDetLayers") << " Trapezoidal parameters of GeomDet (L2/L1/T/H): ";
173  for (int i = 0; i < 4; i++)
174  edm::LogError("TkDetLayers") << " " << 2. * parameters[i] << "\n";
175  }
176 
177  float hbotedge = parameters[0];
178  float htopedge = parameters[1];
179  float hapothem = parameters[3];
180  float hthick = parameters[2];
181 
182  vector<GlobalPoint> corners;
183 
184  corners.push_back(plane.toGlobal(LocalPoint(-htopedge, hapothem, hthick)));
185  corners.push_back(plane.toGlobal(LocalPoint(-htopedge, hapothem, -hthick)));
186  corners.push_back(plane.toGlobal(LocalPoint(htopedge, hapothem, hthick)));
187  corners.push_back(plane.toGlobal(LocalPoint(htopedge, hapothem, -hthick)));
188  corners.push_back(plane.toGlobal(LocalPoint(hbotedge, -hapothem, hthick)));
189  corners.push_back(plane.toGlobal(LocalPoint(hbotedge, -hapothem, -hthick)));
190  corners.push_back(plane.toGlobal(LocalPoint(-hbotedge, -hapothem, hthick)));
191  corners.push_back(plane.toGlobal(LocalPoint(-hbotedge, -hapothem, -hthick)));
192 
193  return corners;
194 }

References mps_fire::i, TrapezoidalPlaneBounds::parameters(), and GeomDet::specificSurface().

◆ operator()()

BoundDiskSector * ForwardDiskSectorBuilderFromDet::operator() ( const std::vector< const GeomDet * > &  dets) const

Warning, remember to assign this pointer to a ReferenceCountingPointer! Should be changed to return a ReferenceCountingPointer<BoundDisk>

Definition at line 11 of file ForwardDiskSectorBuilderFromDet.cc.

11  {
12  // check that the dets are all at about the same radius and z
13  float rcheck = dets.front()->surface().position().perp();
14  float zcheck = dets.front()->surface().position().z();
15  for (vector<const GeomDet*>::const_iterator i = dets.begin(); i != dets.end(); i++) {
16  float rdiff = (**i).surface().position().perp() - rcheck;
17  if (std::abs(rdiff) > 1.)
18  edm::LogError("TkDetLayers") << " ForwardDiskSectorBuilderFromDet: Trying to build Petal Wedge from "
19  << "Dets at different radii !! Delta_r = " << rdiff;
20  float zdiff = zcheck - (**i).surface().position().z();
21  if (std::abs(zdiff) > 0.8)
22  edm::LogError("TkDetLayers") << " ForwardDiskSectorBuilderFromDet: Trying to build Petal Wedge from "
23  << "Dets at different z positions !! Delta_z = " << zdiff;
24  }
25 
26  auto bo = computeBounds(dets);
27 
28  Surface::PositionType pos(bo.second.x(), bo.second.y(), bo.second.z());
30  return new BoundDiskSector(pos, rot, bo.first);
31 }

References funct::abs(), mps_fire::i, PV3DBase< T, PVType, FrameType >::perp(), GloballyPositioned< T >::position(), and makeMuonMisalignmentScenario::rot.

Vector3DBase
Definition: Vector3DBase.h:8
TkRotation< float >
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
mps_fire.i
i
Definition: mps_fire.py:355
ForwardDiskSectorBuilderFromDet::computeRotation
Surface::RotationType computeRotation(const std::vector< const GeomDet * > &dets, Surface::PositionType pos) const
Definition: ForwardDiskSectorBuilderFromDet.cc:144
DiskSectorBounds
Definition: DiskSectorBounds.h:12
min
T min(T a, T b)
Definition: MathUtil.h:58
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
pos
Definition: PixelAliasList.h:18
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
GloballyPositioned< float >::RotationType
TkRotation< float > RotationType
Definition: GloballyPositioned.h:22
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
TrapezoidalPlaneBounds::parameters
virtual const std::array< const float, 4 > parameters() const
Definition: TrapezoidalPlaneBounds.cc:49
ForwardDiskSectorBuilderFromDet::computeBounds
std::pair< DiskSectorBounds *, GlobalVector > computeBounds(const std::vector< const GeomDet * > &dets) const
Definition: ForwardDiskSectorBuilderFromDet.cc:33
DDAxes::z
Geom::pi
constexpr double pi()
Definition: Pi.h:31
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, LocalTag >
ForwardDiskSectorBuilderFromDet::computeTrapezoidalCorners
std::vector< GlobalPoint > computeTrapezoidalCorners(const GeomDet *detu) const
Definition: ForwardDiskSectorBuilderFromDet.cc:154
edm::LogError
Definition: MessageLogger.h:183
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
TrapezoidalPlaneBounds
Definition: TrapezoidalPlaneBounds.h:15
unit
Basic3DVector unit() const
Definition: Basic3DVectorLD.h:162
BoundDiskSector
Definition: BoundDiskSector.h:8
alignCSCRings.r
r
Definition: alignCSCRings.py:93
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
DDAxes::phi
HLT_2018_cff.xAxis
xAxis
Definition: HLT_2018_cff.py:44410
Plane
Definition: Plane.h:16
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HLT_2018_cff.yAxis
yAxis
Definition: HLT_2018_cff.py:44412
HLT_2018_cff.zAxis
zAxis
Definition: HLT_2018_cff.py:44411