1 #ifndef ERRORSANALYZER_CC
2 #define ERRORSANALYZER_CC
7 : treeFileName_(iConfig.getParameter<
std::
string>(
"InputFileName")),
8 resolFitType_(iConfig.getParameter<
int>(
"ResolFitType")),
9 maxEvents_(iConfig.getParameter<
int>(
"MaxEvents")),
10 outputFileName_(iConfig.getParameter<
std::
string>(
"OutputFileName")),
11 ptBins_(iConfig.getParameter<
int>(
"PtBins")),
12 ptMin_(iConfig.getParameter<double>(
"PtMin")),
13 ptMax_(iConfig.getParameter<double>(
"PtMax")),
14 etaBins_(iConfig.getParameter<
int>(
"EtaBins")),
15 etaMin_(iConfig.getParameter<double>(
"EtaMin")),
16 etaMax_(iConfig.getParameter<double>(
"EtaMax")),
17 debug_(iConfig.getParameter<
bool>(
"Debug")) {
23 std::cout <<
"Error: parameters and errors have different number of values" << std::endl;
41 new TProfile(
"sigmaMassVsPtMinusErrProfile",
"sigmaMassVsPtMinusErr",
ptBins_,
ptMin_,
ptMax_);
54 std::vector<double>::const_iterator parIt =
parameters_.begin();
55 std::vector<double>::const_iterator errIt =
errors_.begin();
56 std::vector<int>::const_iterator errFactorIt =
errorFactors_.begin();
58 for (; parIt !=
parameters_.end(); ++parIt, ++errIt, ++errFactorIt, ++
i) {
65 gROOT->SetStyle(
"Plain");
82 const TProfile* histoPlusErr,
83 const TProfile* histoMinusErr,
84 const TString&
type) {
85 TH1D* sigmaPtVsEtaTH1D =
87 TH1D* sigmaPtVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
90 histo->GetXaxis()->GetXmin(),
91 histo->GetXaxis()->GetXmax());
92 TH1D* sigmaPtVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
95 histo->GetXaxis()->GetXmin(),
96 histo->GetXaxis()->GetXmax());
98 TH1D* sigmaMassVsEtaTH1D =
100 TH1D* sigmaMassVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
103 histo->GetXaxis()->GetXmin(),
104 histo->GetXaxis()->GetXmax());
105 TH1D* sigmaMassVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
108 histo->GetXaxis()->GetXmin(),
109 histo->GetXaxis()->GetXmax());
111 TCanvas*
canvas =
new TCanvas(
"canvas" +
type,
"canvas" +
type, 1000, 800);
112 for (
int iBin = 1; iBin <=
histo->GetNbinsX(); ++iBin) {
113 sigmaPtVsEtaTH1D->SetBinContent(iBin,
histo->GetBinContent(iBin));
114 sigmaPtVsEtaPlusErrTH1D->SetBinContent(iBin, histoPlusErr->GetBinContent(iBin));
115 sigmaPtVsEtaMinusErrTH1D->SetBinContent(iBin, histoMinusErr->GetBinContent(iBin));
117 int numBins = sigmaPtVsEtaTH1D->GetNbinsX();
119 Double_t*
values = sigmaPtVsEtaTH1D->GetArray();
120 Double_t* valuesPlus = sigmaPtVsEtaPlusErrTH1D->GetArray();
121 Double_t* valuesMinus = sigmaPtVsEtaMinusErrTH1D->GetArray();
122 double* posErrors =
new double[numBins];
123 double* negErrors =
new double[numBins];
125 TGraphAsymmErrors* graphAsymmErrors =
new TGraphAsymmErrors(sigmaPtVsEtaTH1D);
126 TGraph* graph =
new TGraph(sigmaPtVsEtaTH1D);
128 for (
int i = 1;
i <= numBins; ++
i) {
130 posErrors[
i - 1] = valuesPlus[
i] -
values[
i];
131 if (valuesMinus[
i] < 0)
134 negErrors[
i - 1] =
values[
i] - valuesMinus[
i];
136 graphAsymmErrors->SetPointEYlow(
i - 1, negErrors[
i - 1]);
137 graphAsymmErrors->SetPointEYhigh(
i - 1, posErrors[
i - 1]);
145 graphAsymmErrors->SetTitle(
"");
146 graphAsymmErrors->SetFillColor(kGray);
147 graphAsymmErrors->Draw(
"A2");
151 graphAsymmErrors->GetXaxis()->SetTitle(
title);
152 graphAsymmErrors->GetYaxis()->SetTitle(
"#sigmaPt/Pt");
173 sigmaPtVsEtaPlusErrTH1D->Write();
174 sigmaPtVsEtaTH1D->Write();
175 sigmaPtVsEtaMinusErrTH1D->Write();
182 sigmaMassVsEtaPlusErrTH1D->Write();
183 sigmaMassVsEtaTH1D->Write();
184 sigmaMassVsEtaMinusErrTH1D->Write();
200 typedef std::vector<std::pair<lorentzVector, lorentzVector> >
MuonPairVector;
202 std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
214 MuonPairVector::iterator it = savedPair.begin();
215 std::cout <<
"Starting loop on " << savedPair.size() <<
" muons" << std::endl;
216 for (; it != savedPair.end(); ++it, ++
i) {
217 double pt1 = it->first.pt();
218 double eta1 = it->first.eta();
219 double pt2 = it->second.pt();
220 double eta2 = it->second.eta();
241 std::cout <<
"sigmaPt1 = " << sigmaPt1 <<
" + " << sigmaPtPlusErr1 <<
" - " << sigmaPtMinusErr1 << std::endl;
242 std::cout <<
"sigmaPt2 = " << sigmaPt2 <<
" + " << sigmaPtPlusErr2 <<
" - " << sigmaPtMinusErr2 << std::endl;
243 std::cout <<
"sigmaMass = " << sigmaMass <<
" + " << sigmaMassPlusErr <<
" - " << sigmaMassMinusErr << std::endl;
255 if (sigmaPt1 != sigmaPt1)
257 if (sigmaPt2 != sigmaPt2)
259 if (sigmaPtPlusErr1 != sigmaPtPlusErr1)
261 if (sigmaPtPlusErr2 != sigmaPtPlusErr2)
263 if (sigmaPtMinusErr1 != sigmaPtMinusErr1)
265 if (sigmaPtMinusErr2 != sigmaPtMinusErr2)
267 if (sigmaMass != sigmaMass)
269 if (sigmaMassPlusErr != sigmaMassPlusErr)
271 if (sigmaMassMinusErr != sigmaMassMinusErr)
274 std::cout <<
"Muon pair number " <<
i << std::endl;