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  // Generate pairs
74  OrderedHitPairs pairs; pairs.reserve(30000);
75  thePairGenerator->hitPairs(region,pairs,ev,es);
76 
77  if (pairs.size() == 0) return;
78 
79  int size = theLayers.size();
80 
81  // Set aliases
82  const RecHitsSortedInPhi **thirdHitMap = new const RecHitsSortedInPhi*[size];
83  for(int il=0; il<size; il++)
84  thirdHitMap[il] = &(*theLayerCache)(&theLayers[il], region, ev, es);
85 
86  // Get tracker
87  getTracker(es);
88 
89  // Look at all generated pairs
90  for(OrderedHitPairs::const_iterator ip = pairs.begin();
91  ip!= pairs.end(); ip++)
92  {
93  // Fill rechits and points
94  vector<const TrackingRecHit*> recHits(3);
95  vector<GlobalPoint> points(3);
96 
97  recHits[0] = (*ip).inner()->hit();
98  recHits[1] = (*ip).outer()->hit();
99 
100 #ifdef Debug
101  cerr << " RecHits " + HitInfo::getInfo(*recHits[0]) +
102  HitInfo::getInfo(*recHits[1]) << endl;
103 #endif
104 
105  for(int i=0; i<2; i++)
106  points[i] = getGlobalPosition(recHits[i]);
107 
108  // Initialize helix prediction
110  thePrediction(region,
111  points[0],points[1], es,
112  nSigMultipleScattering,maxAngleRatio,builderName);
113 
114  // Look at all layers
115  for(int il=0; il<size; il++)
116  {
117  const SeedingLayer & layerwithhits = theLayers[il];
118  const DetLayer * layer = layerwithhits.detLayer();
119 
120 #ifdef Debug
121  cerr << " check layer " << layer->subDetector()
122  << " " << layer->location() << endl;
123 #endif
124 
125  // Get ranges for the third hit
126  float phi[2],rz[2];
127  thePrediction.getRanges(layer, phi,rz);
128 
129  PixelRecoRange<float> phiRange(phi[0] , phi[1] );
130  PixelRecoRange<float> rzRange( rz[0] - rzTolerance, rz[1] + rzTolerance);
131 
132  // Get third hit candidates from cache
134  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(),phiRange.max());
135  typedef vector<Hit>::const_iterator IH;
136 
137  for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th)
138  {
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
150  (points[2], recHits, globalDirs, es) == false)
151  {
152 #ifdef Debug
153  cerr << " not compatible: multiple scattering" << endl;
154 #endif
155  if(checkMultipleScattering) 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  {
175  if(! theFilter->checkTrack(recHits,globalDirs))
176  {
177 #ifdef Debug
178  cerr << " not compatible: cluster shape" << endl;
179 #endif
180  continue;
181  }
182  }
183 
184  // All checks passed, put triplet back
185  result.push_back(OrderedHitTriplet((*ip).inner(),(*ip).outer(),*th));
186  }
187  }
188  }
189  delete [] thirdHitMap;
190 
191  return;
192 }
193 
194 
static std::string getInfo(const DetId &id)
Definition: HitInfo.cc:24
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
std::vector< Hit > hits(float phiMin, float phiMax) const
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[])
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