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
Phase2OTECRingedLayer Class Reference

#include <Phase2OTECRingedLayer.h>

Inheritance diagram for Phase2OTECRingedLayer:
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))
 
Phase2OTECRingedLayeroperator= (const Phase2OTECRingedLayer &)=delete
 
 Phase2OTECRingedLayer (std::vector< const Phase2OTECRing * > &rings) __attribute__((cold))
 
 Phase2OTECRingedLayer (const Phase2OTECRingedLayer &)=delete
 
virtual SubDetector subDetector () const
 
 ~Phase2OTECRingedLayer () __attribute__((cold))
 

Private Member Functions

BoundDiskcomputeDisk (const std::vector< const Phase2OTECRing * > &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 (const GlobalPoint[15]) 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 [15]
 
std::vector< GeomDet const * > theBasicComps
 
std::atomic< std::vector
< const GeometricSearchDet * > * > 
theComponents
 
const Phase2OTECRingtheComps [15]
 

Detailed Description

A concrete implementation for Phase 2 OT EC layer built out of Phase2OTECRings

Definition at line 16 of file Phase2OTECRingedLayer.h.

Constructor & Destructor Documentation

Phase2OTECRingedLayer::Phase2OTECRingedLayer ( std::vector< const Phase2OTECRing * > &  rings)

Definition at line 50 of file Phase2OTECRingedLayer.cc.

50  :
51  RingedForwardLayer(true),
52  theComponents{nullptr}
53 {
54  //They should be already R-ordered. TO BE CHECKED!!
55  //sort( theRings.begin(), theRings.end(), DetLessR());
56 
57  if ( rings.size() != NOTECRINGS) throw DetLayerException("Number of rings in Phase2 OT EC layer is not equal to NOTECRINGS !!");
58  setSurface( computeDisk( rings ) );
59 
60  for(int i=0; i!=NOTECRINGS; ++i) {
61  theComps[i]=rings[i];
62  fillRingPars(i);
63  theBasicComps.insert(theBasicComps.end(),
64  (*rings[i]).basicComponents().begin(),
65  (*rings[i]).basicComponents().end());
66  }
67 
68 
69  LogDebug("TkDetLayers") << "==== DEBUG Phase2OTECRingedLayer =====" ;
70  LogDebug("TkDetLayers") << "r,zed pos , thickness, innerR, outerR: "
71  << this->position().perp() << " , "
72  << this->position().z() << " , "
73  << this->specificSurface().bounds().thickness() << " , "
74  << this->specificSurface().innerRadius() << " , "
75  << this->specificSurface().outerRadius() ;
76 }
#define LogDebug(id)
Common base class.
void fillRingPars(int i) __attribute__((cold))
int i
Definition: DBlmapReader.cc:9
ForwardDetLayer RingedForwardLayer
const Phase2OTECRing * theComps[15]
BoundDisk * computeDisk(const std::vector< const Phase2OTECRing * > &rings) const __attribute__((cold))
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
static int position[264][3]
Definition: ReadPGInfo.cc:509
virtual const std::vector< const GeomDet * > & basicComponents() const
#define NOTECRINGS
std::vector< GeomDet const * > theBasicComps
Phase2OTECRingedLayer::~Phase2OTECRingedLayer ( )

Definition at line 110 of file Phase2OTECRingedLayer.cc.

References EnergyCorrector::c, theComponents, and theComps.

110  {
111  for (auto c : theComps) delete c;
112 
113  delete theComponents.load();
114 }
const Phase2OTECRing * theComps[15]
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
Phase2OTECRingedLayer::Phase2OTECRingedLayer ( const Phase2OTECRingedLayer )
delete

Member Function Documentation

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

Definition at line 27 of file Phase2OTECRingedLayer.h.

References theBasicComps.

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

Definition at line 22 of file Phase2OTECRingedLayer.cc.

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

22  {
23  if (not theComponents) {
24  std::unique_ptr<std::vector<const GeometricSearchDet*>> temp( new std::vector<const GeometricSearchDet*>() );
25  temp->reserve(NOTECRINGS);
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  }
const Phase2OTECRing * theComps[15]
std::atomic< std::vector< const GeometricSearchDet * > * > theComponents
#define NOTECRINGS
BoundDisk * Phase2OTECRingedLayer::computeDisk ( const std::vector< const Phase2OTECRing * > &  rings) const
private

Definition at line 80 of file Phase2OTECRingedLayer.cc.

References i, bookConverter::max, min(), makeMuonMisalignmentScenario::rot, SiStripMonitorClusterAlca_cfi::zmax, SiStripMonitorClusterAlca_cfi::zmin, and zPos.

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

Definition at line 275 of file Phase2OTECRingedLayer.cc.

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

Referenced by groupedCompatibleDetsV().

278 {
279  const Plane& startPlane = det->surface();
281  est.maximalLocalDisplacement( tsos, startPlane);
282  return maxDistance.y();
283 }
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 Phase2OTECRingedLayer::fillRingPars ( int  i)
private

Definition at line 38 of file Phase2OTECRingedLayer.cc.

References funct::abs(), and i.

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  ringPars[i].thetaRingMin = ringDisk.innerRadius()/ ringMaxZ;
43  ringPars[i].thetaRingMax = ringDisk.outerRadius()/ ringMinZ;
44  ringPars[i].theRingR=( ringDisk.innerRadius() +
45  ringDisk.outerRadius())/2.;
46 
47 }
int i
Definition: DBlmapReader.cc:9
const Phase2OTECRing * theComps[15]
virtual const BoundSurface & surface() const
The surface of the GeometricSearchDet.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::array< int, 3 > Phase2OTECRingedLayer::findThreeClosest ( const GlobalPoint  ringCrossing[15]) const
private

Definition at line 286 of file Phase2OTECRingedLayer.cc.

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

Referenced by ringIndicesByCrossingProximity().

287 {
288  std::array<int,3> theBins={{-1,-1,-1}};
289  theBins[0] = 0;
290  float initialR = ringPars[0].theRingR;
291  float rDiff0 = std::abs( ringCrossing[0].perp() - initialR);
292  float rDiff1 = -1.;
293  float rDiff2 = -1.;
294  for (int i = 1; i < NOTECRINGS ; i++){
295  float ringR = ringPars[i].theRingR;
296  float testDiff = std::abs( ringCrossing[i].perp() - ringR);
297  if ( testDiff<rDiff0 ) {
298  rDiff2 = rDiff1;
299  rDiff1 = rDiff0;
300  rDiff0 = testDiff;
301  theBins[2] = theBins[1];
302  theBins[1] = theBins[0];
303  theBins[0] = i;
304  }
305  else
306  if ( rDiff1 < 0 || testDiff<rDiff1 ) {
307  rDiff2 = rDiff1;
308  rDiff1 = testDiff;
309  theBins[2] = theBins[1];
310  theBins[1] = i;
311  }
312  else
313  if ( rDiff2 < 0 || testDiff<rDiff2 ) {
314  rDiff2 = testDiff;
315  theBins[2] = i;
316  }
317  }
318 
319  return theBins;
320 }
int i
Definition: DBlmapReader.cc:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T perp() const
Magnitude of transverse component.
#define NOTECRINGS
void Phase2OTECRingedLayer::groupedCompatibleDetsV ( const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est,
std::vector< DetGroup > &  result 
) const

Definition at line 119 of file Phase2OTECRingedLayer.cc.

References DetGroupMerger::addSameLevel(), alongMomentum, computeWindowSize(), constexpr, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), Phase2OTECRing::groupedCompatibleDetsV(), i, cmsHarvester::index, NOTECRINGS, DetGroupMerger::orderAndMergeTwoLevels(), overlapInR(), Propagator::propagationDirection(), ringIndicesByCrossingProximity(), theComps, and PV3DBase< T, PVType, FrameType >::z().

