Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:46

0001 #include "TBPLayer.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "LayerCrossingSide.h"
0006 #include "DetGroupMerger.h"
0007 #include "CompatibleDetToGroupAdder.h"
0008 #include "BarrelUtil.h"
0009 
0010 #include "TrackingTools/DetLayers/interface/DetLayerException.h"
0011 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0012 #include "TrackingTools/GeomPropagators/interface/HelixBarrelCylinderCrossing.h"
0013 #include "TrackingTools/DetLayers/interface/CylinderBuilderFromDet.h"
0014 #include "DataFormats/GeometryVector/interface/VectorUtil.h"
0015 
0016 using namespace std;
0017 
0018 typedef GeometricSearchDet::DetWithState DetWithState;
0019 
0020 void TBPLayer::construct() {
0021   theComps.assign(theInnerComps.begin(), theInnerComps.end());
0022   theComps.insert(theComps.end(), theOuterComps.begin(), theOuterComps.end());
0023 
0024   for (vector<const GeometricSearchDet*>::const_iterator it = theComps.begin(); it != theComps.end(); it++) {
0025     theBasicComps.insert(theBasicComps.end(), (**it).basicComponents().begin(), (**it).basicComponents().end());
0026   }
0027 
0028   theInnerCylinder = cylinder(theInnerComps);
0029   theOuterCylinder = cylinder(theOuterComps);
0030 
0031   if (!theInnerComps.empty())
0032     theInnerBinFinder = BinFinderType(theInnerComps.front()->position().phi(), theInnerComps.size());
0033 
0034   if (!theOuterComps.empty())
0035     theOuterBinFinder = BinFinderType(theOuterComps.front()->position().phi(), theOuterComps.size());
0036 
0037   BarrelDetLayer::initialize();
0038 
0039   //--------- DEBUG INFO --------------
0040   LogDebug("TkDetLayers") << "==== DEBUG TBPLayer =====";
0041   LogDebug("TkDetLayers") << "innerCyl radius, thickness, lenght: " << theInnerCylinder->radius() << " , "
0042                           << theInnerCylinder->bounds().thickness() << " , " << theInnerCylinder->bounds().length();
0043 
0044   LogDebug("TkDetLayers") << "outerCyl radius, thickness, lenght: " << theOuterCylinder->radius() << " , "
0045                           << theOuterCylinder->bounds().thickness() << " , " << theOuterCylinder->bounds().length();
0046 
0047   LogDebug("TkDetLayers") << "Cyl radius, thickness, lenght: " << specificSurface().radius() << " , "
0048                           << specificSurface().bounds().thickness() << " , " << specificSurface().bounds().length();
0049 
0050   for (vector<const GeometricSearchDet*>::const_iterator i = theInnerComps.begin(); i != theInnerComps.end(); i++) {
0051     LogDebug("TkDetLayers") << "inner Rod pos z,perp,eta,phi: " << (**i).position().z() << " , "
0052                             << (**i).position().perp() << " , " << (**i).position().eta() << " , "
0053                             << (**i).position().phi();
0054   }
0055 
0056   for (vector<const GeometricSearchDet*>::const_iterator i = theOuterComps.begin(); i != theOuterComps.end(); i++) {
0057     LogDebug("TkDetLayers") << "outer Rod pos z,perp,eta,phi: " << (**i).position().z() << " , "
0058                             << (**i).position().perp() << " , " << (**i).position().eta() << " , "
0059                             << (**i).position().phi();
0060   }
0061   LogDebug("TkDetLayers") << "==== end DEBUG TBPLayer =====";
0062 }
0063 
0064 TBPLayer::~TBPLayer() {}
0065 
0066 BoundCylinder* TBPLayer::cylinder(const vector<const GeometricSearchDet*>& rods) const {
0067   vector<const GeomDet*> tmp;
0068   for (vector<const GeometricSearchDet*>::const_iterator it = rods.begin(); it != rods.end(); it++) {
0069     tmp.insert(tmp.end(), (*it)->basicComponents().begin(), (*it)->basicComponents().end());
0070   }
0071   return CylinderBuilderFromDet()(tmp.begin(), tmp.end());
0072 }
0073 
0074 // private methods for the implementation of groupedCompatibleDets()
0075 
0076 std::tuple<bool, int, int> TBPLayer::computeIndexes(GlobalPoint gInnerPoint, GlobalPoint gOuterPoint) const {
0077   int innerIndex = theInnerBinFinder.binIndex(gInnerPoint.barePhi());
0078   float innerDist = theInnerBinFinder.binPosition(innerIndex) - gInnerPoint.barePhi();
0079 
0080   int outerIndex = theOuterBinFinder.binIndex(gOuterPoint.barePhi());
0081   float outerDist = theOuterBinFinder.binPosition(outerIndex) - gOuterPoint.barePhi();
0082 
0083   innerDist *= Geom::phiLess(theInnerBinFinder.binPosition(innerIndex), gInnerPoint.barePhi()) ? -1.f : 1.f;
0084   outerDist *= Geom::phiLess(theOuterBinFinder.binPosition(outerIndex), gOuterPoint.barePhi()) ? -1.f : 1.f;
0085   if (innerDist < 0.f) {
0086     innerDist += Geom::ftwoPi();
0087   }
0088   if (outerDist < 0.f) {
0089     outerDist += Geom::ftwoPi();
0090   }
0091 
0092   return std::make_tuple(innerDist < outerDist, innerIndex, outerIndex);
0093 }
0094 
0095 float TBPLayer::computeWindowSize(const GeomDet* det,
0096                                   const TrajectoryStateOnSurface& tsos,
0097                                   const MeasurementEstimator& est) const {
0098   return barrelUtil::computeWindowSize(det, tsos, est);
0099 }
0100 
0101 void TBPLayer::searchNeighbors(const TrajectoryStateOnSurface& tsos,
0102                                const Propagator& prop,
0103                                const MeasurementEstimator& est,
0104                                const SubLayerCrossing& crossing,
0105                                float window,
0106                                vector<DetGroup>& result,
0107                                bool checkClosest) const {
0108   using barrelUtil::overlap;
0109 
0110   const GlobalPoint& gCrossingPos = crossing.position();
0111   auto gphi = gCrossingPos.barePhi();
0112 
0113   const vector<const GeometricSearchDet*>& sLayer(subLayer(crossing.subLayerIndex()));
0114 
0115   int closestIndex = crossing.closestDetIndex();
0116   int negStartIndex = closestIndex - 1;
0117   int posStartIndex = closestIndex + 1;
0118 
0119   if (checkClosest) {  // must decide if the closest is on the neg or pos side
0120     if (Geom::phiLess(gphi, sLayer[closestIndex]->surface().phi())) {
0121       posStartIndex = closestIndex;
0122     } else {
0123       negStartIndex = closestIndex;
0124     }
0125   }
0126 
0127   const BinFinderType& binFinder = (crossing.subLayerIndex() == 0 ? theInnerBinFinder : theOuterBinFinder);
0128 
0129   typedef CompatibleDetToGroupAdder Adder;
0130   int quarter = sLayer.size() / 4;
0131   for (int idet = negStartIndex; idet >= negStartIndex - quarter; idet--) {
0132     const GeometricSearchDet& neighborRod = *sLayer[binFinder.binIndex(idet)];
0133     if (!overlap(gphi, neighborRod, window))
0134       break;
0135     if (!Adder::add(neighborRod, tsos, prop, est, result))
0136       break;
0137     // maybe also add shallow crossing angle test here???
0138   }
0139   for (int idet = posStartIndex; idet < posStartIndex + quarter; idet++) {
0140     const GeometricSearchDet& neighborRod = *sLayer[binFinder.binIndex(idet)];
0141     if (!overlap(gphi, neighborRod, window))
0142       break;
0143     if (!Adder::add(neighborRod, tsos, prop, est, result))
0144       break;
0145     // maybe also add shallow crossing angle test here???
0146   }
0147 }