CMS 3D CMS Logo

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

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))
 
Phase2EndcapLayeroperator= (const Phase2EndcapLayer &)=delete
 
 Phase2EndcapLayer (std::vector< const Phase2EndcapRing * > &rings, const bool isOT) __attribute__((cold))
 
 Phase2EndcapLayer (const Phase2EndcapLayer &)=delete
 
virtual SubDetector subDetector () const
 
 ~Phase2EndcapLayer () __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 51 of file Phase2EndcapLayer.cc.

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

51  :
52  RingedForwardLayer(true),
53  isOuterTracker(isOT),
54  theComponents{nullptr}
55 {
56  //They should be already R-ordered. TO BE CHECKED!!
57  //sort( theRings.begin(), theRings.end(), DetLessR());
58 
59  theRingSize = rings.size();
60  LogDebug("TkDetLayers") << "Number of rings in Phase2 OT EC layer is " << theRingSize << std::endl;
61  setSurface( computeDisk( rings ) );
62 
63  for(unsigned int i=0; i!=rings.size(); ++i) {
64  theComps.push_back(rings[i]);
65  fillRingPars(i);
66  theBasicComps.insert(theBasicComps.end(),
67  (*rings[i]).basicComponents().begin(),
68  (*rings[i]).basicComponents().end());
69  }
70 
71 
72  LogDebug("TkDetLayers") << "==== DEBUG Phase2EndcapLayer =====" ;
73  LogDebug("TkDetLayers") << "r,zed pos , thickness, innerR, outerR: "
74  << this->position().perp() << " , "
75  << this->position().z() << " , "
76  << this->specificSurface().bounds().thickness() << " , "
77  << this->specificSurface().innerRadius() << " , "
78  << this->specificSurface().outerRadius() ;
79 }
#define LogDebug(id)
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
virtual const std::vector< const GeomDet * > & basicComponents() const
static int position[264][3]
Definition: ReadPGInfo.cc:509
Phase2EndcapLayer::~Phase2EndcapLayer ( )

Definition at line 113 of file Phase2EndcapLayer.cc.

References EnergyCorrector::c, theComponents, and theComps.

113  {
114  for (auto c : theComps) delete c;
115 
116  delete theComponents.load();
117 }
std::vector< const Phase2EndcapRing * > theComps
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Phase2EndcapLayer::Phase2EndcapLayer ( const Phase2EndcapLayer )
delete

Member Function Documentation

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

Definition at line 26 of file Phase2EndcapLayer.h.

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

Referenced by Phase2EndcapLayer().

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

Definition at line 22 of file Phase2EndcapLayer.cc.

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

Referenced by basicComponents().

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

Definition at line 83 of file Phase2EndcapLayer.cc.

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

Referenced by Phase2EndcapLayer(), and subDetector().

84 {
85  float theRmin = rings.front()->specificSurface().innerRadius();
86  float theRmax = rings.front()->specificSurface().outerRadius();
87  float theZmin = rings.front()->position().z() -
88  rings.front()->surface().bounds().thickness()/2;
89  float theZmax = rings.front()->position().z() +
90  rings.front()->surface().bounds().thickness()/2;
91 
92  for (vector<const Phase2EndcapRing*>::const_iterator i = rings.begin(); i != rings.end(); i++) {
93  float rmin = (**i).specificSurface().innerRadius();
94  float rmax = (**i).specificSurface().outerRadius();
95  float zmin = (**i).position().z() - (**i).surface().bounds().thickness()/2.;
96  float zmax = (**i).position().z() + (**i).surface().bounds().thickness()/2.;
97  theRmin = min( theRmin, rmin);
98  theRmax = max( theRmax, rmax);
99  theZmin = min( theZmin, zmin);
100  theZmax = max( theZmax, zmax);
101  }
102 
103  float zPos = (theZmax+theZmin)/2.;
104  PositionType pos(0.,0.,zPos);
106 
107  return new BoundDisk( pos, rot, new SimpleDiskBounds(theRmin, theRmax,
108  theZmin-zPos, theZmax-zPos));
109 
110 }
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 Phase2EndcapLayer::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const
private

Definition at line 298 of file Phase2EndcapLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

301 {
302  const Plane& startPlane = det->surface();
304  est.maximalLocalDisplacement( tsos, startPlane);
305  return maxDistance.y();
306 }
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 Phase2EndcapLayer::fillRingPars ( int  i)
private

Definition at line 38 of file Phase2EndcapLayer.cc.

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

Referenced by Phase2EndcapLayer(), and subDetector().

38  {
39  const BoundDisk& ringDisk = static_cast<const BoundDisk&>(theComps[i]->surface());
40  float ringMinZ = std::abs( ringDisk.position().z()) - ringDisk.bounds().thickness()/2.;
41  float ringMaxZ = std::abs( ringDisk.position().z()) + ringDisk.bounds().thickness()/2.;
42  RingPar tempPar;
43  tempPar.thetaRingMin = ringDisk.innerRadius()/ ringMaxZ;
44  tempPar.thetaRingMax = ringDisk.outerRadius()/ ringMinZ;
45  tempPar.theRingR=( ringDisk.innerRadius() +
46  ringDisk.outerRadius())/2.;
47  ringPars.push_back(tempPar);
48 }
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 309 of file Phase2EndcapLayer.cc.

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