123 {
124  std::array<int,3> const & ringIndices = ringIndicesByCrossingProximity(startingState,prop);
125  if ( ringIndices[0]==-1 || ringIndices[1] ==-1 || ringIndices[2] == -1 ) {
126  edm::LogError("TkDetLayers") << "TkRingedForwardLayer::groupedCompatibleDets : error in CrossingProximity";
127  return;
128  }
129 
130  //order is odd rings in front of even rings
131  constexpr int ringOrder[NOTECRINGS]{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0};
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) direction=0;
157  else direction=1;
158  }
159  else{
160  if(prop.propagationDirection() == alongMomentum) direction=1;
161  else direction=0;
162  }
163 
164  if((index(0) == index(1)) && (index(0) == index(2))) {
165  edm::LogInfo("AllRingsInOnePlane") << " All rings: "
166  << ringIndices[0] << " "
167  << ringIndices[1] << " "
168  << ringIndices[2] << " in one plane. Only the first two will be considered";
169  ring2ok=false;
170  }
171 
172  if(index(0) == index(1)) {
173  if(ring1ok) {
174  std::vector<DetGroup> ring1res;
175  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, ring1res);
176  DetGroupMerger::addSameLevel(std::move(ring1res),closestResult);
177  }
178  if(ring2ok) {
179  std::vector<DetGroup> ring2res;
180  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, ring2res);
181  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(ring2res),result,index(0),direction);
182  return;
183  }
184  else {
185  result.swap(closestResult);
186  return;
187  }
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);
198  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(ring1res),result,index(0),direction);
199  return;
200  }
201  else {
202  result.swap(closestResult);
203  return;
204  }
205  }
206  else {
207  std::vector<DetGroup> ring12res;
208  if(ring1ok) {
209  std::vector<DetGroup> ring1res;
210  theComps[ringIndices[1]]->groupedCompatibleDetsV( startingState, prop, est, ring1res);
211  ring12res.swap(ring1res);
212  }
213  if(ring2ok) {
214  std::vector<DetGroup> ring2res;
215  theComps[ringIndices[2]]->groupedCompatibleDetsV( startingState, prop, est, ring2res);
216  DetGroupMerger::addSameLevel(std::move(ring2res),ring12res);
217  }
218  if(!ring12res.empty()) {
219  DetGroupMerger::orderAndMergeTwoLevels(std::move(closestResult),std::move(ring12res),result,index(0),direction);
220  return;
221  }
222  else {
223  result.swap(closestResult);
224  return;
225  }
226  }
227 }
int i
Definition: DBlmapReader.cc:9
virtual PropagationDirection propagationDirection() const
Definition: Propagator.h:155
const Phase2OTECRing * theComps[15]
#define constexpr
static void addSameLevel(std::vector< DetGroup > &&gvec, std::vector< DetGroup > &result)
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const __attribute__((hot))
tuple result
Definition: query.py:137
bool overlapInR(const TrajectoryStateOnSurface &tsos, int i, double ymax) const __attribute__((hot))
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
std::array< int, 3 > ringIndicesByCrossingProximity(const TrajectoryStateOnSurface &startingState, const Propagator &prop) const
#define NOTECRINGS
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
Phase2OTECRingedLayer& Phase2OTECRingedLayer::operator= ( const Phase2OTECRingedLayer )
delete
bool Phase2OTECRingedLayer::overlapInR ( const TrajectoryStateOnSurface tsos,
int  i,
double  ymax 
) const
private

