CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
Phase2EndcapLayer Class Referencefinal

#include <Phase2EndcapLayer.h>

Inheritance diagram for Phase2EndcapLayer:
RingedForwardLayer

Classes

struct  RingPar
 

Public Member Functions

const std::vector< const
GeomDet * > & 
basicComponents () const override
 
const std::vector< const
GeometricSearchDet * > & 
components () const override __attribute__((cold))
 
void groupedCompatibleDetsV (const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
 
Phase2EndcapLayeroperator= (const Phase2EndcapLayer &)=delete
 
 Phase2EndcapLayer (std::vector< const Phase2EndcapRing * > &rings, const bool isOT) __attribute__((cold))
 
 Phase2EndcapLayer (const Phase2EndcapLayer &)=delete
 
SubDetector subDetector () const override
 
 ~Phase2EndcapLayer () override __attribute__((cold))
 

Private Member Functions

BoundDiskcomputeDisk (const std::vector< const Phase2EndcapRing * > &rings) const __attribute__((cold))
 
float computeWindowSize (const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
 
void fillRingPars (int i) __attribute__((cold))
 
std::array< int, 3 > findThreeClosest (std::vector< GlobalPoint >) const __attribute__((hot))
 
bool overlapInR (const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
 
std::array< int, 3 > ringIndicesByCrossingProximity (const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
 

Private Attributes

const bool isOuterTracker
 
std::vector< RingParringPars
 
std::vector< GeomDet const * > theBasicComps
 
std::atomic< std::vector
< const GeometricSearchDet * > * > 
theComponents
 
std::vector< const
Phase2EndcapRing * > 
theComps
 
int theRingSize
 

Detailed Description

A concrete implementation for Phase 2 Endcap/Forward layer built out of Phase2EndcapRings this classs is used for both OT and Pixel detector

Definition at line 15 of file Phase2EndcapLayer.h.

Constructor & Destructor Documentation

Phase2EndcapLayer::Phase2EndcapLayer ( std::vector< const Phase2EndcapRing * > &  rings,
const bool  isOT 
)

Definition at line 46 of file Phase2EndcapLayer.cc.

47  : RingedForwardLayer(true), isOuterTracker(isOT), theComponents{nullptr} {
48  //They should be already R-ordered. TO BE CHECKED!!
49  //sort( theRings.begin(), theRings.end(), DetLessR());
50 
51  theRingSize = rings.size();
52  LogDebug("TkDetLayers") << "Number of rings in Phase2 OT EC layer is " << theRingSize << std::endl;
53  setSurface(computeDisk(rings));
54 
55  for (unsigned int i = 0; i != rings.size(); ++i) {
56  theComps.push_back(rings[i]);
57  fillRingPars(i);
58  theBasicComps.insert(
59  theBasicComps.end(), (*rings[i]).basicComponents().begin(), (*rings[i]).basicComponents().end());
60  }
61 
62  LogDebug("TkDetLayers") << "==== DEBUG Phase2EndcapLayer =====";
63  LogDebug("TkDetLayers") << "r,zed pos , thickness, innerR, outerR: " << this->position().perp() << " , "
64  << this->position().z() << " , " << this->specificSurface().bounds().thickness() << " , "
65  << this->specificSurface().innerRadius() << " , " << this->specificSurface().outerRadius();
66 }
std::vector< const Phase2EndcapRing * > theComps
void fillRingPars(int i) __attribute__((cold))
ForwardDetLayer RingedForwardLayer
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
BoundDisk * computeDisk(const std::vector< const Phase2EndcapRing * > &rings) const __attribute__((cold))
const bool isOuterTracker
std::vector< GeomDet const * > theBasicComps
static int position[264][3]
Definition: ReadPGInfo.cc:289
const std::vector< const GeomDet * > & basicComponents() const override
#define LogDebug(id)
Phase2EndcapLayer::~Phase2EndcapLayer ( )
override

Definition at line 92 of file Phase2EndcapLayer.cc.

References c, theComponents, and theComps.

92  {
93  for (auto c : theComps)
94  delete c;
95 
96  delete theComponents.load();
97 }
std::vector< const Phase2EndcapRing * > theComps
const edm::EventSetup & c
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Phase2EndcapLayer::Phase2EndcapLayer ( const Phase2EndcapLayer )
delete

Member Function Documentation

const std::vector<const GeomDet*>& Phase2EndcapLayer::basicComponents ( ) const
inlineoverride

Definition at line 26 of file Phase2EndcapLayer.h.

References theBasicComps.

26 { return theBasicComps; }
std::vector< GeomDet const * > theBasicComps
const std::vector< const GeometricSearchDet * > & Phase2EndcapLayer::components ( ) const
override

Definition at line 20 of file Phase2EndcapLayer.cc.

References c, and groupFilesInBlocks::temp.

20  {
21  if (not theComponents) {
22  auto temp = std::make_unique<std::vector<const GeometricSearchDet*>>();
23  temp->reserve(15); // This number is just an upper bound
24  for (auto c : theComps)
25  temp->push_back(c);
26  std::vector<const GeometricSearchDet*>* expected = nullptr;
27  if (theComponents.compare_exchange_strong(expected, temp.get())) {
28  //this thread set the value
29  temp.release();
30  }
31  }
32  return *theComponents;
33 }
std::vector< const Phase2EndcapRing * > theComps
const edm::EventSetup & c
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
BoundDisk * Phase2EndcapLayer::computeDisk ( const std::vector< const Phase2EndcapRing * > &  rings) const
private

Definition at line 68 of file Phase2EndcapLayer.cc.

References SiStripPI::max, min(), and makeMuonMisalignmentScenario::rot.

68  {
69  float theRmin = rings.front()->specificSurface().innerRadius();
70  float theRmax = rings.front()->specificSurface().outerRadius();
71  float theZmin = rings.front()->position().z() - rings.front()->surface().bounds().thickness() / 2;
72  float theZmax = rings.front()->position().z() + rings.front()->surface().bounds().thickness() / 2;
73 
74  for (vector<const Phase2EndcapRing*>::const_iterator i = rings.begin(); i != rings.end(); i++) {
75  float rmin = (**i).specificSurface().innerRadius();
76  float rmax = (**i).specificSurface().outerRadius();
77  float zmin = (**i).position().z() - (**i).surface().bounds().thickness() / 2.;
78  float zmax = (**i).position().z() + (**i).surface().bounds().thickness() / 2.;
79  theRmin = min(theRmin, rmin);
80  theRmax = max(theRmax, rmax);
81  theZmin = min(theZmin, zmin);
82  theZmax = max(theZmax, zmax);
83  }
84 
85  float zPos = (theZmax + theZmin) / 2.;
86  PositionType pos(0., 0., zPos);
88 
89  return new BoundDisk(pos, rot, new SimpleDiskBounds(theRmin, theRmax, theZmin - zPos, theZmax - zPos));
90 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:27
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:28
T min(T a, T b)
Definition: MathUtil.h:58
Disk BoundDisk
Definition: BoundDisk.h:54
float Phase2EndcapLayer::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const
private

Definition at line 268 of file Phase2EndcapLayer.cc.

References MeasurementEstimator::maximalLocalDisplacement(), GeomDet::surface(), and PV2DBase< T, PVType, FrameType >::y().

Referenced by groupedCompatibleDetsV().

270  {
271  const Plane& startPlane = det->surface();
272  MeasurementEstimator::Local2DVector maxDistance = est.maximalLocalDisplacement(tsos, startPlane);
273  return maxDistance.y();
274 }
T y() const
Definition: PV2DBase.h:44
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Definition: Plane.h:16
void Phase2EndcapLayer::fillRingPars ( int  i)
private

Definition at line 35 of file Phase2EndcapLayer.cc.

References funct::abs(), mps_fire::i, Phase2EndcapLayer::RingPar::theRingR, Phase2EndcapLayer::RingPar::thetaRingMax, and Phase2EndcapLayer::RingPar::thetaRingMin.

35  {
36  const BoundDisk& ringDisk = static_cast<const BoundDisk&>(theComps[i]->surface());
37  float ringMinZ = std::abs(ringDisk.position().z()) - ringDisk.bounds().thickness() / 2.;
38  float ringMaxZ = std::abs(ringDisk.position().z()) + ringDisk.bounds().thickness() / 2.;
39  RingPar tempPar;
40  tempPar.thetaRingMin = ringDisk.innerRadius() / ringMaxZ;
41  tempPar.thetaRingMax = ringDisk.outerRadius() / ringMinZ;
42  tempPar.theRingR = (ringDisk.innerRadius() + ringDisk.outerRadius()) / 2.;
43  ringPars.push_back(tempPar);
44 }
std::vector< const Phase2EndcapRing * > theComps
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< RingPar > ringPars
std::array< int, 3 > Phase2EndcapLayer::findThreeClosest ( std::vector< GlobalPoint ringCrossing) const
private

Definition at line 276 of file Phase2EndcapLayer.cc.

References funct::abs(), mps_fire::i, perp(), ringPars, and theRingSize.

Referenced by ringIndicesByCrossingProximity().

276  {
277  std::array<int, 3> theBins = {{-1, -1, -1}};
278  theBins[0] = 0;
279  float initialR = ringPars[0].theRingR;
280  float rDiff0 = std::abs(ringCrossing[0].perp() - initialR);
281  float rDiff1 = -1.;
282  float rDiff2 = -1.;
283  for (int i = 1; i < theRingSize; i++) {
284  float ringR = ringPars[i].theRingR;
285  float testDiff = std::abs(ringCrossing[i].perp() - ringR);
286  if (testDiff < rDiff0) {
287  rDiff2 = rDiff1;
288  rDiff1 = rDiff0;
289  rDiff0 = testDiff;
290  theBins[2] = theBins[1];
291  theBins[1] = theBins[0];
292  theBins[0] = i;
293  } else if (rDiff1 < 0 || testDiff < rDiff1) {
294  rDiff2 = rDiff1;
295  rDiff1 = testDiff;
296  theBins[2] = theBins[1];
297  theBins[1] = i;
298  } else if (rDiff2 < 0 || testDiff < rDiff2) {
299  rDiff2 = testDiff;
300  theBins[2] = i;
301  }
302  }
303 
304  return theBins;
305 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< RingPar > ringPars
T perp() const
Magnitude of transverse component.
void Phase2EndcapLayer::groupedCompatibleDetsV ( const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est,
std::vector< DetGroup > &  result 
) const
override

Definition at line 99 of file Phase2EndcapLayer.cc.

References DetGroupMerger::addSameLevel(), alongMomentum, computeWindowSize(), PVValHelper::fill(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, eostools::move(), DetGroupMerger::orderAndMergeTwoLevels(), overlapInR(), position, Propagator::propagationDirection(), ringIndicesByCrossingProximity(), theComps, theRingSize, z, and PV3DBase< T, PVType, FrameType >::z().

102  {
103  std::array<int, 3> const& ringIndices = ringIndicesByCrossingProximity(startingState, prop);
104  if (ringIndices[0] == -1 || ringIndices[1] == -1 || ringIndices[2] == -1) {
105  edm::LogError("TkDetLayers") << "TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
106  return;
107  }
108 
109  //order is: rings in front = 0; rings in back = 1
110  //rings should be already ordered in r
111  //if the layer has 1 ring, it does not matter
112  //FIXME: to be optimized once the geometry is stable
113  std::vector<int> ringOrder(theRingSize);
114  std::fill(ringOrder.begin(), ringOrder.end(), 1);
115  if (theRingSize > 1) {
116  if (fabs(theComps[0]->position().z()) < fabs(theComps[1]->position().z())) {
117  for (int i = 0; i < theRingSize; i++) {
118  if (i % 2 == 0)
119  ringOrder[i] = 0;
120  }
121  } else if (fabs(theComps[0]->position().z()) > fabs(theComps[1]->position().z())) {
122  std::fill(ringOrder.begin(), ringOrder.end(), 0);
123  for (int i = 0; i < theRingSize; i++) {
124  if (i % 2 == 0)
125  ringOrder[i] = 1;
126  }
127  } else {
128  throw DetLayerException("Rings in Endcap Layer have same z position, no idea how to order them!");
129  }
130  }
131 
132  auto index = [&ringIndices, &ringOrder](int i) { return ringOrder[ringIndices[i]]; };
133 
134  std::vector<DetGroup> closestResult;
135  theComps[ringIndices[0]]->groupedCompatibleDetsV(startingState, prop, est, closestResult);
136  // if the closest is empty, use the next one and exit: inherited from TID !
137  if (closestResult.empty()) {
138  theComps[ringIndices[1]]->groupedCompatibleDetsV(startingState, prop, est, result);
139  return;
140  }
141 
142  DetGroupElement closestGel(closestResult.front().front());
143  float rWindow = computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
144 
145  // check if next ring and next next ring are found and if there is overlap
146 
147  bool ring1ok = ringIndices[1] != -1 && overlapInR(closestGel.trajectoryState(), ringIndices[1], rWindow);
148  bool ring2ok = ringIndices[2] != -1 && overlapInR(closestGel.trajectoryState(), ringIndices[2], rWindow);
149 
150  // look for the two rings in the same plane (are they only two?)
151 
152  // determine if we are propagating from in to out (0) or from out to in (1)
153 
154  int direction = 0;
155  if (startingState.globalPosition().z() * startingState.globalMomentum().z() > 0) {
156  if (prop.propagationDirection() == alongMomentum)
157  direction = 0;
158  else
159  direction = 1;
160  } else {
161  if (prop.propagationDirection() == alongMomentum)
162  direction = 1;
163  else
164  direction = 0;
165  }
166 
167  if ((index(0) == index(1)) && (index(0) == index(2))) {
168  edm::LogInfo("AllRingsInOnePlane") << " All rings: " << ringIndices[0] << " " << ringIndices[1] << " "
169  << ringIndices[2] << " in one plane. Only the first two will be considered";
170  ring2ok = false;
171  }
172 
173  if (index(0) == index(1)) {
174  if (ring1ok) {
175  std::vector<DetGroup> ring1res;
176  theComps[ringIndices[1]]->groupedCompatibleDetsV(startingState, prop, est, ring1res);
177  DetGroupMerger::addSameLevel(std::move(ring1res), closestResult);
178  }
179  if (ring2ok) {
180  std::vector<DetGroup> ring2res;
181  theComps[ringIndices[2]]->groupedCompatibleDetsV(startingState, prop, est, ring2res);
183  std::move(closestResult), std::move(ring2res), result, index(0), direction);
184  return;
185  } else {
186  result.swap(closestResult);
187  return;
188  }
189  } else if (index(0) == index(2)) {
190  if (ring2ok) {
191  std::vector<DetGroup> ring2res;
192  theComps[ringIndices[2]]->groupedCompatibleDetsV(startingState, prop, est, ring2res);
193  DetGroupMerger::addSameLevel(std::move(ring2res), closestResult);
194  }
195  if (ring1ok) {
196  std::vector<DetGroup> ring1res;
197  theComps[ringIndices[1]]->groupedCompatibleDetsV(startingState, prop, est, ring1res);
199  std::move(closestResult), std::move(ring1res), result, index(0), direction);
200  return;
201  } else {
202  result.swap(closestResult);
203  return;
204  }
205  } else {
206  std::vector<DetGroup> ring12res;
207  if (ring1ok) {
208  std::vector<DetGroup> ring1res;
209  theComps[ringIndices[1]]->groupedCompatibleDetsV(startingState, prop, est, ring1res);
210  ring12res.swap(ring1res);
211  }
212  if (ring2ok) {
213  std::vector<DetGroup> ring2res;
214  theComps[ringIndices[2]]->groupedCompatibleDetsV(startingState, prop, est, ring2res);
215  DetGroupMerger::addSameLevel(std::move(ring2res), ring12res);
216  }
217  if (!ring12res.empty()) {
219  std::move(closestResult), std::move(ring12res), result, index(0), direction);
220  return;
221  } else {
222  result.swap(closestResult);
223  return;
224  }
225  }
226 }
Common base class.
std::vector< const Phase2EndcapRing * > theComps
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
bool overlapInR(const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
Log< level::Error, false > LogError
tuple result
Definition: mps_fire.py:311
static void addSameLevel(std::vector< DetGroup > &&gvec, std::vector< DetGroup > &result)
def move
Definition: eostools.py:511
Log< level::Info, false > LogInfo
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
static int position[264][3]
Definition: ReadPGInfo.cc:289
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
Phase2EndcapLayer& Phase2EndcapLayer::operator= ( const Phase2EndcapLayer )
delete
bool Phase2EndcapLayer::overlapInR ( const TrajectoryStateOnSurface tsos,
int  i,
double  ymax 
) const
private

Definition at line 307 of file Phase2EndcapLayer.cc.

References funct::abs(), validate-o2o-wbm::f, TrajectoryStateOnSurface::globalPosition(), SiStripPI::max, PV3DBase< T, PVType, FrameType >::perp(), ringPars, SiStrip_OfflineMonitoring_cff::ymax, and PV3DBase< T, PVType, FrameType >::z().

Referenced by groupedCompatibleDetsV().

307  {
308  // assume "fixed theta window", i.e. margin in local y = r is changing linearly with z
309  float tsRadius = tsos.globalPosition().perp();
310  float thetamin = (max(0., tsRadius - ymax)) / (std::abs(tsos.globalPosition().z()) + 10.f); // add 10 cm contingency
311  float thetamax = (tsRadius + ymax) / (std::abs(tsos.globalPosition().z()) - 10.f);
312 
313  // do the theta regions overlap ?
314 
315  return !(thetamin > ringPars[index].thetaRingMax || ringPars[index].thetaRingMin > thetamax);
316 }
T perp() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
T z() const
Definition: PV3DBase.h:61
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< RingPar > ringPars
std::array< int, 3 > Phase2EndcapLayer::ringIndicesByCrossingProximity ( const TrajectoryStateOnSurface startingState,
const Propagator prop 
) const
private

Definition at line 228 of file Phase2EndcapLayer.cc.

References findThreeClosest(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, Propagator::propagationDirection(), rho, theComps, theRingSize, and TrajectoryStateOnSurface::transverseCurvature().

Referenced by groupedCompatibleDetsV().

229  {
230  typedef HelixForwardPlaneCrossing Crossing;
232 
233  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
234  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
236  float rho(startingState.transverseCurvature());
237 
238  // calculate the crossings with the ring surfaces
239  // rings are assumed to be sorted in R !
240 
241  Crossing myXing(startPos, startDir, rho, propDir);
242 
243  std::vector<GlobalPoint> ringCrossings;
244  ringCrossings.reserve(theRingSize);
245  // vector<GlobalVector> ringXDirections;
246 
247  for (int i = 0; i < theRingSize; i++) {
248  const BoundDisk& theRing = static_cast<const BoundDisk&>(theComps[i]->surface());
249  pair<bool, double> pathlen = myXing.pathLength(theRing);
250  if (pathlen.first) {
251  ringCrossings.push_back(GlobalPoint(myXing.position(pathlen.second)));
252  // ringXDirections.push_back( GlobalVector( myXing.direction(pathlen.second )));
253  } else {
254  // TO FIX.... perhaps there is something smarter to do
255  //throw DetLayerException("trajectory doesn't cross TID rings");
256  ringCrossings.push_back(GlobalPoint(0., 0., 0.));
257  // ringXDirections.push_back( GlobalVector( 0.,0.,0.));
258  }
259  }
260 
261  //find three closest rings to the crossing
262 
263  std::array<int, 3> closests = findThreeClosest(ringCrossings);
264 
265  return closests;
266 }
std::vector< const Phase2EndcapRing * > theComps
std::array< int, 3 > findThreeClosest(std::vector< GlobalPoint >) const __attribute__((hot))
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
PropagationDirection
GlobalVector globalMomentum() const
Vector2DBase< float, LocalTag > Local2DVector
SubDetector Phase2EndcapLayer::subDetector ( ) const
inlineoverride

Member Data Documentation

const bool Phase2EndcapLayer::isOuterTracker
private

Definition at line 65 of file Phase2EndcapLayer.h.

Referenced by subDetector().

std::vector<RingPar> Phase2EndcapLayer::ringPars
private

Definition at line 71 of file Phase2EndcapLayer.h.

Referenced by findThreeClosest(), and overlapInR().

std::vector<GeomDet const*> Phase2EndcapLayer::theBasicComps
private

Definition at line 64 of file Phase2EndcapLayer.h.

Referenced by basicComponents().

std::atomic<std::vector<const GeometricSearchDet*>*> Phase2EndcapLayer::theComponents
mutableprivate

Definition at line 66 of file Phase2EndcapLayer.h.

Referenced by ~Phase2EndcapLayer().

std::vector<const Phase2EndcapRing*> Phase2EndcapLayer::theComps
private
int Phase2EndcapLayer::theRingSize
private