CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 MultipleScatteringParametrisation( const DetLayer* layer,const edm::EventSetup &iSetup, X0Source x0Source) :
57  theLayerKeeper(keepers(x0Source))
58 {
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 i
Definition: DBlmapReader.cc:9
MultipleScatteringParametrisation(const DetLayer *layer, const edm::EventSetup &iSetup, X0Source x0source=useX0AtEta)
float sumX0D(float cotTheta) const
Definition: MSLayer.cc:152
int init
Definition: HydjetWrapper.h:67
float x0(float cotTheta) const
Definition: MSLayer.cc:137
T x() const
Cartesian x coordinate.
float cotLine() const
T sqrt(T t)
Definition: SSEVec.h:48
virtual const MSLayersAtAngle & layers(float cotTheta) const =0
float sumX0D(const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO) const
std::pair< PixelRecoPointRZ, bool > crossing(const PixelRecoLineRZ &line) const
Definition: MSLayer.cc:90
float operator()(float pt, float cotTheta, float transverseIP=0.) const
float z() const
static void initKeepers(const edm::EventSetup &iSetup)
virtual MSLayer layer(const DetLayer *dl) const
float r() const
int seqNum() const
Definition: MSLayer.h:41
Square< F >::type sqr(const F &f)
Definition: Square.h:13
long double T