File indexing completed on 2024-04-06 12:28:36
0001 #include "RecoTracker/PixelSeeding/interface/CosmicHitTripletGeneratorFromLayerTriplet.h"
0002 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
0003 #include "TrackingTools/DetLayers/interface/DetLayer.h"
0004 #include "RecoTracker/PixelSeeding/interface/OrderedHitTriplets.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
0007
0008 #include <cmath>
0009
0010 typedef TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit;
0011
0012 CosmicHitTripletGeneratorFromLayerTriplet::CosmicHitTripletGeneratorFromLayerTriplet(const LayerWithHits *inner,
0013 const LayerWithHits *middle,
0014 const LayerWithHits *outer,
0015 const TrackerGeometry &trackGeom)
0016 : trackerGeometry(&trackGeom),
0017
0018 theOuterLayer(outer),
0019 theMiddleLayer(middle),
0020 theInnerLayer(inner) {}
0021 void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion ®ion, OrderedHitTriplets &result) {
0022 if (theInnerLayer->recHits().empty())
0023 return;
0024 if (theMiddleLayer->recHits().empty())
0025 return;
0026 if (theOuterLayer->recHits().empty())
0027 return;
0028 float radius1 = dynamic_cast<const BarrelDetLayer *>(theInnerLayer->layer())->specificSurface().radius();
0029 float radius2 = dynamic_cast<const BarrelDetLayer *>(theMiddleLayer->layer())->specificSurface().radius();
0030 float radius3 = dynamic_cast<const BarrelDetLayer *>(theOuterLayer->layer())->specificSurface().radius();
0031 bool seedfromoverlaps = ((std::abs(radius1 - radius2) < 0.1) || (std::abs(radius3 - radius2) < 0.1)) ? true : false;
0032 std::vector<const TrackingRecHit *>::const_iterator ohh;
0033 std::vector<const TrackingRecHit *>::const_iterator mhh;
0034 std::vector<const TrackingRecHit *>::const_iterator ihh;
0035
0036 if (!seedfromoverlaps) {
0037 for (ohh = theOuterLayer->recHits().begin(); ohh != theOuterLayer->recHits().end(); ohh++) {
0038 auto oh = (BaseTrackerRecHit const *)(&*ohh);
0039 for (mhh = theMiddleLayer->recHits().begin(); mhh != theMiddleLayer->recHits().end(); mhh++) {
0040 auto mh = (BaseTrackerRecHit const *)(&*mhh);
0041 float z_diff = mh->globalPosition().z() - oh->globalPosition().z();
0042 float midy = mh->globalPosition().y();
0043 float outy = oh->globalPosition().y();
0044 float midx = mh->globalPosition().x();
0045 float outx = oh->globalPosition().x();
0046 float dxdy = std::abs((outx - midx) / (outy - midy));
0047 if ((std::abs(z_diff) < 30) && (outy * midy > 0) && (dxdy < 2)) {
0048 for (ihh = theInnerLayer->recHits().begin(); ihh != theInnerLayer->recHits().end(); ihh++) {
0049 auto ih = (BaseTrackerRecHit const *)(&*ihh);
0050 float z_diff = mh->globalPosition().z() - ih->globalPosition().z();
0051 float inny = ih->globalPosition().y();
0052 float innx = ih->globalPosition().x();
0053 float dxdy = std::abs((innx - midx) / (inny - midy));
0054 if ((std::abs(z_diff) < 30) && (inny * midy > 0) && (dxdy < 2) && (!seedfromoverlaps)) {
0055 result.push_back(OrderedHitTriplet(ih, mh, oh));
0056 }
0057 }
0058 }
0059 }
0060 }
0061 } else {
0062 for (ohh = theOuterLayer->recHits().begin(); ohh != theOuterLayer->recHits().end(); ohh++) {
0063 auto oh = (BaseTrackerRecHit const *)(&*ohh);
0064 for (mhh = theMiddleLayer->recHits().begin(); mhh != theMiddleLayer->recHits().end(); mhh++) {
0065 auto mh = (BaseTrackerRecHit const *)(&*mhh);
0066 float z_diff = mh->globalPosition().z() - oh->globalPosition().z();
0067 float midy = mh->globalPosition().y();
0068 float outy = oh->globalPosition().y();
0069 float midx = mh->globalPosition().x();
0070 float outx = oh->globalPosition().x();
0071 float dxdy = std::abs((outx - midx) / (outy - midy));
0072 float DeltaR = oh->globalPosition().perp() - mh->globalPosition().perp();
0073 if ((std::abs(z_diff) < 18) && (std::abs(oh->globalPosition().phi() - mh->globalPosition().phi()) < 0.05) &&
0074 (DeltaR < 0) && (dxdy < 2)) {
0075 for (ihh = theInnerLayer->recHits().begin(); ihh != theInnerLayer->recHits().end(); ihh++) {
0076 auto ih = (BaseTrackerRecHit const *)(&*ihh);
0077 float z_diff = mh->globalPosition().z() - ih->globalPosition().z();
0078 float inny = ih->globalPosition().y();
0079 float innx = ih->globalPosition().x();
0080 float dxdy = std::abs((innx - midx) / (inny - midy));
0081 if ((std::abs(z_diff) < 30) && (inny * midy > 0) && (dxdy < 2)) {
0082 result.push_back(OrderedHitTriplet(ih, mh, oh));
0083 }
0084 }
0085 }
0086 }
0087 }
0088 }
0089 }