CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PixelTripletLargeTipGenerator Class Reference

#include <PixelTripletLargeTipGenerator.h>

Inheritance diagram for PixelTripletLargeTipGenerator:
HitTripletGeneratorFromPairAndLayers HitTripletGenerator OrderedHitsGenerator

Public Member Functions

virtual void hitTriplets (const TrackingRegion &region, OrderedHitTriplets &trs, const edm::Event &ev, const edm::EventSetup &es)
 
virtual void init (const HitPairGenerator &pairs, const std::vector< ctfseeding::SeedingLayer > &layers, LayerCacheType *layerCache)
 
const HitPairGeneratorpairGenerator () const
 
 PixelTripletLargeTipGenerator (const edm::ParameterSet &cfg)
 
const std::vector
< ctfseeding::SeedingLayer > & 
thirdLayers () const
 
virtual ~PixelTripletLargeTipGenerator ()
 
- Public Member Functions inherited from HitTripletGeneratorFromPairAndLayers
virtual ~HitTripletGeneratorFromPairAndLayers ()
 
- Public Member Functions inherited from HitTripletGenerator
virtual void clear ()
 
 HitTripletGenerator (unsigned int size=500)
 
virtual void hitTriplets (const TrackingRegion &reg, OrderedHitTriplets &prs, const edm::EventSetup &es)
 
virtual const OrderedHitTripletsrun (const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es)
 
virtual ~HitTripletGenerator ()
 
- Public Member Functions inherited from OrderedHitsGenerator
 OrderedHitsGenerator ()
 
virtual ~OrderedHitsGenerator ()
 

Private Types

typedef
CombinedHitTripletGenerator::LayerCacheType 
LayerCacheType
 

Private Member Functions

bool checkPhiInRange (float phi, float phi1, float phi2) const
 
std::pair< float, float > mergePhiRanges (const std::pair< float, float > &r1, const std::pair< float, float > &r2) const
 

Private Attributes

float dphi
 
float extraHitRPhitolerance
 
float extraHitRZtolerance
 
LayerCacheTypetheLayerCache
 
std::vector
< ctfseeding::SeedingLayer
theLayers
 
HitPairGeneratorthePairGenerator
 
bool useBend
 
bool useFixedPreFiltering
 
bool useMScat
 

Additional Inherited Members

- Public Types inherited from HitTripletGeneratorFromPairAndLayers
typedef LayerHitMapCache LayerCacheType
 
- Public Attributes inherited from OrderedHitsGenerator
unsigned int theMaxElement
 

Detailed Description

A HitTripletGenerator from HitPairGenerator and vector of Layers. The HitPairGenerator provides a set of hit pairs. For each pair the search for compatible hit(s) is done among provided Layers

Definition at line 22 of file PixelTripletLargeTipGenerator.h.

Member Typedef Documentation

Definition at line 24 of file PixelTripletLargeTipGenerator.h.

Constructor & Destructor Documentation

PixelTripletLargeTipGenerator::PixelTripletLargeTipGenerator ( const edm::ParameterSet cfg)

Definition at line 39 of file PixelTripletLargeTipGenerator.cc.

References dphi, edm::ParameterSet::getParameter(), OrderedHitsGenerator::theMaxElement, and useFixedPreFiltering.

40  : thePairGenerator(0),
41  theLayerCache(0),
42  useFixedPreFiltering(cfg.getParameter<bool>("useFixedPreFiltering")),
43  extraHitRZtolerance(cfg.getParameter<double>("extraHitRZtolerance")),
44  extraHitRPhitolerance(cfg.getParameter<double>("extraHitRPhitolerance")),
45  useMScat(cfg.getParameter<bool>("useMultScattering")),
46  useBend(cfg.getParameter<bool>("useBending"))
47 {
48  theMaxElement=cfg.getParameter<unsigned int>("maxElement");
50  dphi = cfg.getParameter<double>("phiPreFiltering");
51 }
T getParameter(std::string const &) const
virtual PixelTripletLargeTipGenerator::~PixelTripletLargeTipGenerator ( )
inlinevirtual

