CMS 3D CMS Logo

MultipleScatteringParametrisation.cc
Go to the documentation of this file.
1 
2 #include <vector>
7 
8 
9 template <class T> inline T sqr( T t) {return t*t;}
10 
11 #include "MSLayersKeeper.h"
12 #include "MSLayersKeeperX0AtEta.h"
15 #include "MSLayersAtAngle.h"
16 
17 //#include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h"
18 
19 #include<iostream>
20 
21 using namespace std;
22 
24 
25 namespace {
26  struct Keepers {
27  MSLayersKeeperX0DetLayer x0DetLayer;
28  MSLayersKeeperX0AtEta x0AtEta;
29  MSLayersKeeperX0Averaged x0Averaged;
30  MSLayersKeeper * keepers[3];// {&x0DetLayer,&x0AtEta,&x0Averaged};
31  bool isInitialised; // =false;
32  MSLayersKeeper const * operator()(int i) const { return keepers[i];}
33  void init(const edm::EventSetup &iSetup) {
34  if (isInitialised) return;
35  for (auto x : keepers) x->init(iSetup);
36  isInitialised=true;
37  }
38  Keepers() : keepers{&x0DetLayer,&x0AtEta,&x0Averaged}, isInitialised(false) {}
39  };
40 
41  thread_local Keepers keepers;
42  //NOTE: This is being used to globally cache information from the EventSetup
43  // this should not be done so we need this code changed.
44  //NOTE; the thread_local only works in this case because MultipleScateringParametrisation
45  // instances are only ever created on the stack and not the heap.
46 
47 }
48 
50  keepers.init(iSetup);
51 }
52 
53 //using namespace PixelRecoUtilities;
54 //----------------------------------------------------------------------
56 init( const DetLayer* layer,const edm::EventSetup &iSetup, X0Source x0Source) {
57 
58  theLayerKeeper = keepers(x0Source);
59 
60  // FIXME not thread safe: move elsewhere...
61  initKeepers(iSetup);
62 
63  if (!layer) return;
64  theLayer = theLayerKeeper->layer(layer);
65 }
66 
67 //----------------------------------------------------------------------
69  float pT, float cotTheta, float) const
70 {
71  float sumX0D = theLayer.sumX0D(cotTheta);
72  return x0ToSigma * sumX0D /pT;
73 }
74 
75 //----------------------------------------------------------------------
77  float pT, float cotTheta, const PixelRecoPointRZ & pointI, float tip) const
78 {
79 
80  PixelRecoLineRZ lineIO(pointI, cotTheta, tip);
81  PixelRecoPointRZ pointO = theLayer.crossing(lineIO).first;
82 
83  const MSLayersAtAngle & layersAtEta = theLayerKeeper->layers(cotTheta);
84 
85  float sumX0D = layersAtEta.sumX0D(pointI, pointO);
86  return x0ToSigma * sumX0D /pT;
87 }
88 
89 
90 float
91 MultipleScatteringParametrisation::operator()(float pT, float cotTheta, const PixelRecoPointRZ & pointI, int il) const {
92 
93  PixelRecoLineRZ lineIO(pointI, cotTheta);
94  PixelRecoPointRZ pointO = theLayer.crossing(lineIO).first;
95 
96  const MSLayersAtAngle & layersAtEta = theLayerKeeper->layers(cotTheta);
97 
98  float sumX0D = layersAtEta.sumX0D(il, theLayer.seqNum(), pointI, pointO);
99  return x0ToSigma * sumX0D /pT;
100 }
101 
102 
103 //----------------------------------------------------------------------
105  float pT,
106  const PixelRecoPointRZ & pointI,
107  const PixelRecoPointRZ & pointO,
108  Consecutive consecutive,
109  float tip) const
110 {
111 
112 
113  PixelRecoLineRZ lineIO(pointI, pointO, tip);
114  PixelRecoPointRZ pointM = theLayer.crossing(lineIO).first;
115  float cotTheta = lineIO.cotLine();
116 
117  if (consecutive==useConsecutive) {
118  float dist = fabs( (pointO.r()-pointM.r())
119  * (pointM.r()-pointI.r())
120  / (pointO.r()-pointI.r()) );
121  return x0ToSigma * sqrt(theLayer.x0(cotTheta)) * dist /pT;
122  } else {
123  const MSLayersAtAngle & layersAtEta = theLayerKeeper->layers(cotTheta);
124  float sumX0D = layersAtEta.sumX0D(pointI, pointM, pointO);
125  return x0ToSigma * sumX0D /pT;
126  }
127 }
128 
130  float pT,
131  const PixelRecoPointRZ & pointV,
132  const PixelRecoPointRZ & pointO,
133  int ol) const
134 {
135 
136  PixelRecoLineRZ lineIO(pointV, pointO);
137  PixelRecoPointRZ pointI = theLayer.crossing(lineIO).first;
138  float cotTheta = lineIO.cotLine();
139 
140  const MSLayersAtAngle & layersAtEta = theLayerKeeper->layers(cotTheta);
141  float sumX0D = layersAtEta.sumX0D(pointV.z(), theLayer.seqNum(), ol, pointI, pointO);
142  return x0ToSigma * sumX0D /pT;
143 }
int init
Definition: HydjetWrapper.h:67
T x() const
Cartesian x coordinate.
float cotLine() const
T sqrt(T t)
Definition: SSEVec.h:18
float sumX0D(const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO) const
float operator()(float pt, float cotTheta, float transverseIP=0.) const
float z() const
static void initKeepers(const edm::EventSetup &iSetup)
float r() const
void init(const DetLayer *layer, const edm::EventSetup &iSetup, X0Source x0source=useX0AtEta)
long double T