CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelTripletLowPtGenerator.cc
Go to the documentation of this file.
5 
7 
12 
15 
18 
19 #undef Debug
20 
21 using namespace std;
22 using namespace ctfseeding;
23 
24 /*****************************************************************************/
26  theTracker(nullptr), theFilter(nullptr), ps(cfg), thePairGenerator(nullptr), theLayerCache(nullptr),
27  theClusterShapeCacheToken(iC.consumes<SiPixelClusterShapeCache>(cfg.getParameter<edm::InputTag>("clusterShapeCacheSrc")))
28 {}
29 
30 /*****************************************************************************/
32  LayerCacheType* layerCache)
33 {
34  thePairGenerator = pairs.clone();
35  theLayerCache = layerCache;
36 
37  checkMultipleScattering = ps.getParameter<bool>("checkMultipleScattering");
38  nSigMultipleScattering = ps.getParameter<double>("nSigMultipleScattering");
39  checkClusterShape = ps.getParameter<bool>("checkClusterShape");
40  rzTolerance = ps.getParameter<double>("rzTolerance");
41  maxAngleRatio = ps.getParameter<double>("maxAngleRatio");
42  builderName = ps.getParameter<string>("TTRHBuilder");
43 }
44 
45 /*****************************************************************************/
47  std::vector<SeedingLayerSetsHits::SeedingLayer> thirdLayers) {
49  theLayers = thirdLayers;
50 }
51 
52 /*****************************************************************************/
54  (const edm::EventSetup& es)
55 {
56  if(theTracker == 0)
57  {
58  // Get tracker geometry
60  es.get<TrackerDigiGeometryRecord>().get(tracker);
61 
62  theTracker = tracker.product();
63  }
64 
65  if(theFilter == 0)
66  {
67  theFilter = new TripletFilter(es);
68  }
69 }
70 
71 /*****************************************************************************/
73  (const TrackingRecHit* recHit)
74 {
75  DetId detId = recHit->geographicalId();
76 
77  return
78  theTracker->idToDet(detId)->toGlobal(recHit->localPosition());
79 }
80 
81 /*****************************************************************************/
83  const TrackingRegion& region,
85  const edm::Event & ev,
86  const edm::EventSetup& es)
87 {
88 
89  //Retrieve tracker topology from geometry
91  es.get<IdealGeometryRecord>().get(tTopoHand);
92  const TrackerTopology *tTopo=tTopoHand.product();
93 
94  edm::Handle<SiPixelClusterShapeCache> clusterShapeCache;
95  ev.getByToken(theClusterShapeCacheToken, clusterShapeCache);
96 
97  // Generate pairs
98  OrderedHitPairs pairs; pairs.reserve(30000);
99  thePairGenerator->hitPairs(region,pairs,ev,es);
100 
101  if (pairs.size() == 0) return;
102 
103  int size = theLayers.size();
104 
105  // Set aliases
106  const RecHitsSortedInPhi **thirdHitMap = new const RecHitsSortedInPhi*[size];
107  for(int il=0; il<size; il++)
108  thirdHitMap[il] = &(*theLayerCache)(theLayers[il], region, ev, es);
109 
110  // Get tracker
111  getTracker(es);
112 
113  // Look at all generated pairs
114  for(OrderedHitPairs::const_iterator ip = pairs.begin();
115  ip!= pairs.end(); ip++)
116  {
117  // Fill rechits and points
118  vector<const TrackingRecHit*> recHits(3);
119  vector<GlobalPoint> points(3);
120 
121  recHits[0] = (*ip).inner()->hit();
122  recHits[1] = (*ip).outer()->hit();
123 
124 #ifdef Debug
125  cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) +
126  HitInfo::getInfo(*recHits[1]) << endl;
127 #endif
128 
129  for(int i=0; i<2; i++)
130  points[i] = getGlobalPosition(recHits[i]);
131 
132  // Initialize helix prediction
134  thePrediction(region,
135  points[0],points[1], es,
137 
138  // Look at all layers
139  for(int il=0; il<size; il++)
140  {
141  const DetLayer * layer = theLayers[il].detLayer();
142 
143 #ifdef Debug
144  cerr << " check layer " << layer->subDetector()
145  << " " << layer->location() << endl;
146 #endif
147 
148  // Get ranges for the third hit
149  float phi[2],rz[2];
150  thePrediction.getRanges(layer, phi,rz);
151 
152  PixelRecoRange<float> phiRange(phi[0] , phi[1] );
153  PixelRecoRange<float> rzRange( rz[0] - rzTolerance, rz[1] + rzTolerance);
154 
155  // Get third hit candidates from cache
157  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(),phiRange.max());
158  typedef vector<Hit>::const_iterator IH;
159 
160  for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th)
161  {
162  // Fill rechit and point
163  recHits[2] = (*th)->hit();
164  points[2] = getGlobalPosition(recHits[2]);
165 
166 #ifdef Debug
167  cerr << " third hit " + HitInfo::getInfo(*recHits[2]) << endl;
168 #endif
169 
170  // Check if third hit is compatible with multiple scattering
171  vector<GlobalVector> globalDirs;
172  if(thePrediction.isCompatibleWithMultipleScattering
173  (points[2], recHits, globalDirs, es) == false)
174  {
175 #ifdef Debug
176  cerr << " not compatible: multiple scattering" << endl;
177 #endif
178  if(checkMultipleScattering) continue;
179  }
180 
181  // Convert to localDirs
182 /*
183  vector<LocalVector> localDirs;
184  vector<GlobalVector>::const_iterator globalDir = globalDirs.begin();
185  for(vector<const TrackingRecHit *>::const_iterator
186  recHit = recHits.begin();
187  recHit != recHits.end(); recHit++)
188  {
189  localDirs.push_back(theTracker->idToDet(
190  (*recHit)->geographicalId())->toLocal(*globalDir));
191  globalDir++;
192  }
193 */
194 
195  // Check if the cluster shapes are compatible with thrusts
197  {
198  if(! theFilter->checkTrack(recHits,globalDirs,tTopo, *clusterShapeCache))
199  {
200 #ifdef Debug
201  cerr << " not compatible: cluster shape" << endl;
202 #endif
203  continue;
204  }
205  }
206 
207  // All checks passed, put triplet back
208  result.push_back(OrderedHitTriplet((*ip).inner(),(*ip).outer(),*th));
209  }
210  }
211  }
212  delete [] thirdHitMap;
213 
214  return;
215 }
216 
217 
PixelTripletLowPtGenerator(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
T getParameter(std::string const &) const
std::vector< Hit > hits(float phiMin, float phiMax) const
int i
Definition: DBlmapReader.cc:9
virtual HitPairGenerator * clone() const =0
T max() const
void getTracker(const edm::EventSetup &es)
virtual Location location() const =0
Which part of the detector (barrel, endcap)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void setSeedingLayers(SeedingLayerSetsHits::SeedingLayerSet pairLayers, std::vector< SeedingLayerSetsHits::SeedingLayer > thirdLayers) override
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
bool ev
virtual unsigned int size() const
T min() const
#define nullptr
void init(const HitPairGenerator &pairs, LayerCacheType *layerCache) override
std::vector< SeedingLayerSetsHits::SeedingLayer > theLayers
virtual void hitPairs(const TrackingRegion &reg, OrderedHitPairs &prs, const edm::EventSetup &es)
bool checkTrack(const std::vector< const TrackingRecHit * > &recHits, const std::vector< LocalVector > &localDirs, const TrackerTopology *tTopo, const SiPixelClusterShapeCache &clusterShapeCache)
tuple result
Definition: query.py:137
edm::EDGetTokenT< SiPixelClusterShapeCache > theClusterShapeCacheToken
SeedingHitSet::ConstRecHitPointer Hit
BaseTrackerRecHit const * Hit
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
virtual void hitTriplets(const TrackingRegion &region, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es)
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[])
list pairs
sort tag files by run number
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:23
virtual LocalPoint localPosition() const =0
tuple size
Write out results.
virtual void setSeedingLayers(SeedingLayerSetsHits::SeedingLayerSet layers)=0
Definition: DDAxes.h:10