CMS 3D CMS Logo

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