void gethistos() { gROOT->LoadMacro("$VMCWORKDIR/macro/run/Tools.C"); LoadPandaStyle(); //swotch things off gStyle->SetOptTitle(1); gStyle->SetOptStat(0); gStyle->SetOptFit(0); // use bigger font for many plots on a page gStyle->SetTextSize(0.10); gStyle->SetLabelSize(0.07,"x"); gStyle->SetTitleSize(0.07,"x"); gStyle->SetLabelSize(0.07,"y"); gStyle->SetTitleSize(0.07,"y"); gStyle->SetLabelSize(0.07,"z"); gStyle->SetTitleSize(0.07,"z"); gStyle->SetPadBottomMargin(0.17); TFile *canvasfile = new TFile("Residuals.root","READ"); TCanvas *canne = (TCanvas*)canvasfile->Get("VtxPlots;1"); TList *canlist = canne->GetListOfPrimitives(); TList *histolisto = new TList(); if (!canlist) {cout<<"List not there..."<GetEntries();i++) { TPad *apad = (TPad*)canlist->At(i); if (!apad) continue; TList *padlist = apad->GetListOfPrimitives(); if (!padlist) continue; // for(int k=0;kGetEntries();k++) // { // TObject *anob = (TObject*)padlist->At(k); // if (!anob) continue; // //cout<GetName()<At(1); histolisto->Add(his); } canvasfile->Close(); TFile *histosfile = new TFile("Histos.root","RECREATE"); for(int j=0;jGetEntries();j++) { TH1D *his=(TH1D*)histolisto->At(j); his->Write(); } histosfile->Close(); plotandfithistosfromfile("Histos.root",".pdf",3,3,900); //plothistosfromfile("Histos.root",".pdf",3,5,250); } plotandfithistosfromfile(TString filename = "histos.root", TString ext=".pdf", Int_t divx=3, Int_t divy=3, Int_t pix = 1200) { // Plot all histograms into a ps file // works with TH1, TH2, & TProfile TFile* file = new TFile(filename.Data()); if (!file) {cout<<"File \""<SetCanvasSize(pixx,pixy); can->Divide(divx, divy); TString picname = filename; ext="-gfitsA4."+ext; ext.ReplaceAll("..","."); picname.ReplaceAll(".root",ext); // ps, png, pdf ... TString pic = picname + "["; // open empty ps cout << "opening: " << pic.Data()<Print(pic); pic=picname; TList* list = file->GetListOfKeys(); if (!list) {cout<<"List not there..."<GetEntries();i++) { if(padcount > divx*divy) { can->Print(pic.Data()); can->Clear(); can->SetCanvasSize(pixx,pixy); can->Divide(divx, divy); padcount=1; } can->cd(padcount); TKey* key = (TKey*)list->At(i); keyclass = key->GetClassName(); //cout<ReadObj(); TString titleO = his->GetTitle(); //TString titel ="#bar{D} ^{0}#rightarrow K^{0}#pi^{+}#pi^{-} Vertex Resolution - "; TString titel ="Vertex Resolution - "; if(titleO.Contains("Poca")) titel+="POCA"; else if(titleO.Contains("PRG")) titel+="PRG"; else if(titleO.Contains("Kin")) titel+="KINVTX"; his->SetTitle(titel.Data()); his->GetXaxis()->SetNoExponent(); // put exponents to numbers directly his->GetYaxis()->SetNoExponent(); // put exponents to numbers directly GaussFitPlot(his); } else continue; padcount++; } can->Print(pic.Data()); pic = picname + "]"; // close ps can->Print(pic.Data()); cout << "closed: " << pic.Data()<SetParameters(par); cout<<" --- Fitting Gaussian to histogram "<GetName()<<" \""<GetTitle()<<"\" ---"<SetLineColor(4); fitted->SetLineWidth(3); fitted->SetLineStyle(2); his->Fit(fitted,"","",-range,range); fitted->GetParameters(par); his->DrawCopy(""); Double_t mean = par[1]; Double_t sigma = par[2]; TString str="Gaussian Fit:"; DrawText( 0.18, 0.75, str.Data(),0.07,1); str=Form("#mu = %.3g #mum",mean); DrawText( 0.18, 0.65, str.Data(),0.07,1); str=Form("#sigma = %.3g #mum",sigma); DrawText( 0.18, 0.55, str.Data(),0.07,1); ccc++; return; }