void draw_ratio(std::vector<TH1F*> h, TString name, TString xTitle, double xmin, double xmax, TString legHeader = "", bool legRIGHT = true, bool legTOP = true, bool logX = false, bool stat = false, int rebin = -1, int orbin = -1, TString option = "", int nclus = 99) { //double ymin_ratio, double ymax_ratio, TCanvas* can = new TCanvas(name+"_ratio",name+"_ratio",900,450); can->cd(); double legxmin = (legRIGHT ? 0.55 : 0.18); double legxmax = legxmin+0.25; double legymin = (legTOP ? 0.70 : 0.15); double legymax = legymin+0.15; TLegend* leg = new TLegend(legxmin,legymin,legxmax,legymax); if (legHeader!="") leg->SetHeader(legHeader); leg->SetTextSize(0.04); leg->SetFillColor(0); leg->SetLineColor(0); TString options = (option=="" ? "pe" : option); if (rebin>0) h[h.size()-1]->Rebin(rebin); //to rebin benchmark before divide for (size_t i=0; i<h.size(); i++) { //if(h[i]->GetNbinsX() != orbin) cout << "WARNING: orbin for " << h[i]->GetName() << " are " << h[i]->GetNbinsX() << endl; //debug - shift of h[][] wrt clu[][] if (rebin>0 && i<(h.size()-1)) h[i]->Rebin(rebin); TH1F* ratio = (TH1F*)h[i]->Clone("ratio_"+name); ratio->Sumw2(); ratio->Divide(h[h.size()-1]); //benchmark is at the end. if (logX) gPad->SetLogx(); ratio->SetMarkerStyle(20+i); ratio->SetMarkerSize(1.0); //1.2 ratio->GetXaxis()->SetRangeUser(xmin,xmax); ratio->SetMinimum(-0.1); ratio->SetMaximum(4); if (i==0){ //just for the first one ratio->GetXaxis()->SetLabelSize(0.05); ratio->GetXaxis()->SetTitle(xTitle); ratio->GetXaxis()->SetTitleOffset(1); ratio->GetXaxis()->SetTitleSize(0.06); ratio->GetYaxis()->SetTitle("ratio"); ratio->GetYaxis()->SetTitleSize(0.06); ratio->GetYaxis()->SetTitleOffset(0.7); ratio->GetYaxis()->SetLabelSize(0.05); } string nam = ""; nam = translate(clu[nclus][0].c_str()); if(i==(h.size()-1)) leg->AddEntry(h[i],nam.c_str(),"l"); //to print only benchmark (first in the list) if (i==1) options = options + (stat ? "sames" : "same"); //once is enought ratio->Draw(options); } leg->Draw("same"); drawPrivate(0.04); can->Update(); can->SaveAs(Outfolder+name+"_ratio.png"); }
void Atom::drawSelected() { drawPrivate(true); }
void Atom::drawFast() { drawPrivate(false); }
void Atom::draw() { drawPrivate(false); if (s_vibrationDisplayVector) drawDisplacement(); }
void Bond::drawSelected() { bool selectedOnly(true); drawPrivate(selectedOnly); }
void Bond::draw() { bool selectedOnly(false); drawPrivate(selectedOnly); }
void Charge::drawSelected() { bool selectedOnly(true); drawPrivate(selectedOnly); }
void Charge::draw() { bool selectedOnly(false); drawPrivate(selectedOnly); }
void draw(std::vector<TH1F*> h, TString name, TString xTitle, double xmin, double xmax, double ymin, double ymax, TString legHeader = "", bool legRIGHT = true, bool legTOP = true, bool logX = false, bool logY = false, bool stat = false, double scale = -9., int rebin = -1, int orbin = -1, TString option = "", int nclus = 99) { //double ymin_ratio, double ymax_ratio, TCanvas* can = new TCanvas(name,name,900,900); can->cd(); if (logX) gPad->SetLogx(); if (logY) gPad->SetLogy(); double legymax, legymin, legxmin, legxmax; if(legHeader == "BENCHMARKS COMPARISON") { legxmin = (legRIGHT ? 0.58 : 0.18); legxmax = legxmin+0.20; legymax = (legTOP ? 0.90 : 0.15); legymin = legymax-0.35; } TLegend* leg = new TLegend(legxmin,legymin,legxmax,legymax); leg->SetTextSize(0.024); leg->SetFillColor(0); leg->SetLineColor(0); TString options = (option=="" ? "pe" : option); //normalize and set y range ymax=0.; h[0]->Sumw2(); double norm = 10000.; for (size_t i=0; i<h.size(); i++) { if(h[i]->GetNbinsX() != orbin) cout << "WARNING: orbin for " << h[i]->GetName() << " are " << h[i]->GetNbinsX() << endl; //debug - shift of h[][] wrt clu[][] if (rebin>0) h[i]->Rebin(rebin); scale = norm/(h[i]->Integral()); h[i]->Scale(scale); if (h[i]->GetMaximum() > ymax) ymax = h[i]->GetMaximum(); } ymax = ymax*1.2; for (size_t i=0; i<h.size(); i++) { h[i]->GetXaxis()->SetRangeUser(xmin,xmax); h[i]->GetXaxis()->SetTitle(xTitle); h[i]->SetMinimum(ymin); h[i]->SetMaximum(ymax); h[i]->GetYaxis()->SetLabelSize(0.03); h[i]->GetYaxis()->SetTitleOffset(1); h[i]->GetYaxis()->SetTitleSize(0.04); string nam = ""; if(legHeader == "BENCHMARKS COMPARISON"){ if(i==(h.size()-1)){ nam = translate(clu[nclus][0].c_str()); leg->AddEntry(h[i],nam.c_str(),"l"); //to print all for bench comp } else { nam = translate(clu[nclus][i+1].c_str()); leg->AddEntry(h[i],nam.c_str(),"l"); //to print all for bench comp } } else if(i==(h.size()-1)) { h[i]->SetLineColor(kRed); //to print benchmark always red. nam = translate(clu[nclus][0].c_str()); leg->AddEntry(h[i],nam.c_str(),"l"); //to print only benchmark } if (i==1) options = options + (stat ? "sames" : "same"); //once is enought h[i]->Draw(options); } leg->Draw("same"); drawPrivate(0.025); //Ncl.. can->Update(); can->SaveAs(Outfolder+name+".png"); }