CMS 3D CMS Logo

TECLayer.cc
Go to the documentation of this file.
1 #include "TECLayer.h"
2 
4 
6 #include "DetGroupMerger.h"
7 #include "LayerCrossingSide.h"
8 
14 #include "TkDetUtil.h"
15 
16 using namespace std;
17 
19 
20 namespace {
21 
22  template <typename T>
23  BoundDisk* computeDisk(vector<const T*>& petals) {
24  // Attention: it is assumed that the petals do belong to one layer, and are all
25  // of the same rmin/rmax extension !!
26 
27  const BoundDiskSector& diskSector = static_cast<const BoundDiskSector&>(petals.front()->surface());
28 
29  float rmin = diskSector.innerRadius();
30  float rmax = diskSector.outerRadius();
31 
32  float theZmax(petals.front()->position().z());
33  float theZmin(theZmax);
34  for (auto i = petals.begin(); i != petals.end(); i++) {
35  float zmin = (**i).position().z() - (**i).surface().bounds().thickness() / 2.;
36  float zmax = (**i).position().z() + (**i).surface().bounds().thickness() / 2.;
37  theZmax = max(theZmax, zmax);
38  theZmin = min(theZmin, zmin);
39  }
40 
41  float zPos = (theZmax + theZmin) / 2.;
42  Surface::PositionType pos(0., 0., zPos);
44 
45  return new BoundDisk(pos, rot, new SimpleDiskBounds(rmin, rmax, theZmin - zPos, theZmax - zPos));
46  }
47 
48 } // namespace
49 
50 TECLayer::TECLayer(vector<const TECPetal*>& innerPetals, vector<const TECPetal*>& outerPetals)
52  theFrontComps(innerPetals.begin(), innerPetals.end()),
53  theBackComps(outerPetals.begin(), outerPetals.end()) {
54  theComps.assign(theFrontComps.begin(), theFrontComps.end());
55  theComps.insert(theComps.end(), theBackComps.begin(), theBackComps.end());
56 
57  for (vector<const GeometricSearchDet*>::const_iterator it = theComps.begin(); it != theComps.end(); it++) {
58  theBasicComps.insert(theBasicComps.end(), (**it).basicComponents().begin(), (**it).basicComponents().end());
59  }
60 
61  //This should be no necessary. TO BE CHECKED
62  //sort(theFrontPetals.begin(), theFrontPetals.end(), PetalLessPhi());
63  //sort(theBackPetals.begin(), theBackPetals.end(), PetalLessPhi());
64 
65  // building disk for front and back petals
66  setSurface(computeDisk(theComps));
67  theFrontDisk = computeDisk(theFrontComps);
68  theBackDisk = computeDisk(theBackComps);
69 
70  // set up the bin finders
71  theFrontBinFinder = BinFinderPhi(theFrontComps.front()->position().phi(), theFrontComps.size());
72  theBackBinFinder = BinFinderPhi(theBackComps.front()->position().phi(), theBackComps.size());
73 
74  //--------- DEBUG INFO --------------
75  LogDebug("TkDetLayers") << "DEBUG INFO for TECLayer"
76  << "\n"
77  << "TECLayer z,perp, innerRadius, outerR: " << this->position().z() << " , "
78  << this->position().perp() << " , " << this->specificSurface().innerRadius() << " , "
79  << this->specificSurface().outerRadius();
80 
81  for (auto it = theFrontComps.begin(); it != theFrontComps.end(); it++) {
82  LogDebug("TkDetLayers") << "frontPetal phi,z,r: " << (*it)->surface().position().phi() << " , "
83  << (*it)->surface().position().z() << " , " << (*it)->surface().position().perp();
84  }
85 
86  for (auto it = theBackComps.begin(); it != theBackComps.end(); it++) {
87  LogDebug("TkDetLayers") << "backPetal phi,z,r: " << (*it)->surface().position().phi() << " , "
88  << (*it)->surface().position().z() << " , " << (*it)->surface().position().perp();
89  }
90  //-----------------------------------
91 }
92 
94  for (auto i = theComps.begin(); i != theComps.end(); i++) {
95  delete *i;
96  }
97 }
98 
100  const Propagator& prop,
101  const MeasurementEstimator& est,
102  std::vector<DetGroup>& result) const {
103  SubLayerCrossings crossings;
104  crossings = computeCrossings(tsos, prop.propagationDirection());
105  if (!crossings.isValid())
106  return;
107 
108  vector<DetGroup> closestResult;
109  addClosest(tsos, prop, est, crossings.closest(), closestResult);
110  LogDebug("TkDetLayers") << "in TECLayer, closestResult.size(): " << closestResult.size();
111 
112  // this differs from other groupedCompatibleDets logic, which DON'T check next in such cases!!!
113  if (closestResult.empty()) {
114  vector<DetGroup> nextResult;
115  addClosest(tsos, prop, est, crossings.other(), nextResult);
116  LogDebug("TkDetLayers") << "in TECLayer, nextResult.size(): " << nextResult.size();
117  if (nextResult.empty())
118  return;
119 
120  DetGroupElement nextGel(nextResult.front().front());
121  int crossingSide = LayerCrossingSide::endcapSide(nextGel.trajectoryState(), prop);
123  std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
124  } else {
125  DetGroupElement closestGel(closestResult.front().front());
126  float phiWindow = tkDetUtil::computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
127  searchNeighbors(tsos, prop, est, crossings.closest(), phiWindow, closestResult, false);
128  vector<DetGroup> nextResult;
129  searchNeighbors(tsos, prop, est, crossings.other(), phiWindow, nextResult, true);
130 
131  int crossingSide = LayerCrossingSide::endcapSide(closestGel.trajectoryState(), prop);
133  std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
134  }
135 }
136 
138  PropagationDirection propDir) const {
139  double rho(startingState.transverseCurvature());
140 
141  HelixPlaneCrossing::PositionType startPos(startingState.globalPosition());
142  HelixPlaneCrossing::DirectionType startDir(startingState.globalMomentum());
143  HelixForwardPlaneCrossing crossing(startPos, startDir, rho, propDir);
144 
145  pair<bool, double> frontPath = crossing.pathLength(*theFrontDisk);
146  if (!frontPath.first)
148 
149  GlobalPoint gFrontPoint(crossing.position(frontPath.second));
150 
151  LogDebug("TkDetLayers") << "in TECLayer,front crossing point: r,z,phi: (" << gFrontPoint.perp() << ","
152  << gFrontPoint.z() << "," << gFrontPoint.phi() << ")" << endl;
153 
154  int frontIndex = theFrontBinFinder.binIndex(gFrontPoint.barePhi());
155  SubLayerCrossing frontSLC(0, frontIndex, gFrontPoint);
156 
157  pair<bool, double> backPath = crossing.pathLength(*theBackDisk);
158  if (!backPath.first)
160 
161  GlobalPoint gBackPoint(crossing.position(backPath.second));
162  LogDebug("TkDetLayers") << "in TECLayer,back crossing point: r,z,phi: (" << gBackPoint.perp() << ","
163  << gFrontPoint.z() << "," << gBackPoint.phi() << ")" << endl;
164 
165  int backIndex = theBackBinFinder.binIndex(gBackPoint.barePhi());
166  SubLayerCrossing backSLC(1, backIndex, gBackPoint);
167 
168  // 0ss: frontDisk has index=0, backDisk has index=1
169  float frontDist = std::abs(Geom::deltaPhi(gFrontPoint.barePhi(), theFrontComps[frontIndex]->surface().phi()));
170  float backDist = std::abs(Geom::deltaPhi(gBackPoint.barePhi(), theBackComps[backIndex]->surface().phi()));
171 
172  if (frontDist < backDist) {
173  return SubLayerCrossings(frontSLC, backSLC, 0);
174  } else {
175  return SubLayerCrossings(backSLC, frontSLC, 1);
176  }
177 }
178 
180  const Propagator& prop,
181  const MeasurementEstimator& est,
182  const SubLayerCrossing& crossing,
183  vector<DetGroup>& result) const {
184  const auto& sub(subLayer(crossing.subLayerIndex()));
185  const auto det(sub[crossing.closestDetIndex()]);
186 
187  LogDebug("TkDetLayers") << "in TECLayer, adding petal at r,z,phi: (" << det->position().perp() << ","
188  << det->position().z() << "," << det->position().phi() << ")" << endl;
189 
190  return CompatibleDetToGroupAdder().add(*det, tsos, prop, est, result);
191 }
192 
193 namespace {
194  inline bool overlap(float phi, const TECPetal& gsdet, float phiWin) {
195  const BoundDiskSector& diskSector = gsdet.specificSurface();
196  pair<float, float> phiRange(phi - phiWin, phi + phiWin);
197  pair<float, float> petalPhiRange(diskSector.phi() - diskSector.phiHalfExtension(),
198  diskSector.phi() + diskSector.phiHalfExtension());
199 
200  return rangesIntersect(phiRange, petalPhiRange, [](auto x, auto y) { return Geom::phiLess(x, y); });
201  }
202 
203 } // namespace
204 
206  const Propagator& prop,
207  const MeasurementEstimator& est,
208  const SubLayerCrossing& crossing,
209  float window,
210  vector<DetGroup>& result,
211  bool checkClosest) const {
212  const GlobalPoint& gCrossingPos = crossing.position();
213  auto gphi = gCrossingPos.barePhi();
214 
215  const auto& sLayer(subLayer(crossing.subLayerIndex()));
216 
217  int closestIndex = crossing.closestDetIndex();
218  int negStartIndex = closestIndex - 1;
219  int posStartIndex = closestIndex + 1;
220 
221  if (checkClosest) { // must decide if the closest is on the neg or pos side
222  if (Geom::phiLess(gphi, sLayer[closestIndex]->surface().phi())) {
223  posStartIndex = closestIndex;
224  } else {
225  negStartIndex = closestIndex;
226  }
227  }
228 
229  const BinFinderPhi& binFinder = (crossing.subLayerIndex() == 0 ? theFrontBinFinder : theBackBinFinder);
230 
231  typedef CompatibleDetToGroupAdder Adder;
232  int half = sLayer.size() / 2; // to check if dets are called twice....
233  for (int idet = negStartIndex; idet >= negStartIndex - half; idet--) {
234  const auto& neighborPetal = *sLayer[binFinder.binIndex(idet)];
235  if (!overlap(gphi, neighborPetal, window))
236  break;
237  if (!Adder::add(neighborPetal, tsos, prop, est, result))
238  break;
239  // maybe also add shallow crossing angle test here???
240  }
241  for (int idet = posStartIndex; idet < posStartIndex + half; idet++) {
242  const auto& neighborPetal = *sLayer[binFinder.binIndex(idet)];
243  if (!overlap(gphi, neighborPetal, window))
244  break;
245  if (!Adder::add(neighborPetal, tsos, prop, est, result))
246  break;
247  // maybe also add shallow crossing angle test here???
248  }
249 }
SubLayerCrossing::position
const GlobalPoint & position() const
Definition: SubLayerCrossings.h:14
BoundDiskSector::phiHalfExtension
float phiHalfExtension() const
Definition: BoundDiskSector.h:15
TECLayer::theFrontBinFinder
BinFinderPhi theFrontBinFinder
Definition: TECLayer.h:67
MeasurementEstimator
Definition: MeasurementEstimator.h:19
tkDetUtil::computeWindowSize
float computeWindowSize(const GeomDet *det, const TrajectoryStateOnSurface &tsos, const MeasurementEstimator &est)
Definition: TkDetUtil.cc:10
TkRotation< float >
SubLayerCrossings::isValid
bool isValid()
Definition: SubLayerCrossings.h:28
CompositeTECPetal
Definition: CompositeTECPetal.h:18
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
TECLayer::theBackBinFinder
BinFinderPhi theBackBinFinder
Definition: TECLayer.h:68
LayerCrossingSide.h
TECLayer::~TECLayer
~TECLayer() override __attribute__((cold))
Definition: TECLayer.cc:93
SubLayerCrossings::closestIndex
int closestIndex() const
Definition: SubLayerCrossings.h:31
min
T min(T a, T b)
Definition: MathUtil.h:58
VectorUtil.h
ForwardDetLayer::surface
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
Definition: ForwardDetLayer.h:29
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
TECLayer::theBackComps
std::vector< const TECPetal * > theBackComps
Definition: TECLayer.h:60
pos
Definition: PixelAliasList.h:18
TECLayer::theBackDisk
ReferenceCountingPointer< BoundDisk > theBackDisk
Definition: TECLayer.h:63
svgfig.window
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
ForwardDetLayer::setSurface
void setSurface(BoundDisk *cp)
Definition: ForwardDetLayer.cc:13
TECLayer::theFrontDisk
ReferenceCountingPointer< BoundDisk > theFrontDisk
Definition: TECLayer.h:62
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
GeometricSearchDet::position
virtual const Surface::PositionType & position() const
Returns position of the surface.
Definition: GeometricSearchDet.h:31
TECLayer::addClosest
bool addClosest(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, std::vector< DetGroup > &result) const __attribute__((hot))
Definition: TECLayer.cc:179
SiStripMonitorCluster_cfi.zmin
zmin
Definition: SiStripMonitorCluster_cfi.py:200
BoundDisk
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
SimpleDiskBounds
Definition: SimpleDiskBounds.h:11
Propagator
Definition: Propagator.h:44
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TECLayer::searchNeighbors
void searchNeighbors(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, const SubLayerCrossing &crossing, float window, std::vector< DetGroup > &result, bool checkClosest) const __attribute__((hot))
Definition: TECLayer.cc:205
DetLayerException.h
LayerCrossingSide::endcapSide
static int endcapSide(const TrajectoryStateOnSurface &startingState, const Propagator &prop)
Definition: LayerCrossingSide.h:31
SiStripMonitorCluster_cfi.zmax
zmax
Definition: SiStripMonitorCluster_cfi.py:201
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
Propagator::propagationDirection
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
mps_fire.end
end
Definition: mps_fire.py:242
TECLayer::theComps
std::vector< const GeometricSearchDet * > theComps
Definition: TECLayer.h:56
TECLayer::computeCrossings
SubLayerCrossings computeCrossings(const TrajectoryStateOnSurface &startingState, PropagationDirection propDir) const __attribute__((hot))
Definition: TECLayer.cc:137
DetGroupMerger.h
Point3DBase< float, GlobalTag >
trackingPOGFilters_cfi.phiWindow
phiWindow
Definition: trackingPOGFilters_cfi.py:109
DDAxes::rho
DetGroupMerger::orderAndMergeTwoLevels
static void orderAndMergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
Definition: DetGroupMerger.cc:6
TECLayer::TECLayer
TECLayer(std::vector< const TECPetal * > &innerPetals, std::vector< const TECPetal * > &outerPetals) __attribute__((cold))
Definition: TECLayer.cc:50
TkDetUtil.h
funct::true
true
Definition: Factorize.h:173
CompatibleDetToGroupAdder::add
static bool add(const GeometricSearchDet &det, const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) __attribute__((hot))
Definition: CompatibleDetToGroupAdder.cc:7
SubLayerCrossings::closest
const SubLayerCrossing & closest() const
Definition: SubLayerCrossings.h:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
CompositeTECPetal::specificSurface
virtual const BoundDiskSector & specificSurface() const final
Definition: CompositeTECPetal.h:32
Geom::phiLess
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:18
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
GloballyPositioned::phi
T phi() const
Definition: GloballyPositioned.h:40
SubLayerCrossing::closestDetIndex
int closestDetIndex() const
Definition: SubLayerCrossings.h:13
TECLayer::groupedCompatibleDetsV
void groupedCompatibleDetsV(const TrajectoryStateOnSurface &tsos, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetGroup > &result) const override __attribute__((hot))
Definition: TECLayer.cc:99
DetGroupElement
Definition: DetGroup.h:10
goodZToMuMu_cfi.overlap
overlap
Definition: goodZToMuMu_cfi.py:108
GeometricSearchDet::DetWithState
std::pair< const GeomDet *, TrajectoryStateOnSurface > DetWithState
Definition: GeometricSearchDet.h:19
BoundDiskSector::outerRadius
float outerRadius() const
Definition: BoundDiskSector.h:14
CompatibleDetToGroupAdder.h
BoundDiskSector
Definition: BoundDiskSector.h:7
DDAxes::phi
TECLayer::theFrontComps
std::vector< const TECPetal * > theFrontComps
Definition: TECLayer.h:59
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ForwardDetLayer
Definition: ForwardDetLayer.h:22
PeriodicBinFinderInPhi< float >
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
genVertex_cff.x
x
Definition: genVertex_cff.py:12
CompatibleDetToGroupAdder
Definition: CompatibleDetToGroupAdder.h:13
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
SubLayerCrossings::other
const SubLayerCrossing & other() const
Definition: SubLayerCrossings.h:30
rangesIntersect
bool rangesIntersect(const Range &a, const Range &b)
Definition: rangesIntersect.h:14
PeriodicBinFinderInPhi::binIndex
int binIndex(T phi) const override
returns an index in the valid range for the bin that contains phi
Definition: PeriodicBinFinderInPhi.h:25
DetWithState
GeometricSearchDet::DetWithState DetWithState
Definition: TECLayer.cc:18
SubLayerCrossing
Definition: SubLayerCrossings.h:7
SubLayerCrossing::subLayerIndex
int subLayerIndex() const
Definition: SubLayerCrossings.h:12
BoundDiskSector::innerRadius
float innerRadius() const
Definition: BoundDiskSector.h:13
mps_fire.result
result
Definition: mps_fire.py:311
HelixForwardPlaneCrossing
Definition: HelixForwardPlaneCrossing.h:13
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
SimpleDiskBounds.h
BoundDisk
Disk BoundDisk
Definition: BoundDisk.h:54
rangesIntersect.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
Basic3DVector< float >
HelixForwardPlaneCrossing.h
TECLayer.h
TECLayer::subLayer
const std::vector< const TECPetal * > & subLayer(int ind) const
Definition: TECLayer.h:53
ForwardDetLayer::specificSurface
virtual const BoundDisk & specificSurface() const final
Definition: ForwardDetLayer.h:39
TECLayer::theBasicComps
std::vector< const GeomDet * > theBasicComps
Definition: TECLayer.h:57
TECLayer::BinFinderPhi
PeriodicBinFinderInPhi< float > BinFinderPhi
Definition: TECLayer.h:65
SubLayerCrossings
Definition: SubLayerCrossings.h:22