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; }
Propagator.h
GeomDetEnumerators::SubDetector
SubDetector
Definition: GeomDetEnumerators.h:10
MeasurementEstimator
Definition: MeasurementEstimator.h:19
TkRotation< float >
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
min
T min(T a, T b)
Definition: MathUtil.h:58
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
pos
Definition: PixelAliasList.h:18
MTDDetSector.h
ForwardDetLayer::setSurface
void setSurface(BoundDisk *cp)
Definition: ForwardDetLayer.cc:13
MTDSectorForwardLayer::MTDSectorForwardLayer
MTDSectorForwardLayer(const std::vector< const MTDDetSector * > &sectors)
Constructor, takes ownership of pointers.
Definition: MTDSectorForwardLayer.cc:18
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MTDSectorForwardLayer::subDetector
SubDetector subDetector() const override
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel,...
Definition: MTDSectorForwardLayer.cc:136
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
SimpleDiskBounds
Definition: SimpleDiskBounds.h:11
Propagator
Definition: Propagator.h:44
MTDSectorForwardLayer::~MTDSectorForwardLayer
~MTDSectorForwardLayer() override
Definition: MTDSectorForwardLayer.cc:56
MTDSectorForwardLayer::groupedCompatibleDets
std::vector< DetGroup > groupedCompatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDSectorForwardLayer.cc:128
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MTDSectorForwardLayer::basicComponents
const std::vector< const GeomDet * > & basicComponents() const override
Definition: MTDSectorForwardLayer.h:18
LocalError::xx
float xx() const
Definition: LocalError.h:22
MTDSectorForwardLayer::sectors
virtual const std::vector< const MTDDetSector * > & sectors() const
Return the vector of sectors.
Definition: MTDSectorForwardLayer.h:36
TrajectoryStateOnSurface::hasError
bool hasError() const
Definition: TrajectoryStateOnSurface.h:56
MeasurementEstimator.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
MTDSectorForwardLayer::theBasicComps
std::vector< const GeomDet * > theBasicComps
Definition: MTDSectorForwardLayer.h:41
mps_fire.end
end
Definition: mps_fire.py:242
Point3DBase< float, GlobalTag >
MTDSectorForwardLayer::compatibleDets
std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const override
Definition: MTDSectorForwardLayer.cc:62
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
toLocal
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
Definition: ConversionProducer.cc:202
MTDSectorForwardLayer.h
DiskSectorBounds.h
MTDSectorForwardLayer::theSectors
std::vector< const MTDDetSector * > theSectors
Definition: MTDSectorForwardLayer.h:39
GeomDet.h
std
Definition: JetResolutionObject.h:76
ForwardDetLayer
Definition: ForwardDetLayer.h:22
MTDSectorForwardLayer::components
const std::vector< const GeometricSearchDet * > & components() const override
Returns basic components, if any.
Definition: MTDSectorForwardLayer.cc:140
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
MTDSectorForwardLayer::theComponents
std::vector< const GeometricSearchDet * > theComponents
Definition: MTDSectorForwardLayer.h:40
mps_fire.result
result
Definition: mps_fire.py:311
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
volumeBasedMagneticField_160812_cfi.sectors
sectors
Definition: volumeBasedMagneticField_160812_cfi.py:59
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
ForwardDetLayer::compatible
std::pair< bool, TrajectoryStateOnSurface > compatible(const TrajectoryStateOnSurface &, const Propagator &, const MeasurementEstimator &) const override
Definition: ForwardDetLayer.cc:84
BoundDisk
Disk BoundDisk
Definition: BoundDisk.h:54
LocalError::yy
float yy() const
Definition: LocalError.h:24
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39