CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TIDLayer Class Referencefinal

#include <TIDLayer.h>

Inheritance diagram for TIDLayer:
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))
 
TIDLayeroperator= (const TIDLayer &)=delete
 
SubDetector subDetector () const override
 
 TIDLayer (std::vector< const TIDRing * > &rings) __attribute__((cold))
 
 TIDLayer (const TIDLayer &)=delete
 
 ~TIDLayer () override __attribute__((cold))
 

Private Member Functions

BoundDiskcomputeDisk (const std::vector< const TIDRing * > &rings) const __attribute__((cold))
 
float computeWindowSize (const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
 
void fillRingPars (int i) __attribute__((cold))
 
int findClosest (const GlobalPoint[3]) const __attribute__((hot))
 
int findNextIndex (const GlobalPoint[3], int) 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

RingPar ringPars [3]
 
std::vector< GeomDet const * > theBasicComps
 
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
 
const TIDRingtheComps [3]
 

Detailed Description

A concrete implementation for TID layer built out of TIDRings

Definition at line 14 of file TIDLayer.h.

Constructor & Destructor Documentation

TIDLayer::TIDLayer ( std::vector< const TIDRing * > &  rings)

Definition at line 104 of file TIDLayer.cc.

References basicComponents(), computeDisk(), fillRingPars(), mps_fire::i, LogDebug, position, theBasicComps, and theComps.

104  : RingedForwardLayer(true), theComponents{nullptr} {
105  //They should be already R-ordered. TO BE CHECKED!!
106  //sort( theRings.begin(), theRings.end(), DetLessR());
107 
108  if (rings.size() != 3)
109  throw DetLayerException("Number of rings in TID layer is not equal to 3 !!");
110  setSurface(computeDisk(rings));
111 
112  for (int i = 0; i != 3; ++i) {
113  theComps[i] = rings[i];
114  fillRingPars(i);
115  theBasicComps.insert(
116  theBasicComps.end(), (*rings[i]).basicComponents().begin(), (*rings[i]).basicComponents().end());
117  }
118 
119  LogDebug("TkDetLayers") << "==== DEBUG TIDLayer =====";
120  LogDebug("TkDetLayers") << "r,zed pos , thickness, innerR, outerR: " << this->position().perp() << " , "
121  << this->position().z() << " , " << this->specificSurface().bounds().thickness() << " , "
122  << this->specificSurface().innerRadius() << " , " << this->specificSurface().outerRadius();
123 }
#define LogDebug(id)
Common base class.
ForwardDetLayer RingedForwardLayer
std::vector< GeomDet const * > theBasicComps
Definition: TIDLayer.h:60
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Definition: TIDLayer.h:61
void fillRingPars(int i) __attribute__((cold))
Definition: TIDLayer.cc:95
static int position[264][3]
Definition: ReadPGInfo.cc:289
BoundDisk * computeDisk(const std::vector< const TIDRing * > &rings) const __attribute__((cold))
Definition: TIDLayer.cc:125
const TIDRing * theComps[3]
Definition: TIDLayer.h:62
const std::vector< const GeomDet * > & basicComponents() const override
Definition: TIDLayer.h:25
TIDLayer::~TIDLayer ( )
override

Definition at line 149 of file TIDLayer.cc.

References HltBtagPostValidation_cff::c, theComponents, and theComps.

149  {
150  for (auto c : theComps)
151  delete c;
152 
153  delete theComponents.load();
154 }
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Definition: TIDLayer.h:61
const TIDRing * theComps[3]
Definition: TIDLayer.h:62
TIDLayer::TIDLayer ( const TIDLayer )
delete

Member Function Documentation

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

Definition at line 25 of file TIDLayer.h.

References components(), groupedCompatibleDetsV(), mps_fire::result, and theBasicComps.

Referenced by TIDLayer().

25 { return theBasicComps; }
std::vector< GeomDet const * > theBasicComps
Definition: TIDLayer.h:60
const std::vector< const GeometricSearchDet * > & TIDLayer::components ( ) const
override

Definition at line 79 of file TIDLayer.cc.

References HltBtagPostValidation_cff::c, and groupFilesInBlocks::temp.

Referenced by basicComponents().

79  {
80  if (not theComponents) {
81  auto temp = std::make_unique<std::vector<const GeometricSearchDet*>>();
82  temp->reserve(3);
83  for (auto c : theComps)
84  temp->push_back(c);
85  std::vector<const GeometricSearchDet*>* expected = nullptr;
86  if (theComponents.compare_exchange_strong(expected, temp.get())) {
87  //this thread set the value
88  temp.release();
89  }
90  }
91 
92  return *theComponents;
93 }
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Definition: TIDLayer.h:61
const TIDRing * theComps[3]
Definition: TIDLayer.h:62
BoundDisk * TIDLayer::computeDisk ( const std::vector< const TIDRing * > &  rings) const
private

Definition at line 125 of file TIDLayer.cc.

References mps_fire::i, SiStripPI::max, min(), makeMuonMisalignmentScenario::rot, SiStripMonitorCluster_cfi::zmax, and SiStripMonitorCluster_cfi::zmin.

Referenced by subDetector(), and TIDLayer().

125  {
126  float theRmin = rings.front()->specificSurface().innerRadius();
127  float theRmax = rings.front()->specificSurface().outerRadius();
128  float theZmin = rings.front()->position().z() - rings.front()->surface().bounds().thickness() / 2;
129  float theZmax = rings.front()->position().z() + rings.front()->surface().bounds().thickness() / 2;
130 
131  for (vector<const TIDRing*>::const_iterator i = rings.begin(); i != rings.end(); i++) {
132  float rmin = (**i).specificSurface().innerRadius();
133  float rmax = (**i).specificSurface().outerRadius();
134  float zmin = (**i).position().z() - (**i).surface().bounds().thickness() / 2.;
135  float zmax = (**i).position().z() + (**i).surface().bounds().thickness() / 2.;
136  theRmin = min(theRmin, rmin);
137  theRmax = max(theRmax, rmax);
138  theZmin = min(theZmin, zmin);
139  theZmax = max(theZmax, zmax);
140  }
141 
142  float zPos = (theZmax + theZmin) / 2.;
143  PositionType pos(0., 0., zPos);
145 
146  return new BoundDisk(pos, rot, new SimpleDiskBounds(theRmin, theRmax, theZmin - zPos, theZmax - zPos));
147 }
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 TIDLayer::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const
private

Definition at line 264 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

266  {
267  const Plane& startPlane = det->surface();
269  return maxDistance.y();
270 }
T y() const
Definition: PV2DBase.h:44
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
Definition: Plane.h:16
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
void TIDLayer::fillRingPars ( int  i)
private

Definition at line 95 of file TIDLayer.cc.

References funct::abs(), and mps_fire::i.

Referenced by subDetector(), and TIDLayer().

95  {
96  const BoundDisk& ringDisk = static_cast<const BoundDisk&>(theComps[i]->surface());
97  float ringMinZ = std::abs(ringDisk.position().z()) - ringDisk.bounds().thickness() / 2.;
98  float ringMaxZ = std::abs(ringDisk.position().z()) + ringDisk.bounds().thickness() / 2.;
99  ringPars[i].thetaRingMin = ringDisk.innerRadius() / ringMaxZ;
100  ringPars[i].thetaRingMax = ringDisk.outerRadius() / ringMinZ;
101  ringPars[i].theRingR = (ringDisk.innerRadius() + ringDisk.outerRadius()) / 2.;
102 }
const BoundSurface & surface() const override
The surface of the GeometricSearchDet.
Definition: TIDRing.h:19
float thetaRingMin
Definition: TIDLayer.h:64
float thetaRingMax
Definition: TIDLayer.h:64
RingPar ringPars[3]
Definition: TIDLayer.h:66
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const TIDRing * theComps[3]
Definition: TIDLayer.h:62
int TIDLayer::findClosest ( const GlobalPoint  ringCrossing[3]) const
private

Definition at line 272 of file TIDLayer.cc.

References funct::abs(), mps_fire::i, perp(), ringPars, and TIDLayer::RingPar::theRingR.

Referenced by ringIndicesByCrossingProximity(), and subDetector().

272  {
273  int theBin = 0;
274  float initialR = ringPars[0].theRingR;
275  float rDiff = std::abs(ringCrossing[0].perp() - initialR);
276  for (int i = 1; i < 3; i++) {
277  float ringR = ringPars[i].theRingR;
278  float testDiff = std::abs(ringCrossing[i].perp() - ringR);
279  if (testDiff < rDiff) {
280  rDiff = testDiff;
281  theBin = i;
282  }
283  }
284  return theBin;
285 }
RingPar ringPars[3]
Definition: TIDLayer.h:66
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T perp() const
Magnitude of transverse component.
int TIDLayer::findNextIndex ( const GlobalPoint  ringCrossing[3],
int  closest 
) const
private

Definition at line 287 of file TIDLayer.cc.

References funct::abs(), mps_fire::i, perp(), ringPars, and TIDLayer::RingPar::theRingR.

Referenced by ringIndicesByCrossingProximity(), and subDetector().

287  {
288  int firstIndexToCheck = (closest != 0) ? 0 : 1;
289  float initialR = ringPars[firstIndexToCheck].theRingR;
290  float rDiff = std::abs(ringCrossing[firstIndexToCheck].perp() - initialR);
291  int theBin = firstIndexToCheck;
292  for (int i = firstIndexToCheck + 1; i < 3; i++) {
293  if (i != closest) {
294  float ringR = ringPars[i].theRingR;
295  float testDiff = std::abs(ringCrossing[i].perp() - ringR);
296  if (testDiff < rDiff) {
297  rDiff = testDiff;
298  theBin = i;
299  }
300  }
301  }
302  return theBin;
303 }
RingPar ringPars[3]
Definition: TIDLayer.h:66
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T perp() const
Magnitude of transverse component.
void TIDLayer::groupedCompatibleDetsV ( const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est,
std::vector< DetGroup > &  result 
) const
override

Definition at line 156 of file TIDLayer.cc.

References computeWindowSize(), constexpr, TIDRing::groupedCompatibleDetsV(), mps_fire::i, overlapInR(), mps_fire::result, ringIndicesByCrossingProximity(), and theComps.

Referenced by basicComponents().

159  {
160  std::array<int, 3> const& ringIndices = ringIndicesByCrossingProximity(startingState, prop);
161  if (ringIndices[0] == -1) {
162  edm::LogError("TkDetLayers") << "TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
163  return;
164  }
165 
166  std::array<vector<DetGroup>, 3> groupsAtRingLevel;
167  //order is ring3,ring1,ring2 i.e. 2 0 1
168  // 0 1 2
169 #ifdef __INTEL_COMPILER
170  const int ringOrder[3]{1, 2, 0};
171 #else
172  constexpr int ringOrder[3]{1, 2, 0};
173 #endif
174  auto index = [&ringIndices, &ringOrder](int i) { return ringOrder[ringIndices[i]]; };
175 
176  auto& closestResult = groupsAtRingLevel[index(0)];
177  theComps[ringIndices[0]]->groupedCompatibleDetsV(startingState, prop, est, closestResult);
178  if (closestResult.empty()) {
179  theComps[ringIndices[1]]->groupedCompatibleDetsV(startingState, prop, est, result);
180  return;
181  }
182 
183  DetGroupElement closestGel(closestResult.front().front());
184  float rWindow = computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
185 
186  if (!overlapInR(closestGel.trajectoryState(), ringIndices[1], rWindow)) {
187  result.swap(closestResult);
188  return;
189  }
190 
191  auto& nextResult = groupsAtRingLevel[index(1)];
192  theComps[ringIndices[1]]->groupedCompatibleDetsV(startingState, prop, est, nextResult);
193  if (nextResult.empty()) {
194  result.swap(closestResult);
195  return;
196  }
197 
198  if (!overlapInR(closestGel.trajectoryState(), ringIndices[2], rWindow)) {
199  //then merge 2 levels & return
200  orderAndMergeLevels(closestGel.trajectoryState(), prop, groupsAtRingLevel, result);
201  return;
202  }
203 
204  auto& nextNextResult = groupsAtRingLevel[index(2)];
205  theComps[ringIndices[2]]->groupedCompatibleDetsV(startingState, prop, est, nextNextResult);
206  if (nextNextResult.empty()) {
207  // then merge 2 levels and return
208  orderAndMergeLevels(closestGel.trajectoryState(), prop, groupsAtRingLevel, result); //
209  return;
210  }
211 
212  // merge 3 level and return merged
213  orderAndMergeLevels(closestGel.trajectoryState(), prop, groupsAtRingLevel, result);
214 }
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
Definition: TIDRing.cc:68
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
Definition: TIDLayer.cc:216
bool overlapInR(const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
Definition: TIDLayer.cc:305
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
Definition: TIDLayer.cc:264
const TIDRing * theComps[3]
Definition: TIDLayer.h:62
#define constexpr
TIDLayer& TIDLayer::operator= ( const TIDLayer )
delete
bool TIDLayer::overlapInR ( const TrajectoryStateOnSurface tsos,
int  i,
double  ymax 
) const
private

Definition at line 305 of file TIDLayer.cc.

References funct::abs(), f, TrajectoryStateOnSurface::globalPosition(), SiStripPI::max, PV3DBase< T, PVType, FrameType >::perp(), ringPars, TIDLayer::RingPar::thetaRingMax, TIDLayer::RingPar::thetaRingMin, L1TOccupancyClient_cfi::ymax, and PV3DBase< T, PVType, FrameType >::z().

Referenced by groupedCompatibleDetsV(), and subDetector().

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

Definition at line 216 of file TIDLayer.cc.

References findClosest(), findNextIndex(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, bTagCombinedSVVariables_cff::indices, Propagator::propagationDirection(), rho, TIDRing::surface(), theComps, and TrajectoryStateOnSurface::transverseCurvature().

Referenced by groupedCompatibleDetsV(), and subDetector().

217  {
218  typedef HelixForwardPlaneCrossing Crossing;
220 
221  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
222  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
224  float rho(startingState.transverseCurvature());
225 
226  // calculate the crossings with the ring surfaces
227  // rings are assumed to be sorted in R !
228 
229  Crossing myXing(startPos, startDir, rho, propDir);
230 
231  GlobalPoint ringCrossings[3];
232  // vector<GlobalVector> ringXDirections;
233 
234  for (int i = 0; i < 3; i++) {
235  const BoundDisk& theRing = static_cast<const BoundDisk&>(theComps[i]->surface());
236  pair<bool, double> pathlen = myXing.pathLength(theRing);
237  if (pathlen.first) {
238  ringCrossings[i] = GlobalPoint(myXing.position(pathlen.second));
239  // ringXDirections.push_back( GlobalVector( myXing.direction(pathlen.second )));
240  } else {
241  // TO FIX.... perhaps there is something smarter to do
242  //throw DetLayerException("trajectory doesn't cross TID rings");
243  ringCrossings[i] = GlobalPoint(0., 0., 0.);
244  // ringXDirections.push_back( GlobalVector( 0.,0.,0.));
245  }
246  }
247 
248  int closestIndex = findClosest(ringCrossings);
249  int nextIndex = findNextIndex(ringCrossings, closestIndex);
250  if (closestIndex < 0 || nextIndex < 0)
251  return std::array<int, 3>{{-1, -1, -1}};
252  int nextNextIndex = -1;
253  for (int i = 0; i < 3; i++) {
254  if (i != closestIndex && i != nextIndex) {
255  nextNextIndex = i;
256  break;
257  }
258  }
259 
260  std::array<int, 3> indices{{closestIndex, nextIndex, nextNextIndex}};
261  return indices;
262 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
PropagationDirection
const BoundSurface & surface() const override
The surface of the GeometricSearchDet.
Definition: TIDRing.h:19
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
GlobalVector globalMomentum() const
Vector2DBase< float, LocalTag > Local2DVector
const TIDRing * theComps[3]
Definition: TIDLayer.h:62
int findClosest(const GlobalPoint[3]) const __attribute__((hot))
Definition: TIDLayer.cc:272
int findNextIndex(const GlobalPoint[3], int) const __attribute__((hot))
Definition: TIDLayer.cc:287
SubDetector TIDLayer::subDetector ( ) const
inlineoverride

Member Data Documentation

RingPar TIDLayer::ringPars[3]
private

Definition at line 66 of file TIDLayer.h.

Referenced by findClosest(), findNextIndex(), and overlapInR().

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

Definition at line 60 of file TIDLayer.h.

Referenced by basicComponents(), and TIDLayer().

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

Definition at line 61 of file TIDLayer.h.

Referenced by ~TIDLayer().

const TIDRing* TIDLayer::theComps[3]
private