コード例 #1
0
#!/usr/bin/python
import code
import ROOT as rt
from ROOT import TFile, TTree , TCanvas, TH1F, TList , TH2F ,TMath ,TF1, TStyle ,gStyle , TRefArray, TClonesArray, TObjArray, gPad , TLegend ,TString
file = TFile.Open("Incohernt_Phi_PID.root")
#list = file.Get("")
PhiMass = TCanvas("PhiMass","Phi_Mass",600,300,700,527)
Sigma_Radius = TCanvas("Sigma_Radius","Sigma_Radius",600,300)
SigmavsSigma = TCanvas("SigmavsSigma","SigmaVsSigama",600,300)
dEdX = TCanvas("dEdX","dEdX",600,300)
test = TCanvas("test","dEdX",600,300)
list = TList()
list = file.Get("UPCPhiTaskTest/UPCPhiWithTrigger")
tree = list.FindObject("scatterplot")
#MassPlot for Incoherent Candidates
HighPt_Mass = TH1F("HighPt_Mass","Mass Dist of Inco #Phi with TOF",100, 0 ,10)

HighPt_Mass.SetFillStyle(4050)
HighPt_Mass.SetYTitle("Number of Events")
HighPt_Mass.SetXTitle("Phi Mass(MeV/C^2)")
HighPt_Mass.SetTitleOffset(1.5, "Y")
HighPt_Mass.SetTitleOffset(1.3, "X")
HighPt_Mass.SetLineColor(rt.kGreen)
HighPt_Mass.SetMarkerStyle(rt.kCircle)
HighPt_Mass.SetLineWidth(2)
HighPt_Mass.SetOption("E1")
Pt_mass = HighPt_Mass.Clone()
Pt_mass.SetLineColor(rt.kRed)
Pt_mass.SetLineWidth(4)
#Mass Plot for Coherent Candidates
LowPt_Mass =  TH1F("LowPt_Mass","Mass Dist of Incoherent #Phi without TOF info",100, 0 ,2)
コード例 #2
0
from ROOT import TFile, TTree, TCanvas, TH1F, TList, TH2F, TH3F, TMath, TF1, TStyle, gStyle, TRefArray, TClonesArray, TObjArray, gPad, TPaveText, TLegend, TString, TObject, gROOT, TFormula, TEllipse, TDirectory, TLorentzVector
from ROOT import TMath as mt
from datetime import date
# this code creates the histograms from the analysis results and also applies some additional cuts
# however I am still new to the pyroot so I might be defining histogram more than I needed
# my goal was to create just one set of histogram and clear it after every time I store them in root file for different level of cuts
# Different directory are created to store all the histogram at different level of cuts

#Opening the file>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
filename = "PolarizationSample"
infilename = filename + ".root"
file = TFile.Open(infilename)
#file = TFile.Open("AnalysisResults.root")
list = TList()
list = file.Get("Polar")
tree = list.FindObject("result")
daughter = TLorentzVector()
#daughter =
#tree2 = file.Get("tree2")

#tree2.AddFriend(tree)
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
text = TPaveText(.05, .1, .95, .8)
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#this is to use to run in batch mode  to avoid printing all the plots
gROOT.SetBatch(rt.kTRUE)
#this create the master canvas color and the entries to print
#gStyle.SetCanvasColor(22)
gStyle.SetOptStat("e")