CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MTDSectorForwardDoubleLayer.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
10 
11 #include <algorithm>
12 #include <iostream>
13 #include <vector>
14 
15 using namespace std;
16 
17 MTDSectorForwardDoubleLayer::MTDSectorForwardDoubleLayer(const vector<const MTDDetSector*>& frontSectors,
18  const vector<const MTDDetSector*>& backSectors)
20  theFrontLayer(frontSectors),
21  theBackLayer(backSectors),
22  theSectors(frontSectors), // add back later
23  theComponents(),
24  theBasicComponents() {
25  theSectors.insert(theSectors.end(), backSectors.begin(), backSectors.end());
26  theComponents = std::vector<const GeometricSearchDet*>(theSectors.begin(), theSectors.end());
27 
28  // Cache chamber pointers (the basic components_)
29  // and find extension in R and Z
30  for (const auto& isect : theSectors) {
31  vector<const GeomDet*> tmp2 = isect->basicComponents();
32  theBasicComponents.insert(theBasicComponents.end(), tmp2.begin(), tmp2.end());
33  }
34 
36 
37  LogTrace("MTDDetLayers") << "Constructing MTDSectorForwardDoubleLayer: " << std::fixed << std::setw(14)
38  << basicComponents().size() << " Dets " << std::setw(14) << theSectors.size() << " Sectors "
39  << " Z: " << std::setw(14) << specificSurface().position().z() << " R1: " << std::setw(14)
40  << specificSurface().innerRadius() << " R2: " << std::setw(14)
41  << specificSurface().outerRadius();
42 
43  selfTest();
44 }
45 
47  const BoundDisk& frontDisk = theFrontLayer.specificSurface();
48  const BoundDisk& backDisk = theBackLayer.specificSurface();
49 
50  float rmin = min(frontDisk.innerRadius(), backDisk.innerRadius());
51  float rmax = max(frontDisk.outerRadius(), backDisk.outerRadius());
52  float zmin = frontDisk.position().z();
53  float halfThickness = frontDisk.bounds().thickness() / 2.;
54  zmin = (zmin > 0) ? zmin - halfThickness : zmin + halfThickness;
55  float zmax = backDisk.position().z();
56  halfThickness = backDisk.bounds().thickness() / 2.;
57  zmax = (zmax > 0) ? zmax + halfThickness : zmax - halfThickness;
58  float zPos = (zmax + zmin) / 2.;
59  PositionType pos(0., 0., zPos);
61 
62  return new BoundDisk(pos, rot, new SimpleDiskBounds(rmin, rmax, zmin - zPos, zmax - zPos));
63 }
64 
66  return tsos.globalPosition().basicVector().dot(tsos.globalMomentum().basicVector()) > 0;
67 }
68 
69 std::pair<bool, TrajectoryStateOnSurface> MTDSectorForwardDoubleLayer::compatible(
70  const TrajectoryStateOnSurface& startingState, const Propagator& prop, const MeasurementEstimator& est) const {
71  // mostly copied from ForwardDetLayer, except propagates to closest surface,
72  // not to center
73 
74  bool insideOut = isInsideOut(startingState);
75  const MTDSectorForwardLayer& closerLayer = (insideOut) ? theFrontLayer : theBackLayer;
76  LogTrace("MTDDetLayers") << "MTDSectorForwardDoubleLayer::compatible is assuming inside-out direction: " << insideOut;
77 
78  TrajectoryStateOnSurface myState = prop.propagate(startingState, closerLayer.specificSurface());
79  if (!myState.isValid())
80  return make_pair(false, myState);
81 
82  // take into account the thickness of the layer
83  float deltaR = surface().bounds().thickness() / 2. * std::abs(tan(myState.localDirection().theta()));
84 
85  // take into account the error on the predicted state
86  constexpr float nSigma = 3.;
87  if (myState.hasError()) {
88  LocalError err = myState.localError().positionError();
89  // ignore correlation for the moment...
90  deltaR += nSigma * sqrt(err.xx() + err.yy());
91  }
92 
93  float zPos = (zmax() + zmin()) / 2.;
94  SimpleDiskBounds tmp(rmin() - deltaR, rmax() + deltaR, zmin() - zPos, zmax() - zPos);
95 
96  return make_pair(tmp.inside(myState.localPosition()), myState);
97 }
98 
99 vector<GeometricSearchDet::DetWithState> MTDSectorForwardDoubleLayer::compatibleDets(
100  const TrajectoryStateOnSurface& startingState, const Propagator& prop, const MeasurementEstimator& est) const {
101  vector<DetWithState> result;
102  pair<bool, TrajectoryStateOnSurface> compat = compatible(startingState, prop, est);
103 
104  if (!compat.first) {
105  LogTrace("MTDDetLayers") << " MTDSectorForwardDoubleLayer::compatibleDets: not compatible"
106  << " (should not have been selected!)";
107  return result;
108  }
109 
110  TrajectoryStateOnSurface& tsos = compat.second;
111 
112  // standard implementation of compatibleDets() for class which have
113  // groupedCompatibleDets implemented.
114  // This code should be moved in a common place intead of being
115  // copied many times.
116  vector<DetGroup> vectorGroups(groupedCompatibleDets(tsos, prop, est));
117  for (const auto& thisDG : vectorGroups) {
118  for (const auto& thisDGE : thisDG) {
119  result.emplace_back(DetWithState(thisDGE.det(), thisDGE.trajectoryState()));
120  }
121  }
122 
123  return result;
124 }
125 
127  const Propagator& prop,
128  const MeasurementEstimator& est) const {
129  vector<GeometricSearchDet::DetWithState> detWithStates1, detWithStates2;
130 
131  LogTrace("MTDDetLayers") << "groupedCompatibleDets are currently given always in inside-out order";
132  // this should be fixed either in RecoMTD/MeasurementDet/MTDDetLayerMeasurements or
133  // RecoMTD/DetLayers/MTDSectorForwardDoubleLayer
134 
135  detWithStates1 = theFrontLayer.compatibleDets(startingState, prop, est);
136  detWithStates2 = theBackLayer.compatibleDets(startingState, prop, est);
137 
138  vector<DetGroup> result;
139  if (!detWithStates1.empty())
140  result.push_back(DetGroup(detWithStates1));
141  if (!detWithStates2.empty())
142  result.push_back(DetGroup(detWithStates2));
143  LogTrace("MTDDetLayers") << "DoubleLayer Compatible dets: " << result.size();
144  return result;
145 }
146 
148  bool result = false;
149  LogTrace("MTDDetLayers")
150  << "MTDSectorForwardDoubleLayer::isCrack kept only for backward compatibility, no real implementation";
151  return result;
152 }
153 
155  const std::vector<const GeomDet*>& frontDets = theFrontLayer.basicComponents();
156  const std::vector<const GeomDet*>& backDets = theBackLayer.basicComponents();
157 
158  // test that each front z is less than each back z
159  float frontz(0.);
160  float backz(1e3f);
161  for (const auto& thisFront : frontDets) {
162  float tmpz(std::abs(thisFront->surface().position().z()));
163  if (tmpz > frontz) {
164  frontz = tmpz;
165  }
166  }
167  for (const auto& thisBack : backDets) {
168  float tmpz(std::abs(thisBack->surface().position().z()));
169  if (tmpz < backz) {
170  backz = tmpz;
171  }
172  }
173  assert(frontz < backz);
174 }
float xx() const
Definition: LocalError.h:22
const std::vector< const GeomDet * > & basicComponents() const override
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
LocalVector localDirection() const
void setSurface(BoundDisk *cp)
float rmin() const
GlobalPoint globalPosition() const
const Bounds & bounds() const
Definition: Surface.h:87
assert(be >=bs)
float zmin() const
LocalError positionError() const
#define LogTrace(id)
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
tuple result
Definition: mps_fire.py:311
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
virtual float thickness() const =0
bool isCrack(const GlobalPoint &gp) const
float yy() const
Definition: LocalError.h:24
bool inside(const Local3DPoint &p) const override
Determine if the point is inside the bounds.
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
T min(T a, T b)
Definition: MathUtil.h:58
const LocalTrajectoryError & localError() const
float zmax() const
std::vector< const GeomDet * > theBasicComponents
Disk BoundDisk
Definition: BoundDisk.h:54
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
MTDSectorForwardDoubleLayer(const std::vector< const MTDDetSector * > &frontSectors, const std::vector< const MTDDetSector * > &backSectors)
Constructor, takes ownership of pointers.
std::vector< const MTDDetSector * > theSectors
bool isInsideOut(const TrajectoryStateOnSurface &tsos) const
GlobalVector globalMomentum() const
float rmax() const
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
virtual const BoundDisk & specificSurface() const final
std::vector< const GeometricSearchDet * > theComponents
const std::vector< const GeomDet * > & basicComponents() const override
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
tmp
align.sh
Definition: createJobs.py:716
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.