CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HitPairGeneratorFromLayerPair.cc
Go to the documentation of this file.
3 
7 
13 
17 
18 using namespace GeomDetEnumerators;
19 using namespace ctfseeding;
20 using namespace std;
21 
23 template<class T> inline T sqr( T t) {return t*t;}
24 
25 
26 
32 
34  const Layer& inner,
35  const Layer& outer,
36  LayerCacheType* layerCache,
37  unsigned int nSize,
38  unsigned int max)
39  : HitPairGenerator(nSize),
40  theLayerCache(*layerCache), theOuterLayer(outer), theInnerLayer(inner)
41 {
43 }
44 
46  const TrackingRegion & region, OrderedHitPairs & result,
47  const edm::Event& iEvent, const edm::EventSetup& iSetup)
48 {
49 
50  typedef OrderedHitPair::InnerRecHit InnerHit;
51  typedef OrderedHitPair::OuterRecHit OuterHit;
53 
54  const RecHitsSortedInPhi & innerHitsMap = theLayerCache(&theInnerLayer, region, iEvent, iSetup);
55  if (innerHitsMap.empty()) return;
56 
57  const RecHitsSortedInPhi& outerHitsMap = theLayerCache(&theOuterLayer, region, iEvent, iSetup);
58  if (outerHitsMap.empty()) return;
59 
60  InnerDeltaPhi deltaPhi(*theInnerLayer.detLayer(), region, iSetup);
61 
62  RecHitsSortedInPhi::Range outerHits = outerHitsMap.all();
63 
64  static const float nSigmaRZ = std::sqrt(12.f);
65  static const float nSigmaPhi = 3.f;
66  vector<Hit> innerHits;
67  for (RecHitsSortedInPhi::HitIter oh = outerHits.first; oh!= outerHits.second; ++oh) {
68  Hit ohit = (*oh).hit();
69  GlobalPoint oPos = ohit->globalPosition();
70  PixelRecoRange<float> phiRange = deltaPhi( oPos.perp(), oPos.phi(), oPos.z(), nSigmaPhi*(ohit->errorGlobalRPhi()));
71 
72  if (phiRange.empty()) continue;
73 
74  const HitRZCompatibility *checkRZ = region.checkRZ(theInnerLayer.detLayer(), ohit, iSetup);
75  if(!checkRZ) continue;
76 
77  innerHits.clear();
78  innerHitsMap.hits(phiRange.min(), phiRange.max(), innerHits);
79  LogDebug("HitPairGeneratorFromLayerPair")<<
80  "preparing for combination of: "<<innerHits.size()<<" inner and: "<<outerHits.second-outerHits.first<<" outter";
81  for ( vector<Hit>::const_iterator ih=innerHits.begin(), ieh = innerHits.end(); ih < ieh; ++ih) {
82  GlobalPoint innPos = (*ih)->globalPosition();
83  float r_reduced = std::sqrt( sqr(innPos.x()-region.origin().x())+sqr(innPos.y()-region.origin().y()));
84  Range allowed;
85  Range hitRZ;
86  if (theInnerLayer.detLayer()->location() == barrel) {
87  allowed = checkRZ->range(r_reduced);
88  float zErr = nSigmaRZ * (*ih)->errorGlobalZ();
89  hitRZ = Range(innPos.z()-zErr, innPos.z()+zErr);
90  } else {
91  allowed = checkRZ->range(innPos.z());
92  float rErr = nSigmaRZ * (*ih)->errorGlobalR();
93  hitRZ = Range(r_reduced-rErr, r_reduced+rErr);
94  }
95  Range crossRange = allowed.intersection(hitRZ);
96  if (! crossRange.empty() ) {
97  if (theMaxElement!=0 && result.size() >= theMaxElement){
98  result.clear();
99  edm::LogError("TooManyPairs")<<"number of pairs exceed maximum, no pairs produced";
100  delete checkRZ;
101  return;
102  }
103  result.push_back( OrderedHitPair( *ih, ohit) );
104  }
105  }
106  delete checkRZ;
107  }
108  LogDebug("HitPairGeneratorFromLayerPair")<<" total number of pairs provided back: "<<result.size();
109 }
#define LogDebug(id)
T perp() const
Definition: PV3DBase.h:71
virtual GlobalPoint origin() const =0
T max() const
virtual Location location() const =0
Which part of the detector (barrel, endcap)
const DetLayer * detLayer() const
Definition: SeedingLayer.cc:80
virtual Range range(const float &rORz) const =0
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
HitPairGeneratorFromLayerPair(const Layer &inner, const Layer &outer, LayerCacheType *layerCache, unsigned int nSize=30000, unsigned int max=0)
bool empty() const
virtual unsigned int size() const
T min() const
virtual void hitPairs(const TrackingRegion &reg, OrderedHitPairs &prs, const edm::Event &ev, const edm::EventSetup &es)
std::pair< HitIter, HitIter > Range
int iEvent
Definition: GenABIO.cc:243
const T & max(const T &a, const T &b)
std::vector< HitWithPhi >::const_iterator HitIter
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
double f[11][100]
*virtual HitRZCompatibility * checkRZ(const DetLayer *layer, const Hit &outerHit, const edm::EventSetup &iSetup) const =0
static const double nSigmaRZ
PixelRecoRange< float > Range
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
TransientTrackingRecHit::ConstRecHitPointer Hit
long double T
T x() const
Definition: PV3DBase.h:61