Definition at line 29 of file PixelTripletLargeTipGenerator.h.

References thePairGenerator.

29 { delete thePairGenerator; }

Member Function Documentation

bool PixelTripletLargeTipGenerator::checkPhiInRange ( float  phi,
float  phi1,
float  phi2 
) const
private

Definition at line 277 of file PixelTripletLargeTipGenerator.cc.

References M_PI.

Referenced by hitTriplets().

278 {
279  while (phi > phi2) phi -= 2. * M_PI;
280  while (phi < phi1) phi += 2. * M_PI;
281  return phi <= phi2;
282 }
#define M_PI
Definition: BFit3D.cc:3
Definition: DDAxes.h:10
void PixelTripletLargeTipGenerator::hitTriplets ( const TrackingRegion region,
OrderedHitTriplets trs,
const edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements HitTripletGenerator.

Definition at line 72 of file PixelTripletLargeTipGenerator.cc.

References GeomDetEnumerators::barrel, checkPhiInRange(), PixelRecoUtilities::curvature(), dphi, extraHitRPhitolerance, extraHitRZtolerance, first, edm::EventSetup::get(), HitPairGenerator::hitPairs(), RecHitsSortedInPhi::hits(), intersect(), geometryCSVtoXML::line, DetLayer::location(), max(), ThirdHitPredictionFromCircle::HelixRZ::maxCurvature(), mergePhiRanges(), min, nSigmaPhi, nSigmaRZ, TrackingRegion::originRBound(), p3, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), TrackingRegion::ptMin(), Basic2DVector< T >::r(), CosmicsPD_Skims::radius, edm::second(), OrderedHitTriplets::size(), findQualityFiles::size, theLayers, OrderedHitsGenerator::theMaxElement, thePairGenerator, patCandidatesForDimuonsSequences_cff::tracker, useBend, useFixedPreFiltering, useMScat, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

