CMS 3D CMS Logo

MTDSectorForwardLayer.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
9 
11 
12 #include <algorithm>
13 #include <iostream>
14 #include <vector>
15 
16 using namespace std;
17 
18 MTDSectorForwardLayer::MTDSectorForwardLayer(const vector<const MTDDetSector*>& sectors)
19  : ForwardDetLayer(false), theSectors(sectors), theComponents(theSectors.begin(), theSectors.end()) {
20  // Initial values for R, Z and Phi bounds
21  float theRmin = sectors.front()->basicComponents().front()->position().perp();
22  float theRmax = theRmin;
23  float theZmin = sectors.front()->position().z();
24  float theZmax = theZmin;
25 
26  // Cache chamber pointers (the basic components_)
27  // and find extension in R and Z
28  for (const auto& isect : sectors) {
29  vector<const GeomDet*> tmp2 = isect->basicComponents();
30  theBasicComps.insert(theBasicComps.end(), tmp2.begin(), tmp2.end());
31 
32  theRmin = min(theRmin, isect->specificSurface().innerRadius());
33  theRmax = max(theRmax, isect->specificSurface().outerRadius());
34  float halfThick = isect->surface().bounds().thickness() / 2.;
35  float zCenter = isect->surface().position().z();
36  theZmin = min(theZmin, zCenter - halfThick);
37  theZmax = max(theZmax, zCenter + halfThick);
38  }
39 
40  // Build surface
41 
42  float zPos = (theZmax + theZmin) / 2.;
43  PositionType pos(0., 0., zPos);
45 
46  setSurface(new BoundDisk(pos, rot, new SimpleDiskBounds(theRmin, theRmax, theZmin - zPos, theZmax - zPos)));
47 
48  LogTrace("MTDDetLayers") << "Constructing MTDSectorForwardLayer: " << std::fixed << std::setw(14)
49  << basicComponents().size() << " Dets, " << std::setw(14) << theSectors.size()
50  << " Sectors, "
51  << " Z: " << std::setw(14) << specificSurface().position().z() << " R1: " << std::setw(14)
52  << specificSurface().innerRadius() << " R2: " << std::setw(14)
53  << specificSurface().outerRadius();
54 }
55 
57  for (auto& i : theSectors) {
58  delete i;
59  }
60 }
61 
62 vector<GeometricSearchDet::DetWithState> MTDSectorForwardLayer::compatibleDets(
63  const TrajectoryStateOnSurface& startingState, const Propagator& prop, const MeasurementEstimator& est) const {
64  vector<DetWithState> result;
65 
66  LogTrace("MTDDetLayers") << "MTDSectorForwardLayer::compatibleDets,"
67  << " R1 " << std::fixed << std::setw(14) << specificSurface().innerRadius()
68  << " R2: " << std::setw(14) << specificSurface().outerRadius()
69  << " FTS at R: " << std::setw(14) << startingState.globalPosition().perp();
70 
71  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
72 
73  if (!compat.first) {
74  LogTrace("MTDDetLayers") << " MTDSectorForwardLayer::compatibleDets: not compatible"
75  << " (should not have been selected!)";
76  return result;
77  }
78 
79  TrajectoryStateOnSurface& tsos = compat.second;
80 
81  // as there are either two or four sectors only, avoid complex logic and just loop on all of them
82 
83  // Use state on layer surface. Note that local coordinates and errors
84  // are the same on the layer and on all sectors surfaces, since
85  // all BoundDisks are centered in 0,0 and have the same rotation.
86  // CAVEAT: if the sectors are not at the same Z, the local position and error
87  // will be "Z-projected" to the sectors. This is a fairly good approximation.
88  // However in this case additional propagation will be done when calling
89  // compatibleDets.
90  GlobalPoint startPos = tsos.globalPosition();
91 
92  for (unsigned int isect = 0; isect < theSectors.size(); isect++) {
93  LocalPoint nextPos(theSectors[isect]->specificSurface().toLocal(startPos));
94  LogDebug("MTDDetLayers") << "Global point = " << std::fixed << startPos << " local point = " << nextPos
95  << " global sector ref pos = " << theSectors[isect]->specificSurface().position();
96  bool inside = false;
97  if (tsos.hasError()) {
98  inside = theSectors[isect]->specificSurface().bounds().inside(nextPos, tsos.localError().positionError(), 1.);
99  } else {
100  inside = theSectors[isect]->specificSurface().bounds().inside(nextPos);
101  }
102  if (inside) {
103 #ifdef EDM_ML_DEBUG
104  LogTrace("MTDDetLayers") << " MTDSectorForwardLayer::fastCompatibleDets:NextSector " << std::fixed
105  << std::setw(14) << isect << "\n"
106  << (*theSectors[isect]) << "\n FTS at Z,R,phi: " << std::setw(14)
107  << tsos.globalPosition().z() << " , " << std::setw(14) << tsos.globalPosition().perp()
108  << "," << std::setw(14) << tsos.globalPosition().phi();
109  if (tsos.hasError()) {
110  LogTrace("MTDDetLayers") << " sR: " << sqrt(tsos.localError().positionError().yy())
111  << " sX: " << sqrt(tsos.localError().positionError().xx());
112  }
113 #endif
114  vector<DetWithState> nextRodDets(theSectors[isect]->compatibleDets(tsos, prop, est));
115  if (!nextRodDets.empty()) {
116  result.insert(result.end(), nextRodDets.begin(), nextRodDets.end());
117  } else {
118  break;
119  }
120  }
121  }
122 
123  LogTrace("MTDDetLayers") << " MTDSectorForwardLayer::fastCompatibleDets: found: " << result.size();
124 
125  return result;
126 }
127 
129  const Propagator& prop,
130  const MeasurementEstimator& est) const {
131  // FIXME should return only 1 group
132  edm::LogInfo("MTDDetLayers") << "dummy implementation of MTDSectorForwardLayer::groupedCompatibleDets()";
133  return vector<DetGroup>();
134 }
135 
137  return theBasicComps.front()->subDetector();
138 }
139 
140 const vector<const GeometricSearchDet*>& MTDSectorForwardLayer::components() const { return theComponents; }
SubDetector subDetector() const override
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
T perp() const
Definition: PV3DBase.h:69
const std::vector< const GeomDet * > & basicComponents() const override
const LocalTrajectoryError & localError() const
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void setSurface(BoundDisk *cp)
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
virtual const std::vector< const MTDDetSector * > & sectors() const
Return the vector of sectors.
LocalError positionError() const
#define LogTrace(id)
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
float yy() const
Definition: LocalError.h:24
GlobalPoint globalPosition() const
MTDSectorForwardLayer(const std::vector< const MTDDetSector *> &sectors)
Constructor, takes ownership of pointers.
T sqrt(T t)
Definition: SSEVec.h:19
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Log< level::Info, false > LogInfo
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
std::vector< const MTDDetSector * > theSectors
std::vector< const GeomDet * > theBasicComps
Disk BoundDisk
Definition: BoundDisk.h:54
const std::vector< const GeometricSearchDet * > & components() const override
Returns basic components, if any.
std::vector< const GeometricSearchDet * > theComponents
virtual const BoundDisk & specificSurface() const final
float xx() const
Definition: LocalError.h:22
#define LogDebug(id)