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(iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("clusterShapeCacheSrc")))
29 {
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 
44 /*****************************************************************************/
46  (const edm::EventSetup& es)
47 {
48  if(theTracker == nullptr)
49  {
50  // Get tracker geometry
52  es.get<TrackerDigiGeometryRecord>().get(tracker);
53 
54  theTracker = tracker.product();
55  }
56 
57  if(!theFilter)
58  {
59  theFilter = std::make_unique<TripletFilter>(es);
60  }
61 }
62 
63 /*****************************************************************************/
66 {
67  DetId detId = recHit->geographicalId();
68 
69  return
70  theTracker->idToDet(detId)->toGlobal(recHit->localPosition());
71 }
72 
73 /*****************************************************************************/
75  const TrackingRegion& region,
77  const edm::Event & ev,
78  const edm::EventSetup& es,
79  const SeedingLayerSetsHits::SeedingLayerSet& pairLayers,
80  const std::vector<SeedingLayerSetsHits::SeedingLayer>& thirdLayers)
81 {
82 
83  //Retrieve tracker topology from geometry
85  es.get<TrackerTopologyRcd>().get(tTopoHand);
86  const TrackerTopology *tTopo=tTopoHand.product();
87 
88  edm::Handle<SiPixelClusterShapeCache> clusterShapeCache;
89  ev.getByToken(theClusterShapeCacheToken, clusterShapeCache);
90 
91  // Generate pairs
92  OrderedHitPairs pairs; pairs.reserve(30000);
93  thePairGenerator->hitPairs(region,pairs,ev,es, pairLayers);
94 
95  if (pairs.empty()) return;
96 
97  int size = thirdLayers.size();
98 
99  // Set aliases
100  const RecHitsSortedInPhi **thirdHitMap = new const RecHitsSortedInPhi*[size];
101  for(int il=0; il<size; il++)
102  thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, es);
103 
104  // Get tracker
105  getTracker(es);
106 
107  // Look at all generated pairs
108  for(OrderedHitPairs::const_iterator ip = pairs.begin();
109  ip!= pairs.end(); ip++)
110  {
111  // Fill rechits and points
112  vector<const TrackingRecHit*> recHits(3);
113  vector<GlobalPoint> points(3);
114 
115  recHits[0] = (*ip).inner()->hit();
116  recHits[1] = (*ip).outer()->hit();
117 
118 #ifdef Debug
119  cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) +
120  HitInfo::getInfo(*recHits[1]) << endl;
121 #endif
122 
123  for(int i=0; i<2; i++)
124  points[i] = getGlobalPosition(recHits[i]);
125 
126  // Initialize helix prediction
128  thePrediction(region,
129  points[0],points[1], es,
131 
132  // Look at all layers
133  for(int il=0; il<size; il++)
134  {
135  const DetLayer * layer = thirdLayers[il].detLayer();
136 
137 #ifdef Debug
138  cerr << " check layer " << layer->subDetector()
139  << " " << layer->location() << endl;
140 #endif
141 
142  // Get ranges for the third hit
143  float phi[2],rz[2];
144  thePrediction.getRanges(layer, phi,rz);
145 
146  PixelRecoRange<float> phiRange(phi[0] , phi[1] );
147  PixelRecoRange<float> rzRange( rz[0] - rzTolerance, rz[1] + rzTolerance);
148 
149  // Get third hit candidates from cache
151  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(),phiRange.max());
152  typedef vector<Hit>::const_iterator IH;
153 
154  for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th)
155  {
156  // Fill rechit and point
157  recHits[2] = (*th)->hit();
158  points[2] = getGlobalPosition(recHits[2]);
159 
160 #ifdef Debug
161  cerr << " third hit " + HitInfo::getInfo(*recHits[2]) << endl;
162 #endif
163 
164  // Check if third hit is compatible with multiple scattering
165  vector<GlobalVector> globalDirs;
166  if(thePrediction.isCompatibleWithMultipleScattering
167  (points[2], recHits, globalDirs, es) == false)
168  {
169 #ifdef Debug
170  cerr << " not compatible: multiple scattering" << endl;
171 #endif
172  if(checkMultipleScattering) continue;
173  }
174 
175  // Convert to localDirs
176 /*
177  vector<LocalVector> localDirs;
178  vector<GlobalVector>::const_iterator globalDir = globalDirs.begin();
179  for(vector<const TrackingRecHit *>::const_iterator
180  recHit = recHits.begin();
181  recHit != recHits.end(); recHit++)
182  {
183  localDirs.push_back(theTracker->idToDet(
184  (*recHit)->geographicalId())->toLocal(*globalDir));
185  globalDir++;
186  }
187 */
188 
189  // Check if the cluster shapes are compatible with thrusts
191  {
192  if(! theFilter->checkTrack(recHits,globalDirs,tTopo, *clusterShapeCache))
193  {
194 #ifdef Debug
195  cerr << " not compatible: cluster shape" << endl;
196 #endif
197  continue;
198  }
199  }
200 
201  // All checks passed, put triplet back
202  result.push_back(OrderedHitTriplet((*ip).inner(),(*ip).outer(),*th));
203  }
204  }
205  }
206  delete [] thirdHitMap;
207 
208  return;
209 }
211  const TrackingRegion& region,
213  const edm::EventSetup & es,
214  const HitDoublets & doublets,
215  const RecHitsSortedInPhi ** thirdHitMap,
216  const std::vector<const DetLayer *> & thirdLayerDetLayer,
217  const int nThirdLayers)
218 {
219  throw cms::Exception("Error")<<"PixelTripletLowPtGenerator::hitTriplets is not implemented \n";
220 }
221 
222 
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:517
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:54
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:18
std::unique_ptr< HitPairGeneratorFromLayerPair > thePairGenerator
const TrackerGeometry * theTracker
HLT enums.
T get() const
Definition: EventSetup.h:71
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:23
T const * product() const
Definition: ESHandle.h:86