77 {
79  es.get<TrackerDigiGeometryRecord>().get(tracker);
80 
81  OrderedHitPairs pairs;
82  pairs.reserve(30000);
83  thePairGenerator->hitPairs(region,pairs,ev,es);
84  if (pairs.empty())
85  return;
86 
87  int size = theLayers.size();
88 
89  map<const DetLayer*, LayerRZPredictions> mapPred;
90  const RecHitsSortedInPhi **thirdHitMap = new const RecHitsSortedInPhi*[size];
91  for(int il = 0; il < size; il++) {
92  thirdHitMap[il] = &(*theLayerCache)(&theLayers[il], region, ev, es);
93  const DetLayer *layer = theLayers[il].detLayer();
94  LayerRZPredictions &predRZ = mapPred[layer];
95  predRZ.line.initLayer(layer);
96  predRZ.helix1.initLayer(layer);
97  predRZ.helix2.initLayer(layer);
98  predRZ.line.initTolerance(extraHitRZtolerance);
99  predRZ.helix1.initTolerance(extraHitRZtolerance);
100  predRZ.helix2.initTolerance(extraHitRZtolerance);
101  predRZ.rzPositionFixup = MatchedHitRZCorrectionFromBending(layer);
102  }
103 
104  double curv = PixelRecoUtilities::curvature(1. / region.ptMin(), es);
105 
106  for(OrderedHitPairs::const_iterator ip = pairs.begin();
107  ip != pairs.end(); ++ip) {
108 
109  GlobalPoint gp1 = ip->inner()->globalPosition();
110  GlobalPoint gp2 = ip->outer()->globalPosition();
111 
112  PixelRecoLineRZ line(gp1, gp2);
113  PixelRecoPointRZ point2(gp2.perp(), gp2.z());
114  ThirdHitPredictionFromCircle predictionRPhi(gp1, gp2, extraHitRPhitolerance);
115 
116  Range generalCurvature = predictionRPhi.curvature(region.originRBound());
117  if (!intersect(generalCurvature, Range(-curv, curv)))
118  continue;
119 
120  for(int il = 0; il < size; il++) {
121  const DetLayer *layer = theLayers[il].detLayer();
122 // bool pixelLayer = layer->subDetector() == GeomDetEnumerators::PixelBarrel ||
123 // layer->subDetector() == GeomDetEnumerators::PixelEndcap;
124  bool barrelLayer = layer->location() == GeomDetEnumerators::barrel;
125 
126  Range curvature = generalCurvature;
127  ThirdHitCorrection correction(es, region.ptMin(), layer, line, point2, useMScat);
128 
129  LayerRZPredictions &predRZ = mapPred.find(layer)->second;
130  predRZ.line.initPropagator(&line);
131 
132  HelixRZ helix;
133  Range rzRange;
134  if (useBend) {
135  // For the barrel region:
136  // swiping the helix passing through the two points across from
137  // negative to positive bending, can give us a sort of U-shaped
138  // projection onto the phi-z (barrel) or r-z plane (forward)
139  // so we checking minimum/maximum of all three possible extrema
140  //
141  // For the endcap region:
142  // Checking minimum/maximum radius of the helix projection
143  // onto an endcap plane, here we have to guard against
144  // looping tracks, when phi(delta z) gets out of control.
145  // HelixRZ::rAtZ should not follow looping tracks, but clamp
146  // to the minimum reachable r with the next-best lower |curvature|.
147  // So same procedure as for the barrel region can be applied.
148  //
149  // In order to avoid looking for potential looping tracks at all
150  // we also clamp the allowed curvature range for this layer,
151  // and potentially fail the layer entirely
152 
153  if (!barrelLayer) {
154  Range z3s = predRZ.line.detRange();
155  double z3 = z3s.first < 0 ? max(z3s.first, z3s.second)
156  : min(z3s.first, z3s.second);
157  double maxCurvature = HelixRZ::maxCurvature(&predictionRPhi,
158  gp1.z(), gp2.z(), z3);
159  if (!intersect(curvature, Range(-maxCurvature, maxCurvature)))
160  continue;
161  }
162 
163  helix = HelixRZ(&predictionRPhi, gp1.z(), gp2.z(), curvature.first);
164  HelixRZ helix2(&predictionRPhi, gp1.z(), gp2.z(), curvature.second);
165 
166  predRZ.helix1.initPropagator(&helix);
167  predRZ.helix2.initPropagator(&helix2);
168 
169  Range rzRanges[2] = { predRZ.helix1(), predRZ.helix2() };
170  rzRange.first = min(rzRanges[0].first, rzRanges[1].first);
171  rzRange.second = max(rzRanges[0].second, rzRanges[1].second);
172 
173  // if the allowed curvatures include a straight line,
174  // this can give us another extremum for allowed r/z
175  if (curvature.first * curvature.second < 0.0) {
176  Range rzLineRange = predRZ.line();
177  rzRange.first = min(rzRange.first, rzLineRange.first);
178  rzRange.second = max(rzRange.second, rzLineRange.second);
179  }
180  } else
181  rzRange = predRZ.line();
182 
183  if (rzRange.first >= rzRange.second)
184  continue;
185 
186  correction.correctRZRange(rzRange);
187 
188  Range phiRange;
189  if (useFixedPreFiltering) {
190  float phi0 = ip->outer()->globalPosition().phi();
191  phiRange = Range(phi0 - dphi, phi0 + dphi);
192  } else {
193  Range radius;
194 
195  if (barrelLayer) {
196  radius = predRZ.line.detRange();
197  if (!intersect(rzRange, predRZ.line.detSize()))
198  continue;
199  } else {
200  radius = rzRange;
201  if (!intersect(radius, predRZ.line.detSize()))
202  continue;
203  }
204 
205  Range rPhi1 = predictionRPhi(curvature, radius.first);
206  Range rPhi2 = predictionRPhi(curvature, radius.second);
207  correction.correctRPhiRange(rPhi1);
208  correction.correctRPhiRange(rPhi2);
209  rPhi1.first /= radius.first;
210  rPhi1.second /= radius.first;
211  rPhi2.first /= radius.second;
212  rPhi2.second /= radius.second;
213  phiRange = mergePhiRanges(rPhi1, rPhi2);
214  }
215 
217  vector<Hit> thirdHits = thirdHitMap[il]->hits(phiRange.min(), phiRange.max());
218 
219  MatchedHitRZCorrectionFromBending l2rzFixup(ip->outer()->det()->geographicalId());
220  MatchedHitRZCorrectionFromBending l3rzFixup = predRZ.rzPositionFixup;
221 
222  typedef vector<Hit>::const_iterator IH;
223  for (IH th=thirdHits.begin(), eh=thirdHits.end(); th < eh; ++th) {
224  GlobalPoint p3 = (*th)->globalPosition();
225  double p3_r = p3.perp();
226  double p3_z = p3.z();
227  double p3_phi = p3.phi();
228 
229  Range rangeRPhi = predictionRPhi(curvature, p3_r);
230  correction.correctRPhiRange(rangeRPhi);
231 
232  double phiErr = nSigmaPhi * (*th)->errorGlobalRPhi()/p3_r;
233  if (!checkPhiInRange(p3_phi, rangeRPhi.first/p3_r - phiErr, rangeRPhi.second/p3_r + phiErr))
234  continue;
235 
237  Basic2DVector<double> thc(p3.x(), p3.y());
238 
239  double curv_ = predictionRPhi.curvature(thc);
240  double p2_r = point2.r(), p2_z = point2.z();
241 
242  l2rzFixup(predictionRPhi, curv_, *ip->outer(), p2_r, p2_z);
243  l3rzFixup(predictionRPhi, curv_, **th, p3_r, p3_z);
244 
245  Range rangeRZ;
246  if (useBend) {
247  HelixRZ updatedHelix(&predictionRPhi, gp1.z(), p2_z, curv_);
248  rangeRZ = predRZ.helix1(barrelLayer ? p3_r : p3_z, updatedHelix);
249  } else {
250  float tIP = predictionRPhi.transverseIP(thc);
251  PixelRecoPointRZ updatedPoint2(p2_r, p2_z);
252  PixelRecoLineRZ updatedLine(line.origin(), point2, tIP);
253  rangeRZ = predRZ.line(barrelLayer ? p3_r : p3_z, line);
254  }
255  correction.correctRZRange(rangeRZ);
256 
257  double err = nSigmaRZ * (barrelLayer
258  ? hit->errorGlobalZ()
259  : hit->errorGlobalR());
260  rangeRZ.first -= err, rangeRZ.second += err;
261 
262  if (!rangeRZ.inside(barrelLayer ? p3_z : p3_r))
263  continue;
264  if (theMaxElement!=0 && result.size() >= theMaxElement){
265  result.clear();
266  edm::LogError("TooManyTriplets")<<" number of triples exceed maximum. no triplets produced.";
267  delete[] thirdHitMap;
268  return;
269  }
270  result.push_back(OrderedHitTriplet(ip->inner(), ip->outer(), *th));
271  }
272  }
273  }
274  delete[] thirdHitMap;
275 }
T perp() const
Definition: PV3DBase.h:71
virtual Location location() const =0
Which part of the detector (barrel, endcap)
ThirdHitPredictionFromCircle::HelixRZ HelixRZ
static const double nSigmaPhi
std::vector< Hit > hits(float phiMin, float phiMax) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
#define min(a, b)
Definition: mlp_lapack.h:161
T r() const
Radius, same as mag()
U second(std::pair< T, U > const &p)
bool checkPhiInRange(float phi, float phi1, float phi2) const
T curvature(T InversePt, const edm::EventSetup &iSetup)
const T & max(const T &a, const T &b)
virtual void hitPairs(const TrackingRegion &reg, OrderedHitPairs &prs, const edm::EventSetup &es)
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
bool first
Definition: L1TdeRCT.cc:94
static const double nSigmaRZ
std::pair< float, float > mergePhiRanges(const std::pair< float, float > &r1, const std::pair< float, float > &r2) const
PixelRecoRange< float > Range
static double maxCurvature(const ThirdHitPredictionFromCircle *circle, double z1, double z2, double z3)
const T & get() const
Definition: EventSetup.h:55
std::vector< ctfseeding::SeedingLayer > theLayers
static bool intersect(Range &range, const Range &second)
TransientTrackingRecHit::ConstRecHitPointer Hit
T x() const
Definition: PV3DBase.h:61
tuple size
Write out results.
double p3[4]
Definition: TauolaWrapper.h:91
void PixelTripletLargeTipGenerator::init ( const HitPairGenerator pairs,
const std::vector< ctfseeding::SeedingLayer > &  layers,
LayerCacheType layerCache 
)
virtual

