CMS 3D CMS Logo

PixelTripletLowPtGenerator.cc
Go to the documentation of this file.
5 
8 
10 
13 
18 
19 #undef Debug
20 
21 using namespace std;
22 
23 /*****************************************************************************/
25  : HitTripletGeneratorFromPairAndLayers(), // no theMaxElement used in this class
27  m_topoToken(iC.esConsumes<TrackerTopology, TrackerTopologyRcd>()),
28  m_magfieldToken(iC.esConsumes()),
29  m_ttrhBuilderToken(iC.esConsumes(edm::ESInputTag("", cfg.getParameter<string>("TTRHBuilder")))),
30  m_msmakerToken(iC.esConsumes()),
31  theTracker(nullptr),
32  theClusterShapeCacheToken(
33  iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("clusterShapeCacheSrc"))) {
34  checkMultipleScattering = cfg.getParameter<bool>("checkMultipleScattering");
35  nSigMultipleScattering = cfg.getParameter<double>("nSigMultipleScattering");
36  checkClusterShape = cfg.getParameter<bool>("checkClusterShape");
37  rzTolerance = cfg.getParameter<double>("rzTolerance");
38  maxAngleRatio = cfg.getParameter<double>("maxAngleRatio");
39 }
40 
41 /*****************************************************************************/
43 
44 /*****************************************************************************/
45 
46 /*****************************************************************************/
48  if (theTracker == nullptr) {
49  // Get tracker geometry
51  }
52 
53  if (!theFilter) {
54  theFilter = std::make_unique<TripletFilter>(es);
55  }
56 }
57 
58 /*****************************************************************************/
60  DetId detId = recHit->geographicalId();
61 
62  return theTracker->idToDet(detId)->toGlobal(recHit->localPosition());
63 }
64 
65 /*****************************************************************************/
68  const edm::Event& ev,
69  const edm::EventSetup& es,
70  const SeedingLayerSetsHits::SeedingLayerSet& pairLayers,
71  const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers) {
72  //Retrieve tracker topology from geometry
73  const TrackerTopology* tTopo = &es.getData(m_topoToken);
74  const auto& magfield = es.getData(m_magfieldToken);
75  const auto& ttrhBuilder = es.getData(m_ttrhBuilderToken);
76  const auto& msmaker = es.getData(m_msmakerToken);
77 
80 
81  // Generate pairs
82  OrderedHitPairs pairs;
83  pairs.reserve(30000);
84  thePairGenerator->hitPairs(region, pairs, ev, es, pairLayers);
85 
86  if (pairs.empty())
87  return;
88 
89  int size = thirdLayers.size();
90 
91  // Set aliases
92  const RecHitsSortedInPhi** thirdHitMap = new const RecHitsSortedInPhi*[size];
93  for (int il = 0; il < size; il++)
94  thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region);
95 
96  // Get tracker
97  getTracker(es);
98 
99  // Look at all generated pairs
100  for (OrderedHitPairs::const_iterator ip = pairs.begin(); ip != pairs.end(); ip++) {
101  // Fill rechits and points
102  vector<const TrackingRecHit*> recHits(3);
103  vector<GlobalPoint> points(3);
104 
105  recHits[0] = (*ip).inner()->hit();
106  recHits[1] = (*ip).outer()->hit();
107 
108 #ifdef Debug
109  cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) + HitInfo::getInfo(*recHits[1]) << endl;
110 #endif
111 
112  for (int i = 0; i < 2; i++)
114 
115  // Initialize helix prediction
116  ThirdHitPrediction thePrediction(
118 
119  // Look at all layers
120  for (int il = 0; il < size; il++) {
121  const DetLayer* layer = thirdLayers[il].detLayer();
122 
123 #ifdef Debug
124  cerr << " check layer " << layer->subDetector() << " " << layer->location() << endl;
125 #endif
126 
127  // Get ranges for the third hit
128  float phi[2], rz[2];
129  thePrediction.getRanges(layer, phi, rz);
130 
131  PixelRecoRange<float> phiRange(phi[0], phi[1]);
132  PixelRecoRange<float> rzRange(rz[0] - rzTolerance, rz[1] + rzTolerance);
133 
134  // Get third hit candidates from cache
136  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(), phiRange.max());
137  typedef vector<Hit>::const_iterator IH;
138 
139  for (IH th = thirdHits.begin(), eh = thirdHits.end(); th < eh; ++th) {
140  // Fill rechit and point
141  recHits[2] = (*th)->hit();
143 
144 #ifdef Debug
145  cerr << " third hit " + HitInfo::getInfo(*recHits[2]) << endl;
146 #endif
147 
148  // Check if third hit is compatible with multiple scattering
149  vector<GlobalVector> globalDirs;
150  if (thePrediction.isCompatibleWithMultipleScattering(points[2], recHits, globalDirs, msmaker) == false) {
151 #ifdef Debug
152  cerr << " not compatible: multiple scattering" << endl;
153 #endif
155  continue;
156  }
157 
158  // Convert to localDirs
159  /*
160  vector<LocalVector> localDirs;
161  vector<GlobalVector>::const_iterator globalDir = globalDirs.begin();
162  for(vector<const TrackingRecHit *>::const_iterator
163  recHit = recHits.begin();
164  recHit != recHits.end(); recHit++)
165  {
166  localDirs.push_back(theTracker->idToDet(
167  (*recHit)->geographicalId())->toLocal(*globalDir));
168  globalDir++;
169  }
170 */
171 
172  // Check if the cluster shapes are compatible with thrusts
173  if (checkClusterShape) {
174  if (!theFilter->checkTrack(recHits, globalDirs, tTopo, *clusterShapeCache)) {
175 #ifdef Debug
176  cerr << " not compatible: cluster shape" << endl;
177 #endif
178  continue;
179  }
180  }
181 
182  // All checks passed, put triplet back
183  result.push_back(OrderedHitTriplet((*ip).inner(), (*ip).outer(), *th));
184  }
185  }
186  }
187  delete[] thirdHitMap;
188 
189  return;
190 }
193  const edm::EventSetup& es,
194  const HitDoublets& doublets,
195  const RecHitsSortedInPhi** thirdHitMap,
196  const std::vector<const DetLayer*>& thirdLayerDetLayer,
197  const int nThirdLayers) {
198  throw cms::Exception("Error") << "PixelTripletLowPtGenerator::hitTriplets is not implemented \n";
199 }
size
Write out results.
PixelTripletLowPtGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void getTracker(const edm::EventSetup &es)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > m_geomToken
void hitTriplets(const TrackingRegion &region, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es, const SeedingLayerSetsHits::SeedingLayerSet &pairLayers, const std::vector< SeedingLayerSetsHits::SeedingLayer > &thirdLayers) override
constexpr std::array< uint8_t, layerIndexSize > layer
std::unique_ptr< TripletFilter > theFilter
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_magfieldToken
const TrackerGeomDet * idToDet(DetId) const override
std::vector< Hit > hits(float phiMin, float phiMax) const
edm::EDGetTokenT< SiPixelClusterShapeCache > theClusterShapeCacheToken
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
Definition: DetId.h:17
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
const TrackerGeometry * theTracker
HLT enums.
GlobalPoint getGlobalPosition(const TrackingRecHit *recHit)
void getRanges(const DetLayer *layer, float phi[], float rz[])
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:19
edm::ESGetToken< MultipleScatteringParametrisationMaker, TrackerMultipleScatteringRecord > m_msmakerToken
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_topoToken
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > m_ttrhBuilderToken
bool isCompatibleWithMultipleScattering(GlobalPoint g3, const std::vector< const TrackingRecHit *> &h, std::vector< GlobalVector > &localDirs, const MultipleScatteringParametrisationMaker &msmaker)