4 MergeFilesAndCalculateEfficiencies.py
6 Merges multiple root files containing the numerator and denominator histograms produced by the
7 TauTagValidation package. The efficiency (num/denominator) is then computed
8 as defined Validation/RecoTau/python/RecoTauValidation_cff.py and stored in OutputFile_Eff.root
10 Usage: cmsRun MergeFilesAndCalculateEfficiencies.py OutputFile InputFiles
12 Example: ./MergeFilesAndCalculateEfficiencies.py CMSSW_3_1_0_Signal.root CMSSW_3_1_0_ZTT_*.root
21 print "Error. Expected at least 2 arguments\n\nUsage: MergeFilesAndCalculateEfficiencies.py OutputFile InputFileGlob"
24 OutputFile = sys.argv[2]
28 if not os.path.exists(aFile):
29 print "Input file %s does not exist!" % aFile
32 if os.path.exists(OutputFile):
35 while not GotGoodValue:
36 userInput = raw_input(
"Output file %s exists; replace it? [yn] " % OutputFile).
strip()
37 if userInput !=
'y' and userInput !=
'n':
38 print "Please enter y or n"
45 commandString =
"hadd -f %s " % OutputFile
47 commandString += aFile
50 os.system(commandString)
52 print "Running cmsRun command to generate efficiencies"
54 process = cms.Process(
"TEST")
56 process.source = cms.Source(
"EmptySource")
58 process.maxEvents = cms.untracked.PSet(
59 input = cms.untracked.int32(1)
62 process.DQMStore = cms.Service(
"DQMStore")
63 process.load(
"Validation.RecoTau.RecoTauValidation_cfi")
65 process.loadFile = cms.EDAnalyzer(
"DQMFileLoader",
67 inputFileNames = cms.vstring(OutputFile),
68 scaleFactor = cms.double(1.),
72 process.saveTauEff = cms.EDAnalyzer(
"DQMSimpleFileSaver",
74 outputFileName = cms.string(OutputFile)
79 process.TauEfficiencies*