CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SummaryPlots_cfg.py
Go to the documentation of this file.
2 import os
3 import glob
4 
5 try:
6  ReleaseBase = os.path.join(os.environ['CMSSW_BASE'], "src")
7  ReleaseVersion = os.environ['CMSSW_VERSION']
8 except KeyError:
9  print "CMSSW enviroment not set, please run cmsenv!"
10  sys.exit()
11 
12 import FWCore.ParameterSet.Config as cms
13 import FWCore.ParameterSet.VarParsing as VarParsing
14 
15 #options = VarParsing.VarParsing ('standard')
17 
18 options.register( 'usesLegacyProdNames',
19  0,
20  VarParsing.VarParsing.multiplicity.singleton,
21  VarParsing.VarParsing.varType.int,
22  "Set to 1 if the reference files contains old (eg pfRecoTauProducer) PFTau product names"
23  )
24 
25 options.register( 'scale',
26  'linear',
27  VarParsing.VarParsing.multiplicity.singleton,
28  VarParsing.VarParsing.varType.string,
29  "Set scale of yaxis on plots (linear/log)"
30  )
31 
32 options.parseArguments()
33 
34 process = cms.Process('MakingPlots')
35 process.DQMStore = cms.Service("DQMStore")
36 
37 process.maxEvents = cms.untracked.PSet(
38  input = cms.untracked.int32(0)
39 )
40 
41 process.source = cms.Source("EmptySource")
42 
43 # Get test file name
44 rootFilesInCurrentDirectory = glob.glob("*.root")
45 if len(rootFilesInCurrentDirectory) != 1:
46  print "There must be one (and only one) root files in the current directory, otherwise I don't know what to compare!"
47  sys.exit()
48 testRootFile = rootFilesInCurrentDirectory[0]
49 print "Loading test file: ", testRootFile
50 
51 EventType = "unknown"
52 # Get event type
53 if testRootFile.find("ZTT"):
54  EventType = 'ZTT'
55 elif testRootFile.find('QCD'):
56  EventType = 'QCD'
57 elif testRootFile.find('ZEE'):
58  EventType = 'ZEE'
59 elif testRootFile.find('ZMM'):
60  EventType = 'ZMM'
61 
62 # Output dir to hold the comparision
63 PlotOutputDir = "SummaryPlots"
64 if not os.path.exists(PlotOutputDir):
65  os.makedirs(PlotOutputDir)
66 
67 # Load plotting sequences
68 process.load("Validation.RecoTau.RecoTauValidation_cfi")
69 #set scale
70 from Validation.RecoTau.RecoTauValidation_cfi import SetLogScale
71 from Validation.RecoTau.RecoTauValidation_cfi import SetSmartLogScale
72 if options.scale == 'log':
73  print "Setting everything to log scale"
74  SetLogScale(process.plotTauValidation)
75 
76 # Get helper functions
77 from Validation.RecoTau.RecoTauValidation_cfi import SetTestFileToPlot
78 from Validation.RecoTau.RecoTauValidation_cfi import SetReferenceFileToPlot
79 from Validation.RecoTau.RecoTauValidation_cfi import SetPlotDirectory
80 from Validation.RecoTau.RecoTauValidation_cfi import SetPlotOnlyStepByStep
81 
82 #Set the test/reference files
83 SetTestFileToPlot(process, testRootFile)
84 SetReferenceFileToPlot(process, None)
85 
86 # Set the right plot directory
87 SetPlotDirectory(process.plotTauValidation, PlotOutputDir)
88 
89 # Only plot the summaries (we aren't comparing to anything)
90 SetPlotOnlyStepByStep(process.plotTauValidation)
91 
92 #############################
93 # Path to be executed
94 ###############################
95 
96 process.p = cms.Path( process.loadTau
97  +process.plotTauValidation
98  )
99 
100 cfgLog = open(os.path.join(PlotOutputDir, "plot_config.py"), "write")
101 
102 print >>cfgLog, process.dumpPython()
103 
104