import os import ROOT as r if not os.path.exists('PlotsForKaterina'): os.system('mkdir PlotsForKaterina') cSaver = {} f, t = {}, {} r.gStyle.SetOptStat('') r.gStyle.SetOptTitle(r.kFALSE) for data in ['PIMU', 'MUMUNU']: cSaver[data] = [] f[data] = r.TFile("../DATA/New%s/ShipAna_newGen.root"%data, "read") t[data] = f[data].Get('t') c1 = r.TCanvas(data+'-'+"vtxz",data+'-'+"vtxz") t[data].Draw('vtxz>>histo') r.gDirectory.Get('histo').SetMarkerColor(r.kRed) r.gDirectory.Get('histo').SetLineColor(r.kRed) t[data].Draw('NoB_vtxz', '', 'same') c1.BuildLegend(0.3, 0.67, 0.58, 0.88) cSaver[data].append(c1) c2 = r.TCanvas(data+'-'+"doca",data+'-'+"doca") t[data].Draw('DOCA>>histo2') r.gDirectory.Get('histo2').SetMarkerColor(r.kRed) r.gDirectory.Get('histo2').SetLineColor(r.kRed) t[data].Draw('NoB_DOCA','','same') c2.BuildLegend() c2.SetLogy() cSaver[data].append(c2) c3 = r.TCanvas(data+'-'+"vtxxy",data+'-'+"vtxxy") t[data].SetMarkerSize(0.3) t[data].SetMarkerColor(r.kRed) t[data].SetLineColor(r.kRed) t[data].Draw('(TMath::Sqrt(vtxySqr)) : (TMath::Sqrt(vtxxSqr)) >> histo3') t[data].SetMarkerColor(r.kBlack) t[data].SetLineColor(r.kBlack) t[data].Draw('(TMath::Sqrt(NoB_vtxySqr)) : (TMath::Sqrt(NoB_vtxxSqr))','','same') cSaver[data].append(c3) for canvas in cSaver[data]: canvas.Modified(); canvas.Update() canvas.Print('PlotsForKaterina/'+canvas.GetName()+'.pdf')