Exemplo n.º 1
0
def output_mapper(channel, sample, jobId, label=''):
    output_file = os.path.join(
        getHarvestingFilePath(channel),
        'local',
        "harvested_%s_%s_%s.root" % (channel, sample, jobId)
    )
    if label:
        output_file = output_file.replace('.root', "_" + label + ".root")
    # Make the direcdtory if it doesn't exist
    if not os.path.exists(os.path.dirname(output_file)):
        os.makedirs(os.path.dirname(output_file))
    return output_file
#!/usr/bin/env python

from TauAnalysis.TauIdEfficiency.recoSampleDefinitionsTauIdEfficiency_7TeV_grid_cfi import recoSampleDefinitionsTauIdEfficiency_7TeV
from TauAnalysis.Configuration.harvestAnalysisResults_grid import harvestAnalysisResults
from TauAnalysis.Configuration.userRegistry import getAnalysisFilePath, getHarvestingFilePath, getJobId, getTmpFilePath

import os
import subprocess

import TauAnalysis.Configuration.tools.castor as castor
from TauAnalysis.Configuration.tools.harvestingMakefile import buildMakefile

channel = 'ZtoMuTau_tauIdEff'
analysisFilePath = getAnalysisFilePath(channel)
harvestingFilePath = getHarvestingFilePath(channel)
jobId = getJobId(channel)
tmpFilePath = getTmpFilePath(channel)

SAMPLES_TO_ANALYZE = [
    'data_SingleMu_Run2011A_May10ReReco_v1',
    'data_SingleMu_Run2011A_PromptReco_v4',
    'Ztautau_pythia',
    'Zmumu_pythia',
    'PPmuXptGt20Mu15',
    'WplusJets_madgraph',
    'TTplusJets_madgraph'
]

def harvestTauIdEffSamples(channel = None, samples = None, inputFilePath = None,
                           outputFilePath = None, jobId = None,
                           tmpFilePath = None):
Exemplo n.º 3
0
}

meNames = {
    'visMass': 'DiTauCandidateQuantities/VisMass'
    #'SVfitMass' : 'DiTauCandidateSVfitQuantities/psKine_MEt_ptBalance/Mass'
}

#--------------------------------------------------------------------------------
# load template histogram for Z --> tau+ tau- signal and different types of background events,
# and distributions observed in (pseudo)data in events passing final analysis selection criteria
#--------------------------------------------------------------------------------

process.loadAnalysisResultsZtoMuTau = cms.EDAnalyzer(
    "DQMFileLoader",
    Ztautau=cms.PSet(inputFileNames=cms.vstring(
        reg.getHarvestingFilePath('ZtoMuTau_bgEstTemplate') + '/' +
        'bgEstTemplateHistZtoMuTau_skimmed.root'),
                     scaleFactor=cms.double(1.),
                     dqmDirectory_store=cms.string('/')))

#--------------------------------------------------------------------------------
# produce auxiliary histograms representing bias of visible muon + tau-jet mass distribution
# introduced by differences in event selection between background enriched samples
# and final Z --> muon + tau-jet analysis
#
# NOTE:
#  minuend    = contribution of (pure) signal/background process expected in final analysis
#               (estimated by Monte Carlo)
#  subtrahend = template histogram taken from background enriched sample,
#               including contributions from other signal/background processes
#               (determined by (pseudo)data)
#!/usr/bin/env python

from TauAnalysis.Configuration.recoSampleDefinitionsAHtoMuTau_7TeV_grid_cfi import recoSampleDefinitionsAHtoMuTau_7TeV
from TauAnalysis.Configuration.harvestAnalysisResults_grid import harvestAnalysisResults
import TauAnalysis.Configuration.userRegistry as reg

channel = 'AHtoMuTau'
#reg.overrideJobId(channel, 'Run33')
analysisFilePath = reg.getAnalysisFilePath(channel)
harvestingFilePath = reg.getHarvestingFilePath(channel)
jobId = reg.getJobId(channel)
tmpFilePath = reg.getTmpFilePath(channel)

harvestAnalysisResults(channel = channel, samples = recoSampleDefinitionsAHtoMuTau_7TeV,
                       inputFilePath = analysisFilePath, outputFilePath = harvestingFilePath, jobId = jobId,
                       tmpFilePath = tmpFilePath)
