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")),
18 ptMinCut_(iConfig.getUntrackedParameter<double>(
"PtMinCut", 0.)),
19 ptMaxCut_(iConfig.getUntrackedParameter<double>(
"PtMaxCut", 999999.)),
20 etaMinCut_(iConfig.getUntrackedParameter<double>(
"EtaMinCut", 0.)),
21 etaMaxCut_(iConfig.getUntrackedParameter<double>(
"EtaMaxCut", 100.)) {
27 std::cout <<
"Error: parameters and errors have different number of values" << std::endl;
45 new TProfile(
"sigmaMassVsPtMinusErrProfile",
"sigmaMassVsPtMinusErr",
ptBins_,
ptMin_,
ptMax_);
54 new TProfile(
"sigmaMassOverMassVsPtProfile",
"sigmaMassOverMassVsPt",
ptBins_,
ptMin_,
ptMax_);
56 new TProfile(
"sigmaMassOverMassVsPtPlusErrProfile",
"sigmaMassOverMassVsPtPlusErr",
ptBins_,
ptMin_,
ptMax_);
58 new TProfile(
"sigmaMassOverMassVsPtMinusErrProfile",
"sigmaMassOverMassVsPtMinusErr",
ptBins_,
ptMin_,
ptMax_);
63 new TProfile(
"sigmaMassOverMassVsEtaPlusErrProfile",
"sigmaMassOverMassVsEtaPlusErr",
etaBins_,
etaMin_,
etaMax_);
75 std::vector<double>::const_iterator parIt =
parameters_.begin();
76 std::vector<double>::const_iterator errIt =
errors_.begin();
77 std::vector<int>::const_iterator errFactorIt =
errorFactors_.begin();
79 for (; parIt !=
parameters_.end(); ++parIt, ++errIt, ++errFactorIt, ++
i) {
86 gROOT->SetStyle(
"Plain");
101 "sigmaMassOverMassVsEta",
106 "sigmaMassOverMassVsPt",
117 const TProfile* histoPlusErr,
118 const TProfile* histoMinusErr,
120 const TString& yLabel) {
121 TH1D* sigmaPtVsEtaTH1D =
123 TH1D* sigmaPtVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
126 histo->GetXaxis()->GetXmin(),
127 histo->GetXaxis()->GetXmax());
128 TH1D* sigmaPtVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
131 histo->GetXaxis()->GetXmin(),
132 histo->GetXaxis()->GetXmax());
134 TH1D* sigmaMassVsEtaTH1D =
136 TH1D* sigmaMassVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
139 histo->GetXaxis()->GetXmin(),
140 histo->GetXaxis()->GetXmax());
141 TH1D* sigmaMassVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
144 histo->GetXaxis()->GetXmin(),
145 histo->GetXaxis()->GetXmax());
147 TH1D* sigmaMassOverMassVsEtaTH1D =
149 TH1D* sigmaMassOverMassVsEtaPlusErrTH1D =
new TH1D(
type +
"PlusErr",
152 histo->GetXaxis()->GetXmin(),
153 histo->GetXaxis()->GetXmax());
154 TH1D* sigmaMassOverMassVsEtaMinusErrTH1D =
new TH1D(
type +
"MinusErr",
157 histo->GetXaxis()->GetXmin(),
158 histo->GetXaxis()->GetXmax());
160 TCanvas*
canvas =
new TCanvas(
"canvas" +
type,
"canvas" +
type, 1000, 800);
161 for (
int iBin = 1; iBin <=
histo->GetNbinsX(); ++iBin) {
162 sigmaPtVsEtaTH1D->SetBinContent(iBin,
histo->GetBinContent(iBin));
163 sigmaPtVsEtaPlusErrTH1D->SetBinContent(iBin, histoPlusErr->GetBinContent(iBin));
164 sigmaPtVsEtaMinusErrTH1D->SetBinContent(iBin, histoMinusErr->GetBinContent(iBin));
166 int numBins = sigmaPtVsEtaTH1D->GetNbinsX();
168 Double_t*
values = sigmaPtVsEtaTH1D->GetArray();
169 Double_t* valuesPlus = sigmaPtVsEtaPlusErrTH1D->GetArray();
170 Double_t* valuesMinus = sigmaPtVsEtaMinusErrTH1D->GetArray();
171 double* posErrors =
new double[numBins];
172 double* negErrors =
new double[numBins];
174 TGraphAsymmErrors* graphAsymmErrors =
new TGraphAsymmErrors(sigmaPtVsEtaTH1D);
175 TGraph* graph =
new TGraph(sigmaPtVsEtaTH1D);
177 for (
int i = 1;
i <= numBins; ++
i) {
179 posErrors[
i - 1] = valuesPlus[
i] -
values[
i];
180 if (valuesMinus[
i] < 0)
183 negErrors[
i - 1] =
values[
i] - valuesMinus[
i];
185 graphAsymmErrors->SetPointEYlow(
i - 1, negErrors[
i - 1]);
186 graphAsymmErrors->SetPointEYhigh(
i - 1, posErrors[
i - 1]);
194 graphAsymmErrors->SetTitle(
"");
195 graphAsymmErrors->SetFillColor(kGray);
196 graphAsymmErrors->Draw(
"A2");
200 graphAsymmErrors->GetXaxis()->SetTitle(
title);
201 graphAsymmErrors->GetYaxis()->SetTitle(
"yLabel");
222 sigmaPtVsEtaPlusErrTH1D->Write();
223 sigmaPtVsEtaTH1D->Write();
224 sigmaPtVsEtaMinusErrTH1D->Write();
231 sigmaMassVsEtaPlusErrTH1D->Write();
232 sigmaMassVsEtaTH1D->Write();
233 sigmaMassVsEtaMinusErrTH1D->Write();
235 sigmaMassOverMassVsEtaPlusErrTH1D->Write();
236 sigmaMassOverMassVsEtaTH1D->Write();
237 sigmaMassOverMassVsEtaMinusErrTH1D->Write();
255 const std::vector<double>& parval,
256 const double& sigmaPt1,
257 const double& sigmaPt2) {
258 double*
p =
new double[(
int)(parval.size())];
259 std::vector<double>::const_iterator it = parval.begin();
261 for (; it != parval.end(); ++it, ++
id) {
272 const double& sigmaPt1,
273 const double& sigmaPt2) {
275 double pt1 = mu1.Pt();
276 double phi1 = mu1.Phi();
277 double eta1 = mu1.Eta();
278 double theta1 = 2 * atan(
exp(-
eta1));
279 double pt2 = mu2.Pt();
280 double phi2 = mu2.Phi();
281 double eta2 = mu2.Eta();
282 double theta2 = 2 * atan(
exp(-
eta2));
298 double dmdcotgth1 = (
pt1 *
pt1 *
cos(theta1) /
sin(theta1) *
303 double dmdcotgth2 = (
pt2 *
pt2 *
cos(theta2) /
sin(theta2) *
313 double sigma_pt1 = sigmaPt1;
314 double sigma_pt2 = sigmaPt2;
325 std::pow(dmdcotgth1 * sigma_cotgth1, 2) +
std::pow(dmdcotgth2 * sigma_cotgth2, 2) +
326 2 * dmdpt1 * dmdpt2 * cov_pt1pt2);
335 typedef std::vector<std::pair<lorentzVector, lorentzVector> >
MuonPairVector;
337 std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
352 MuonPairVector::iterator it = savedPair.begin();
353 std::cout <<
"Starting loop on " << savedPair.size() <<
" muons" << std::endl;
354 for (; it != savedPair.end(); ++it, ++
i) {
355 double pt1 = it->first.pt();
356 double eta1 = it->first.eta();
357 double pt2 = it->second.pt();
358 double eta2 = it->second.eta();
391 double mass = (it->first + it->second).
mass();
394 std::cout <<
"sigmaPt1 = " << sigmaPt1 <<
" + " << sigmaPtPlusErr1 <<
" - " << sigmaPtMinusErr1 << std::endl;
395 std::cout <<
"sigmaPt2 = " << sigmaPt2 <<
" + " << sigmaPtPlusErr2 <<
" - " << sigmaPtMinusErr2 << std::endl;
396 std::cout <<
"sigmaMass = " << sigmaMass <<
" + " << sigmaMassPlusErr <<
" - " << sigmaMassMinusErr << std::endl;
408 if (sigmaPt1 != sigmaPt1)
410 if (sigmaPt2 != sigmaPt2)
412 if (sigmaPtPlusErr1 != sigmaPtPlusErr1)
414 if (sigmaPtPlusErr2 != sigmaPtPlusErr2)
416 if (sigmaPtMinusErr1 != sigmaPtMinusErr1)
418 if (sigmaPtMinusErr2 != sigmaPtMinusErr2)
420 if (sigmaMass != sigmaMass)
422 if (sigmaMassPlusErr != sigmaMassPlusErr)
424 if (sigmaMassMinusErr != sigmaMassMinusErr)
429 std::cout <<
"Muon pair number " <<
i << std::endl;