CMS 3D CMS Logo

ThirdHitCorrection.cc
Go to the documentation of this file.
1 #include "ThirdHitCorrection.h"
2 
5 
6 
7 using namespace pixelrecoutilities;
8 
9 namespace {
10  template <class T> inline T sqr( T t) {return t*t;}
11 }
12 
14 
15 
16 
18  const edm::EventSetup &es,
19  float pt,
20  const DetLayer & layer3,
22  bool useBendingCorrection) {
23 
24  theUseMultipleScattering = useMultipleScattering;
25  theUseBendingCorrection = useBendingCorrection;
26  if (useBendingCorrection) theBendingCorrection.init(pt,es);
27 
28  theMultScattCorrRPhi=0;
29  theMScoeff=0;
30 
31  theBarrel = layer3.isBarrel();
32  thePt = pt;
33 
34  if (theUseMultipleScattering) sigmaRPhi.init(&layer3,es);
35 }
36 
37 
38 
39 void
41  const edm::EventSetup &es,
42  float pt,
43  const DetLayer & layer1,
44  const DetLayer & layer2,
45  const DetLayer & layer3,
47  bool useBendingCorrection) {
48 
49  init(es,pt,layer3, useMultipleScattering, useBendingCorrection);
50 
51  if (!theUseMultipleScattering) return;
52 
53  auto point3 = [&]()->PixelRecoPointRZ {
54  if(theBarrel) {
55  const BarrelDetLayer& bl = static_cast<const BarrelDetLayer&>(layer3);
56  float rLayer = bl.specificSurface().radius();
57  auto zmax = 0.5f*layer3.surface().bounds().length();
58  return PixelRecoPointRZ(rLayer, zmax);
59  } else {
60  const ForwardDetLayer &fl = static_cast<const ForwardDetLayer&>(layer3);
61  auto maxR = fl.specificSurface().outerRadius();
62  auto layerZ = layer3.position().z();
63  return PixelRecoPointRZ(maxR, layerZ);
64  }
65  };
66 
67  PixelRecoPointRZ zero(0., 0.);
68  SimpleLineRZ line(zero,point3());
69 
70  auto point2 = [&]()->PixelRecoPointRZ {
71  if (layer2.isBarrel()) {
72  const BarrelDetLayer& bl = static_cast<const BarrelDetLayer&>(layer2);
73  float rLayer = bl.specificSurface().radius();
74  return PixelRecoPointRZ(rLayer, line.zAtR(rLayer));
75  } else {
76  auto layerZ = layer2.position().z();
77  return PixelRecoPointRZ(line.rAtZ(layerZ), layerZ);
78  }
79  };
80 
81  theMultScattCorrRPhi = 3.f*sigmaRPhi(pt, line.cotLine(), point2(), layer2.seqNum());
82 
83 }
84 
86  const PixelRecoLineRZ & line,
87  const PixelRecoPointRZ & constraint, int il) {
88 
89  theLine = line;
90  if (!theUseMultipleScattering) return;
91 
92  // auto newCorr = theMultScattCorrRPhi;
93  theMultScattCorrRPhi = 3.f*sigmaRPhi(thePt, line.cotLine(), constraint, il);
94  // std::cout << "ThirdHitCorr " << (theBarrel ? "B " : "F " )<< theMultScattCorrRPhi << ' ' << newCorr << ' ' << newCorr/theMultScattCorrRPhi << std::endl;
95  float overSinTheta = std::sqrt(1.f+sqr(line.cotLine()));
96  if (theBarrel) {
97  theMScoeff = theMultScattCorrRPhi*overSinTheta;
98  } else {
99  float overCosTheta = std::abs(line.cotLine()) < 1.e-4f ?
100  1.e4f : overSinTheta/std::abs(line.cotLine());
101  theMScoeff = theMultScattCorrRPhi*overCosTheta;
102  }
103 
104 }
105 
106 
108 {
109  range.first -= theMScoeff;
110  range.second += theMScoeff;
111 
112 
113  if (theUseBendingCorrection) {
114  if (theBarrel) {
115  float cotTheta = theLine.cotLine();
116  if (cotTheta > 0) {
117  float radius = theLine.rAtZ(range.max());
118  float corr = theBendingCorrection(radius) * cotTheta;
119  range.second += corr;
120  } else {
121  float radius = theLine.rAtZ(range.min());
122  float corr = theBendingCorrection(radius) * std::abs(cotTheta);
123  range.first -= corr;
124  }
125  }
126  else {
127  float radius = range.max();
128  float corr = theBendingCorrection(radius);
129  range.first -= corr;
130  }
131  }
132 }
virtual float length() const =0
float cotLine() const
T max() const
int init
Definition: HydjetWrapper.h:67
const Bounds & bounds() const
Definition: Surface.h:120
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
T min() const
int seqNum() const
Definition: DetLayer.h:36
float cotLine() const
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
double f[11][100]
list theLine
Definition: crabWrapper.py:26
JetCorrectorParameters corr
Definition: classes.h:5
bool isBarrel() const
Definition: DetLayer.h:32
virtual const BoundDisk & specificSurface() const final
virtual const Surface::PositionType & position() const
Returns position of the surface.
void init(const edm::EventSetup &es, float pt, const DetLayer &layer1, const DetLayer &layer2, const DetLayer &layer3, bool useMultipleScattering, bool useBendingCorrection)
Square< F >::type sqr(const F &f)
Definition: Square.h:13
float rAtZ(float z) const
float zAtR(float r) const
void correctRZRange(Range &range) const
long double T