Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:05

0001 #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
0002 #include <cmath>
0003 #include <sstream>
0004 #include "TrackingTools/DetLayers/interface/DetLayer.h"
0005 #include "RecoTracker/TkTrackingRegions/interface/HitEtaCheck.h"
0006 #include "RecoTracker/TkTrackingRegions/interface/HitRCheck.h"
0007 #include "RecoTracker/TkTrackingRegions/interface/HitZCheck.h"
0008 
0009 #include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h"
0010 #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisation.h"
0011 #include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h"
0012 #include "RecoTracker/TkMSParametrization/interface/PixelRecoLineRZ.h"
0013 
0014 template <class T>
0015 T sqr(T t) {
0016   return t * t;
0017 }
0018 
0019 using namespace GeomDetEnumerators;
0020 
0021 std::string GlobalTrackingRegion::print() const {
0022   std::ostringstream str;
0023   str << TrackingRegionBase::print() << "precise: " << thePrecise;
0024   return str.str();
0025 }
0026 
0027 TrackingRegion::Hits GlobalTrackingRegion::hits(const SeedingLayerSetsHits::SeedingLayer& layer) const {
0028   return layer.hits();
0029 }
0030 
0031 std::unique_ptr<HitRZCompatibility> GlobalTrackingRegion::checkRZ(const DetLayer* layer,
0032                                                                   const Hit& outerHit,
0033                                                                   const DetLayer* outerlayer,
0034                                                                   float lr,
0035                                                                   float gz,
0036                                                                   float dr,
0037                                                                   float dz) const {
0038   bool isBarrel = layer->isBarrel();
0039   bool isPixel = (layer->subDetector() == PixelBarrel || layer->subDetector() == PixelEndcap);
0040 
0041   if UNLIKELY (!outerlayer) {
0042     GlobalPoint ohit = outerHit->globalPosition();
0043     lr = std::sqrt(sqr(ohit.x() - origin().x()) + sqr(ohit.y() - origin().y()));
0044     gz = ohit.z();
0045     dr = outerHit->errorGlobalR();
0046     dz = outerHit->errorGlobalZ();
0047   }
0048 
0049   PixelRecoPointRZ outerred(lr, gz);
0050 
0051   PixelRecoPointRZ vtxR = (gz > origin().z() + originZBound())
0052                               ? PixelRecoPointRZ(-originRBound(), origin().z() + originZBound())
0053                               : PixelRecoPointRZ(originRBound(), origin().z() + originZBound());
0054   PixelRecoPointRZ vtxL = (gz < origin().z() - originZBound())
0055                               ? PixelRecoPointRZ(-originRBound(), origin().z() - originZBound())
0056                               : PixelRecoPointRZ(originRBound(), origin().z() - originZBound());
0057 
0058   if UNLIKELY ((!thePrecise) && (isPixel)) {
0059     auto VcotMin = PixelRecoLineRZ(vtxR, outerred).cotLine();
0060     auto VcotMax = PixelRecoLineRZ(vtxL, outerred).cotLine();
0061     return std::make_unique<HitEtaCheck>(isBarrel, outerred, VcotMax, VcotMin);
0062   }
0063 
0064   constexpr float nSigmaPhi = 3.;
0065 
0066   dr *= nSigmaPhi;
0067   dz *= nSigmaPhi;
0068 
0069   PixelRecoPointRZ outerL, outerR;
0070   if (isBarrel) {
0071     outerL = PixelRecoPointRZ(lr, gz - dz);
0072     outerR = PixelRecoPointRZ(lr, gz + dz);
0073   } else if (gz > 0) {
0074     outerL = PixelRecoPointRZ(lr + dr, gz);
0075     outerR = PixelRecoPointRZ(lr - dr, gz);
0076   } else {
0077     outerL = PixelRecoPointRZ(lr - dr, gz);
0078     outerR = PixelRecoPointRZ(lr + dr, gz);
0079   }
0080 
0081   auto corr = isBarrel ? dz : dr;
0082 
0083   SimpleLineRZ leftLine(vtxL, outerL);
0084   SimpleLineRZ rightLine(vtxR, outerR);
0085   HitRZConstraint rzConstraint(leftLine, rightLine);
0086 
0087   if UNLIKELY (theUseMS) {
0088     MultipleScatteringParametrisation iSigma = theMSMaker->parametrisation(layer);
0089     PixelRecoPointRZ vtxMean(0., origin().z());
0090 
0091     float innerScatt = 3.f * (outerlayer ? iSigma(ptMin(), vtxMean, outerred, outerlayer->seqNum())
0092                                          : iSigma(ptMin(), vtxMean, outerred));
0093 
0094     float cotTheta = SimpleLineRZ(vtxMean, outerred).cotLine();
0095 
0096     if (isBarrel) {
0097       float sinTheta = 1 / std::sqrt(1 + sqr(cotTheta));
0098       corr = innerScatt / sinTheta + dz;
0099     } else {
0100       float cosTheta = 1 / std::sqrt(1 + sqr(1 / cotTheta));
0101       corr = innerScatt / cosTheta + dr;
0102     }
0103   }
0104 
0105   if (isBarrel) {
0106     return std::make_unique<HitZCheck>(rzConstraint, HitZCheck::Margin(corr, corr));
0107   } else {
0108     return std::make_unique<HitRCheck>(rzConstraint, HitRCheck::Margin(corr, corr));
0109   }
0110 }
0111 
0112 void GlobalTrackingRegion::checkTracks(reco::TrackCollection const& tracks, std::vector<bool>& mask) const {
0113   const math::XYZPoint regOrigin(origin().x(), origin().y(), origin().z());
0114 
0115   assert(mask.size() == tracks.size());
0116   int i = -1;
0117   for (auto const& track : tracks) {
0118     i++;
0119     if (mask[i])
0120       continue;
0121 
0122     if (track.pt() < ptMin()) {
0123       continue;
0124     }
0125     if (std::abs(track.dxy(regOrigin)) > originRBound()) {
0126       continue;
0127     }
0128     if (std::abs(track.dz(regOrigin)) > originZBound()) {
0129       continue;
0130     }
0131 
0132     mask[i] = true;
0133   }
0134 }