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 
11 
14 
15 #undef Debug
16 
17 using namespace std;
18 using namespace ctfseeding;
19 
20 /*****************************************************************************/
22  const vector<SeedingLayer> & layers,
23  LayerCacheType* layerCache)
24 {
25  thePairGenerator = pairs.clone();
26  theLayers = layers;
27  theLayerCache = layerCache;
28 
29  checkMultipleScattering = ps.getParameter<bool>("checkMultipleScattering");
30  nSigMultipleScattering = ps.getParameter<double>("nSigMultipleScattering");
31  checkClusterShape = ps.getParameter<bool>("checkClusterShape");
32  rzTolerance = ps.getParameter<double>("rzTolerance");
33  maxAngleRatio = ps.getParameter<double>("maxAngleRatio");
34  builderName = ps.getParameter<string>("TTRHBuilder");
35 }
36 
37 /*****************************************************************************/
39  (const edm::EventSetup& es)
40 {
41  if(theTracker == 0)
42  {
43  // Get tracker geometry
45  es.get<TrackerDigiGeometryRecord>().get(tracker);
46 
47  theTracker = tracker.product();
48  }
49 
50  if(theFilter == 0)
51  {
52  theFilter = new TripletFilter(es);
53  }
54 }
55 
56 /*****************************************************************************/
58  (const TrackingRecHit* recHit)
59 {
60  DetId detId = recHit->geographicalId();
61 
62  return
63  theTracker->idToDet(detId)->toGlobal(recHit->localPosition());
64 }
65 
66 /*****************************************************************************/
68  const TrackingRegion& region,
70  const edm::Event & ev,
71  const edm::EventSetup& es)
72 {
73 
74  //Retrieve tracker topology from geometry
76  es.get<IdealGeometryRecord>().get(tTopoHand);
77  const TrackerTopology *tTopo=tTopoHand.product();
78 
79  // Generate pairs
80  OrderedHitPairs pairs; pairs.reserve(30000);
81  thePairGenerator->hitPairs(region,pairs,ev,es);
82 
83  if (pairs.size() == 0) return;
84 
85  int size = theLayers.size();
86 
87  // Set aliases
88  const RecHitsSortedInPhi **thirdHitMap = new const RecHitsSortedInPhi*[size];
89  for(int il=0; il<size; il++)
90  thirdHitMap[il] = &(*theLayerCache)(&theLayers[il], region, ev, es);
91 
92  // Get tracker
93  getTracker(es);
94 
95  // Look at all generated pairs
96  for(OrderedHitPairs::const_iterator ip = pairs.begin();
97  ip!= pairs.end(); ip++)
98  {
99  // Fill rechits and points
100  vector<const TrackingRecHit*> recHits(3);
101  vector<GlobalPoint> points(3);
102 
103  recHits[0] = (*ip).inner()->hit();
104  recHits[1] = (*ip).outer()->hit();
105 
106 #ifdef Debug
107  cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) +
108  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
116  thePrediction(region,
117  points[0],points[1], es,
118  nSigMultipleScattering,maxAngleRatio,builderName);
119 
120  // Look at all layers
121  for(int il=0; il<size; il++)
122  {
123  const SeedingLayer & layerwithhits = theLayers[il];
124  const DetLayer * layer = layerwithhits.detLayer();
125 
126 #ifdef Debug
127  cerr << " check layer " << layer->subDetector()
128  << " " << layer->location() << endl;
129 #endif
130 
131  // Get ranges for the third hit
132  float phi[2],rz[2];
133  thePrediction.getRanges(layer, phi,rz);
134 
135  PixelRecoRange<float> phiRange(phi[0] , phi[1] );
136  PixelRecoRange<float> rzRange( rz[0] - rzTolerance, rz[1] + rzTolerance);
137 
138  // Get third hit candidates from cache
140  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(),phiRange.max());
141  typedef vector<Hit>::const_iterator IH;
142 
143  for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th)
144  {
145  // Fill rechit and point
146  recHits[2] = (*th)->hit();
147  points[2] = getGlobalPosition(recHits[2]);
148 
149 #ifdef Debug
150  cerr << " third hit " + HitInfo::getInfo(*recHits[2]) << endl;
151 #endif
152 
153  // Check if third hit is compatible with multiple scattering
154  vector<GlobalVector> globalDirs;
155  if(thePrediction.isCompatibleWithMultipleScattering
156  (points[2], recHits, globalDirs, es) == false)
157  {
158 #ifdef Debug
159  cerr << " not compatible: multiple scattering" << endl;
160 #endif
161  if(checkMultipleScattering) continue;
162  }
163 
164  // Convert to localDirs
165 /*
166  vector<LocalVector> localDirs;
167  vector<GlobalVector>::const_iterator globalDir = globalDirs.begin();
168  for(vector<const TrackingRecHit *>::const_iterator
169  recHit = recHits.begin();
170  recHit != recHits.end(); recHit++)
171  {
172  localDirs.push_back(theTracker->idToDet(
173  (*recHit)->geographicalId())->toLocal(*globalDir));
174  globalDir++;
175  }
176 */
177 
178  // Check if the cluster shapes are compatible with thrusts
179  if(checkClusterShape)
180  {
181  if(! theFilter->checkTrack(recHits,globalDirs,tTopo))
182  {
183 #ifdef Debug
184  cerr << " not compatible: cluster shape" << endl;
185 #endif
186  continue;
187  }
188  }
189 
190  // All checks passed, put triplet back
191  result.push_back(OrderedHitTriplet((*ip).inner(),(*ip).outer(),*th));
192  }
193  }
194  }
195  delete [] thirdHitMap;
196 
197  return;
198 }
199 
200 
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)
const DetLayer * detLayer() const
Definition: SeedingLayer.cc:80
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
virtual unsigned int size() const
T min() const
tuple result
Definition: query.py:137
bool isCompatibleWithMultipleScattering(GlobalPoint g3, std::vector< const TrackingRecHit * > h, std::vector< GlobalVector > &localDirs, const edm::EventSetup &es)
Definition: DetId.h:20
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)
TransientTrackingRecHit::ConstRecHitPointer Hit
GlobalPoint getGlobalPosition(const TrackingRecHit *recHit)
DetId geographicalId() const
void getRanges(const DetLayer *layer, float phi[], float rz[])
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:25
virtual LocalPoint localPosition() const =0
virtual void init(const HitPairGenerator &pairs, const std::vector< ctfseeding::SeedingLayer > &layers, LayerCacheType *layerCache)
tuple size
Write out results.
Definition: DDAxes.h:10