from TauAnalysis.Configuration.makePlots2_grid import makePlots
import TauAnalysis.Configuration.userRegistry as reg

# import utility function to enable factorization
from TauAnalysis.Configuration.tools.factorizationTools import \
        enableFactorization_makeAHtoElecTauPlots_grid2

process = cms.Process('makeAHtoElecTauPlots')

channel = 'AHtoElecTau'

categories = ['wBtag', 'woBtag', 'ZeroOneJets', 'VBF', 'Boosted']

reg.overrideJobId(channel, 'Run41')

inputFilePath = reg.getHarvestingFilePath(channel)
jobId = reg.getJobId(channel)

plotsDirectory = './plots'
outputFileNameMaker = lambda channel: 'plots%s_all.root' % channel

analyzer_draw_jobs = []

for cat in categories:
    for sign in ['OS', 'SS']:
        analyzer_draw_jobs.append([
            'ahElecTauAnalyzer' + sign + '_' + cat,
            drawJobConfiguratorDict[sign + '_' + cat],
            'plotAHtoElecTauOS_' + cat + '_#PLOT#.png'
        ])
        dqmDirectory_store=cms.string(
            '/analysis/harvested/ZtoMuTau_from_ZmumuEmbedding' + '/' +
            dqmDirectories_control['ZmumuEmbedding']
            #'/analysis/harvested/ZtoMuTau_from_ZmumuEmbedding'
        )))

#--------------------------------------------------------------------------------
# load template histogram of for different types of background events,
# obtained from background enriched control samples
#--------------------------------------------------------------------------------

process.loadTemplateHistZtoMuTau = cms.EDAnalyzer(
    "DQMFileLoader",
    Ztautau=cms.PSet(
        inputFileNames=cms.vstring(
            getHarvestingFilePath('ZtoMuTau_bgEstTemplate') +
            'plotsZtoMuTau_bgEstTemplate_all.root'
            ##'/data1/veelken/CMSSW_3_8_x/plots/ZtoMuTau_bgEstTemplate/2011Jan21_HPSloose/plotsZtoMuTau_bgEstTemplate_all.root'
        ),
        scaleFactor=cms.double(1.),
        dqmDirectory_store=cms.string('/template')))

#--------------------------------------------------------------------------------
# load distributions expected for different signal/background processes
# and observed in (pseudo)data in events passing final analysis selection criteria
#--------------------------------------------------------------------------------