Referenced by ringIndicesByCrossingProximity(), and subDetector().

310 {
311  std::array<int,3> theBins={{-1,-1,-1}};
312  theBins[0] = 0;
313  float initialR = ringPars[0].theRingR;
314  float rDiff0 = std::abs( ringCrossing[0].perp() - initialR);
315  float rDiff1 = -1.;
316  float rDiff2 = -1.;
317  for (int i = 1; i < theRingSize ; i++){
318  float ringR = ringPars[i].theRingR;
319  float testDiff = std::abs( ringCrossing[i].perp() - ringR);
320  if ( testDiff<rDiff0 ) {
321  rDiff2 = rDiff1;
322  rDiff1 = rDiff0;
323  rDiff0 = testDiff;
324  theBins[2] = theBins[1];
325  theBins[1] = theBins[0];
326  theBins[0] = i;
327  }
328  else
329  if ( rDiff1 < 0 || testDiff<rDiff1 ) {
330  rDiff2 = rDiff1;
331  rDiff1 = testDiff;
332  theBins[2] = theBins[1];
333  theBins[1] = i;
334  }
335  else
336  if ( rDiff2 < 0 || testDiff<rDiff2 ) {
337  rDiff2 = testDiff;
338  theBins[2] = i;
339  }
340  }
341 
342  return theBins;
343 }
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

Definition at line 122 of file Phase2EndcapLayer.cc.

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

Referenced by basicComponents().

126 {
127  std::array<int,3> const & ringIndices = ringIndicesByCrossingProximity(startingState,prop);
128  if ( ringIndices[0]==-1 || ringIndices[1] ==-1 || ringIndices[2] == -1 ) {
129  edm::LogError("TkDetLayers") << "TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
130  return;
131  }
132 
133  //order is: rings in front = 0; rings in back = 1
134  //rings should be already ordered in r
135  //if the layer has 1 ring, it does not matter
136  //FIXME: to be optimized once the geometry is stable
137  std::vector<int> ringOrder(theRingSize);
138  std::fill(ringOrder.begin(), ringOrder.end(), 1);
139  if (theRingSize > 1){
140  if(fabs(theComps[0]->position().z()) < fabs(theComps[1]->position().z())){
141  for (int i=0; i<theRingSize; i++) {
142  if(i % 2 == 0) ringOrder[i] = 0;
143  }
144  } else if(fabs(theComps[0]->position().z()) > fabs(theComps[1]->position().z())){
145  std::fill(ringOrder.begin(), ringOrder.end(), 0);
146  for (int i=0; i<theRingSize; i++) {
147  if(i % 2 == 0) ringOrder[i] = 1;
148  }
149  } else {
150  throw DetLayerException("Rings in Endcap Layer have same z position, no idea how to order them!");
151  }
152  }
153 
154  auto index = [&ringIndices,& ringOrder](int i) { return ringOrder[ringIndices[i]];};
155 
156  std::vector<DetGroup> closestResult;
157  theComps[ringIndices[0]]->groupedCompatibleDetsV( startingState, prop, est, closestResult);
158  // if the closest is empty, use the next one and exit: inherited from TID !
159  if ( closestResult.empty() ){
160  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, result);
161  return;
162  }
163 
164  DetGroupElement closestGel( closestResult.front().front());
165  float rWindow = computeWindowSize( closestGel.det(), closestGel.trajectoryState(), est);
166 
167  // check if next ring and next next ring are found and if there is overlap
168 
169  bool ring1ok = ringIndices[1] != -1 && overlapInR(closestGel.trajectoryState(),ringIndices[1],rWindow);
170  bool ring2ok = ringIndices[2] != -1 && overlapInR(closestGel.trajectoryState(),ringIndices[2],rWindow);
171 
172  // look for the two rings in the same plane (are they only two?)
173 
174  // determine if we are propagating from in to out (0) or from out to in (1)
175 
176  int direction = 0;
177  if(startingState.globalPosition().z()*startingState.globalMomentum().z()>0) {
178  if(prop.propagationDirection() == alongMomentum) direction=0;
179  else direction=1;
180  }
181  else{
182  if(prop.propagationDirection() == alongMomentum) direction=1;
183  else direction=0;
184  }
185 
186  if((index(0) == index(1)) && (index(0) == index(2))) {
187  edm::LogInfo("AllRingsInOnePlane") << " All rings: "
188  << ringIndices[0] << " "
189  << ringIndices[1] << " "
190  << ringIndices[2] << " in one plane. Only the first two will be considered";
191  ring2ok=false;
192  }
193 
194  if(index(0) == index(1)) {
195  if(ring1ok) {
196  std::vector<DetGroup> ring1res;
197  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, ring1res);
198  DetGroupMerger::addSameLevel(std::move(ring1res),closestResult);
199  }
200  if(ring2ok) {
201  std::vector<DetGroup> ring2res;
202  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, ring2res);
203  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(ring2res),result,index(0),direction);
204  return;
205  }
206  else {
207  result.swap(closestResult);
208  return;
209  }
210  }
211  else if(index(0) == index(2)) {
212  if(ring2ok) {
213  std::vector<DetGroup> ring2res;
214  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, ring2res);
215  DetGroupMerger::addSameLevel(std::move(ring2res),closestResult);
216  }
217  if(ring1ok) {
218  std::vector<DetGroup> ring1res;
219  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, ring1res);
220  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(ring1res),result,index(0),direction);
221  return;
222  }
223  else {
224  result.swap(closestResult);
225  return;
226  }
227  }
228  else {
229  std::vector<DetGroup> ring12res;
230  if(ring1ok) {
231  std::vector<DetGroup> ring1res;
232  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, ring1res);
233  ring12res.swap(ring1res);
234  }
235  if(ring2ok) {
236  std::vector<DetGroup> ring2res;
237  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, ring2res);
238  DetGroupMerger::addSameLevel(std::move(ring2res),ring12res);
239  }
240  if(!ring12res.empty()) {
241  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(ring12res),result,index(0),direction);
242  return;
243  }
244  else {
245  result.swap(closestResult);
246  return;
247  }
248  }
249 }
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))
static void addSameLevel(std::vector< DetGroup > &&gvec, std::vector< DetGroup > &result)
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
static int position[264][3]
Definition: ReadPGInfo.cc:509
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
def move(src, dest)
Definition: eostools.py:510
Phase2EndcapLayer& Phase2EndcapLayer::operator= ( const Phase2EndcapLayer )
delete
bool Phase2EndcapLayer::overlapInR ( const TrajectoryStateOnSurface tsos,
int  i,
double  ymax 
) const
private

