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 
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 }
PixelRecoPointRZ.h
PixelRecoPointRZ::r
float r() const
Definition: PixelRecoPointRZ.h:10
init
int init
Definition: HydjetWrapper.h:64
mps_fire.i
i
Definition: mps_fire.py:428
MultipleScatteringParametrisation::X0Source
X0Source
Definition: MultipleScatteringParametrisation.h:20
DetLayer
Definition: DetLayer.h:21
MSLayersKeeperX0DetLayer.h
MSLayersKeeperX0DetLayer
Definition: MSLayersKeeperX0DetLayer.h:9
MultipleScatteringParametrisation::Consecutive
Consecutive
Definition: MultipleScatteringParametrisation.h:21
MultipleScatteringParametrisation::operator()
float operator()(float pt, float cotTheta, float transverseIP=0.) const
Definition: MultipleScatteringParametrisation.cc:69
PixelRecoPointRZ::z
float z() const
Definition: PixelRecoPointRZ.h:11
MSLayersKeeper.h
PVValHelper::pT
Definition: PVValidationHelpers.h:70
MSLayersKeeperX0AtEta.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
MultipleScatteringParametrisation::initKeepers
static void initKeepers(const edm::EventSetup &iSetup)
Definition: MultipleScatteringParametrisation.cc:53
MSLayersKeeper::init
virtual void init(const edm::EventSetup &iSetup)
Definition: MSLayersKeeper.h:16
MSLayersAtAngle::sumX0D
float sumX0D(const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO) const
Definition: MSLayersAtAngle.cc:51
MSLayersAtAngle
Definition: MSLayersAtAngle.h:16
MultipleScatteringParametrisation::x0ToSigma
static const float x0ToSigma
Definition: MultipleScatteringParametrisation.h:59
qcdUeDQM_cfi.tip
tip
Definition: qcdUeDQM_cfi.py:23
MSLayersKeeperX0AtEta
Definition: MSLayersKeeperX0AtEta.h:10
PixelRecoLineRZ
Definition: PixelRecoLineRZ.h:12
sqr
T sqr(T t)
Definition: MultipleScatteringParametrisation.cc:9
edm::EventSetup
Definition: EventSetup.h:57
MSLayersKeeperX0Averaged
Definition: MSLayersKeeperX0Averaged.h:8
PixelRecoPointRZ
Definition: PixelRecoPointRZ.h:6
MultipleScatteringParametrisation.h
std
Definition: JetResolutionObject.h:76
PixelRecoLineRZ::cotLine
float cotLine() const
Definition: PixelRecoLineRZ.h:31
T
long double T
Definition: Basic3DVectorLD.h:48
genVertex_cff.x
x
Definition: genVertex_cff.py:12
MultipleScatteringParametrisation::init
void init(const DetLayer *layer, const edm::EventSetup &iSetup, X0Source x0source=useX0AtEta)
Definition: MultipleScatteringParametrisation.cc:57
DetLayer.h
PixelRecoLineRZ.h
MSLayersKeeperX0Averaged.h
MSLayersAtAngle.h
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MSLayersKeeper
Definition: MSLayersKeeper.h:11