File indexing completed on 2023-03-17 11:14:51
0001 #include "ScaleFraction.C"
0002 #include "TFile.h"
0003 #include "TH1F.h"
0004 #include "TProfile.h"
0005 #include "TDirectory.h"
0006 #include "TLegend.h"
0007 #include "TString.h"
0008
0009
0010
0011
0012
0013
0014
0015 bool first = true;
0016
0017 void mergeAll(const TString & inputFileName, const int color1, const int color2, TLegend * legend, const TString & when, const TString & options = "")
0018 {
0019 TFile * inputFile = new TFile(inputFileName);
0020 TH1F * histo1 = (TH1F*)inputFile->Get("hRecBestRes_Mass");
0021 TDirectory * profileDir = (TDirectory*)inputFile->Get("Mass_fine_P");
0022 TProfile * histo2 = (TProfile*)profileDir->Get("Mass_fine_PProf");
0023
0024 histo1->Rebin(8);
0025 histo2->Rebin(2);
0026
0027 ScaleFraction scaleFraction;
0028 pair<TH1*, TH1*> newHistosUpsilon1S = scaleFraction.scale(histo1, histo2, 9, 9.8, "1");
0029
0030 if( first ) {
0031 newHistosUpsilon1S.first->Draw(options);
0032 first = false;
0033 }
0034 else {
0035 newHistosUpsilon1S.first->Draw(options+"same");
0036 }
0037 newHistosUpsilon1S.first->SetLineColor(color1);
0038 newHistosUpsilon1S.second->Scale(newHistosUpsilon1S.first->Integral("width")/newHistosUpsilon1S.second->Integral("width"));
0039 newHistosUpsilon1S.second->Draw("same");
0040 newHistosUpsilon1S.second->SetLineColor(color2);
0041
0042 legend->AddEntry(newHistosUpsilon1S.first, "mass "+when+" correction");
0043 legend->AddEntry(newHistosUpsilon1S.second, "mass prob "+when+" correction");
0044
0045 pair<TH1*, TH1*> newHistosUpsilon2S = scaleFraction.scale(histo1, histo2, 9.8, 10.2, "2");
0046
0047 newHistosUpsilon2S.first->Draw(options+"same");
0048 newHistosUpsilon2S.first->SetLineColor(color1);
0049 newHistosUpsilon2S.second->Scale(newHistosUpsilon2S.first->Integral("width")/newHistosUpsilon2S.second->Integral("width"));
0050 newHistosUpsilon2S.second->Draw("same");
0051 newHistosUpsilon2S.second->SetLineColor(color2);
0052
0053 pair<TH1*, TH1*> newHistosUpsilon3S = scaleFraction.scale(histo1, histo2, 10.2, 10.8, "3");
0054
0055 newHistosUpsilon3S.first->Draw(options+"same");
0056 newHistosUpsilon3S.first->SetLineColor(color1);
0057 newHistosUpsilon3S.second->Scale(newHistosUpsilon3S.first->Integral("width")/newHistosUpsilon3S.second->Integral("width"));
0058 newHistosUpsilon3S.second->Draw("same");
0059 newHistosUpsilon3S.second->SetLineColor(color2);
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 newHistosUpsilon1S.first->GetXaxis()->SetTitle("Mass (GeV)");
0070 newHistosUpsilon1S.first->GetYaxis()->SetTitle("arbitrary units");
0071 }
0072
0073 void MergeScaled()
0074 {
0075 TLegend * legend = new TLegend(0.7,0.71,0.98,1.);
0076 legend->SetTextSize(0.02);
0077 legend->SetFillColor(0);
0078
0079 mergeAll("0_MuScleFit.root", 1, 2, legend, "before");
0080 mergeAll("2_MuScleFit.root", 3, 4, legend, "after");
0081
0082 legend->Draw("SAME");
0083 }