CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoTracker/TkMSParametrization/src/MultipleScatteringParametrisation.cc

Go to the documentation of this file.
00001 
00002 #include <vector>
00003 #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisation.h"
00004 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00005 #include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h"
00006 #include "RecoTracker/TkMSParametrization/interface/PixelRecoLineRZ.h"
00007 
00008 
00009 template <class T> inline T sqr( T t) {return t*t;}
00010 
00011 #include "MSLayersKeeper.h"
00012 #include "MSLayersKeeperX0AtEta.h"
00013 #include "MSLayersKeeperX0Averaged.h"
00014 #include "MSLayersKeeperX0DetLayer.h"
00015 #include "MSLayersAtAngle.h"
00016 
00017 //#include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h"
00018 
00019 #include<iostream>
00020 
00021 using namespace std;
00022 
00023 const float MultipleScatteringParametrisation::x0ToSigma = 0.0136f;
00024 
00025 namespace {
00026   struct Keepers {
00027     MSLayersKeeperX0DetLayer x0DetLayer;
00028     MSLayersKeeperX0AtEta x0AtEta;
00029     MSLayersKeeperX0Averaged x0Averaged;
00030     MSLayersKeeper * keepers[3];// {&x0DetLayer,&x0AtEta,&x0Averaged};
00031     bool isInitialised; // =false;
00032     MSLayersKeeper const * operator()(int i) const { return keepers[i];}
00033     void init(const edm::EventSetup &iSetup) {
00034       if (isInitialised) return;
00035       for (auto x : keepers) x->init(iSetup);
00036       isInitialised=true;
00037     }
00038     Keepers() : keepers{&x0DetLayer,&x0AtEta,&x0Averaged}, isInitialised(false) {}
00039   };
00040 
00041   const Keepers keepers;
00042 
00043 }
00044 
00045 void MultipleScatteringParametrisation::initKeepers(const edm::EventSetup &iSetup){
00046   const_cast<Keepers&>(keepers).init(iSetup);
00047 }
00048 
00049 //using namespace PixelRecoUtilities;
00050 //----------------------------------------------------------------------
00051 MultipleScatteringParametrisation::
00052 MultipleScatteringParametrisation( const DetLayer* layer,const edm::EventSetup &iSetup, X0Source x0Source) :
00053   theLayerKeeper(keepers(x0Source))
00054 {
00055 
00056   // FIXME not thread safe: move elsewhere...
00057   initKeepers(iSetup);
00058 
00059   if (!layer) return;
00060   theLayer = theLayerKeeper->layer(layer);
00061 } 
00062 
00063 //----------------------------------------------------------------------
00064 float MultipleScatteringParametrisation::operator()(
00065     float pT, float cotTheta, float tip) const
00066 {
00067   float sumX0D = theLayer.sumX0D(cotTheta); 
00068   return x0ToSigma * sumX0D /pT;
00069 }
00070 
00071 //----------------------------------------------------------------------
00072 float MultipleScatteringParametrisation::operator()(
00073   float pT, float cotTheta, const PixelRecoPointRZ & pointI, float tip) const
00074 {
00075 
00076   PixelRecoLineRZ lineIO(pointI, cotTheta, tip);
00077   PixelRecoPointRZ pointO = theLayer.crossing(lineIO).first;
00078 
00079   const MSLayersAtAngle & layersAtEta = theLayerKeeper->layers(cotTheta);
00080   
00081   float sumX0D = layersAtEta.sumX0D(pointI, pointO);
00082   return x0ToSigma * sumX0D /pT;
00083 }
00084 
00085 //----------------------------------------------------------------------
00086 float MultipleScatteringParametrisation::operator()(
00087     float pT,
00088     const PixelRecoPointRZ & pointI,
00089     const PixelRecoPointRZ & pointO,
00090     Consecutive consecutive,
00091     float tip) const
00092 {   
00093 
00094 
00095   PixelRecoLineRZ lineIO(pointI, pointO, tip);
00096   PixelRecoPointRZ pointM = theLayer.crossing(lineIO).first;
00097   float cotTheta = lineIO.cotLine();
00098 
00099   if (consecutive==useConsecutive) {
00100     float dist = fabs(  (pointO.r()-pointM.r())
00101                       * (pointM.r()-pointI.r())
00102                       / (pointO.r()-pointI.r()) );
00103     return  x0ToSigma * sqrt(theLayer.x0(cotTheta)) * dist /pT;
00104   } else {
00105     const MSLayersAtAngle & layersAtEta = theLayerKeeper->layers(cotTheta);
00106     float sumX0D = layersAtEta.sumX0D(pointI, pointM, pointO);
00107     return x0ToSigma * sumX0D /pT;
00108   }
00109 }