CMS 3D CMS Logo

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

#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.

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.
int i
Definition: DBlmapReader.cc:9
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 theBasicComps.

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.

94  {
95  if( not theComponents) {
96  std::unique_ptr<std::vector<const GeometricSearchDet*>> temp( new 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 i, bookConverter::max, min(), makeMuonMisalignmentScenario::rot, SiStripMonitorClusterAlca_cfi::zmax, SiStripMonitorClusterAlca_cfi::zmin, and zPos.

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
int i
Definition: DBlmapReader.cc:9
double zPos
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 304 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV().

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

Definition at line 111 of file TIDLayer.cc.

References funct::abs(), and i.

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 }
int i
Definition: DBlmapReader.cc:9
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 316 of file TIDLayer.cc.

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

Referenced by ringIndicesByCrossingProximity().

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

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

Referenced by ringIndicesByCrossingProximity().

334 {
335 
336  int firstIndexToCheck = (closest != 0)? 0 : 1;
337  float initialR = ringPars[firstIndexToCheck].theRingR;
338  float rDiff = std::abs( ringCrossing[firstIndexToCheck].perp() - initialR);
339  int theBin = firstIndexToCheck;
340  for (int i = firstIndexToCheck+1; i < 3 ; i++){
341  if ( i != closest) {
342  float ringR = ringPars[i].theRingR;
343  float testDiff = std::abs( ringCrossing[i].perp() - ringR);
344  if ( testDiff<rDiff ) {
345  rDiff = testDiff;
346  theBin = i;
347  }
348  }
349  }
350  return theBin;
351 }
int i
Definition: DBlmapReader.cc:9
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(), i, cmsHarvester::index, overlapInR(), query::result, ringIndicesByCrossingProximity(), and theComps.

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  constexpr int ringOrder[3]{1,2,0};
207  auto index = [&ringIndices,& ringOrder](int i) { return ringOrder[ringIndices[i]];};
208 
209  auto & closestResult = groupsAtRingLevel[index(0)];
210  theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);
211  if ( closestResult.empty() ){
212  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result);
213  return;
214  }
215 
216  DetGroupElement closestGel( closestResult.front().front());
217  float rWindow = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
218 
219  if(!overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow)) {
220  result.swap(closestResult);
221  return;
222  }
223 
224 
225  auto & nextResult = groupsAtRingLevel[index(1)];
226  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, nextResult);
227  if(nextResult.empty()) {
228  result.swap(closestResult);
229  return;
230  }
231 
232  if(!overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow) ) {
233  //then merge 2 levels & return
234  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,result);
235  return;
236  }
237 
238  auto & nextNextResult = groupsAtRingLevel[index(2)];
239  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, nextNextResult);
240  if(nextNextResult.empty()) {
241  // then merge 2 levels and return
242  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel,result); //
243  return;
244  }
245 
246  // merge 3 level and return merged
247  orderAndMergeLevels(closestGel.trajectoryState(),prop,groupsAtRingLevel, result);
248 }
int i
Definition: DBlmapReader.cc:9
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
Definition: TIDLayer.cc:252
#define constexpr
tuple result
Definition: query.py:137
bool overlapInR(const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
Definition: TIDLayer.cc:356
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
Definition: TIDLayer.cc:304
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 356 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV().

357 {
358  // assume "fixed theta window", i.e. margin in local y = r is changing linearly with z
359  float tsRadius = tsos.globalPosition().perp();
360  float thetamin = ( max(0.,tsRadius-ymax))/(std::abs(tsos.globalPosition().z())+10.f); // add 10 cm contingency
361  float thetamax = ( tsRadius + ymax)/(std::abs(tsos.globalPosition().z())-10.f);
362 
363  // do the theta regions overlap ?
364 
365  return !( thetamin > ringPars[index].thetaRingMax || ringPars[index].thetaRingMin > thetamax);
366 }
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 252 of file TIDLayer.cc.

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

Referenced by groupedCompatibleDetsV().

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

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

Definition at line 65 of file TIDLayer.h.

Referenced by groupedCompatibleDetsV(), ringIndicesByCrossingProximity(), and ~TIDLayer().