CMS 3D CMS Logo

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

#include <MTDDetSector.h>

Inheritance diagram for MTDDetSector:
GeometricSearchDet

Public Member Functions

const std::vector< const GeomDet * > & basicComponents () const override
 
std::pair< bool, TrajectoryStateOnSurfacecompatible (const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est) const override
 
std::vector< DetWithStatecompatibleDets (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
 
void compatibleDetsLine (const size_t idetMin, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est) const
 
void compatibleDetsV (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetWithState > &result) const override
 
const std::vector< const GeometricSearchDet * > & components () const override
 Returns basic components, if any. More...
 
 GeometricSearchDet (bool doHaveGroups)
 
std::vector< DetGroupgroupedCompatibleDets (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
 
size_t hshift (const uint32_t detid, const int horizontalShift) const
 
 MTDDetSector (std::vector< const GeomDet *>::const_iterator first, std::vector< const GeomDet *>::const_iterator last, const MTDTopology &topo)
 Construct from iterators on GeomDet*. More...
 
 MTDDetSector (const std::vector< const GeomDet *> &dets, const MTDTopology &topo)
 Construct from a vector of GeomDet*. More...
 
const BoundDiskSectorspecificSurface () const
 
const BoundSurfacesurface () const final
 The surface of the GeometricSearchDet. More...
 
size_t vshift (const uint32_t detid, const int verticalShift, size_t &closest) const
 
 ~MTDDetSector () override
 
- Public Member Functions inherited from GeometricSearchDet
 GeometricSearchDet (bool doHaveGroups)
 
virtual void groupedCompatibleDetsV (const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const
 
bool hasGroups () const
 
virtual const Surface::PositionTypeposition () const
 Returns position of the surface. More...
 
virtual ~GeometricSearchDet ()
 

Protected Member Functions

bool add (size_t idet, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est) const
 
void setDisk (BoundDiskSector *diskS)
 

Private Member Functions

void init ()
 

Private Attributes

std::vector< const GeomDet * > theDets
 
ReferenceCountingPointer< BoundDiskSectortheDiskS
 
const MTDTopologytopo_
 

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

Definition at line 12 of file MTDDetSector.h.

Constructor & Destructor Documentation

◆ MTDDetSector() [1/2]

MTDDetSector::MTDDetSector ( std::vector< const GeomDet *>::const_iterator  first,
std::vector< const GeomDet *>::const_iterator  last,
const MTDTopology topo 
)

Construct from iterators on GeomDet*.

Definition at line 21 of file MTDDetSector.cc.

References init().

24  : GeometricSearchDet(false), theDets(first, last), topo_(&topo) {
25  init();
26 }
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75
GeometricSearchDet(bool doHaveGroups)
const MTDTopology * topo_
Definition: MTDDetSector.h:77

◆ MTDDetSector() [2/2]

MTDDetSector::MTDDetSector ( const std::vector< const GeomDet *> &  dets,
const MTDTopology topo 
)

Construct from a vector of GeomDet*.

Definition at line 28 of file MTDDetSector.cc.

References init().

29  : GeometricSearchDet(false), theDets(vdets), topo_(&topo) {
30  init();
31 }
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75
GeometricSearchDet(bool doHaveGroups)
const MTDTopology * topo_
Definition: MTDDetSector.h:77

◆ ~MTDDetSector()

MTDDetSector::~MTDDetSector ( )
inlineoverride

Definition at line 24 of file MTDDetSector.h.

24 {}

Member Function Documentation

◆ add()

bool MTDDetSector::add ( size_t  idet,
std::vector< DetWithState > &  result,
const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est 
) const
protected

Definition at line 165 of file MTDDetSector.cc.

References TrajectoryStateOnSurface::globalPosition(), GeomDetCompatibilityChecker::isCompatible(), LogTrace, mag2(), mps_fire::result, mathSSE::sqrt(), GeometricSearchDet::theCompatibilityChecker, and theDets.

Referenced by compatibleDets(), compatibleDetsLine(), and counter.Counter::register().

169  {
170  pair<bool, TrajectoryStateOnSurface> compat = theCompatibilityChecker.isCompatible(theDets[idet], tsos, prop, est);
171 
172  if (compat.first) {
173  result.push_back(DetWithState(theDets[idet], compat.second));
174  LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets found compatible det idetMin " << idet
175  << " detId = " << theDets[idet]->geographicalId().rawId() << " at "
176  << theDets[idet]->position()
177  << " dist = " << std::sqrt((tsos.globalPosition() - theDets[idet]->position()).mag2());
178  }
179 
180  return compat.first;
181 }
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75
GeomDetCompatibilityChecker theCompatibilityChecker
#define LogTrace(id)
GlobalPoint globalPosition() const
static std::pair< bool, TrajectoryStateOnSurface > isCompatible(const GeomDet *theDet, const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est)
T sqrt(T t)
Definition: SSEVec.h:23
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState

◆ basicComponents()

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

Implements GeometricSearchDet.

Definition at line 28 of file MTDDetSector.h.

References theDets.

Referenced by compatibleDets().

28 { return theDets; }
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75

◆ compatible()

pair< bool, TrajectoryStateOnSurface > MTDDetSector::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 47 of file MTDDetSector.cc.

References MeasurementEstimator::estimate(), alignBH_cfg::fixed, TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), LogTrace, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), Propagator::propagate(), specificSurface(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by compatibleDets().

49  {
50  TrajectoryStateOnSurface ms = prop.propagate(ts, specificSurface());
51 
52 #ifdef EDM_ML_DEBUG
53  LogTrace("MTDDetLayers") << "MTDDetSector::compatible, sector: \n"
54  << (*this) << "\n TS at Z,R,phi: " << std::fixed << std::setw(14) << ts.globalPosition().z()
55  << " , " << std::setw(14) << ts.globalPosition().perp() << " , " << std::setw(14)
56  << ts.globalPosition().phi();
57  if (ms.isValid()) {
58  LogTrace("MTDDetLayers") << " DEST at Z,R,phi: " << std::fixed << std::setw(14) << ms.globalPosition().z() << " , "
59  << std::setw(14) << ms.globalPosition().perp() << " , " << std::setw(14)
60  << ms.globalPosition().phi() << " local Z: " << std::setw(14) << ms.localPosition().z();
61  } else {
62  LogTrace("MTDDetLayers") << " DEST: not valid";
63  }
64 #endif
65 
66  return make_pair(ms.isValid() and est.estimate(ms, specificSurface()) != 0, ms);
67 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const BoundDiskSector & specificSurface() const
Definition: MTDDetSector.h:53
#define LogTrace(id)
GlobalPoint globalPosition() const

◆ compatibleDets()

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

Returns all Dets compatible with a trajectory state according to the estimator est. The startingState should be propagated to the surface of each compatible Det using the Propagator passed as an argument. The default implementation should be overridden in dets with specific surface types to avoid propagation to a generic Surface

Reimplemented from GeometricSearchDet.

Definition at line 69 of file MTDDetSector.cc.

References add(), basicComponents(), pv::closest(), compatible(), compatibleDetsLine(), alignBH_cfg::fixed, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), mag2(), WZElectronSkims53X_cff::max, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), nano_mu_digi_cff::rawId, mps_fire::result, findQualityFiles::size, theDets, vshift(), and PV3DBase< T, PVType, FrameType >::z().

71  {
72  LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets, sector: \n"
73  << (*this) << "\n TS at Z,R,phi: " << std::fixed << std::setw(14)
74  << startingState.globalPosition().z() << " , " << std::setw(14)
75  << startingState.globalPosition().perp() << " , " << std::setw(14)
76  << startingState.globalPosition().phi();
77 
78  vector<DetWithState> result;
79 
80  // Propagate and check that the result is within bounds
81  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
82  if (!compat.first) {
83  LogTrace("MTDDetLayers") << " MTDDetSector::compatibleDets: not compatible"
84  << " (should not have been selected!)";
85  return result;
86  }
87 
88  TrajectoryStateOnSurface& tsos = compat.second;
89  GlobalPoint startPos = tsos.globalPosition();
90 
91  LogTrace("MTDDetLayers") << "Starting position: " << startPos << " starting p/pT: " << tsos.globalMomentum().mag()
92  << " / " << tsos.globalMomentum().perp();
93 
94  // determine distance of det center from extrapolation on the surface, sort dets accordingly
95 
96  size_t idetMin = basicComponents().size();
97  double dist2Min = std::numeric_limits<double>::max();
98  std::vector<std::pair<double, size_t> > tmpDets;
99  tmpDets.reserve(basicComponents().size());
100 
101  for (size_t idet = 0; idet < basicComponents().size(); idet++) {
102  double dist2 = (startPos - theDets[idet]->position()).mag2();
103  tmpDets.emplace_back(dist2, idet);
104  if (dist2 < dist2Min) {
105  dist2Min = dist2;
106  idetMin = idet;
107  }
108  }
109 
110  //look for the compatibledets considering each line of the sector
111 
112  if (add(idetMin, result, tsos, prop, est)) {
113  compatibleDetsLine(idetMin, result, tsos, prop, est);
114 
115  for (int iside = -1; iside <= 1; iside += 2) {
116  bool isCompatible(true);
117  size_t idetNew(idetMin);
118  size_t closest = theDets.size();
119 
120  while (isCompatible) {
121  idetNew = vshift(theDets[idetNew]->geographicalId().rawId(), iside, closest);
122  if (idetNew >= theDets.size()) {
123  if (closest < theDets.size()) {
124  idetNew = closest;
125  } else {
126  break;
127  }
128  }
129  isCompatible = add(idetNew, result, tsos, prop, est);
130  if (isCompatible) {
131  compatibleDetsLine(idetNew, result, tsos, prop, est);
132  }
133  }
134  }
135  }
136 
137 #ifdef EDM_ML_DEBUG
138  if (result.empty()) {
139  LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets, closest not compatible!";
140  } else {
141  LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets, found " << result.size() << " compatible dets";
142  }
143 #endif
144 
145  return result;
146 }
size
Write out results.
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &ts, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDDetSector.cc:47
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
int closest(std::vector< int > const &vec, int value)
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75
#define LogTrace(id)
size_t vshift(const uint32_t detid, const int verticalShift, size_t &closest) const
GlobalPoint globalPosition() const
T mag() const
Definition: PV3DBase.h:64
const std::vector< const GeomDet * > & basicComponents() const override
Definition: MTDDetSector.h:28
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
GlobalVector globalMomentum() const
bool add(size_t idet, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est) const
void compatibleDetsLine(const size_t idetMin, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est) const

◆ compatibleDetsLine()

void MTDDetSector::compatibleDetsLine ( const size_t  idetMin,
std::vector< DetWithState > &  result,
const TrajectoryStateOnSurface tsos,
const Propagator prop,
const MeasurementEstimator est 
) const

Definition at line 202 of file MTDDetSector.cc.

References add(), hshift(), nano_mu_digi_cff::rawId, mps_fire::result, and theDets.

Referenced by compatibleDets().

206  {
207  for (int iside = -1; iside <= 1; iside += 2) {
208  bool isCompatible(true);
209  size_t idetNew(idetMin);
210 
211  while (isCompatible) {
212  idetNew = hshift(theDets[idetNew]->geographicalId().rawId(), iside);
213  if (idetNew >= theDets.size()) {
214  break;
215  }
216  isCompatible = add(idetNew, result, tsos, prop, est);
217  }
218  }
219 
220  return;
221 }
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75
bool add(size_t idet, std::vector< DetWithState > &result, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est) const
size_t hshift(const uint32_t detid, const int horizontalShift) const

◆ compatibleDetsV()

void MTDDetSector::compatibleDetsV ( const TrajectoryStateOnSurface startingState,
const Propagator prop,
const MeasurementEstimator est,
std::vector< DetWithState > &  result 
) const
overridevirtual

Reimplemented from GeometricSearchDet.

Definition at line 148 of file MTDDetSector.cc.

151  {
152  edm::LogError("MTDDetLayers") << "At the moment not a real implementation";
153 }
Log< level::Error, false > LogError

◆ components()

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

Returns basic components, if any.

Returns direct components, if any

Implements GeometricSearchDet.

Definition at line 40 of file MTDDetSector.cc.

References mps_fire::result.

40  {
41  // FIXME dummy impl.
42  edm::LogError("MTDDetLayers") << "temporary dummy implementation of MTDDetSector::components()!!";
43  static const vector<const GeometricSearchDet*> result;
44  return result;
45 }
Log< level::Error, false > LogError

◆ GeometricSearchDet()

GeometricSearchDet::GeometricSearchDet
inline

Definition at line 24 of file GeometricSearchDet.h.

24 : haveGroups(doHaveGroups) {}

◆ groupedCompatibleDets()

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

Similar to compatibleDets(), but the compatible Dets are grouped in one or more groups. Dets are put in the same group if they are mutually exclusive for track crossing, i.e. a reconstructible track cannot cross more than one Det from a group. Pathological tracks (spirals etc.) can of course violate this rule.
The DetGroups are sorted in the sequence of crossing by a track. In order to define the direction of crossing the Propagator used in this method should have a defined direction() : either "alongMomentum" or "oppositeToMomentum" but not "anyDirection".
The three signatures of this method differ by the input trajectory state arguments: the starting state can be a TrajectoryStateOnSurface or a FreeTrajectoryState, and the state on this CompositeDet may be already known or not. The last two arguments are as for the method compatibleDets().
First signature: The first argument is a TrajectoryStateOnSurface, usually not on the surface of this CompositeDet.

Reimplemented from GeometricSearchDet.

Definition at line 155 of file MTDDetSector.cc.

References mps_fire::result.

157  {
158  // FIXME should be implemented to allow returning overlapping chambers
159  // as separate groups!
160  edm::LogInfo("MTDDetLayers") << "dummy implementation of MTDDetSector::groupedCompatibleDets()";
161  vector<DetGroup> result;
162  return result;
163 }
Log< level::Info, false > LogInfo

◆ hshift()

size_t MTDDetSector::hshift ( const uint32_t  detid,
const int  horizontalShift 
) const

Definition at line 223 of file MTDDetSector.cc.

References ALCARECOPPSCalTrackBasedSel_cff::detid, MTDTopology::hshiftETL(), and topo_.

Referenced by compatibleDetsLine().

223  {
224  return topo_->hshiftETL(detid, horizontalShift);
225 }
size_t hshiftETL(const uint32_t detid, const int horizontalShift) const
Definition: MTDTopology.cc:23
const MTDTopology * topo_
Definition: MTDDetSector.h:77

◆ init()

void MTDDetSector::init ( void  )
private

Definition at line 33 of file MTDDetSector.cc.

References setDisk(), and theDets.

Referenced by MTDDetSector().

33  {
34  // Add here the sector build based on a collection of GeomDets, mimic what done in ForwardDetRingOneZ
35  // using the code from tracker BladeShapeBuilderFromDet
36  // simple initial version, no sorting for the time being
38 }
std::vector< const GeomDet * > theDets
Definition: MTDDetSector.h:75
void setDisk(BoundDiskSector *diskS)
Definition: MTDDetSector.h:65

◆ setDisk()

void MTDDetSector::setDisk ( BoundDiskSector diskS)
inlineprotected

Definition at line 65 of file MTDDetSector.h.

References theDiskS.

Referenced by init().

65 { theDiskS = diskS; }
ReferenceCountingPointer< BoundDiskSector > theDiskS
Definition: MTDDetSector.h:74

◆ specificSurface()

const BoundDiskSector& MTDDetSector::specificSurface ( ) const
inline

Definition at line 53 of file MTDDetSector.h.

References theDiskS.

Referenced by compatible().

53 { return *theDiskS; }
ReferenceCountingPointer< BoundDiskSector > theDiskS
Definition: MTDDetSector.h:74

◆ surface()

const BoundSurface& MTDDetSector::surface ( ) const
inlinefinalvirtual

The surface of the GeometricSearchDet.

Implements GeometricSearchDet.

Definition at line 30 of file MTDDetSector.h.

References theDiskS.

30 { return *theDiskS; }
ReferenceCountingPointer< BoundDiskSector > theDiskS
Definition: MTDDetSector.h:74

◆ vshift()

size_t MTDDetSector::vshift ( const uint32_t  detid,
const int  verticalShift,
size_t &  closest 
) const

Definition at line 227 of file MTDDetSector.cc.

References pv::closest(), ALCARECOPPSCalTrackBasedSel_cff::detid, topo_, and MTDTopology::vshiftETL().

Referenced by compatibleDets().

227  {
228  return topo_->vshiftETL(detid, verticalShift, closest);
229 }
int closest(std::vector< int > const &vec, int value)
const MTDTopology * topo_
Definition: MTDDetSector.h:77
size_t vshiftETL(const uint32_t detid, const int verticalShift, size_t &closest) const
Definition: MTDTopology.cc:68

Member Data Documentation

◆ theDets

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

Definition at line 75 of file MTDDetSector.h.

Referenced by add(), basicComponents(), compatibleDets(), compatibleDetsLine(), and init().

◆ theDiskS

ReferenceCountingPointer<BoundDiskSector> MTDDetSector::theDiskS
private

Definition at line 74 of file MTDDetSector.h.

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

◆ topo_

const MTDTopology* MTDDetSector::topo_
private

Definition at line 77 of file MTDDetSector.h.

Referenced by hshift(), and vshift().