Implements HitTripletGeneratorFromPairAndLayers.

Definition at line 53 of file PixelTripletLargeTipGenerator.cc.

References HitPairGenerator::clone(), theLayerCache, theLayers, and thePairGenerator.

55 {
56  thePairGenerator = pairs.clone();
57  theLayers = layers;
58  theLayerCache = layerCache;
59 }
virtual HitPairGenerator * clone() const =0
std::vector< ctfseeding::SeedingLayer > theLayers
std::pair< float, float > PixelTripletLargeTipGenerator::mergePhiRanges ( const std::pair< float, float > &  r1,
const std::pair< float, float > &  r2 
) const
private

Definition at line 284 of file PixelTripletLargeTipGenerator.cc.

References M_PI, max(), and min.

Referenced by hitTriplets().

286 {
287  float r2Min = r2.first;
288  float r2Max = r2.second;
289  while (r1.first - r2Min > +M_PI) r2Min += 2. * M_PI, r2Max += 2. * M_PI;
290  while (r1.first - r2Min < -M_PI) r2Min -= 2. * M_PI, r2Max -= 2. * M_PI;
291  return std::make_pair(min(r1.first, r2Min), max(r1.second, r2Max));
292 }
#define min(a, b)
Definition: mlp_lapack.h:161
const T & max(const T &a, const T &b)
#define M_PI
Definition: BFit3D.cc:3
const HitPairGenerator& PixelTripletLargeTipGenerator::pairGenerator ( ) const
inline

