CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MTDTrayBarrelLayer Class Reference

#include <MTDTrayBarrelLayer.h>

Inheritance diagram for MTDTrayBarrelLayer:
RodBarrelLayer

Public Member Functions

const std::vector< const GeomDet * > & basicComponents () const override
 
std::vector< DetWithStatecompatibleDets (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
 
const std::vector< const GeometricSearchDet * > & components () const override
 
std::vector< DetGroupgroupedCompatibleDets (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
 
 MTDTrayBarrelLayer (std::vector< const DetRod *> &rods)
 Constructor, takes ownership of pointers. More...
 
virtual const std::vector< const DetRod * > & rods () const
 Return the vector of rods. More...
 
SubDetector subDetector () const override
 
 ~MTDTrayBarrelLayer () override
 

Private Member Functions

float xError (const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
 

Private Attributes

bool isOverlapping
 
std::vector< const GeomDet * > theBasicComps
 
BaseBinFinder< double > * theBinFinder
 
std::vector< const GeometricSearchDet * > theComponents
 
std::vector< const DetRod * > theRods
 

Detailed Description

A cylinder composed of half-trays. Represents Barrel Timing Layer.

Author
L. Gray - FNAL

Definition at line 17 of file MTDTrayBarrelLayer.h.

Constructor & Destructor Documentation

◆ MTDTrayBarrelLayer()

MTDTrayBarrelLayer::MTDTrayBarrelLayer ( std::vector< const DetRod *> &  rods)

Constructor, takes ownership of pointers.

Definition at line 27 of file MTDTrayBarrelLayer.cc.

References basicComponents(), filterCSVwithJSON::copy, BarrelDetLayer::initialize(), isOverlapping, PhiBorderFinder::isPhiOverlapping(), PhiBorderFinder::isPhiPeriodic(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogTrace, precomputed_value_sort(), rods(), theBasicComps, theBinFinder, theComponents, and theRods.

28  : RodBarrelLayer(false), theRods(rods), theBinFinder(nullptr), isOverlapping(false) {
29  // Sort rods in phi
31 
32  theComponents.reserve(theRods.size());
33  std::copy(theRods.begin(), theRods.end(), back_inserter(theComponents));
34 
35  // Cache chamber pointers (the basic components_)
36  for (const auto& it : rods) {
37  vector<const GeomDet*> tmp2 = it->basicComponents();
38  theBasicComps.insert(theBasicComps.end(), tmp2.begin(), tmp2.end());
39  }
40 
41  // Initialize the binfinder
43  isOverlapping = bf.isPhiOverlapping();
44 
45  if (bf.isPhiPeriodic()) {
46  theBinFinder = new PeriodicBinFinderInPhi<double>(theRods.front()->position().phi(), theRods.size());
47  } else {
49  }
50 
51  // Compute the layer's surface and bounds (from the components())
53 
54  LogTrace("MTDDetLayers") << "Constructing MTDTrayBarrelLayer: " << basicComponents().size() << " Dets "
55  << theRods.size() << " Rods "
56  << " R: " << specificSurface().radius() << " Per.: " << bf.isPhiPeriodic()
57  << " Overl.: " << isOverlapping;
58 }
const std::vector< const GeomDet * > & basicComponents() const override
virtual void initialize()
std::vector< const DetRod * > theRods
#define LogTrace(id)
std::vector< const GeomDet * > theBasicComps
BarrelDetLayer RodBarrelLayer
virtual const std::vector< const DetRod * > & rods() const
Return the vector of rods.
void precomputed_value_sort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr, const Compare &comp)
BaseBinFinder< double > * theBinFinder
std::vector< const GeometricSearchDet * > theComponents

◆ ~MTDTrayBarrelLayer()

MTDTrayBarrelLayer::~MTDTrayBarrelLayer ( )
override

Definition at line 60 of file MTDTrayBarrelLayer.cc.

References mps_fire::i, theBinFinder, and theRods.

60  {
61  delete theBinFinder;
62  for (auto& i : theRods) {
63  delete i;
64  }
65 }
std::vector< const DetRod * > theRods
BaseBinFinder< double > * theBinFinder

Member Function Documentation

◆ basicComponents()

const std::vector<const GeomDet*>& MTDTrayBarrelLayer::basicComponents ( ) const
inlineoverride

Definition at line 26 of file MTDTrayBarrelLayer.h.

References theBasicComps.

Referenced by MTDTrayBarrelLayer().

26 { return theBasicComps; }
std::vector< const GeomDet * > theBasicComps

◆ compatibleDets()

vector< GeometricSearchDet::DetWithState > MTDTrayBarrelLayer::compatibleDets ( const TrajectoryStateOnSurface startingState,
const Propagator prop,
const MeasurementEstimator est 
) const
override

Definition at line 67 of file MTDTrayBarrelLayer.cc.

References BaseBinFinder< T >::binIndex(), Surface::bounds(), pv::closest(), GeometricSearchDet::compatibleDets(), TrajectoryStateOnSurface::globalPosition(), createfilelist::int, isOverlapping, TrajectoryStateOnSurface::localPosition(), LogTrace, GetRecoTauVFromDQM_MC_cff::next, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GloballyPositioned< T >::position(), mps_fire::result, DetRod::surface(), theBinFinder, theRods, Bounds::width(), PV3DBase< T, PVType, FrameType >::x(), and xError().

Referenced by groupedCompatibleDets().

68  {
69  vector<DetWithState> result;
70 
71  LogTrace("MTDDetLayers") << "MTDTrayBarrelLayer::compatibleDets, Cyl R: " << specificSurface().radius()
72  << " TSOS at R= " << startingState.globalPosition().perp()
73  << " phi= " << startingState.globalPosition().phi();
74 
75  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
76  if (!compat.first) {
77  LogTrace("MTDDetLayers") << " MTDTrayBarrelLayer::compatibleDets: not compatible"
78  << " (should not have been selected!)";
79  return vector<DetWithState>();
80  }
81 
82  TrajectoryStateOnSurface& tsos = compat.second;
83 
84  LogTrace("MTDDetLayers") << " MTDTrayBarrelLayer::compatibleDets, reached layer at: " << tsos.globalPosition()
85  << " R = " << tsos.globalPosition().perp() << " phi = " << tsos.globalPosition().phi();
86 
88  const DetRod* closestRod = theRods[closest];
89 
90  // Check the closest rod
91  LogTrace("MTDDetLayers") << " MTDTrayBarrelLayer::compatibleDets, closestRod: " << closest
92  << " phi : " << closestRod->surface().position().phi()
93  << " FTS phi: " << tsos.globalPosition().phi();
94 
95  result = closestRod->compatibleDets(tsos, prop, est);
96 
97 #ifdef EDM_ML_DEBUG
98  int nclosest = result.size(); // Debug counter
99 #endif
100 
101  bool checknext = false;
102  double dist;
103 
104  if (!result.empty()) {
105  // Check if the track go outside closest rod, then look for closest.
106  TrajectoryStateOnSurface& predictedState = result.front().second;
107  float xErr = xError(predictedState, est);
108  float halfWid = closestRod->surface().bounds().width() / 2.;
109  dist = predictedState.localPosition().x();
110 
111  // If the layer is overlapping, additionally reduce halfWid by 10%
112  // to account for overlap.
113  // FIXME: should we account for the real amount of overlap?
114  if (isOverlapping)
115  halfWid *= 0.9;
116 
117  if (fabs(dist) + xErr > halfWid) {
118  checknext = true;
119  }
120  } else { // Rod is not compatible
121  //FIXME: Usually next cannot be either. Implement proper logic.
122  // (in general at least one rod should be when this method is called by
123  // compatibleDets() which calls compatible())
124  checknext = true;
125 
126  // Look for the next-to closest in phi.
127  // Note Geom::Phi, subtraction is pi-border-safe
128  if (tsos.globalPosition().phi() - closestRod->surface().position().phi() > 0.) {
129  dist = -1.;
130  } else {
131  dist = +1.;
132  }
133 
134  LogTrace("MTDDetLayers") << " MTDTrayBarrelLayer::fastCompatibleDets, none on closest rod!";
135  }
136 
137  if (checknext) {
138  int next;
139  if (dist < 0.)
140  next = closest + 1;
141  else
142  next = closest - 1;
143 
144  next = theBinFinder->binIndex(next); // Bin Periodicity
145  const DetRod* nextRod = theRods[next];
146 
147  LogTrace("MTDDetLayers") << " MTDTrayBarrelLayer::fastCompatibleDets, next-to closest"
148  << " rod: " << next << " dist " << dist << " phi : " << nextRod->surface().position().phi()
149  << " FTS phi: " << tsos.globalPosition().phi();
150 
151  vector<DetWithState> nextRodDets = nextRod->compatibleDets(tsos, prop, est);
152  result.insert(result.end(), nextRodDets.begin(), nextRodDets.end());
153  }
154 
155 #ifdef EDM_ML_DEBUG
156  LogTrace("MTDDetLayers") << " MTDTrayBarrelLayer::fastCompatibleDets: found: " << result.size()
157  << " on closest: " << nclosest << " # checked rods: " << 1 + int(checknext);
158 #endif
159 
160  return result;
161 }
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
Definition: DetRod.h:19
T perp() const
Definition: PV3DBase.h:69
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int closest(std::vector< int > const &vec, int value)
std::vector< const DetRod * > theRods
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
#define LogTrace(id)
T x() const
Definition: PV3DBase.h:59
GlobalPoint globalPosition() const
Definition: DetRod.h:13
const PositionType & position() const
BaseBinFinder< double > * theBinFinder
float xError(const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est) const
virtual float width() const =0
const Bounds & bounds() const
Definition: Surface.h:87

◆ components()

const vector< const GeometricSearchDet * > & MTDTrayBarrelLayer::components ( ) const
override

Definition at line 180 of file MTDTrayBarrelLayer.cc.

References theComponents.

180 { return theComponents; }
std::vector< const GeometricSearchDet * > theComponents

◆ groupedCompatibleDets()

vector< DetGroup > MTDTrayBarrelLayer::groupedCompatibleDets ( const TrajectoryStateOnSurface startingState,
const Propagator prop,
const MeasurementEstimator est 
) const
override

Definition at line 163 of file MTDTrayBarrelLayer.cc.

References compatibleDets(), LogTrace, and mps_fire::result.

165  {
166  vector<GeometricSearchDet::DetWithState> detWithStates;
167 
168  detWithStates = compatibleDets(startingState, prop, est);
169 
170  vector<DetGroup> result;
171  if (!detWithStates.empty()) {
172  result.push_back(DetGroup(detWithStates));
173  }
174  LogTrace("MTDDetLayers") << "MTDTrayBarrelLayer Compatible rods: " << result.size();
175  return result;
176 }
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
#define LogTrace(id)

◆ rods()

virtual const std::vector<const DetRod*>& MTDTrayBarrelLayer::rods ( ) const
inlinevirtual

Return the vector of rods.

Definition at line 44 of file MTDTrayBarrelLayer.h.

References theRods.

Referenced by MTDTrayBarrelLayer().

44 { return theRods; }
std::vector< const DetRod * > theRods

◆ subDetector()

GeomDetEnumerators::SubDetector MTDTrayBarrelLayer::subDetector ( ) const
override

Definition at line 178 of file MTDTrayBarrelLayer.cc.

References theBasicComps.

178 { return theBasicComps.front()->subDetector(); }
std::vector< const GeomDet * > theBasicComps

◆ xError()

float MTDTrayBarrelLayer::xError ( const TrajectoryStateOnSurface tsos,
const MeasurementEstimator est 
) const
private

Definition at line 182 of file MTDTrayBarrelLayer.cc.

References TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::localError(), LocalTrajectoryError::positionError(), mathSSE::sqrt(), and LocalError::xx().

Referenced by compatibleDets().

182  {
183  const float nSigmas = 3.f;
184  if (tsos.hasError()) {
185  return nSigmas * sqrt(tsos.localError().positionError().xx());
186  } else
187  return nSigmas * 0.5;
188 }
const LocalTrajectoryError & localError() const
LocalError positionError() const
T sqrt(T t)
Definition: SSEVec.h:23
float xx() const
Definition: LocalError.h:22

Member Data Documentation

◆ isOverlapping

bool MTDTrayBarrelLayer::isOverlapping
private

Definition at line 53 of file MTDTrayBarrelLayer.h.

Referenced by compatibleDets(), and MTDTrayBarrelLayer().

◆ theBasicComps

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

Definition at line 51 of file MTDTrayBarrelLayer.h.

Referenced by basicComponents(), MTDTrayBarrelLayer(), and subDetector().

◆ theBinFinder

BaseBinFinder<double>* MTDTrayBarrelLayer::theBinFinder
private

Definition at line 52 of file MTDTrayBarrelLayer.h.

Referenced by compatibleDets(), MTDTrayBarrelLayer(), and ~MTDTrayBarrelLayer().

◆ theComponents

std::vector<const GeometricSearchDet*> MTDTrayBarrelLayer::theComponents
private

Definition at line 50 of file MTDTrayBarrelLayer.h.

Referenced by components(), and MTDTrayBarrelLayer().

◆ theRods

std::vector<const DetRod*> MTDTrayBarrelLayer::theRods
private

Definition at line 49 of file MTDTrayBarrelLayer.h.

Referenced by compatibleDets(), MTDTrayBarrelLayer(), rods(), and ~MTDTrayBarrelLayer().