def plotHitTruthPositions(topPlotPath,topPlotTitle,bottomPlotPath,bottomPlotTitle) : #Create a fresh canvas c = TCanvas("c","",1200,800) c.Divide(1,2) #First hit plot h_primaryPositronHits = rh.getFromFile(rootFile,topPlotPath) c.cd(1) h_primaryPositronHits.SetTitle(topPlotTitle) #h_primaryPositronHits.GetYaxis().SetTitleOffset(1.5) h_primaryPositronHits.SetStats(False) h_primaryPositronHits.GetYaxis().SetRangeUser(-200.,400.) h_primaryPositronHits.Draw("COLZ") #Second hit plot h_secondaryHits = rh.getFromFile(rootFile,bottomPlotPath) c.cd(2) h_secondaryHits.SetTitle(bottomPlotTitle) #h_secondaryHits.GetYaxis().SetTitleOffset(1.5) h_secondaryHits.SetStats(False) h_secondaryHits.GetYaxis().SetRangeUser(-200.,400.) h_secondaryHits.Draw("COLZ") raw_input("Press Enter to continue...")
def plotHitTrajectories(particle,station) : gr = rh.getFromFile(rootFile,'straw_calo_truth/%s/station_%i/g_hitPosTop' % (particle,station) ) gr.Draw("AP") gr.GetYaxis().SetTitleOffset(1.5) raw_input("Press Enter to continue...")
def plotBirthAndHitPositionsFromChosenVolume(particle,station,volume,xRange,yRange) : mg = TMultiGraph() #Get birth points and add to multi-graph g_birthPos = rh.getFromFile(rootFile,'straw_calo_truth/%s/tracker/station_%i/g_birthPosTop_%s' % (particle,station,volume) ) g_birthPos.SetMarkerColor(kGreen) mg.Add(g_birthPos) #Get hit points and add to multi-graph g_hitPos = rh.getFromFile(rootFile,'straw_calo_truth/%s/tracker/station_%i/g_hitPosTop_%s' % (particle,station,volume) ) g_hitPos.SetMarkerColor(kRed) mg.Add(g_hitPos) #Draw multi-graph mg.Draw("AP") mg.SetTitle( g_birthPos.GetTitle() ) mg.GetXaxis().SetTitle("Downstream pos (calo at left) [mm]") mg.GetYaxis().SetTitle("Radially inwards pos (ring towards bottom) [mm]") mg.GetXaxis().SetRangeUser(xRange[0],xRange[1]) mg.GetYaxis().SetRangeUser(yRange[0],yRange[1]) mg.GetYaxis().SetTitleOffset(1.5) raw_input("Press Enter to continue...")
def combineAndPlotTrajectories(xaxis,yaxis) : mg = TMultiGraph() numTrajsPlotted = 0 for i_event in range(0,args.numEventsTotal) : #Add trajectory plot to multi graph axesLabel = xaxis.capitalize() + yaxis.capitalize() #e.g. "x" and "y" -> "XY" gr = rh.getFromFile(rootFile,'trajectories/primary_e+/trajectories/g_traj%s_evt%05i' % (axesLabel,i_event+1), False ) if not gr : continue #Skip if this event didn't return a trajectory (e.g. due to filters) gr.SetMarkerStyle(7) mg.Add(gr) #Plot birth point birthPoint = TGraph(1) x = Double(0) y = Double(0) gr.GetPoint(0,x,y) birthPoint.SetPoint(0,x,y) birthPoint.SetMarkerStyle(4) birthPoint.SetMarkerColor(kGreen) mg.Add(birthPoint) #Plot death point birthPoint = TGraph(1) x = Double(0) y = Double(0) gr.GetPoint(gr.GetN()-1,x,y) birthPoint.SetPoint(0,x,y) birthPoint.SetMarkerStyle(4) birthPoint.SetMarkerColor(kRed) mg.Add(birthPoint) #Break loop if have plotted enough numTrajsPlotted += 1 if numTrajsPlotted >= args.numEventsToPlot: break print "Number of events plotted = %i" % (numTrajsPlotted) #Draw multi graph mg.Draw("APL") mg.SetTitle( "Decay positron trajectories;%s global [mm];%s global [mm]" % (xaxis,yaxis) ) mg.GetXaxis().SetRangeUser(-1.5e4,1.5e4) mg.GetYaxis().SetRangeUser(-1.5e4,1.5e4) mg.GetYaxis().SetTitleOffset(1.5) raw_input("Press Enter to continue...")
def makePlots(inputFiles,message) : #Open all files (keep them in dict so have them in memory simultaneously) rootFiles = OrderedDict() for key, rootFileName in inputFiles.iteritems() : print key,':',rootFileName rootFiles[key] = rh.openFile(rootFileName) mg_numDigits = TMultiGraph() #Loop over files to get each graph to add to mutligraph counter = 0 for key, rootFile in rootFiles.items() : counter += 1 #Get graph g_numDigits = rh.getFromFile(rootFile,"straw_unpackers_summary/g_numDigits") #Set colors g_numDigits.SetMarkerColor(counter) g_numDigits.SetLineColor(counter) #Add to multigraph to canvas mg_numDigits.Add(g_numDigits) # # Draw the final multigraph # mg_numDigits.Draw("APL") #Draw once to populate axes mg_numDigits.GetXaxis().SetTitle( "Event number" ) mg_numDigits.GetYaxis().SetTitle( "Num hits" ) mg_numDigits.GetYaxis().SetTitleOffset(1.2) #mg_numDigits.GetXaxis().SetRangeUser(700.,900.) mg_numDigits.SetTitle(message) mg_numDigits.Draw("APL") raw_input("Press Enter to continue...")
lbDir = 'EventSelection/Islands/LB0/' asdq = 'TDC2ASDQ0' #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #gStyle.SetOptStat(False) #Loop over files counter = 0 for key, rootFile in rootFiles.items() : #Get histogram hit time diffs in adjacent channels in same layer hist = rh.getFromFile(rootFile,lbDir+'h_digitTimeGapsInIslandAdjacentChannelsSameLayer'+asdq) counter += 1 #Format histo hist.SetTitle(key+' : Same layer ;Hit time difference [ns];') hist.GetXaxis().SetRangeUser(-50.,100.) #Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...") # # Cross-talk in different layer
# # Drift time diff histo # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #gStyle.SetOptStat(False) #Loop over files counter = 0 for key, rootFile in rootFiles.items() : #Get histogram for hottest straw hit time difference with self hottestStrawDir = 'StrawDigits/Station_0/Module_0/View_0/Layer_1/Wire_11/' #Hottest straw hist = rh.getFromFile(rootFile,hottestStrawDir+'h_hitTimeDiff_S0_M0_V0_L1_W11') #Hottest straw again counter += 1 #Format histo hist.SetTitle(key+';Hit time difference [ns];') hist.GetXaxis().SetRangeUser(-200.,50.) #Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...")
# # Global layer number for hit histo # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #Loop over files counter = 0 for key, rootFile in rootFiles.items() : #Get histogram hist = rh.getFromFile(rootFile,'StrawDigits/h_globalLayer') counter += 1 #Normalise to max bin maxBinContent = hist.GetBinContent( hist.GetMaximumBin() ) for i_bin in range(1,hist.GetNbinsX()+1) : #Bin range starts at 1, not 0 newBinContent = hist.GetBinContent(i_bin) / maxBinContent hist.SetBinContent( i_bin, newBinContent ) #Format histo hist.SetTitle(key) hist.GetXaxis().SetTitle('Layer number of hit') hist.GetYaxis().SetTitle('[Fraction of max]') hist.GetYaxis().SetRangeUser(0.,1.1) hist.GetYaxis().SetTitleOffset(1.4) hist.SetStats(False)
profile.Fit("profileFit","R") #R enforces range of TF1 for fit profileIntercept = profileFit.GetParameter(0) profileSlope = profileFit.GetParameter(1) #Draw it profile.GetXaxis().SetRangeUser(-10.,60.) profile.Draw() raw_input("Press Enter to continue...") ''' # # Doublet drift time pairs # #Get drift time pair graph gr = rh.getFromFile(rootFile,graphName) #Draw it gr.SetTitle('Ar-Ethane 1800V 200mV') #gr.SetStats(False) gr.GetYaxis().SetTitleOffset(1.2) gr.GetXaxis().SetRangeUser(-10.,60.) gr.GetYaxis().SetRangeUser(-10.,60.) #gr.SetMarkerStyle(7) gr.GetXaxis().SetTitle("Drift time in straw (layer 0) [ns]") gr.GetYaxis().SetTitle("Drift time in straw (layer 1) [ns]") gr.Draw("AP") raw_input("Press Enter to continue...") #Fit it linFit = TF1("linFit", "[0] + [1]*x", 20., 40.)
def combineAndPlotTrajectories(station,perspective,yMin,yMax) : mg = TMultiGraph() numTrajsPlotted = 0 #Add "trackable" to path if arg set rootDirName = "straw_calo_truth/primary_e+/station_%i" % (station) if args.trackable : rootDirName += "/trackable" rootDirName += "/trajectories" for i_event in range(0,args.numEventsTotal) : if args.chosenEvent > 0 : if i_event != args.chosenEvent : continue #Add trajectory plot to multi graph name = rootDirName + "/g_trajInStation%s_evt%05i" % (perspective,i_event+1) gr = rh.getFromFile(rootFile,name,False) if not gr : continue #Skip if this event didn't return a trajectory (e.g. due to filters) gr.SetMarkerStyle(8) gr.SetMarkerSize(1) mg.Add(gr) print "Using event %i" % (i_event) #Plot birth point birthPoint = TGraph(1) x = Double(0) y = Double(0) gr.GetPoint(0,x,y) birthPoint.SetPoint(0,x,y) birthPoint.SetMarkerStyle(4) birthPoint.SetMarkerColor(kGreen) mg.Add(birthPoint) #Plot death point birthPoint = TGraph(1) x = Double(0) y = Double(0) gr.GetPoint(gr.GetN()-1,x,y) birthPoint.SetPoint(0,x,y) birthPoint.SetMarkerStyle(4) birthPoint.SetMarkerColor(kRed) mg.Add(birthPoint) #Store first graph so can copy titles etc later if numTrajsPlotted == 0 : storedGraph = gr #Break loop if have plotted enough numTrajsPlotted += 1 if numTrajsPlotted >= args.numEventsToPlot: break if numTrajsPlotted == 0 : print "No trajectories plotted for \"%s\" perspective in station %i" % (perspective,station) return print "Number of events plotted = %i" % (numTrajsPlotted) #Draw multi graph mg.Draw("APL") #mg.GetXaxis().SetRangeUser(xMin,xMax) #TODO Can't make larger that range in point x values, FIXME Can this be forced before filling? mg.GetYaxis().SetRangeUser(yMin,yMax) mg.GetXaxis().SetTitle( storedGraph.GetXaxis().GetTitle() ) #Get axis titles from one of the individual graphs mg.GetYaxis().SetTitle( storedGraph.GetYaxis().GetTitle() ) mg.GetYaxis().SetTitleOffset(1.2) mg.GetYaxis().SetTitleOffset(1.5) mg.SetTitle( "Decay positron trajectories in station %i (using straw hit positions) : %s" % (station,perspective) ) mg.Draw("APL") raw_input("Press Enter to continue...")
# # Track time difference between doublets # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #Loop over files counter = 0 for key, rootFile in rootFiles.iteritems() : #Get histogram hist = rh.getFromFile(rootFile,'Doublets/h_doubletTrackTimeDiff') counter += 1 #Format histo hist.SetTitle(key+' : t0 (track time) difference between two doublets in reco hit ; t0 diff [ns]') #Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...") # # Num reco his in island #
def plotRatioOfTwoHistos(numeratorHistoName,denominatorHistoName,title,xtitle,addScaledPlot) : # Get the two histograms hn = rh.getFromFile(rootFile,numeratorHistoName) hd = rh.getFromFile(rootFile,denominatorHistoName) # Find which has the largest value numeratorHistoHasLargestValue = True if hn.GetMaximum() > hd.GetMaximum() else False # Normalise #hn.Scale( 1. / hn.Integral() ) #hd.Scale( 1. / hd.Integral() ) # Define the Canvas c = TCanvas("c", "canvas", 800, 800) # Upper plot will be in topPad topPad = TPad("topPad", "topPad", 0, 0.3, 1, 1.0) topPad.SetBottomMargin(0.04) # Upper and lower plot are joined topPad.SetGridx() # Vertical grid topPad.Draw() # Draw the upper pad: topPad topPad.cd() # topPad becomes the current pad hn.SetStats(0) # No statistics on upper plot # Draw histo with largest value first (to get correct y axis range), then overlay other if numeratorHistoHasLargestValue : hn.SetTitle(title) hn.Draw() # Draw hn hd.Draw("same") # Draw hd on top of hn else : hd.SetTitle(title) hd.Draw() # Draw hd hn.Draw("same") # Draw hn on top of hd # Draw a scaled version of the smaller histo for ease of viewer if addScaledPlot : hs = hd.Clone("hs") if numeratorHistoHasLargestValue else hn.Clone("hs") maxBin = hd.GetMaximumBin() if numeratorHistoHasLargestValue else hn.GetMaximumBin() scaleFactor = hn.GetBinContent(maxBin)/hd.GetBinContent(maxBin) if numeratorHistoHasLargestValue else hd.GetBinContent(maxBin)/hn.GetBinContent(maxBin) hs.Scale(scaleFactor) hs.SetStats(0) hs.Draw("same") # Do not draw the Y axis label on the upper plot and redraw a small # axis instead, in order to avoid the first label (0) to be clipped. # lower plot will be in pad c.cd() # Go back to the main canvas before defining bottomPad bottomPad = TPad("bottomPad", "bottomPad", 0, 0.05, 1, 0.3) bottomPad.SetBottomMargin(0.25) bottomPad.SetGridx() # vertical grid bottomPad.Draw() bottomPad.cd() # bottomPad becomes the current pad # Define the ratio plot hr = hn.Clone("hr") hr.SetLineColor(kBlack) #hr.SetMinimum(0.8) # Define Y .. #hr.SetMaximum(1.35) # .. range hr.Sumw2() hr.SetStats(0) # No statistics on lower plot hr.Divide(hd) hr.Scale(100.) # Ratio -> percentage hr.SetMarkerStyle(21) hr.Draw("ep") # Draw the ratio plot # hn settings hn.SetLineColor(kBlue+1) hn.SetLineWidth(2) # X axis hn plot settings hn.GetXaxis().SetTitleSize(0) hn.GetXaxis().SetLabelSize(0) # Y axis hn plot settings hn.GetYaxis().SetTitleSize(20) hn.GetYaxis().SetTitleFont(43) hn.GetYaxis().SetTitleOffset(1.55) # hd settings hd.SetLineColor(kRed) hd.SetLineWidth(2) # hs settings if addScaledPlot : if numeratorHistoHasLargestValue : hs.SetLineColor(kRed) else : hs.SetLineColor(kBlue+1) hs.SetLineWidth(2) hs.SetLineStyle(7) # Ratio plot (hr) settings hr.SetTitle("") # Remove the ratio title hr.GetXaxis().SetTitle(xtitle) # Y axis ratio plot settings hr.GetYaxis().SetTitle("ratio (%)") hr.GetYaxis().SetNdivisions(505) hr.GetYaxis().SetTitleSize(20) hr.GetYaxis().SetTitleFont(43) hr.GetYaxis().SetTitleOffset(1.55) hr.GetYaxis().SetLabelFont(43) # Absolute font size in pixel (precision 3) hr.GetYaxis().SetLabelSize(15) # X axis ratio plot settings hr.GetXaxis().SetTitleSize(20) hr.GetXaxis().SetTitleFont(43) hr.GetXaxis().SetTitleOffset(4.) hr.GetXaxis().SetLabelFont(43) # Absolute font size in pixel (precision 3) hr.GetXaxis().SetLabelSize(15) # Set ratio plot x axis range minNonZeroBinContent = 1.e99 for i_bin in range(1,hr.GetXaxis().GetNbins()+1) : binContent = hr.GetBinContent(i_bin) if binContent > 0. : minNonZeroBinContent = min(binContent,minNonZeroBinContent) hr.GetYaxis().SetRangeUser(minNonZeroBinContent*0.6,hr.GetMaximum()*1.4) # wait so user can see the plot raw_input("Press Enter to continue...")
# # Plot ratios for all desired histo combinations # gStyle.SetOptStat(0) # # Beam profile # canvas = TCanvas("canvas","",700,600) h_beamProfile = rh.getFromFile(rootFile,"detector_acceptance/beam/h_vertex_x_vs_y_norm") #h_beamProfile.Rebin2D(5,5) h_beamProfile.SetTitle("") h_beamProfile.GetXaxis().SetTitleOffset(1.1) h_beamProfile.GetYaxis().SetTitleOffset(1.2) h_beamProfile.Draw() canvas.SetTopMargin(0.05); canvas.SetLeftMargin(0.1); canvas.SetRightMargin(0.16); canvas.Draw() canvas.SaveAs(args.outputDir+"/"+"BeamProfile.eps") if args.pauseForPlots : raw_input("Press Enter to continue...") # # Numbers for acceptance
# # Num digits in island histo # # Create a fresh canvas canvas = TCanvas() canvas.Divide(2, 2) # gStyle.SetOptStat(False) # Loop over files counter = 0 for efficiency, rootFile in rootFiles.iteritems(): # Get histogram hist = rh.getFromFile(rootFile, "StrawEfficiency/h_numDigitsInIsland") counter += 1 # Format histo hist.SetTitle("Efficiency = " + str(efficiency) + ";Num digits in island;") # Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...") # # Num seeds in island histo #
# # Look at uncertainty in detector offsets # gStyle.SetOptStat(0) glibClockPeriodNs = 25. #Loop over straw views views = ["U","V"] for view in views : print view,"view:" #Get time offset plot h_detectorOffset = rh.getFromFile(rootFile,'CompareTrackToStraws/TimeSync/'+view+'/h_detectorOffset') #Have offsets around n*25ns where n=0,-1,-2,-3. Fit Guassian to each nVals = [0,-1,-2,-3] for n in nVals : expectedOffset = float(n) * glibClockPeriodNs #Perform fit window = 0.5 * glibClockPeriodNs fitName = "f_detectorOffset_%s_n%s" % ( view, str(n) ) f_detectorOffset = TF1(fitName,"gaus", expectedOffset-window, expectedOffset+window) h_detectorOffset.Fit(fitName,"R") #R enforces range of TF1 for fit mean = f_detectorOffset.GetParameter(1) sigma = f_detectorOffset.GetParameter(2) print "%s view : n = %i : Mean = %f ns : sigma = %f ns " % (view,n,mean,sigma)
#Get y residual yRes = y - ((m*x)+c) return xRes,yRes,perpRes # # Compare first and last stations # gStyle.SetOptStat(0) #Get drift time pair graph gr = rh.getFromFile(rootFile,'CompareTrackToStraws/StrawDoublets/g_trackToWireDCA_vs_driftDist') #Draw it gr.SetTitle('Ar-Ethane 1800V 300mV') gr.GetXaxis().SetTitle('Silicon track to straw wire DCA [mm]') gr.GetYaxis().SetTitle('Drift distance in straw [mm]') gr.GetXaxis().SetRangeUser(0.,3.) gr.GetYaxis().SetRangeUser(0.,3.) gr.SetMarkerStyle(7) gr.Draw("AP") raw_input("Press Enter to continue...") #Fit it fit = TF1("fit", "[0] + [1]*x", 1., 2.) fit.SetParameters(0., 1.) #Initial guesses fit.FixParameter(1,fit.GetParameter(1)) #Fix gradient
# Open input file rootFile = rh.openFile(args.inputFile) if not rootFile: sys.exit(-1) numClosestClustersUsed = 3 # # Drift times # gStyle.SetOptStat(111111) canvas = TCanvas("canvas", "", 800, 600) h_firstCrossingTime = rh.getFromFile(rootFile, "h_firstCrossingTime") h_firstCrossingTime.SetTitle(";Drift time [ns]") h_firstCrossingTime.Draw() canvas.SetTopMargin(0.05) canvas.SetLeftMargin(0.1) canvas.SetRightMargin(0.16) canvas.Draw() canvas.SaveAs(args.outputDir + "/" + "MTestDriftTimes.eps") # # Drift times versus DCA # gStyle.SetOptStat(0) canvas = TCanvas("canvas", "", 800, 600)
if not rootFile : sys.exit(-1) clusterRootDirName = "mean_electron_energy/cluster" gStyle.SetOptStat(0) mg = TMultiGraph() # # Get electron and laser E sum graphs # mg = TMultiGraph() g_electronMeanE = rh.getFromFile(rootFile,clusterRootDirName+'/g_electronMeanE') g_electronMeanE.SetMarkerStyle(8) g_electronMeanE.SetMarkerSize(1) g_electronMeanE.SetMarkerColor(kRed) g_electronMeanE.SetLineColor(kRed) mg.Add(g_electronMeanE) g_laserMeanE = rh.getFromFile(rootFile,clusterRootDirName+'/g_laserMeanE') g_laserMeanE.SetMarkerStyle(8) g_laserMeanE.SetMarkerColor(kBlue) g_laserMeanE.SetLineColor(kBlue) mg.Add(g_laserMeanE) # # Correct e- E sum based on laser
# # Drift time diff histo # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #gStyle.SetOptStat(False) #Loop over files counter = 0 for key, rootFile in rootFiles.items() : #Get histogram for hottest straw pair (U1_S11 is hottest straw, paried with either U0_S11 or 12 for doublet) hottestStrawDir = 'StrawDigits/Station_0/Module_0/View_0/Layer_1/Wire_11/' #Hottest straw hist = rh.getFromFile(rootFile,hottestStrawDir+'h_hitTimeDiff_S0_M0_V0_L0_W11') #Completes hottest doublet counter += 1 #Format histo hist.SetTitle(key+';Hit time difference [ns];') #hist.GetXaxis().SetRangeUser(-100.,100.) #Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...")
# # Num digits in island histo # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2,2) #gStyle.SetOptStat(False) #Loop over files counter = 0 for hv, rootFile in rootFiles.items() : #Get histogram hist = rh.getFromFile(rootFile,'StrawEfficiency/h_numDigitsInIsland') counter += 1 #Format histo hist.SetTitle(str(hv)+'V ; Num digits in island;') #Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...") #TODO num islands #TODO num hits
# # Num digits in island histo # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #gStyle.SetOptStat(False) #Loop over files counter = 0 for key, rootFile in rootFiles.items() : #Get histogram hist = rh.getFromFile(rootFile,'StrawEfficiency/h_numDigitsInIsland') counter += 1 #Format histo hist.SetTitle(key+';Num digits in island;') #Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...") # # Num seeds in island histo #
mg_x_area = TMultiGraph() leg_x_area = TLegend(0.4,0.6,0.7,0.8) # # Loop over fibers # for i_fiber in range(0,7) : fiberNum = i_fiber + 1 fiberRootDirName = "harp_calibration_scan/fiber%i" % (fiberNum) #Get area plots g_x_area = rh.getFromFile(rootFile,fiberRootDirName+'/g_x_area') g_x_area.SetMarkerStyle(8) g_x_area.SetMarkerSize(1) g_x_area.SetMarkerColor(i_fiber+1) g_x_area.SetLineColor(i_fiber+1) mg_x_area.Add(g_x_area) leg_x_area.AddEntry(g_x_area, "Fiber %i" % fiberNum, "l" ) #Get amplitude plots g_x_amplitude = rh.getFromFile(rootFile,fiberRootDirName+'/g_x_amplitude') g_x_amplitude.SetMarkerStyle(8) g_x_amplitude.SetMarkerSize(1) g_x_amplitude.SetMarkerColor(i_fiber+1) g_x_amplitude.SetLineColor(i_fiber+1) mg_x_amplitude.Add(g_x_amplitude) leg_x_amplitude.AddEntry(g_x_amplitude, "Fiber %i" % fiberNum, "l" )
# # Loop over input files # i_file = 0 for inputFile in inputFiles : #Open input file print "\n+++ Opening %s\n" % (inputFile) rootFile = rh.openFile(inputFile) if not rootFile : sys.exit(-1) #Get run info tree t_runInfo = rh.getFromFile(rootFile,"Garfield/RunInfo") t_runInfo.GetEntry(0) #Only one entry # # Event loop # #Get event tree t_event = rh.getFromFile(rootFile,"Garfield/Events") #Get mean gain for this run tmpHistName = "h_tmp_%i" % (i_file) t_event.Draw("electronGain>>%s" % (tmpHistName) ) gain = gDirectory.Get(tmpHistName).GetMean() #Plot gain vs HV
rootFile = rh.openFile(args.inputFile) if not rootFile : sys.exit(-1) gStyle.SetOptStat(0) # # Compare laser cluster E # clusterRootDirName = "gain_correction/clusters" mg_laserClusters = TMultiGraph() g_meanLaserEnergy = rh.getFromFile(rootFile,clusterRootDirName+'/g_meanLaserEnergy') g_meanLaserEnergy.SetMarkerStyle(1) g_meanLaserEnergy.SetMarkerSize(1) g_meanLaserEnergy.SetMarkerColor(kRed) g_meanLaserEnergy.SetLineColor(kRed) mg_laserClusters.Add(g_meanLaserEnergy) g_meanCorrectedLaserEnergy = rh.getFromFile(rootFile,clusterRootDirName+'/g_meanCorrectedLaserEnergy') g_meanCorrectedLaserEnergy.SetMarkerStyle(1) g_meanCorrectedLaserEnergy.SetMarkerSize(1) g_meanCorrectedLaserEnergy.SetMarkerColor(kBlue) g_meanCorrectedLaserEnergy.SetLineColor(kBlue) mg_laserClusters.Add(g_meanCorrectedLaserEnergy) mg_laserClusters.Draw("APL") #Draw once to populate axes mg_laserClusters.GetXaxis().SetTitle( "Fill time [s]" )
rootFiles[key] = rh.openFile(rootFileName) # # Num digits in island histo # #Create a fresh canvas canvas = TCanvas() canvas.Divide(2) #gStyle.SetOptStat(False) #Loop over files counter = 0 for key, rootFile in rootFiles.items() : #Get hit map h_hitPos = rh.getFromFile(rootFile,'RecoHits/h_recoHitPosTransverse') counter += 1 #Draw to canvas canvas.cd(counter) h_hitPos.SetTitle(key+' : Hit map ; Radial position [mm] ; Vertical position [ mm ]') h_hitPos.GetXaxis().SetRangeUser(-60.,40.) h_hitPos.GetYaxis().SetRangeUser(-50.,50.) #h_hitPos.SetStats(False) h_hitPos.Draw("CONT0") raw_input("Press Enter to continue...")
import RootHelper as rh import math # Inputs rootFileName = "/unix/muons/g-2/scratch/tom/sim/gm2Dev_v6_01_00_testbeam_coordSystems/data/testbeam/run00344/mtestRecoAnalysis_reconstructedSiTrackPlots.root" # Open input file rootFile = rh.openFile(rootFileName) # # Compare first and last stations # # Get drift time pair graph gr = rh.getFromFile(rootFile, "Station_0/g_YvsY_Station_3") # Fit it fit = TF1("fit", "[0] + [1]*x", -10.0e3, 10.0e3) fit.SetParameters(0.0, 1.0) # fit.FixParameter(1,fit.GetParameter(1)) #Fix gradient gr.Fit("fit", "R") # R enforces range of TF1 for fit fitIntercept = fit.GetParameter(0) fitSlope = fit.GetParameter(1) # Draw it # gr.GetXaxis().SetRangeUser(-10.,60.) gr.Draw("AP") raw_input("Press Enter to continue...")
#rootFileName = '/unix/muons/g-2/scratch/tom/sim/gm2Dev_v6_01_00_testbeam_coordSystems/data/sim/MO_80_15_5-Res_140um/mtestRecoAnalysis_compareSiliconTrackToStraws.root' rootFileName = '/unix/muons/g-2/scratch/tom/sim/gm2Dev_v6_01_00_testbeam_coordSystems/data/testbeam/run00402/mtestRecoAnalysis_compareSiliconTrackToStraws.root' #rootFileName = '/unix/muons/g-2/scratch/tom/sim/gm2Dev_v6_01_00_testbeam_coordSystems/data/testbeam/run00404/mtestRecoAnalysis_compareSiliconTrackToStraws.root' #Open input file rootFile = rh.openFile(rootFileName) gStyle.SetOptStat(0) # # Fit y residuals # #Get histo h_yResiduals = rh.getFromFile(rootFile,'CompareTrackToStraws/StrawRecoHits/h_recoHitToTrackYResidual') #Fit core f_yResiduals = TF1("f_yResiduals", "gaus", -500., 500.); h_yResiduals.Fit("f_yResiduals","R") #Draw it h_yResiduals.SetTitle('Ar-Ethane 1800V 300mV') h_yResiduals.GetXaxis().SetTitle('Straw reconstructed hit radial residual to silicon track [um]') h_yResiduals.GetYaxis().SetTitle('Counts') h_yResiduals.GetXaxis().SetRangeUser(-750.,750.) #[um] h_yResiduals.Draw() #Draw expected distribution f_yResidualsExpected = TF1("f_yResidualsExpected", "gaus", -500., 500.); f_yResidualsExpected.SetParameters(10.,0.,100.) #Norm,mean,sigma #100um sigma for 200um DCA resolution
# # Cross-talk in same layer # strawDir = "EventSelection/Islands/Station_0/" # Create a fresh canvas canvas = TCanvas() canvas.Divide(3) # Loop over files counter = 0 for key, rootFile in rootFiles.items(): # Get histogram hist = rh.getFromFile(rootFile, strawDir + "h_digitTimeGapsInIslandNearestNeighbourStrawSameLayer") counter += 1 # Format histo hist.SetTitle(key + " : Same layer ; Hit time difference [ns];") hist.GetXaxis().SetRangeUser(-50.0, 100.0) hist.GetYaxis().SetRangeUser(-0.0, 200.0) # Draw to canvas canvas.cd(counter) hist.Draw() raw_input("Press Enter to continue...") #