Definition at line 37 of file PixelTripletLargeTipGenerator.h.

References thePairGenerator.

37 { return *thePairGenerator; }
const std::vector<ctfseeding::SeedingLayer>& PixelTripletLargeTipGenerator::thirdLayers ( ) const
inline

Definition at line 38 of file PixelTripletLargeTipGenerator.h.

References theLayers.

38 { return theLayers; }
std::vector< ctfseeding::SeedingLayer > theLayers

Member Data Documentation

float PixelTripletLargeTipGenerator::dphi
private

Definition at line 57 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets(), and PixelTripletLargeTipGenerator().

float PixelTripletLargeTipGenerator::extraHitRPhitolerance
private

Definition at line 54 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets().

float PixelTripletLargeTipGenerator::extraHitRZtolerance
private

Definition at line 53 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets().

LayerCacheType* PixelTripletLargeTipGenerator::theLayerCache
private

Definition at line 50 of file PixelTripletLargeTipGenerator.h.

Referenced by init().

std::vector<ctfseeding::SeedingLayer> PixelTripletLargeTipGenerator::theLayers
private

Definition at line 49 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets(), init(), and thirdLayers().

HitPairGenerator* PixelTripletLargeTipGenerator::thePairGenerator
private
bool PixelTripletLargeTipGenerator::useBend
private

Definition at line 56 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets().

bool PixelTripletLargeTipGenerator::useFixedPreFiltering
private

Definition at line 52 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets(), and PixelTripletLargeTipGenerator().

bool PixelTripletLargeTipGenerator::useMScat
private

Definition at line 55 of file PixelTripletLargeTipGenerator.h.

Referenced by hitTriplets().