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

virtual const std::vector< const GeomDet * > & basicComponents () const
 
virtual const std::vector< const GeometricSearchDet * > & components () const __attribute__((cold))
 
void groupedCompatibleDetsV (const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
 
TIDLayeroperator= (const TIDLayer &)=delete
 
virtual SubDetector subDetector () const
 
 TIDLayer (std::vector< const TIDRing * > &rings) __attribute__((cold))
 
 TIDLayer (const TIDLayer &)=delete
 
 ~TIDLayer () __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 15 of file TIDLayer.h.

Constructor & Destructor Documentation

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

Definition at line 123 of file TIDLayer.cc.

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

123  :
124  RingedForwardLayer(true),
125  theComponents{nullptr}
126 {
127  //They should be already R-ordered. TO BE CHECKED!!
128  //sort( theRings.begin(), theRings.end(), DetLessR());
129 
130  if ( rings.size() != 3) throw DetLayerException("Number of rings in TID layer is not equal to 3 !!");
131  setSurface( computeDisk( rings ) );
132 
133  for(int i=0; i!=3; ++i) {
134  theComps[i]=rings[i];
135  fillRingPars(i);
136  theBasicComps.insert(theBasicComps.end(),
137  (*rings[i]).basicComponents().begin(),
138  (*rings[i]).basicComponents().end());
139  }
140 
141 
142  LogDebug("TkDetLayers") << "==== DEBUG TIDLayer =====" ;
143  LogDebug("TkDetLayers") << "r,zed pos , thickness, innerR, outerR: "
144  << this->position().perp() << " , "
145  << this->position().z() << " , "
146  << this->specificSurface().bounds().thickness() << " , "
147  << this->specificSurface().innerRadius() << " , "
148  << this->specificSurface().outerRadius() ;
149 }
#define LogDebug(id)
Common base class.
ForwardDetLayer RingedForwardLayer
std::vector< GeomDet const * > theBasicComps
Definition: TIDLayer.h:63
virtual const std::vector< const GeomDet * > & basicComponents() const
Definition: TIDLayer.h:26
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Definition: TIDLayer.h:64
void fillRingPars(int i) __attribute__((cold))
Definition: TIDLayer.cc:111
static int position[264][3]
Definition: ReadPGInfo.cc:509
BoundDisk * computeDisk(const std::vector< const TIDRing * > &rings) const __attribute__((cold))
Definition: TIDLayer.cc:153
const TIDRing * theComps[3]
Definition: TIDLayer.h:65
TIDLayer::~TIDLayer ( )

Definition at line 183 of file TIDLayer.cc.

References EnergyCorrector::c, theComponents, and theComps.

183  {
184  for (auto c : theComps) delete c;
185 
186  delete theComponents.load();
187 }
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Definition: TIDLayer.h:64
const TIDRing * theComps[3]
Definition: TIDLayer.h:65
TIDLayer::TIDLayer ( const TIDLayer )
delete

Member Function Documentation

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

Definition at line 26 of file TIDLayer.h.

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

Referenced by TIDLayer().

26 {return theBasicComps;}
std::vector< GeomDet const * > theBasicComps
Definition: TIDLayer.h:63
const std::vector< const GeometricSearchDet * > & TIDLayer::components ( ) const
virtual

Definition at line 94 of file TIDLayer.cc.

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

Referenced by basicComponents().

94  {
95  if( not theComponents) {
96  auto temp = std::make_unique<std::vector<const GeometricSearchDet*>>();
97  temp->reserve(3);
98  for ( auto c: theComps) temp->push_back(c);
99  std::vector<const GeometricSearchDet*>* expected = nullptr;
100  if(theComponents.compare_exchange_strong(expected,temp.get())) {
101  //this thread set the value
102  temp.release();
103  }
104  }
105 
106  return *theComponents;
107  }
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Definition: TIDLayer.h:64
const TIDRing * theComps[3]
Definition: TIDLayer.h:65
BoundDisk * TIDLayer::computeDisk ( const std::vector< const TIDRing * > &  rings) const
private

Definition at line 153 of file TIDLayer.cc.

References mps_fire::i, hpstanc_transforms::max, min(), and makeMuonMisalignmentScenario::rot.

Referenced by subDetector(), and TIDLayer().

154 {
155  float theRmin = rings.front()->specificSurface().innerRadius();
156  float theRmax = rings.front()->specificSurface().outerRadius();
157  float theZmin = rings.front()->position().z() -
158  rings.front()->surface().bounds().thickness()/2;
159  float theZmax = rings.front()->position().z() +
160  rings.front()->surface().bounds().thickness()/2;
161 
162  for (vector<const TIDRing*>::const_iterator i = rings.begin(); i != rings.end(); i++) {
163  float rmin = (**i).specificSurface().innerRadius();
164  float rmax = (**i).specificSurface().outerRadius();
165  float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
166  float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
167  theRmin = min( theRmin, rmin);
168  theRmax = max( theRmax, rmax);
169  theZmin = min( theZmin, zmin);
170  theZmax = max( theZmax, zmax);
171  }
172 
173  float zPos = (theZmax+theZmin)/2.;
174  PositionType pos(0.,0.,zPos);
176 
177  return new BoundDisk( pos, rot, new SimpleDiskBounds(theRmin, theRmax,
178  theZmin-zPos, theZmax-zPos));
179 
180 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
T min(T a, T b)
Definition: MathUtil.h:58
Disk BoundDisk
Definition: BoundDisk.h:62
float TIDLayer::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const
private

Definition at line 308 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

311 {
312  const Plane& startPlane = det->surface();
314  est.maximalLocalDisplacement( tsos, startPlane);
315  return maxDistance.y();
316 }
T y() const
Definition: PV2DBase.h:46
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
Definition: Plane.h:17
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
void TIDLayer::fillRingPars ( int  i)
private

Definition at line 111 of file TIDLayer.cc.

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

Referenced by subDetector(), and TIDLayer().

111  {
112  const BoundDisk& ringDisk = static_cast<const BoundDisk&>(theComps[i]->surface());
113  float ringMinZ = std::abs( ringDisk.position().z()) - ringDisk.bounds().thickness()/2.;
114  float ringMaxZ = std::abs( ringDisk.position().z()) + ringDisk.bounds().thickness()/2.;
115  ringPars[i].thetaRingMin = ringDisk.innerRadius()/ ringMaxZ;
116  ringPars[i].thetaRingMax = ringDisk.outerRadius()/ ringMinZ;
117  ringPars[i].theRingR=( ringDisk.innerRadius() +
118  ringDisk.outerRadius())/2.;
119 
120 }
float thetaRingMin
Definition: TIDLayer.h:66
float thetaRingMax
Definition: TIDLayer.h:66
RingPar ringPars[3]
Definition: TIDLayer.h:67
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
Definition: TIDRing.h:21
const TIDRing * theComps[3]
Definition: TIDLayer.h:65
int TIDLayer::findClosest ( const GlobalPoint  ringCrossing[3]) const
private

Definition at line 320 of file TIDLayer.cc.

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

Referenced by ringIndicesByCrossingProximity(), and subDetector().

321 {
322  int theBin = 0;
323  float initialR = ringPars[0].theRingR;
324  float rDiff = std::abs( ringCrossing[0].perp() - initialR);
325  for (int i = 1; i < 3 ; i++){
326  float ringR = ringPars[i].theRingR;
327  float testDiff = std::abs( ringCrossing[i].perp() - ringR);
328  if ( testDiff<rDiff ) {
329  rDiff = testDiff;
330  theBin = i;
331  }
332  }
333  return theBin;
334 }
RingPar ringPars[3]
Definition: TIDLayer.h:67
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 337 of file TIDLayer.cc.

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

Referenced by ringIndicesByCrossingProximity(), and subDetector().

338 {
339 
340  int firstIndexToCheck = (closest != 0)? 0 : 1;
341  float initialR = ringPars[firstIndexToCheck].theRingR;
342  float rDiff = std::abs( ringCrossing[firstIndexToCheck].perp() - initialR);
343  int theBin = firstIndexToCheck;
344  for (int i = firstIndexToCheck+1; i < 3 ; i++){
345  if ( i != closest) {
346  float ringR = ringPars[i].theRingR;
347  float testDiff = std::abs( ringCrossing[i].perp() - ringR);
348  if ( testDiff<rDiff ) {
349  rDiff = testDiff;
350  theBin = i;
351  }
352  }
353  }
354  return theBin;
355 }
RingPar ringPars[3]
Definition: TIDLayer.h:67
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

Definition at line 192 of file TIDLayer.cc.

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

Referenced by basicComponents().

196 {
197  std::array<int,3> const & ringIndices = ringIndicesByCrossingProximity(startingState,prop);
198  if ( ringIndices[0]==-1 ) {
199  edm::LogError("TkDetLayers") << "TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
200  return;
201  }
202 
203  std::array<vector<DetGroup>,3> groupsAtRingLevel;
204  //order is ring3,ring1,ring2 i.e. 2 0 1
205  // 0 1 2
206 #ifdef __INTEL_COMPILER
207  const int ringOrder[3]{1,2,0};
208 #else
209  constexpr int ringOrder[3]{1,2,0};
210 #endif
211  auto index = [&ringIndices,& ringOrder](int i) { return ringOrder[ringIndices[i]];};
212 
213  auto & closestResult = groupsAtRingLevel[index(0)];
214  theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);
215  if ( closestResult.empty() ){
216  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result);
217  return;
218  }
219 
220  DetGroupElement closestGel( closestResult.front().front());
221  float rWindow = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
222 
223  if(!overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
224  result.swap(closestResult);
225  return;
226  }
227 
228 
229  auto & nextResult = groupsAtRingLevel[index(1)];
230  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, nextResult);
231  if(nextResult.empty()) {
232  result.swap(closestResult);
233  return;
234  }
235 
236  if(!overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
237  //then merge 2 levels & return
238  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,result);
239  return;
240  }
241 
242  auto & nextNextResult = groupsAtRingLevel[index(2)];
243  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, nextNextResult);
244  if(nextNextResult.empty()) {
245  // then merge 2 levels and return
246  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,result); //
247  return;
248  }
249 
250  // merge 3 level and return merged
251  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel, result);
252 }
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
Definition: TIDLayer.cc:256
#define constexpr
bool overlapInR(const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
Definition: TIDLayer.cc:360
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
Definition: TIDLayer.cc:308
const TIDRing * theComps[3]
Definition: TIDLayer.h:65
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TIDRing.cc:92
TIDLayer& TIDLayer::operator= ( const TIDLayer )
delete
bool TIDLayer::overlapInR ( const TrajectoryStateOnSurface tsos,
int  i,
double  ymax 
) const
private

Definition at line 360 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

361 {
362  // assume "fixed theta window", i.e. margin in local y = r is changing linearly with z
363  float tsRadius = tsos.globalPosition().perp();
364  float thetamin = ( max(0.,tsRadius-ymax))/(std::abs(tsos.globalPosition().z())+10.f); // add 10 cm contingency
365  float thetamax = ( tsRadius + ymax)/(std::abs(tsos.globalPosition().z())-10.f);
366 
367  // do the theta regions overlap ?
368 
369  return !( thetamin > ringPars[index].thetaRingMax || ringPars[index].thetaRingMin > thetamax);
370 }
T perp() const
Definition: PV3DBase.h:72
GlobalPoint globalPosition() const
float thetaRingMin
Definition: TIDLayer.h:66
float thetaRingMax
Definition: TIDLayer.h:66
RingPar ringPars[3]
Definition: TIDLayer.h:67
T z() const
Definition: PV3DBase.h:64
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 256 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

258 {
259  typedef HelixForwardPlaneCrossing Crossing;
261 
262  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition());
263  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum());
265  float rho( startingState.transverseCurvature());
266 
267  // calculate the crossings with the ring surfaces
268  // rings are assumed to be sorted in R !
269 
270  Crossing myXing( startPos, startDir, rho, propDir );
271 
272  GlobalPoint ringCrossings[3];
273  // vector<GlobalVector> ringXDirections;
274 
275  for (int i = 0; i < 3 ; i++ ) {
276  const BoundDisk & theRing = static_cast<const BoundDisk &>(theComps[i]->surface());
277  pair<bool,double> pathlen = myXing.pathLength( theRing);
278  if ( pathlen.first ) {
279  ringCrossings[i] = GlobalPoint( myXing.position(pathlen.second ));
280  // ringXDirections.push_back( GlobalVector( myXing.direction(pathlen.second )));
281  } else {
282  // TO FIX.... perhaps there is something smarter to do
283  //throw DetLayerException("trajectory doesn't cross TID rings");
284  ringCrossings[i] = GlobalPoint( 0.,0.,0.);
285  // ringXDirections.push_back( GlobalVector( 0.,0.,0.));
286  }
287  }
288 
289  int closestIndex = findClosest(ringCrossings);
290  int nextIndex = findNextIndex(ringCrossings,closestIndex);
291  if ( closestIndex<0 || nextIndex<0 ) return std::array<int,3>{{-1,-1,-1}};
292  int nextNextIndex = -1;
293  for(int i=0; i<3 ; i++){
294  if(i!= closestIndex && i!=nextIndex) {
295  nextNextIndex = i;
296  break;
297  }
298  }
299 
300  std::array<int,3> indices{{closestIndex,nextIndex,nextNextIndex}};
301  return indices;
302 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint globalPosition() const
Vector2DBase< float, LocalTag > Local2DVector
PropagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
Definition: TIDRing.h:21
GlobalVector globalMomentum() const
const TIDRing * theComps[3]
Definition: TIDLayer.h:65
int findClosest(const GlobalPoint[3]) const __attribute__((hot))
Definition: TIDLayer.cc:320
int findNextIndex(const GlobalPoint[3], int) const __attribute__((hot))
Definition: TIDLayer.cc:337
virtual SubDetector TIDLayer::subDetector ( ) const
inlinevirtual

Member Data Documentation

RingPar TIDLayer::ringPars[3]
private

Definition at line 67 of file TIDLayer.h.

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

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

Definition at line 63 of file TIDLayer.h.

Referenced by basicComponents(), and TIDLayer().

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

Definition at line 64 of file TIDLayer.h.

Referenced by ~TIDLayer().

const TIDRing* TIDLayer::theComps[3]
private