CMS 3D CMS Logo

PixelTripletLowPtGenerator.cc
Go to the documentation of this file.
5 
8 
13 
16 
19 
20 #undef Debug
21 
22 using namespace std;
23 
24 /*****************************************************************************/
26  : HitTripletGeneratorFromPairAndLayers(), // no theMaxElement used in this class
27  theTracker(nullptr),
28  theClusterShapeCacheToken(
29  iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("clusterShapeCacheSrc"))) {
30  checkMultipleScattering = cfg.getParameter<bool>("checkMultipleScattering");
31  nSigMultipleScattering = cfg.getParameter<double>("nSigMultipleScattering");
32  checkClusterShape = cfg.getParameter<bool>("checkClusterShape");
33  rzTolerance = cfg.getParameter<double>("rzTolerance");
34  maxAngleRatio = cfg.getParameter<double>("maxAngleRatio");
35  builderName = cfg.getParameter<string>("TTRHBuilder");
36 }
37 
38 /*****************************************************************************/
40 
41 /*****************************************************************************/
42 
43 /*****************************************************************************/
45  if (theTracker == nullptr) {
46  // Get tracker geometry
48  es.get<TrackerDigiGeometryRecord>().get(tracker);
49 
50  theTracker = tracker.product();
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
74  es.get<TrackerTopologyRcd>().get(tTopoHand);
75  const TrackerTopology* tTopo = tTopoHand.product();
76 
78  ev.getByToken(theClusterShapeCacheToken, clusterShapeCache);
79 
80  // Generate pairs
81  OrderedHitPairs pairs;
82  pairs.reserve(30000);
83  thePairGenerator->hitPairs(region, pairs, ev, es, pairLayers);
84 
85  if (pairs.empty())
86  return;
87 
88  int size = thirdLayers.size();
89 
90  // Set aliases
91  const RecHitsSortedInPhi** thirdHitMap = new const RecHitsSortedInPhi*[size];
92  for (int il = 0; il < size; il++)
93  thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, es);
94 
95  // Get tracker
96  getTracker(es);
97 
98  // Look at all generated pairs
99  for (OrderedHitPairs::const_iterator ip = pairs.begin(); ip != pairs.end(); ip++) {
100  // Fill rechits and points
101  vector<const TrackingRecHit*> recHits(3);
102  vector<GlobalPoint> points(3);
103 
104  recHits[0] = (*ip).inner()->hit();
105  recHits[1] = (*ip).outer()->hit();
106 
107 #ifdef Debug
108  cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) + HitInfo::getInfo(*recHits[1]) << endl;
109 #endif
110 
111  for (int i = 0; i < 2; i++)
112  points[i] = getGlobalPosition(recHits[i]);
113 
114  // Initialize helix prediction
115  ThirdHitPrediction thePrediction(
116  region, points[0], points[1], es, nSigMultipleScattering, maxAngleRatio, builderName);
117 
118  // Look at all layers
119  for (int il = 0; il < size; il++) {
120  const DetLayer* layer = thirdLayers[il].detLayer();
121 
122 #ifdef Debug
123  cerr << " check layer " << layer->subDetector() << " " << layer->location() << endl;
124 #endif
125 
126  // Get ranges for the third hit
127  float phi[2], rz[2];
128  thePrediction.getRanges(layer, phi, rz);
129 
130  PixelRecoRange<float> phiRange(phi[0], phi[1]);
131  PixelRecoRange<float> rzRange(rz[0] - rzTolerance, rz[1] + rzTolerance);
132 
133  // Get third hit candidates from cache
135  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(), phiRange.max());
136  typedef vector<Hit>::const_iterator IH;
137 
138  for (IH th = thirdHits.begin(), eh = thirdHits.end(); th < eh; ++th) {
139  // Fill rechit and point
140  recHits[2] = (*th)->hit();
141  points[2] = getGlobalPosition(recHits[2]);
142 
143 #ifdef Debug
144  cerr << " third hit " + HitInfo::getInfo(*recHits[2]) << endl;
145 #endif
146 
147  // Check if third hit is compatible with multiple scattering
148  vector<GlobalVector> globalDirs;
149  if (thePrediction.isCompatibleWithMultipleScattering(points[2], recHits, globalDirs, es) == false) {
150 #ifdef Debug
151  cerr << " not compatible: multiple scattering" << endl;
152 #endif
154  continue;
155  }
156 
157  // Convert to localDirs
158  /*
159  vector<LocalVector> localDirs;
160  vector<GlobalVector>::const_iterator globalDir = globalDirs.begin();
161  for(vector<const TrackingRecHit *>::const_iterator
162  recHit = recHits.begin();
163  recHit != recHits.end(); recHit++)
164  {
165  localDirs.push_back(theTracker->idToDet(
166  (*recHit)->geographicalId())->toLocal(*globalDir));
167  globalDir++;
168  }
169 */
170 
171  // Check if the cluster shapes are compatible with thrusts
172  if (checkClusterShape) {
173  if (!theFilter->checkTrack(recHits, globalDirs, tTopo, *clusterShapeCache)) {
174 #ifdef Debug
175  cerr << " not compatible: cluster shape" << endl;
176 #endif
177  continue;
178  }
179  }
180 
181  // All checks passed, put triplet back
182  result.push_back(OrderedHitTriplet((*ip).inner(), (*ip).outer(), *th));
183  }
184  }
185  }
186  delete[] thirdHitMap;
187 
188  return;
189 }
192  const edm::EventSetup& es,
193  const HitDoublets& doublets,
194  const RecHitsSortedInPhi** thirdHitMap,
195  const std::vector<const DetLayer*>& thirdLayerDetLayer,
196  const int nThirdLayers) {
197  throw cms::Exception("Error") << "PixelTripletLowPtGenerator::hitTriplets is not implemented \n";
198 }
size
Write out results.
PixelTripletLowPtGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
T getParameter(std::string const &) const
std::vector< Hit > hits(float phiMin, float phiMax) const
T max() const
void getTracker(const edm::EventSetup &es)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
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
#define nullptr
virtual Location location() const =0
Which part of the detector (barrel, endcap)
bool ev
T min() const
std::unique_ptr< TripletFilter > theFilter
virtual LocalPoint localPosition() const =0
edm::EDGetTokenT< SiPixelClusterShapeCache > theClusterShapeCacheToken
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
Definition: DetId.h:17
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
const TrackerGeometry * theTracker
HLT enums.
T get() const
Definition: EventSetup.h:73
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint getGlobalPosition(const TrackingRecHit *recHit)
DetId geographicalId() const
bool isCompatibleWithMultipleScattering(GlobalPoint g3, const std::vector< const TrackingRecHit * > &h, std::vector< GlobalVector > &localDirs, const edm::EventSetup &es)
void getRanges(const DetLayer *layer, float phi[], float rz[])
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:19
T const * product() const
Definition: ESHandle.h:86