CMS 3D CMS Logo

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

#include <TIBRing.h>

Inheritance diagram for TIBRing:
GeometricSearchDet

Classes

struct  SubRingCrossings
 

Public Member Functions

const std::vector< const GeomDet * > & basicComponents () const override
 
std::pair< bool, TrajectoryStateOnSurfacecompatible (const TrajectoryStateOnSurface &ts, const Propagator &, const MeasurementEstimator &) const override __attribute__((cold))
 
const std::vector< const GeometricSearchDet * > & components () const override __attribute__((cold))
 Returns basic components, if any. More...
 
void groupedCompatibleDetsV (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
 
virtual const BoundCylinderspecificSurface () const
 Return the ring surface as a. More...
 
const BoundSurfacesurface () const override
 The surface of the GeometricSearchDet. More...
 
 TIBRing (std::vector< const GeomDet *> &theGeomDets) __attribute__((cold))
 
 ~TIBRing () override __attribute__((cold))
 
- Public Member Functions inherited from GeometricSearchDet
virtual std::vector< DetWithStatecompatibleDets (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
 
virtual void compatibleDetsV (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetWithState > &result) const
 
 GeometricSearchDet (bool doHaveGroups)
 
virtual std::vector< DetGroupgroupedCompatibleDets (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
 
bool hasGroups () const
 
virtual const Surface::PositionTypeposition () const
 Returns position of the surface. More...
 
virtual ~GeometricSearchDet ()
 

Private Types

typedef PeriodicBinFinderInPhi< float > BinFinderType
 

Private Member Functions

void checkPeriodicity (std::vector< const GeomDet *>::const_iterator first, std::vector< const GeomDet *>::const_iterator last) __attribute__((cold))
 
void checkRadius (std::vector< const GeomDet *>::const_iterator first, std::vector< const GeomDet *>::const_iterator last) __attribute__((cold))
 
std::optional< SubRingCrossingscomputeCrossings (const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const __attribute__((hot))
 
void computeHelicity () __attribute__((cold))
 
float computeWindowSize (const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
 
void searchNeighbors (const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubRingCrossings &crossings, float window, std::vector< DetGroup > &result) const __attribute__((hot))
 

Private Attributes

BinFinderType theBinFinder
 
ReferenceCountingPointer< BoundCylindertheCylinder
 
std::vector< const GeomDet * > theDets
 
int theHelicity
 

Additional Inherited Members

- Public Types inherited from GeometricSearchDet
typedef std::pair< const GeomDet *, TrajectoryStateOnSurfaceDetWithState
 
typedef BoundSurface::PositionType PositionType
 
typedef BoundSurface::RotationType RotationType
 
typedef TrajectoryStateOnSurface TrajectoryState
 
- Protected Attributes inherited from GeometricSearchDet
bool haveGroups
 
GeomDetCompatibilityChecker theCompatibilityChecker
 

Detailed Description

A concrete implementation for TIB rings

Definition at line 14 of file TIBRing.h.

Member Typedef Documentation

◆ BinFinderType

Definition at line 76 of file TIBRing.h.

Constructor & Destructor Documentation

◆ TIBRing()

TIBRing::TIBRing ( std::vector< const GeomDet *> &  theGeomDets)

Definition at line 21 of file TIBRing.cc.

References computeHelicity(), mps_fire::i, LogDebug, theBinFinder, theCylinder, and theDets.

22  : GeometricSearchDet(true), theDets(theGeomDets.begin(), theGeomDets.end()) {
23  //checkRadius( first, last);
24  //sort( theDets.begin(), theDets.end(), DetLessPhi());
25  //checkPeriodicity( theDets.begin(), theDets.end());
26 
27  theBinFinder = BinFinderType(theDets.front()->surface().position().phi(), theDets.size());
28 
30 
32 
33  LogDebug("TkDetLayers") << "==== DEBUG TIBRing =====";
34  LogDebug("TkDetLayers") << "radius, thickness, lenght: " << theCylinder->radius() << " , "
35  << theCylinder->bounds().thickness() << " , " << theCylinder->bounds().length();
36 
37  for (vector<const GeomDet*>::const_iterator i = theDets.begin(); i != theDets.end(); i++) {
38  LogDebug("TkDetLayers") << "Ring's Det pos z,perp,eta,phi: " << (**i).position().z() << " , "
39  << (**i).position().perp() << " , " << (**i).position().eta() << " , "
40  << (**i).position().phi();
41  }
42  LogDebug("TkDetLayers") << "==== end DEBUG TIBRing =====";
43 }
BinFinderType theBinFinder
Definition: TIBRing.h:77
void computeHelicity() __attribute__((cold))
Definition: TIBRing.cc:85
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79
GeometricSearchDet(bool doHaveGroups)
ReferenceCountingPointer< BoundCylinder > theCylinder
Definition: TIBRing.h:80
PeriodicBinFinderInPhi< float > BinFinderType
Definition: TIBRing.h:76
#define LogDebug(id)

◆ ~TIBRing()

TIBRing::~TIBRing ( )
override

Definition at line 100 of file TIBRing.cc.

100 {}

Member Function Documentation

◆ basicComponents()

const std::vector<const GeomDet*>& TIBRing::basicComponents ( ) const
inlineoverridevirtual

Implements GeometricSearchDet.

Definition at line 22 of file TIBRing.h.

References theDets.

22 { return theDets; }
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79

◆ checkPeriodicity()

void TIBRing::checkPeriodicity ( std::vector< const GeomDet *>::const_iterator  first,
std::vector< const GeomDet *>::const_iterator  last 
)
private

Definition at line 64 of file TIBRing.cc.

References funct::abs(), dqmdumpme::first, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::last, Geom::pi(), stat_mean(), and theDets.

65  {
66  vector<double> adj_diff(last - first - 1);
67  for (int i = 0; i < static_cast<int>(adj_diff.size()); i++) {
68  vector<const GeomDet*>::const_iterator curent = first + i;
69  adj_diff[i] = (**(curent + 1)).surface().position().phi() - (**curent).surface().position().phi();
70  }
71  double step = stat_mean(adj_diff);
72  double phi_step = 2. * Geom::pi() / (last - first);
73 
74  if (std::abs(step - phi_step) / phi_step > 0.01) {
75  int ndets = last - first;
76  edm::LogError("TkDetLayers") << "TIBRing Warning: not periodic. ndets=" << ndets;
77  for (int j = 0; j < ndets; j++) {
78  edm::LogError("TkDetLayers") << "Dets(r,phi): (" << theDets[j]->surface().position().perp() << ","
79  << theDets[j]->surface().position().phi() << ") ";
80  }
81  throw DetLayerException("Error: TIBRing is not periodic");
82  }
83 }
Common base class.
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79
Log< level::Error, false > LogError
double stat_mean(const CONT &cont)
Definition: simple_stat.h:13
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
step
Definition: StallMonitor.cc:83
constexpr double pi()
Definition: Pi.h:31

◆ checkRadius()

void TIBRing::checkRadius ( std::vector< const GeomDet *>::const_iterator  first,
std::vector< const GeomDet *>::const_iterator  last 
)
private

Definition at line 49 of file TIBRing.cc.

References dqmdumpme::first, mps_fire::i, dqmdumpme::last, alignCSCRings::r, photonAnalyzer_cfi::rMax, and photonAnalyzer_cfi::rMin.

49  {
50  // check radius range
51  float rMin = 10000.;
52  float rMax = 0.;
53  for (vector<const GeomDet*>::const_iterator i = first; i != last; i++) {
54  float r = (**i).surface().position().perp();
55  if (r < rMin)
56  rMin = r;
57  if (r > rMax)
58  rMax = r;
59  }
60  if (rMax - rMin > 0.1)
61  throw DetLayerException("TIBRing construction failed: detectors not at constant radius");
62 }
Common base class.

◆ compatible()

pair< bool, TrajectoryStateOnSurface > TIBRing::compatible ( const TrajectoryStateOnSurface ts,
const Propagator ,
const MeasurementEstimator  
) const
overridevirtual

tests the geometrical compatibility of the Det with the predicted state. The FreeTrajectoryState argument is propagated to the Det surface using the Propagator argument. The resulting TrajectoryStateOnSurface is tested for compatibility with the surface bounds. If compatible, a std::pair< true, propagatedState> is returned. If the propagation fails, or if the state is not compatible, a std::pair< false, propagatedState> is returned.

Implements GeometricSearchDet.

Definition at line 102 of file TIBRing.cc.

104  {
105  edm::LogError("TkDetLayers") << "temporary dummy implementation of TIBRing::compatible()!!";
106  return pair<bool, TrajectoryStateOnSurface>();
107 }
Log< level::Error, false > LogError

◆ components()

const vector< const GeometricSearchDet * > & TIBRing::components ( ) const
overridevirtual

Returns basic components, if any.

Returns direct components, if any

Implements GeometricSearchDet.

Definition at line 45 of file TIBRing.cc.

45  {
46  throw DetLayerException("TIBRing doesn't have GeometricSearchDet components");
47 }
Common base class.

◆ computeCrossings()

std::optional< TIBRing::SubRingCrossings > TIBRing::computeCrossings ( const TrajectoryStateOnSurface startingState,
PropagationDirection  propDir 
) const
private

Definition at line 196 of file TIBRing.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::barePhi(), HelixBarrelCylinderCrossing::bestSol, PeriodicBinFinderInPhi< T >::binIndex(), HelixBarrelCylinderCrossing::direction(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), HelixBarrelCylinderCrossing::hasSolution(), Geom::phiLess(), GloballyPositioned< T >::position(), HelixBarrelCylinderCrossing::position(), rho, specificSurface(), surface(), theBinFinder, theDets, TrajectoryStateOnSurface::transverseCurvature(), and PV3DBase< T, PVType, FrameType >::x().

Referenced by groupedCompatibleDetsV().

197  {
198  typedef HelixBarrelPlaneCrossing2OrderLocal Crossing;
200 
201  GlobalPoint startPos(startingState.globalPosition());
202  GlobalVector startDir(startingState.globalMomentum());
203  auto rho = startingState.transverseCurvature();
204 
205  HelixBarrelCylinderCrossing cylCrossing(
206  startPos, startDir, rho, propDir, specificSurface(), HelixBarrelCylinderCrossing::bestSol);
207 
208  if (!cylCrossing.hasSolution())
209  return std::nullopt;
210 
211  GlobalPoint cylPoint(cylCrossing.position());
212  GlobalVector cylDir(cylCrossing.direction());
213  int closestIndex = theBinFinder.binIndex(cylPoint.barePhi());
214 
215  const Plane& closestPlane(theDets[closestIndex]->surface());
216 
217  LocalPoint closestPos = Crossing::positionOnly(cylPoint, cylDir, rho, closestPlane);
218  float closestDist = closestPos.x(); // use fact that local X perp to global Z
219 
220  //int next = cylPoint.phi() - closestPlane.position().phi() > 0 ? closest+1 : closest-1;
221  int nextIndex =
222  Geom::phiLess(closestPlane.position().barePhi(), cylPoint.barePhi()) ? closestIndex + 1 : closestIndex - 1;
223 
224  const Plane& nextPlane(theDets[theBinFinder.binIndex(nextIndex)]->surface());
225  LocalPoint nextPos = Crossing::positionOnly(cylPoint, cylDir, rho, nextPlane);
226  float nextDist = nextPos.x();
227 
228  if (std::abs(closestDist) < std::abs(nextDist)) {
229  return SubRingCrossings(closestIndex, nextIndex, nextDist);
230  } else {
231  return SubRingCrossings(nextIndex, closestIndex, closestDist);
232  }
233 }
const BoundSurface & surface() const override
The surface of the GeometricSearchDet.
Definition: TIBRing.h:20
BinFinderType theBinFinder
Definition: TIBRing.h:77
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79
Definition: Plane.h:16
T x() const
Definition: PV3DBase.h:59
GlobalPoint globalPosition() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
virtual const BoundCylinder & specificSurface() const
Return the ring surface as a.
Definition: TIBRing.h:39
GlobalVector globalMomentum() const
Vector2DBase< float, LocalTag > Local2DVector

◆ computeHelicity()

void TIBRing::computeHelicity ( )
private

Definition at line 85 of file TIBRing.cc.

References normal, PV3DBase< T, PVType, FrameType >::phi(), Geom::phiLess(), GloballyPositioned< T >::position(), GeomDet::surface(), theDets, theHelicity, and Surface::toGlobal().

Referenced by TIBRing().

85  {
86  const GeomDet& det = *theDets.front();
87  GlobalVector radial = det.surface().position() - GlobalPoint(0, 0, 0);
89  if (normal.dot(radial) <= 0)
90  normal *= -1;
91  // edm::LogInfo(TkDetLayers) << "BarrelDetRing::computeHelicity: phi(normal) " << normal.phi()
92  // << " phi(radial) " << radial.phi() ;
93  if (Geom::phiLess(normal.phi(), radial.phi())) {
94  theHelicity = 1; // smaller phi angles mean "inner" group
95  } else {
96  theHelicity = 0; // smaller phi angles mean "outer" group
97  }
98 }
Local3DVector LocalVector
Definition: LocalVector.h:12
static const char * normal
Definition: DMRtrends.cc:35
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79
int theHelicity
Definition: TIBRing.h:81
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const PositionType & position() const

◆ computeWindowSize()

float TIBRing::computeWindowSize ( const GeomDet det,
const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const
private

Definition at line 235 of file TIBRing.cc.

References MeasurementEstimator::maximalLocalDisplacement(), GeomDet::surface(), and x.

Referenced by groupedCompatibleDetsV().

237  {
238  return est.maximalLocalDisplacement(tsos, det->surface()).x();
239 }
virtual Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const Plane &plane) const =0
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37

◆ groupedCompatibleDetsV()

void TIBRing::groupedCompatibleDetsV ( const TrajectoryStateOnSurface startingState,
const Propagator prop,
const MeasurementEstimator est,
std::vector< DetGroup > &  result 
) const
overridevirtual

Reimplemented from GeometricSearchDet.

Definition at line 109 of file TIBRing.cc.

References PVValHelper::add(), LayerCrossingSide::barrelSide(), PeriodicBinFinderInPhi< T >::binIndex(), computeCrossings(), computeWindowSize(), f, eostools::move(), DetGroupMerger::orderAndMergeTwoLevels(), Propagator::propagationDirection(), mps_fire::result, searchNeighbors(), theBinFinder, theDets, theHelicity, and svgfig::window().

112  {
113  vector<DetGroup> closestResult;
114  auto crossings = computeCrossings(tsos, prop.propagationDirection());
115  if (not crossings)
116  return;
117 
118  typedef CompatibleDetToGroupAdder Adder;
119  Adder::add(*theDets[theBinFinder.binIndex(crossings->closestIndex)], tsos, prop, est, closestResult);
120 
121  if (closestResult.empty()) {
122  Adder::add(*theDets[theBinFinder.binIndex(crossings->nextIndex)], tsos, prop, est, result);
123  return;
124  }
125 
126  DetGroupElement closestGel(closestResult.front().front());
127  float window = computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
128 
129  float detWidth = closestGel.det()->surface().bounds().width();
130  if (crossings->nextDistance < detWidth + window) {
131  vector<DetGroup> nextResult;
132  if (Adder::add(*theDets[theBinFinder.binIndex(crossings->nextIndex)], tsos, prop, est, nextResult)) {
133  int crossingSide = LayerCrossingSide::barrelSide(tsos, prop);
134  if (crossings->closestIndex < crossings->nextIndex) {
136  std::move(closestResult), std::move(nextResult), result, theHelicity, crossingSide);
137  } else {
139  std::move(nextResult), std::move(closestResult), result, theHelicity, crossingSide);
140  }
141  } else {
142  result.swap(closestResult);
143  }
144  } else {
145  result.swap(closestResult);
146  }
147 
148  // only loop over neighbors (other than closest and next) if window is BIG
149  if (window > 0.5f * detWidth) {
150  searchNeighbors(tsos, prop, est, *crossings, window, result);
151  }
152 }
static int barrelSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
returns 0 if barrel layer crossed from inside, 1 if from outside
BinFinderType theBinFinder
Definition: TIBRing.h:77
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
std::optional< SubRingCrossings > computeCrossings(const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const __attribute__((hot))
Definition: TIBRing.cc:196
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
int theHelicity
Definition: TIBRing.h:81
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const __attribute__((hot))
Definition: TIBRing.cc:235
double f[11][100]
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubRingCrossings &crossings, float window, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TIBRing.cc:154
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
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:511

◆ searchNeighbors()

void TIBRing::searchNeighbors ( const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est,
const SubRingCrossings crossings,
float  window,
std::vector< DetGroup > &  result 
) const
private

Definition at line 154 of file TIBRing.cc.

References PVValHelper::add(), LayerCrossingSide::barrelSide(), PeriodicBinFinderInPhi< T >::binIndex(), TIBRing::SubRingCrossings::closestIndex, SiStripPI::max, HLT_2024v10_cff::Merger, SiStripPI::min, eostools::move(), TIBRing::SubRingCrossings::nextIndex, mps_fire::result, theBinFinder, theDets, and theHelicity.

Referenced by groupedCompatibleDetsV().

159  {
160  typedef CompatibleDetToGroupAdder Adder;
161  int crossingSide = LayerCrossingSide::barrelSide(tsos, prop);
162  typedef DetGroupMerger Merger;
163 
164  int negStart = std::min(crossings.closestIndex, crossings.nextIndex) - 1;
165  int posStart = std::max(crossings.closestIndex, crossings.nextIndex) + 1;
166 
167  int quarter = theDets.size() / 4;
168  for (int idet = negStart; idet >= negStart - quarter + 1; idet--) {
169  const GeomDet* neighbor = theDets[theBinFinder.binIndex(idet)];
170  // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
171  // maybe also add shallow crossing angle test here???
172  vector<DetGroup> tmp1;
173  if (!Adder::add(*neighbor, tsos, prop, est, tmp1))
174  break;
175  vector<DetGroup> tmp2;
176  tmp2.swap(result);
177  vector<DetGroup> newResult;
178  Merger::orderAndMergeTwoLevels(std::move(tmp1), std::move(tmp2), newResult, theHelicity, crossingSide);
179  result.swap(newResult);
180  }
181  for (int idet = posStart; idet < posStart + quarter - 1; idet++) {
182  const GeomDet* neighbor = theDets[theBinFinder.binIndex(idet)];
183  // if (!overlap( gCrossingPos, *neighbor, window)) break; // mybe not needed?
184  // maybe also add shallow crossing angle test here???
185  vector<DetGroup> tmp1;
186  if (!Adder::add(*neighbor, tsos, prop, est, tmp1))
187  break;
188  vector<DetGroup> tmp2;
189  tmp2.swap(result);
190  vector<DetGroup> newResult;
191  Merger::orderAndMergeTwoLevels(std::move(tmp2), std::move(tmp1), newResult, theHelicity, crossingSide);
192  result.swap(newResult);
193  }
194 }
static int barrelSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
returns 0 if barrel layer crossed from inside, 1 if from outside
BinFinderType theBinFinder
Definition: TIBRing.h:77
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
std::vector< const GeomDet * > theDets
Definition: TIBRing.h:79
int theHelicity
Definition: TIBRing.h:81
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
def move(src, dest)
Definition: eostools.py:511

◆ specificSurface()

virtual const BoundCylinder& TIBRing::specificSurface ( ) const
inlinevirtual

Return the ring surface as a.

Definition at line 39 of file TIBRing.h.

References theCylinder.

Referenced by computeCrossings().

39 { return *theCylinder; }
ReferenceCountingPointer< BoundCylinder > theCylinder
Definition: TIBRing.h:80

◆ surface()

const BoundSurface& TIBRing::surface ( ) const
inlineoverridevirtual

The surface of the GeometricSearchDet.

Implements GeometricSearchDet.

Definition at line 20 of file TIBRing.h.

References theCylinder.

Referenced by computeCrossings().

20 { return *theCylinder; }
ReferenceCountingPointer< BoundCylinder > theCylinder
Definition: TIBRing.h:80

Member Data Documentation

◆ theBinFinder

BinFinderType TIBRing::theBinFinder
private

Definition at line 77 of file TIBRing.h.

Referenced by computeCrossings(), groupedCompatibleDetsV(), searchNeighbors(), and TIBRing().

◆ theCylinder

ReferenceCountingPointer<BoundCylinder> TIBRing::theCylinder
private

Definition at line 80 of file TIBRing.h.

Referenced by specificSurface(), surface(), and TIBRing().

◆ theDets

std::vector<const GeomDet*> TIBRing::theDets
private

◆ theHelicity

int TIBRing::theHelicity
private

Definition at line 81 of file TIBRing.h.

Referenced by computeHelicity(), groupedCompatibleDetsV(), and searchNeighbors().