Go to the documentation of this file.00001 #include "ForIA/AnalysisTools/MinBiasPhiGridCorrections.hh"
00002 #include "ForIA/IDataLoader.hh"
00003
00004 #include "TH2F.h"
00005
00006 #include "boost/lexical_cast.hpp"
00007
00008 namespace ForIA{
00009
00010 MinBiasPhiGridCorrections::MinBiasPhiGridCorrections(): m_segments(32), m_doInitialise(true),
00011 m_gotSegment(m_segments, false), m_gotGrid(false), m_randomGenerator(0){
00012
00013 }
00014
00015 MinBiasPhiGridCorrections::~MinBiasPhiGridCorrections(){
00016 if(m_randomGenerator != 0){
00017 gsl_rng_free(m_randomGenerator);
00018 }
00019 }
00020
00021 void MinBiasPhiGridCorrections::initialise(){
00022
00023 DataLoaderPtr dl = IDataLoader::create();
00024 dl->open("Root/MinBias/TruthReco.simple.quantiles.root");
00025
00026 m_quantilePlot = dl->retrieve<TH2F>("TruthRecoCorrelations/quantile/self");
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 dl->close();
00044
00045 m_minPT = m_quantilePlot->GetXaxis()->GetBinUpEdge(1);
00046
00047 std::cout<<"correction min pT = "<<m_minPT<<std::endl;
00048
00049
00050 m_randomGenerator = gsl_rng_alloc (gsl_rng_taus2);
00051
00052 gsl_rng_set(m_randomGenerator, 8912041);
00053
00054 m_doInitialise = false;
00055 return;
00056 }
00057
00058 bool MinBiasPhiGridCorrections::setGrid(const vector<double> &grid){
00059
00060 if(m_doInitialise) initialise();
00061
00062 for(vector<bool>::iterator seg = m_gotSegment.begin();
00063 seg != m_gotSegment.end(); ++seg){
00064 (*seg) = false;
00065 }
00066
00067 m_gotGrid = false;
00068
00069 m_input = grid;
00070
00071 return true;
00072 }
00073
00075 const vector<double> &MinBiasPhiGridCorrections::correctedGrid(){
00076
00077 if(m_gotGrid) return m_corrected;
00078
00079
00080 vector<double> left;
00081 vector<double> right;
00082
00083 m_corrected.clear();
00084
00085 for(int seg=0; seg != m_segments; ++seg){
00086
00087 double delta = getDelta(m_quantilePlot, m_input[seg]);
00088 if(delta < 500. && delta > 0.) delta = 0.;
00089 double result = m_input[seg] + delta;
00090 if(result < m_minPT) result = 0.;
00091 m_corrected.push_back(result);
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 m_gotGrid = true;
00135 return m_corrected;
00136 }
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 double MinBiasPhiGridCorrections::getDelta(const TH2F *qPlot, double pT){
00157
00158 int xbin = qPlot->GetXaxis()->FindBin(pT);
00159
00160 double ran = gsl_rng_uniform(m_randomGenerator);
00161
00162 int ybin = qPlot->GetYaxis()->FindBin(ran);
00163
00164 if(ybin < 2) ybin=2;
00165
00166 int binUp = qPlot->GetBin(xbin, ybin);
00167 int binDn = qPlot->GetBin(xbin, ybin - 1);
00168
00169 double deltaUp = qPlot->GetBinContent(binUp);
00170 double deltaDn = qPlot->GetBinContent(binDn);
00171
00172 double upEdge = qPlot->GetYaxis()->GetBinUpEdge(ybin);
00173 double dnEdge = qPlot->GetYaxis()->GetBinLowEdge(ybin);
00174
00175
00176 return (deltaUp - (upEdge - ran) * (deltaUp - deltaDn) / (upEdge - dnEdge));
00177 }
00178
00179 }
00180
00181