File indexing completed on 2024-04-06 12:18:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 from __future__ import print_function
0010 DQMfileOld="/afs/cern.ch/user/s/sdonato/AFSwork/public/DQM_V0001_R000000001__CMSSW_X_Y_Z__RelVal__TrigVal.root"
0011 DQMfileNew="/afs/cern.ch/user/s/sdonato/AFSwork/public/DQM_V0001_R000000002__CMSSW_X_Y_Z__RelVal__TrigVal.root"
0012 labelNew = "New"
0013 labelOld = "Old"
0014
0015
0016
0017 import os, string, re, sys, math
0018
0019 try:
0020 import ROOT
0021 except:
0022 print("\nCannot load PYROOT, make sure you have setup ROOT in the path")
0023 print("and pyroot library is also defined in the variable PYTHONPATH, try:\n")
0024 if (os.getenv("PYTHONPATH")):
0025 print(" setenv PYTHONPATH ${PYTHONPATH}:$ROOTSYS/lib\n")
0026 else:
0027 print(" setenv PYTHONPATH $ROOTSYS/lib\n")
0028 sys.exit()
0029
0030 folder="plots"
0031 try:
0032 os.mkdir(folder)
0033 except:
0034 print("folder " + folder + " already exist")
0035
0036 from ROOT import TFile
0037 from ROOT import TCanvas
0038 from ROOT import TLegend
0039 from ROOT import TH1F
0040 from ROOT import TGraphErrors
0041
0042
0043
0044 def GetPlots(_file0):
0045
0046 dir1 = _file0.Get("DQMData")
0047 dir2 = dir1.Get("Run 1")
0048 dir3 = dir2.Get("HLT")
0049 dir4 = dir3.Get("Run summary")
0050 plots=[]
0051 for type in dir4.GetListOfKeys():
0052 dirType= dir4.Get(type.GetName())
0053 for triggerKey in dirType.GetListOfKeys():
0054 triggerDir=dirType.Get(triggerKey.GetName())
0055 for plotKey in triggerDir.GetListOfKeys():
0056 plotPointer=triggerDir.Get(plotKey.GetName())
0057 plot=plotPointer
0058 if(plot.GetName()=="efficiency"):
0059 for plotEfficiencyKey in plotPointer.GetListOfKeys():
0060 plot=plotPointer.Get(plotEfficiencyKey.GetName())
0061 plots=plots+[plot.Clone(triggerKey.GetName() + "_" + plot.GetName())]
0062 else:
0063 plots=plots+[plot.Clone(triggerKey.GetName() + "_" + plot.GetName())]
0064
0065 return plots
0066
0067
0068 fileNew=TFile(DQMfileOld)
0069
0070 plotsNew=0
0071 plotsOld=0
0072
0073 try:
0074 plotsNew = GetPlots(fileNew)
0075 except:
0076 print("Problem with ", fileNew)
0077
0078 fileOld=TFile(DQMfileNew)
0079
0080 try:
0081 plotsOld = GetPlots(fileOld)
0082 except:
0083 print("Problem with ", fileOld)
0084
0085
0086
0087 ROOT.gROOT.SetBatch()
0088 ROOT.gStyle.SetOptStat(0)
0089 c1 = TCanvas("c1","",1280,720)
0090 c1.SetGridx()
0091 c1.SetGridy()
0092 legend = TLegend(0.07,0.85,0.2,0.93);
0093
0094 first=True
0095 for plotNew in plotsNew:
0096 for plotOld in plotsOld:
0097 if(plotNew.GetName()==plotOld.GetName()):
0098 plotOld.SetLineColor(4)
0099 plotOld.SetMarkerColor(4)
0100
0101 plotNew.SetLineColor(2)
0102 plotNew.SetMarkerColor(2)
0103
0104
0105
0106 plotNew.SetLineWidth(2)
0107 plotOld.SetLineWidth(2)
0108 if first:
0109 legend.AddEntry(plotNew,labelNew,"l");
0110 legend.AddEntry(plotOld,labelOld,"l");
0111
0112 if plotNew.GetName().rfind("mistagrate)")>0:
0113 plotOld.SetMinimum(0.001)
0114 plotNew.SetMinimum(0.001)
0115 c1.SetLogy(1)
0116 else:
0117 c1.SetLogy(0)
0118
0119 plotOld.SetMaximum(1.05*max(plotOld.GetMaximum(),plotNew.GetMaximum(),1))
0120 plotOld.Draw()
0121 plotNew.Draw("same")
0122 legend.Draw()
0123 c1.SaveAs(folder+"/"+plotNew.GetName()+".png")
0124 first=False
0125