Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:48

0001 #include "TBLayer.h"
0002 
0003 #include "LayerCrossingSide.h"
0004 #include "DetGroupMerger.h"
0005 #include "CompatibleDetToGroupAdder.h"
0006 
0007 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0008 #include "TrackingTools/GeomPropagators/interface/HelixBarrelCylinderCrossing.h"
0009 
0010 TBLayer::~TBLayer() {
0011   for (auto i : theComps)
0012     delete i;
0013 }
0014 
0015 void TBLayer::groupedCompatibleDetsV(const TrajectoryStateOnSurface& tsos,
0016                                      const Propagator& prop,
0017                                      const MeasurementEstimator& est,
0018                                      std::vector<DetGroup>& result) const {
0019   SubLayerCrossings crossings;
0020   crossings = computeCrossings(tsos, prop.propagationDirection());
0021   if (!crossings.isValid())
0022     return;
0023 
0024   std::vector<DetGroup> closestResult;
0025   addClosest(tsos, prop, est, crossings.closest(), closestResult);
0026   // for TIB this differs from compatibleDets logic, which checks next in such cases!!!
0027   if (closestResult.empty()) {
0028     if (!isTIB())
0029       addClosest(tsos, prop, est, crossings.other(), result);
0030     return;
0031   }
0032 
0033   DetGroupElement closestGel(closestResult.front().front());
0034   float window = computeWindowSize(closestGel.det(), closestGel.trajectoryState(), est);
0035 
0036   searchNeighbors(tsos, prop, est, crossings.closest(), window, closestResult, false);
0037 
0038   std::vector<DetGroup> nextResult;
0039   searchNeighbors(tsos, prop, est, crossings.other(), window, nextResult, true);
0040 
0041   int crossingSide = LayerCrossingSide().barrelSide(closestGel.trajectoryState(), prop);
0042   DetGroupMerger::orderAndMergeTwoLevels(
0043       std::move(closestResult), std::move(nextResult), result, crossings.closestIndex(), crossingSide);
0044 }
0045 
0046 SubLayerCrossings TBLayer::computeCrossings(const TrajectoryStateOnSurface& startingState,
0047                                             PropagationDirection propDir) const {
0048   GlobalPoint startPos(startingState.globalPosition());
0049   GlobalVector startDir(startingState.globalMomentum());
0050   double rho(startingState.transverseCurvature());
0051 
0052   bool inBetween = ((theOuterCylinder->position() - startPos).perp() < theOuterCylinder->radius()) &&
0053                    ((theInnerCylinder->position() - startPos).perp() > theInnerCylinder->radius());
0054 
0055   HelixBarrelCylinderCrossing innerCrossing(
0056       startPos, startDir, rho, propDir, *theInnerCylinder, HelixBarrelCylinderCrossing::onlyPos);
0057   if (!inBetween && !innerCrossing.hasSolution())
0058     return SubLayerCrossings();
0059 
0060   HelixBarrelCylinderCrossing outerCrossing(
0061       startPos, startDir, rho, propDir, *theOuterCylinder, HelixBarrelCylinderCrossing::onlyPos);
0062 
0063   if (!innerCrossing.hasSolution() && outerCrossing.hasSolution()) {
0064     innerCrossing = outerCrossing;
0065   } else if (!outerCrossing.hasSolution() && innerCrossing.hasSolution()) {
0066     outerCrossing = innerCrossing;
0067   }
0068 
0069   GlobalPoint gInnerPoint(innerCrossing.position());
0070   GlobalPoint gOuterPoint(outerCrossing.position());
0071 
0072   int innerIndex, outerIndex;
0073   bool inLess;
0074   std::tie(inLess, innerIndex, outerIndex) = computeIndexes(gInnerPoint, gOuterPoint);
0075 
0076   SubLayerCrossing innerSLC(0, innerIndex, gInnerPoint);
0077   SubLayerCrossing outerSLC(1, outerIndex, gOuterPoint);
0078 
0079   if (inLess) {
0080     return SubLayerCrossings(innerSLC, outerSLC, 0);
0081   } else {
0082     return SubLayerCrossings(outerSLC, innerSLC, 1);
0083   }
0084 }
0085 
0086 bool TBLayer::addClosest(const TrajectoryStateOnSurface& tsos,
0087                          const Propagator& prop,
0088                          const MeasurementEstimator& est,
0089                          const SubLayerCrossing& crossing,
0090                          std::vector<DetGroup>& result) const {
0091   auto const& sub = subLayer(crossing.subLayerIndex());
0092   auto det = sub[crossing.closestDetIndex()];
0093   return CompatibleDetToGroupAdder().add(*det, tsos, prop, est, result);
0094 }