process.loadAnalysisHistZtoMuTau = cms.EDAnalyzer(
    "DQMFileLoader",
    data=cms.PSet(
        inputFileNames=cms.vstring(
)                          

##process.fitZtoElecTauSysTauEnUp = copy.deepcopy(process.fitZtoElecTau)
##process.fitZtoElecTauSysTauEnUp.processes.Ztautau.templates.visMass.meName = \
##  cms.string(dqmDirectory_Ztautau_templateSysTauEnUp + '/' + meName_visMass)
##process.fitZtoElecTauSysTauEnUp.output.controlPlots.fileName = \
##  cms.string("./plots/fitBgEstTemplateZtoElecTau_#PLOT#_sysTauEnUp.pdf")

##process.fitZtoElecTauSysTauEnDown = copy.deepcopy(process.fitZtoElecTau)
##process.fitZtoElecTauSysTauEnDown.processes.Ztautau.templates.visMass.meName = \
##  cms.string(dqmDirectory_Ztautau_templateSysTauEnDown + '/' + meName_visMass)
##process.fitZtoElecTauSysTauEnDown.output.controlPlots.fileName = \
##  cms.string("./plots/fitBgEstTemplateZtoElecTau_#PLOT#_sysTauEnDown.pdf")

process.saveFitResultsZtoElecTau = cms.EDAnalyzer("DQMSimpleFileSaver",
    outputFileName = cms.string( getHarvestingFilePath('ZtoElecTau_bgEstTemplate') + '/' +'fitBgEstTemplateZtoElecTau_results.root'),
    outputCommands = cms.vstring(
           'keep *'
##         'drop /harvested/*',
##         'keep /template/*',
##         'keep /analysis/*/',
##         'keep /fitResults/*'
    )
)

process.dumpDQMStore = cms.EDAnalyzer("DQMStoreDump")

process.p = cms.Path(
    process.loadAnalysisResultsZtoElecTau
   ##+ process.dumpDQMStore 
   #+ process.prodSysBiasHistZtoElecTau
Exemplo n.º 8
0
#!/usr/bin/env python

from TauAnalysis.Configuration.makeYieldPlot import makeYieldPlot
from TauAnalysis.Configuration.userRegistry import getHarvestingFilePath

import os

inputFileName = getHarvestingFilePath('ZtoMuTau') + '/' + "plotsZtoMuTau_all.root"
inputFileName.replace('//', '/')

dqmDirectory = 'harvested/data/zMuTauAnalyzer/FilterStatistics/evtSelDiMuPairZmumuHypothesisVetoByMass/events_passed_cumulative/'

makeYieldPlot(inputFileName = inputFileName, dqmDirectory = dqmDirectory, outputFileName = "plotZtoMuTau_yield.png")
}

meNames = {
    'visMass'   : 'DiTauCandidateQuantities/VisMass'
    #'SVfitMass' : 'DiTauCandidateSVfitQuantities/psKine_MEt_ptBalance/Mass'
}

#--------------------------------------------------------------------------------
# load template histogram for Z --> tau+ tau- signal and different types of background events,
# and distributions observed in (pseudo)data in events passing final analysis selection criteria
#--------------------------------------------------------------------------------

process.loadAnalysisResultsZtoMuTau = cms.EDAnalyzer("DQMFileLoader",
    Ztautau = cms.PSet(
        inputFileNames = cms.vstring(
            reg.getHarvestingFilePath('ZtoMuTau_bgEstTemplate') + '/' + 'bgEstTemplateHistZtoMuTau_skimmed.root'
        ),
        scaleFactor = cms.double(1.),
        dqmDirectory_store = cms.string('/')
    )
)

#--------------------------------------------------------------------------------
# produce auxiliary histograms representing bias of visible muon + tau-jet mass distribution
# introduced by differences in event selection between background enriched samples
# and final Z --> muon + tau-jet analysis
#
# NOTE:
#  minuend    = contribution of (pure) signal/background process expected in final analysis
#               (estimated by Monte Carlo)
#  subtrahend = template histogram taken from background enriched sample,
reg.overrideJobId(channel, 'Run33FR')

process = cms.Process('makeBgEstFakeRatePlots')

process.DQMStore = cms.Service("DQMStore")

process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(0)
)
process.source = cms.Source("EmptySource")

# Load the regular analysis workflow file
reg.overrideJobId(channel, _REGULAR_JOBID)
makePlots.makePlots(
    process, channel, samples,
    inputFilePath = reg.getHarvestingFilePath(channel),
    jobId = reg.getJobId(channel),
    skimStatFileMapper = reg.makeSkimStatFileMapper(channel),
    skimFilterStatistic = 'evtSelDiMuPairZmumuHypothesisVetoByLooseIsolation',
    analyzer_drawJobConfigurator_indOutputFileName_sets  = [],
    drawJobTemplate = plots_AHtoMuTau,
    enableFactorizationFunction = None,
    dqmDirectoryFilterStatistics = {
        'factorizationDisabled' : 'ahMuTauAnalyzerOS_woBtag/FilterStatistics',
        'factorizationEnabled' : 'ahMuTauAnalyzerOS_woBtag_factorizedWithMuonIsolation/FilterStatistics'
    },
    dqmDirectoryFilterStatisticsForSkim = {
        'factorizationDisabled' : 'ahMuTauAnalyzerOS_woBtag/FilterStatistics',
        'factorizationEnabled' : 'ahMuTauAnalyzerOS_woBtag_factorizedWithMuonIsolation/FilterStatistics'
    },
    disableFactorizationSample = True,
        dqmDirectory_store = cms.string(
            '/analysis/harvested/ZtoMuTau_from_ZmumuEmbedding' + '/' + dqmDirectories_control['ZmumuEmbedding']
            #'/analysis/harvested/ZtoMuTau_from_ZmumuEmbedding'
        )
    )
)

#--------------------------------------------------------------------------------
# load template histogram of for different types of background events,
# obtained from background enriched control samples
#--------------------------------------------------------------------------------

process.loadTemplateHistZtoMuTau = cms.EDAnalyzer("DQMFileLoader",
    Ztautau = cms.PSet(
        inputFileNames = cms.vstring(
            getHarvestingFilePath('ZtoMuTau_bgEstTemplate') + 'plotsZtoMuTau_bgEstTemplate_all.root'
            ##'/data1/veelken/CMSSW_3_8_x/plots/ZtoMuTau_bgEstTemplate/2011Jan21_HPSloose/plotsZtoMuTau_bgEstTemplate_all.root'
        ),
        scaleFactor = cms.double(1.),
        dqmDirectory_store = cms.string('/template')
    )
)

