CMS 3D CMS Logo

MTDRingForwardLayer.cc
Go to the documentation of this file.
1 
12 
14 
15 #include "RBorderFinder.h"
16 #include "GeneralBinFinderInR.h"
17 
18 #include <algorithm>
19 #include <iostream>
20 #include <vector>
21 
22 using namespace std;
23 
24 MTDRingForwardLayer::MTDRingForwardLayer(const vector<const ForwardDetRing*>& rings)
26  theRings(rings),
27  theComponents(theRings.begin(), theRings.end()),
28  theBinFinder(nullptr),
29  isOverlapping(false) {
30  const std::string metname = "MTD|RecoMTD|RecoMTDDetLayers|MTDRingForwardLayer";
31 
32  // Initial values for R and Z bounds
33  float theRmin = rings.front()->basicComponents().front()->position().perp();
34  float theRmax = theRmin;
35  float theZmin = rings.front()->position().z();
36  float theZmax = theZmin;
37 
38  // Cache chamber pointers (the basic components_)
39  // and find extension in R and Z
40  for (vector<const ForwardDetRing*>::const_iterator it = rings.begin(); it != rings.end(); it++) {
41  vector<const GeomDet*> tmp2 = (*it)->basicComponents();
42  theBasicComps.insert(theBasicComps.end(), tmp2.begin(), tmp2.end());
43 
44  theRmin = min(theRmin, (*it)->specificSurface().innerRadius());
45  theRmax = max(theRmax, (*it)->specificSurface().outerRadius());
46  float halfThick = (*it)->surface().bounds().thickness() / 2.;
47  float zCenter = (*it)->surface().position().z();
48  theZmin = min(theZmin, zCenter - halfThick);
49  theZmax = max(theZmax, zCenter + halfThick);
50  }
51 
55 
56  // Build surface
57 
58  float zPos = (theZmax + theZmin) / 2.;
59  PositionType pos(0., 0., zPos);
61 
62  setSurface(new BoundDisk(pos, rot, new SimpleDiskBounds(theRmin, theRmax, theZmin - zPos, theZmax - zPos)));
63 
64  LogTrace(metname) << "Constructing MTDRingForwardLayer: " << basicComponents().size() << " Dets " << theRings.size()
65  << " Rings "
66  << " Z: " << specificSurface().position().z() << " R1: " << specificSurface().innerRadius()
67  << " R2: " << specificSurface().outerRadius() << " Per.: " << bf.isRPeriodic()
68  << " Overl.: " << bf.isROverlapping();
69 }
70 
72  delete theBinFinder;
73  for (vector<const ForwardDetRing*>::iterator i = theRings.begin(); i < theRings.end(); i++) {
74  delete *i;
75  }
76 }
77 
78 vector<GeometricSearchDet::DetWithState> MTDRingForwardLayer::compatibleDets(
79  const TrajectoryStateOnSurface& startingState, const Propagator& prop, const MeasurementEstimator& est) const {
80  const std::string metname = "MTD|RecoMTD|RecoMTDDetLayers|MTDRingForwardLayer";
81  vector<DetWithState> result;
82 
83  LogTrace(metname) << "MTDRingForwardLayer::compatibleDets,"
84  << " R1 " << specificSurface().innerRadius() << " R2: " << specificSurface().outerRadius()
85  << " FTS at R: " << startingState.globalPosition().perp();
86 
87  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
88 
89  if (!compat.first) {
90  LogTrace(metname) << " MTDRingForwardLayer::compatibleDets: not compatible"
91  << " (should not have been selected!)";
92  return result;
93  }
94 
95  TrajectoryStateOnSurface& tsos = compat.second;
96 
97  int closest = theBinFinder->binIndex(tsos.globalPosition().perp());
98  const ForwardDetRing* closestRing = theRings[closest];
99 
100  // Check the closest ring
101 
102  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets, closestRing: " << closest << " R1 "
103  << closestRing->specificSurface().innerRadius()
104  << " R2: " << closestRing->specificSurface().outerRadius()
105  << " FTS R: " << tsos.globalPosition().perp();
106  if (tsos.hasError()) {
107  LogTrace(metname) << " sR: " << sqrt(tsos.localError().positionError().yy())
108  << " sX: " << sqrt(tsos.localError().positionError().xx());
109  }
110  LogTrace(metname) << endl;
111 
112  result = closestRing->compatibleDets(tsos, prop, est);
113 
114 #ifdef EDM_ML_DEBUG
115  int nclosest = result.size();
116  int nnextdet = 0; // MDEBUG counters
117 #endif
118 
119  //FIXME: if closest is not compatible next cannot be either?
120 
121  // Use state on layer surface. Note that local coordinates and errors
122  // are the same on the layer and on all rings surfaces, since
123  // all BoundDisks are centered in 0,0 and have the same rotation.
124  // CAVEAT: if the rings are not at the same Z, the local position and error
125  // will be "Z-projected" to the rings. This is a fairly good approximation.
126  // However in this case additional propagation will be done when calling
127  // compatibleDets.
128  GlobalPoint startPos = tsos.globalPosition();
129  LocalPoint nextPos(surface().toLocal(startPos));
130 
131  for (unsigned int idet = closest + 1; idet < theRings.size(); idet++) {
132  bool inside = false;
133  if (tsos.hasError()) {
134  inside = theRings[idet]->specificSurface().bounds().inside(nextPos, tsos.localError().positionError());
135  } else {
136  inside = theRings[idet]->specificSurface().bounds().inside(nextPos);
137  }
138  if (inside) {
139  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets:NextRing" << idet << " R1 "
140  << theRings[idet]->specificSurface().innerRadius()
141  << " R2: " << theRings[idet]->specificSurface().outerRadius() << " FTS R " << nextPos.perp();
142 #ifdef EDM_ML_DEBUG
143  nnextdet++;
144 #endif
145  vector<DetWithState> nextRodDets = theRings[idet]->compatibleDets(tsos, prop, est);
146  if (!nextRodDets.empty()) {
147  result.insert(result.end(), nextRodDets.begin(), nextRodDets.end());
148  } else {
149  break;
150  }
151  }
152  }
153 
154  for (int idet = closest - 1; idet >= 0; idet--) {
155  bool inside = false;
156  if (tsos.hasError()) {
157  inside = theRings[idet]->specificSurface().bounds().inside(nextPos, tsos.localError().positionError());
158  } else {
159  inside = theRings[idet]->specificSurface().bounds().inside(nextPos);
160  }
161  if (inside) {
162  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets:PreviousRing:" << idet << " R1 "
163  << theRings[idet]->specificSurface().innerRadius()
164  << " R2: " << theRings[idet]->specificSurface().outerRadius() << " FTS R " << nextPos.perp();
165 #ifdef EDM_ML_DEBUG
166  nnextdet++;
167 #endif
168  vector<DetWithState> nextRodDets = theRings[idet]->compatibleDets(tsos, prop, est);
169  if (!nextRodDets.empty()) {
170  result.insert(result.end(), nextRodDets.begin(), nextRodDets.end());
171  } else {
172  break;
173  }
174  }
175  }
176 
177 #ifdef EDM_ML_DEBUG
178  LogTrace(metname) << " MTDRingForwardLayer::fastCompatibleDets: found: " << result.size()
179  << " on closest: " << nclosest << " # checked rings: " << 1 + nnextdet;
180 #endif
181 
182  return result;
183 }
184 
186  const Propagator& prop,
187  const MeasurementEstimator& est) const {
188  // FIXME should return only 1 group
189  cout << "dummy implementation of MTDRingForwardLayer::groupedCompatibleDets()" << endl;
190  return vector<DetGroup>();
191 }
192 
194  return theBasicComps.front()->subDetector();
195 }
196 
197 const vector<const GeometricSearchDet*>& MTDRingForwardLayer::components() const { return theComponents; }
Propagator.h
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
MeasurementEstimator
Definition: MeasurementEstimator.h:19
GeneralBinFinderInR
Definition: GeneralBinFinderInR.h:17
mps_fire.i
i
Definition: mps_fire.py:355
ForwardDetRing::specificSurface
const BoundDisk & specificSurface() const
Return the ring surface as a BoundDisk.
Definition: ForwardDetRing.h:27
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
align::RotationType
TkRotation< Scalar > RotationType
Definition: Definitions.h:27
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
MTDRingForwardLayer::~MTDRingForwardLayer
~MTDRingForwardLayer() override
Definition: MTDRingForwardLayer.cc:71
min
T min(T a, T b)
Definition: MathUtil.h:58
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
MTDRingForwardLayer::components
const std::vector< const GeometricSearchDet * > & components() const override
Definition: MTDRingForwardLayer.cc:197
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
MTDRingForwardLayer::subDetector
SubDetector subDetector() const override
Definition: MTDRingForwardLayer.cc:193
align::PositionType
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:28
GeometricSearchDet::compatibleDets
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: GeometricSearchDet.cc:35
end
#define end
Definition: vmac.h:39
RBorderFinder::isROverlapping
bool isROverlapping() const
Returns true if any 2 of the Det overlap in R.
Definition: RBorderFinder.h:35
SimpleDiskBounds
Definition: SimpleDiskBounds.h:11
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
GeneralBinFinderInR.h
MTDRingForwardLayer::isOverlapping
bool isOverlapping
Definition: MTDRingForwardLayer.h:52
LocalError::xx
float xx() const
Definition: LocalError.h:22
TrajectoryStateOnSurface::hasError
bool hasError() const
Definition: TrajectoryStateOnSurface.h:56
MeasurementEstimator.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
RBorderFinder::isRPeriodic
bool isRPeriodic() const
Returns true if the Dets are periodic in R.
Definition: RBorderFinder.h:32
MTDRingForwardLayer::theComponents
std::vector< const GeometricSearchDet * > theComponents
Definition: MTDRingForwardLayer.h:49
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MTDRingForwardLayer::theRings
std::vector< const ForwardDetRing * > theRings
Definition: MTDRingForwardLayer.h:48
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MTDDetRing.h
RBorderFinder
Definition: RBorderFinder.h:22
RingedForwardLayer
GeomDet.h
std
Definition: JetResolutionObject.h:76
MTDRingForwardLayer::MTDRingForwardLayer
MTDRingForwardLayer(const std::vector< const ForwardDetRing * > &rings)
Constructor, takes ownership of pointers.
Definition: MTDRingForwardLayer.cc:24
MTDRingForwardLayer.h
MTDRingForwardLayer::compatibleDets
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDRingForwardLayer.cc:78
MTDRingForwardLayer::groupedCompatibleDets
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDRingForwardLayer.cc:185
MTDRingForwardLayer::basicComponents
const std::vector< const GeomDet * > & basicComponents() const override
Definition: MTDRingForwardLayer.h:27
toLocal
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Definition: ConversionProducer.h:192
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
MTDRingForwardLayer::rings
virtual const std::vector< const ForwardDetRing * > & rings() const
Return the vector of rings.
Definition: MTDRingForwardLayer.h:45
mps_fire.result
result
Definition: mps_fire.py:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
SimpleDiskBounds.h
MTDRingForwardLayer::theBasicComps
std::vector< const GeomDet * > theBasicComps
Definition: MTDRingForwardLayer.h:50
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
BoundDisk
Disk BoundDisk
Definition: BoundDisk.h:54
RBorderFinder.h
LocalError::yy
float yy() const
Definition: LocalError.h:24
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
begin
#define begin
Definition: vmac.h:32
MTDRingForwardLayer::theBinFinder
BaseBinFinder< double > * theBinFinder
Definition: MTDRingForwardLayer.h:51
BaseBinFinder::binIndex
virtual int binIndex(T pos) const =0
Return the index of bin at given position.
ForwardDetRing
Definition: ForwardDetRing.h:11
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43