Definition at line 323 of file Phase2OTECRingedLayer.cc.

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

Referenced by groupedCompatibleDetsV().

324 {
325  // assume "fixed theta window", i.e. margin in local y = r is changing linearly with z
326  float tsRadius = tsos.globalPosition().perp();
327  float thetamin = ( max(0.,tsRadius-ymax))/(std::abs(tsos.globalPosition().z())+10.f); // add 10 cm contingency
328  float thetamax = ( tsRadius + ymax)/(std::abs(tsos.globalPosition().z())-10.f);
329 
330  // do the theta regions overlap ?
331 
332  return !( thetamin > ringPars[index].thetaRingMax || ringPars[index].thetaRingMin > thetamax);
333 }
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::array< int, 3 > Phase2OTECRingedLayer::ringIndicesByCrossingProximity ( const TrajectoryStateOnSurface startingState,
const Propagator prop 
) const
private

Definition at line 231 of file Phase2OTECRingedLayer.cc.

References findThreeClosest(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), i, NOTECRINGS, Propagator::propagationDirection(), rho, Phase2OTECRing::surface(), theComps, and TrajectoryStateOnSurface::transverseCurvature().

Referenced by groupedCompatibleDetsV().

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

Member Data Documentation

RingPar Phase2OTECRingedLayer::ringPars[15]
private

Definition at line 66 of file Phase2OTECRingedLayer.h.

Referenced by findThreeClosest(), and overlapInR().

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

Definition at line 62 of file Phase2OTECRingedLayer.h.

Referenced by basicComponents().

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

Definition at line 63 of file Phase2OTECRingedLayer.h.

Referenced by ~Phase2OTECRingedLayer().

const Phase2OTECRing* Phase2OTECRingedLayer::theComps[15]
private