Definition at line 346 of file Phase2EndcapLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

347 {
348  // assume "fixed theta window", i.e. margin in local y = r is changing linearly with z
349  float tsRadius = tsos.globalPosition().perp();
350  float thetamin = ( max(0.,tsRadius-ymax))/(std::abs(tsos.globalPosition().z())+10.f); // add 10 cm contingency
351  float thetamax = ( tsRadius + ymax)/(std::abs(tsos.globalPosition().z())-10.f);
352 
353  // do the theta regions overlap ?
354 
355  return !( thetamin > ringPars[index].thetaRingMax || ringPars[index].thetaRingMin > thetamax);
356 }
T perp() const
Definition: PV3DBase.h:72
GlobalPoint globalPosition() const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
std::vector< RingPar > ringPars
std::array< int, 3 > Phase2EndcapLayer::ringIndicesByCrossingProximity ( const TrajectoryStateOnSurface startingState,
const Propagator prop 
) const
private

Definition at line 253 of file Phase2EndcapLayer.cc.

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

Referenced by groupedCompatibleDetsV(), and subDetector().

255 {
256  typedef HelixForwardPlaneCrossing Crossing;
258 
259  HelixPlaneCrossing::PositionType startPos( startingState.globalPosition());
260  HelixPlaneCrossing::DirectionType startDir( startingState.globalMomentum());
262  float rho( startingState.transverseCurvature());
263 
264  // calculate the crossings with the ring surfaces
265  // rings are assumed to be sorted in R !
266 
267  Crossing myXing( startPos, startDir, rho, propDir );
268 
269  std::vector<GlobalPoint> ringCrossings;
270  ringCrossings.reserve(theRingSize);
271  // vector<GlobalVector> ringXDirections;
272 
273  for (int i = 0; i < theRingSize ; i++ ) {
274  const BoundDisk & theRing = static_cast<const BoundDisk &>(theComps[i]->surface());
275  pair<bool,double> pathlen = myXing.pathLength( theRing);
276  if ( pathlen.first ) {
277  ringCrossings.push_back(GlobalPoint( myXing.position(pathlen.second )));
278  // ringXDirections.push_back( GlobalVector( myXing.direction(pathlen.second )));
279  } else {
280  // TO FIX.... perhaps there is something smarter to do
281  //throw DetLayerException("trajectory doesn't cross TID rings");
282  ringCrossings.push_back(GlobalPoint( 0.,0.,0.));
283  // ringXDirections.push_back( GlobalVector( 0.,0.,0.));
284  }
285  }
286 
287  //find three closest rings to the crossing
288 
289  std::array<int,3> closests = findThreeClosest(ringCrossings);
290 
291  return closests;
292 }
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
Vector2DBase< float, LocalTag > Local2DVector
PropagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
GlobalVector globalMomentum() const
virtual SubDetector Phase2EndcapLayer::subDetector ( ) const
inlinevirtual

Member Data Documentation

const bool Phase2EndcapLayer::isOuterTracker
private

Definition at line 63 of file Phase2EndcapLayer.h.

Referenced by subDetector().

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

Definition at line 67 of file Phase2EndcapLayer.h.

Referenced by findThreeClosest(), and overlapInR().

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

Definition at line 62 of file Phase2EndcapLayer.h.

Referenced by basicComponents(), and Phase2EndcapLayer().

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

Definition at line 64 of file Phase2EndcapLayer.h.

Referenced by ~Phase2EndcapLayer().

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