CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalTrackingRegion.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <sstream>
8 
15 
16 
17 template <class T> T sqr( T t) {return t*t;}
18 
19 using namespace GeomDetEnumerators;
20 
22  std::ostringstream str;
23  str << TrackingRegionBase::print() << "precise: "<<thePrecise;
24  return str.str();
25 }
26 
27 TrackingRegion::Hits GlobalTrackingRegion::hits(
28  const edm::Event& ev,
29  const edm::EventSetup& es,
30  const ctfseeding::SeedingLayer* layer) const
31 {
32  return layer->hits(ev,es);
33 }
34 
35 TrackingRegion::Hits GlobalTrackingRegion::hits(
36  const edm::Event& ev,
37  const edm::EventSetup& es,
38  const SeedingLayerSetsHits::SeedingLayer& layer) const {
39  return layer.hits();
40 }
41 
42 
43 
45 GlobalTrackingRegion::checkRZ(const DetLayer* layer,
46  const Hit& outerHit, const edm::EventSetup& iSetup,
47  const DetLayer* outerlayer, float lr, float gz, float dr, float dz) const
48 {
49 
50  bool isBarrel = layer->isBarrel();
51  bool isPixel = (layer->subDetector() == PixelBarrel || layer->subDetector() == PixelEndcap);
52 
53  if unlikely(!outerlayer) {
54  GlobalPoint ohit = outerHit->globalPosition();
55  lr = sqrt( sqr(ohit.x()-origin().x())+sqr(ohit.y()-origin().y()) );
56  gz = ohit.z();
57  dr = outerHit->errorGlobalR();
58  dz = outerHit->errorGlobalZ();
59  }
60 
61 
62  PixelRecoPointRZ outerred(lr, gz);
63 
64 
65  PixelRecoPointRZ vtxR = (gz > origin().z()+originZBound()) ?
66  PixelRecoPointRZ(-originRBound(), origin().z()+originZBound())
67  : PixelRecoPointRZ( originRBound(), origin().z()+originZBound());
68  PixelRecoPointRZ vtxL = (gz< origin().z()-originZBound()) ?
69  PixelRecoPointRZ(-originRBound(), origin().z()-originZBound())
70  : PixelRecoPointRZ( originRBound(), origin().z()-originZBound());
71 
72  if unlikely((!thePrecise) &&(isPixel )) {
73  double VcotMin = PixelRecoLineRZ( vtxR, outerred).cotLine();
74  double VcotMax = PixelRecoLineRZ( vtxL, outerred).cotLine();
75  return new HitEtaCheck(isBarrel, outerred, VcotMax, VcotMin);
76  }
77 
78  constexpr float nSigmaPhi = 3.;
79 
80  dr *= nSigmaPhi;
81  dz *= nSigmaPhi;
82  PixelRecoPointRZ outerL, outerR;
83 
84  if (layer->isBarrel()) {
85  outerL = PixelRecoPointRZ(lr, gz-dz);
86  outerR = PixelRecoPointRZ(lr, gz+dz);
87  }
88  else if (gz > 0) {
89  outerL = PixelRecoPointRZ(lr+dr, gz);
90  outerR = PixelRecoPointRZ(lr-dr, gz);
91  }
92  else {
93  outerL = PixelRecoPointRZ(lr-dr, gz);
94  outerR = PixelRecoPointRZ(lr+dr, gz);
95  }
96 
97  MultipleScatteringParametrisation iSigma(layer,iSetup);
98  PixelRecoPointRZ vtxMean(0.,origin().z());
99 
100  /*
101  float innerScatt=0;
102  if (outerlayer) {
103  innerScatt = 3.f * iSigma( ptMin(), vtxMean, outerred);
104  float anew = 3.f * iSigma( ptMin(), vtxMean, outerred, outerlayer->seqNum());
105  if (std::abs( (innerScatt-anew)/innerScatt) > .05)
106  std::cout << "MS old/new in " << outerlayer->seqNum() << " " << layer->seqNum()
107  << ": " << innerScatt << " / " << anew
108  << std::endl;
109  } else
110  innerScatt = 3.f * iSigma( ptMin(), vtxMean, outerred);
111  */
112 
113 
114  float innerScatt = 3.f * ( outerlayer ?
115  iSigma( ptMin(), vtxMean, outerred, outerlayer->seqNum())
116  : iSigma( ptMin(), vtxMean, outerred) ) ;
117 
118 
119  //
120  //
121  //
122  SimpleLineRZ leftLine( vtxL, outerL);
123  SimpleLineRZ rightLine( vtxR, outerR);
124  HitRZConstraint rzConstraint(leftLine, rightLine);
125  float cotTheta = SimpleLineRZ(vtxMean,outerred).cotLine();
126 
127  if (isBarrel) {
128  float sinTheta = 1/std::sqrt(1+sqr(cotTheta));
129  float corrZ = innerScatt/sinTheta + dz;
130  return new HitZCheck(rzConstraint, HitZCheck::Margin(corrZ,corrZ));
131  } else {
132  float cosTheta = 1/std::sqrt(1+sqr(1/cotTheta));
133  float corrR = innerScatt/cosTheta + dr;
134  return new HitRCheck( rzConstraint, HitRCheck::Margin(corrR,corrR));
135  }
136 }
float cotLine() const
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:8
T y() const
Definition: PV3DBase.h:63
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
float float float z
#define unlikely(x)
Definition: Likely.h:21
int seqNum() const
Definition: DetLayer.h:39
float cotLine() const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
static GlobalPoint vtxMean(const GlobalPoint &p1, const GlobalError &e1, const GlobalPoint &p2, const GlobalError &e2)
constexpr double nSigmaPhi
void hits(const edm::Event &ev, const edm::EventSetup &es, Hits &) const
bool isBarrel() const
Definition: DetLayer.h:35
std::vector< Hit > Hits
virtual std::string print() const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
long double T
T x() const
Definition: PV3DBase.h:62
#define constexpr