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 18 import FWCore.ParameterSet.Config
as cms
19 from Validation.RecoTau.ValidationOptions_cff
import allowedOptions
22 print "Error. Expected at least 3 arguments\n\nUsage: MergeFilesAndCalculateEfficiencies.py dataType OutputFile InputFileGlob" 25 dataType = sys.argv[2]
26 OutputFile = sys.argv[3]
29 if not dataType
in allowedOptions[
'eventType']:
30 print "Error. The first argument must be the dataType. Types availables are:" 31 print allowedOptions[
'eventType']
35 if not os.path.exists(aFile):
36 print "Input file %s does not exist!" % aFile
39 if os.path.exists(OutputFile):
42 while not GotGoodValue:
43 userInput = raw_input(
"Output file %s exists; replace it? [yn] " % OutputFile).
strip()
44 if userInput !=
'y' and userInput !=
'n':
45 print "Please enter y or n" 52 commandString =
"hadd -f %s " % OutputFile
54 commandString += aFile
57 os.system(commandString)
59 print "Running cmsRun command to generate efficiencies" 61 process = cms.Process(
"TEST")
63 process.source = cms.Source(
"EmptySource")
65 process.maxEvents = cms.untracked.PSet(
66 input = cms.untracked.int32(1)
69 process.DQMStore = cms.Service(
"DQMStore")
70 process.load(
"Validation.RecoTau.dataTypes.ValidateTausOn%s_cff"%dataType)
72 process.loadFile = cms.EDAnalyzer(
"TauDQMFileLoader",
74 inputFileNames = cms.vstring(OutputFile),
75 scaleFactor = cms.double(1.),
79 process.saveTauEff = cms.EDAnalyzer(
"TauDQMSimpleFileSaver",
81 outputFileName = cms.string(OutputFile)
86 getattr(process,
'TauEfficiencies%s'%dataType)*