46 const string& drawOpt,
54 hist->SetLineColor(lineColor);
55 hist->SetLineWidth(lineWidth);
56 hist->SetLineStyle(lineStyle);
57 hist->SetMarkerColor(lineColor);
58 hist->SetMarkerSize(markerSize);
59 hist->SetMarkerStyle(markerStyle);
66 hist->GetXaxis()->SetLabelSize(textSize);
67 hist->GetXaxis()->SetNdivisions(505, kTRUE);
68 hist->GetYaxis()->SetLabelSize(textSize);
69 hist->GetXaxis()->SetTitleSize(textSize);
70 hist->GetYaxis()->SetTitleSize(textSize);
71 hist->GetXaxis()->SetTitleOffset(1.0);
72 hist->GetYaxis()->SetTitleOffset(1.3);
74 gPad->SetTopMargin(0.20);
75 gPad->SetLeftMargin(0.17);
76 gPad->SetBottomMargin(0.15);
78 if (fillColor > 0) hist->SetFillColor(fillColor);
80 if (canvName != canvas->GetName()) {
81 canvName = canvas->GetName();
82 canvVect.push_back(canvas);
83 maxHeight += canvas->GetWh();
86 hist->Draw(drawOpt.c_str());
87 gPad->SetGrid(
true,
true);
88 hist->SetStats(
false);
99 const string& drawOpt) {
110 hist->GetXaxis()->SetLabelSize(textSize);
111 hist->GetXaxis()->SetNdivisions(505, kTRUE);
112 hist->GetYaxis()->SetLabelSize(textSize);
113 hist->GetYaxis()->SetNdivisions(505, kTRUE);
114 hist->GetZaxis()->SetLabelSize(textSize);
116 hist->GetXaxis()->SetTitleSize(textSize);
117 hist->GetYaxis()->SetTitleSize(textSize);
118 hist->GetZaxis()->SetTitleSize(textSize);
119 hist->GetXaxis()->SetTitleOffset(1.0);
120 hist->GetYaxis()->SetTitleOffset(1.3);
121 hist->GetZaxis()->SetTitleOffset(1.5);
124 gPad->SetTopMargin(0.20);
125 gPad->SetLeftMargin(0.17);
126 gPad->SetRightMargin(0.30);
127 gPad->SetBottomMargin(0.15);
128 gPad->SetTicks(1, 1);
130 if (canvName != canvas->GetName()) {
131 canvName = canvas->GetName();
132 canvVect.push_back(canvas);
133 maxHeight += canvas->GetWh();
136 hist->Draw(drawOpt.c_str());
137 gPad->SetGrid(
true,
true);
138 hist->SetStats(
false);
144 const vector<TH1*>& histos,
145 const vector<string>& histLabels,
153 const string& drawOpt,
154 Bool_t outputMeanValue01) {
155 assert(histos.size() != 0 && histLabels.size() == histos.size());
156 Double_t
max = std::numeric_limits<Double_t>::min();
157 Int_t nofHistos = histos.size();
158 TLegend* legend =
new TLegend(x1, y1, x2, y2);
159 legend->SetFillColor(kWhite);
160 for (Int_t iHist = 0; iHist < nofHistos; iHist++) {
161 TH1* hist = histos[iHist];
162 string opt = (iHist == 0) ? drawOpt : (iHist == nofHistos - 1) ?
"SAME" + drawOpt :
"SAME" + drawOpt;
166 max = std::max(
max, hist->GetMaximum());
167 Int_t nonZeroBins = 0;
168 for (Int_t
i = 0;
i < hist->GetNbinsX(); ++
i) {
169 if (hist->GetBinContent(
i) != 0.0) nonZeroBins++;
172 Double_t xMax = hist->GetBinCenter(hist->GetNbinsX());
174 Int_t nGev = Int_t(hist->GetNbinsX() * xGev / xMax);
175 Double_t effAll = hist->Integral() / nonZeroBins;
176 Double_t eff01 = hist->Integral(0.0, nGev) / nGev;
178 if (outputMeanValue01) legText = TString::Format(
"%s | mean = %3.1f | mean01 = %3.1f", histLabels[iHist].c_str(), effAll, eff01).Data();
179 else legText = TString::Format(
"%s | mean = %3.1f", histLabels[iHist].c_str(), effAll).Data();
180 legend->AddEntry(hist, legText,
"lp");
182 FILE*
f = fopen(
"test.dat",
"a+");
183 if (((TString) hist->GetName()).Contains(
"vs_P")) fprintf(
f,
"%s %s %f %f\n", hist->GetName(), histLabels[iHist].c_str(), effAll, eff01);
187 histos[0]->SetMaximum(
max * 1.10);
199 gPad->SetTopMargin(0.20);
200 gPad->SetLeftMargin(0.17);
201 gPad->SetBottomMargin(0.15);
202 gPad->SetTicks(1, 1);
204 if (canvName != canvas->GetName()) {
205 canvName = canvas->GetName();
206 canvVect.push_back(canvas);
207 maxHeight += canvas->GetWh();
211 gPad->SetGrid(
true,
true);
242 Int_t height = maxHeight;
243 TCanvas* mainCanvas =
new TCanvas(nameOfCanv,
"title",1280, height);
244 Int_t numOfCanvases = (canvVect.size());
245 mainCanvas -> Divide(1,numOfCanvases,0.01,0.002);
246 TPad* newpad[numOfCanvases];
247 TPaveLabel* title[numOfCanvases];
249 for( Int_t
i=0;
i < numOfCanvases; ++
i) {
251 canvVect[
i] -> DrawClonePad();
253 TString newpadName =
"newpad" + std::to_string(
i);
254 newpad[
i]=
new TPad(newpadName,
"a transparent pad",0.0,0.93,1.0,1.0);
255 newpad[
i]->SetFillStyle(4000);
258 title[
i] =
new TPaveLabel(0.0,0.0,1.0,1.0,canvVect[
i] ->GetName());
259 title[
i]->SetFillColor(16);
260 title[
i]->SetTextFont(52);
264 mainCanvas -> Write();
267 vector<TCanvas*>().swap(canvVect);
void DrawH2(TCanvas *canvas, TH2 *hist, HistScale logx=kLinear, HistScale logy=kLinear, HistScale logz=kLinear, const string &drawOpt="COLZ")
void DrawH1(TCanvas *canvas, TH1 *hist, HistScale logx=kLinear, HistScale logy=kLinear, const string &drawOpt="", Int_t color=BmnDrawingOptions::Color(0), Int_t lineWidth=BmnDrawingOptions::LineWidth(), Int_t lineStyle=BmnDrawingOptions::LineStyle(0), Float_t markerSize=BmnDrawingOptions::MarkerSize(), Int_t markerStyle=BmnDrawingOptions::MarkerStyle(0), Int_t fillColor=-1)