compareCafs.py
Go to the documentation of this file.
1 from ROOT import *
2 import sys, os
3 import cafe
4 import canMan
5 import novaStyle
6 from collections import OrderedDict
7 
8 
9 
10 
11 
12 vars = OrderedDict()
13 """
14 vars["nhit"] = "trk.kalman.nhit"
15 vars["nhitx"] = "trk.kalman.nhitx"
16 vars["nhity"] = "trk.kalman.nhity"
17 vars["nplane"] = "trk.kalman.nplane"
18 vars["maxplanegap"] = "trk.kalman.maxplanegap"
19 vars["maxplanecont"] = "trk.kalman.maxplanecont"
20 
21 vars["nhitc"] = "trk.cosmic.nhit"
22 vars["nhitxc"] = "trk.cosmic.nhitx"
23 vars["nhityc"] = "trk.cosmic.nhity"
24 vars["nplanec"] = "trk.cosmic.nplane"
25 vars["maxplanegapc"] = "trk.cosmic.maxplanegap"
26 vars["maxplanecontc"] = "trk.cosmic.maxplanecont"
27 
28 """
29 leaves = None
30 
31 histSets = []
32 files = []
33 canMan.newCan("bogus")
34 for filePath in [filePath for filePath in sys.argv[1:] if ".root" in filePath]:
35  histSet = OrderedDict()
36  histSets.append(histSet)
37  fileId = canMan.getFileId(filePath)
38  tFile = TFile(filePath, "READ")
39  files.append(tFile)
40  tree = tFile.Get("recTree")
41  if not leaves:
42  leaves = tree.GetListOfLeaves()
43  for leaf in leaves:
44  if "_" in leaf.GetName():
45  continue
46  if "fUnique" in leaf.GetName():
47  continue
48  if "fBits" in leaf.GetName():
49  continue
50  vars[leaf.GetName()] = "rec." + leaf.GetName()
51 
52  for varKey in vars.keys():
53 
54  histName = fileId + varKey
55 
56  tree.Draw(vars[varKey] + ">>" + histName, "", "")
57 
58  histSet[varKey] = gDirectory.Get(histName)
59 
60 differences = open("caf_differences.txt", 'w')
61 
62 texts = []
63 for varKey in vars.keys():
64  hists = [histSet[varKey] for histSet in histSets]
65  canMan.drawOverlay(hists)
66  boxHeight = 0.075 * (len(hists) + 1)
67  text = TPaveText()
68  text.SetX1NDC(0.7)
69  text.SetY1NDC(0.8 - boxHeight)
70  text.SetX2NDC(0.85)
71  text.SetY2NDC(0.8)
72  text.AddText("Means")
73  lastMeanStr = None
74  for hist in hists:
75  meanStr = str(round(hist.GetMean(), 4))
76  text.AddText(meanStr)
77  if not lastMeanStr == None:
78  if not meanStr == lastMeanStr:
79  print vars[varKey], meanStr, lastMeanStr
80  differences.write(vars[varKey]+" "+meanStr+" "+lastMeanStr+'\n')
81  lastMeanStr = meanStr
82 
83 
84  text.Draw()
85  texts.append(text)
86 novaStyle.prettyStat("emr")
87 canMan.canUp()
88 del canMan.cans[0]
def getFileId(filePath)
Definition: canMan.py:176
def canUp()
Definition: canMan.py:33
fvar< T > round(const fvar< T > &x)
Definition: round.hpp:23
procfile open("FD_BRL_v0.txt")
def newCan(title)
Definition: canMan.py:19
def drawOverlay(listOfHists, name="", opt="hist", varOpts=[""], colors=[kRed, kBlue, kGreen, kMagenta, kOrange, kBlack, kViolet, lineStyles=[1], legEntries=[], logY=False, axisMin=0, legPos="right", legTextSize=0, inputCan=None, legHeight=0.15, legWidth=0.2, supressZero=False, padFactor=1.1, lineWidths=[gStyle.GetHistLineWidth()], fillStyles=[0], preserveStyle=False, yOffset=1.05)
Definition: canMan.py:64