#--------------------------------------------------------------------------------
# load distributions expected for different signal/background processes
# and observed in (pseudo)data in events passing final analysis selection criteria
#--------------------------------------------------------------------------------

process.loadAnalysisHistZtoMuTau = cms.EDAnalyzer("DQMFileLoader",
    data = cms.PSet(
        inputFileNames = cms.vstring(
                Data = plotHistZtoElecTauStacked.processes.Data.clone(
                    dqmDirectory = cms.string('/template/harvested/' + dqmDirectories_processes['Data']['template'])
                )
            ),
            drawJobs = drawJobConfiguratorZtoElecTauStacked.configure(),
            indOutputFileName = cms.string('bgEstControlZtoElecTau_%s_#PLOT#.pdf' % selectionName)
        )
        dqmHistPlotterModuleName = "plotZtoElecTauStacked%s" % selectionName
        setattr(process, dqmHistPlotterModuleName, dqmHistPlotterModule)

        process.plotAnalysisHistZtoElecTauStacked += dqmHistPlotterModule
    

process.saveBgEstTemplateHistZtoElecTau = cms.EDAnalyzer("DQMSimpleFileSaver",
    outputFileName = cms.string(
        getHarvestingFilePath('ZtoElecTau_bgEstTemplate') + '/' + 'bgEstTemplateHistZtoElecTau_skimmed.root'
        #'/data1/veelken/CMSSW_3_8_x/plots/ZtoElecTau_bgEstTemplate/2011Feb01_HPSloose/bgEstTemplateHistZtoElecTau_skimmed.root'
	#'skim.root'
    ),
    outputCommands = cms.vstring(
        'drop *',
#        'keep *',
	
##         'keep /analysis/harvested/*/zElecTauAnalyzerOS/afterEvtSelDiTauCandidateForElecTauZeroCharge/*',
         'keep *ZtautauSum/*',
         'keep *ZeeSum/*',	
##         'keep /template/harvested/Zmumu/*',
##         'keep /template/harvested/Zmumu_powheg/*',
         'keep *qcdSum/*',
##         'keep /template/harvested/WplusJets_madgraph/*',
         'keep *WplusJets_*',
Exemplo n.º 13
0
##process.fitZtoElecTauSysTauEnUp = copy.deepcopy(process.fitZtoElecTau)
##process.fitZtoElecTauSysTauEnUp.processes.Ztautau.templates.visMass.meName = \
##  cms.string(dqmDirectory_Ztautau_templateSysTauEnUp + '/' + meName_visMass)
##process.fitZtoElecTauSysTauEnUp.output.controlPlots.fileName = \
##  cms.string("./plots/fitBgEstTemplateZtoElecTau_#PLOT#_sysTauEnUp.pdf")

##process.fitZtoElecTauSysTauEnDown = copy.deepcopy(process.fitZtoElecTau)
##process.fitZtoElecTauSysTauEnDown.processes.Ztautau.templates.visMass.meName = \
##  cms.string(dqmDirectory_Ztautau_templateSysTauEnDown + '/' + meName_visMass)
##process.fitZtoElecTauSysTauEnDown.output.controlPlots.fileName = \
##  cms.string("./plots/fitBgEstTemplateZtoElecTau_#PLOT#_sysTauEnDown.pdf")

process.saveFitResultsZtoElecTau = cms.EDAnalyzer(
    "DQMSimpleFileSaver",
    outputFileName=cms.string(
        getHarvestingFilePath('ZtoElecTau_bgEstTemplate') + '/' +
        'fitBgEstTemplateZtoElecTau_results.root'),
    outputCommands=cms.vstring(
        'keep *'
        ##         'drop /harvested/*',
        ##         'keep /template/*',
        ##         'keep /analysis/*/',
        ##         'keep /fitResults/*'
    ))

process.dumpDQMStore = cms.EDAnalyzer("DQMStoreDump")

process.p = cms.Path(
    process.loadAnalysisResultsZtoElecTau
    ##+ process.dumpDQMStore
    #+ process.prodSysBiasHistZtoElecTau