###############################################################################
process.TFileService = cms.Service(
    "TFileService", fileName=cms.string("Selection_OnData_2012.root"))
###############################################################################

###############################################################################
# Filters
###############################################################################
from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
process.PBNRFilter = jetIDFailure.clone(JetSource=cms.InputTag('patJetsPF'),
                                        MinJetPt=cms.double(30.0),
                                        taggingMode=cms.bool(False))
from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    file=cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
    taggingMode=cms.bool(False))

process.load("SandBox.Skims.filterBoolean_cfi")
process.RA2_HBHENoiseFilterRA2 = process.booleanFilter.clone()
process.RA2_HBHENoiseFilterRA2.ResultSource = cms.InputTag(
    "HBHENoiseFilterRA2", "HBHENoiseFilterResult", "PAT")
process.RA2_beamHaloFilter = process.booleanFilter.clone()
process.RA2_beamHaloFilter.ResultSource = cms.InputTag("beamHaloFilter")
process.RA2_eeNoiseFilter = process.booleanFilter.clone()
process.RA2_eeNoiseFilter.ResultSource = cms.InputTag("eeNoiseFilter")
process.RA2_trackingFailureFilter = process.booleanFilter.clone()
process.RA2_trackingFailureFilter.ResultSource = cms.InputTag(
    "trackingFailureFilter")
process.RA2_inconsistentMuons = process.booleanFilter.clone()
process.RA2_inconsistentMuons.ResultSource = cms.InputTag("inconsistentMuons")
    src = cms.VInputTag(
        cms.InputTag("rhoToPhotonMap")
    )
)
process.patPhotonsUserData = addphotonuserdata2.clone()
process.patPhotonsUserData.photonLabel = cms.InputTag("patPhotonsUser1")

process.load('ZInvisibleBkgds.Photons.ZinvMETProducers_cff')
process.load('ZInvisibleBkgds.Photons.ZinvVetos_cff')

process.load('SandBox.Skims.RA2CleaningFilterResults_cfg')
process.load('SandBox.Skims.RA2CaloVsPFMHTFilterSequence_cff')
process.RA2CaloVsPFMHTFilter.TaggingMode = cms.bool(False)
process.load('RecoMET.METFilters.ecalLaserCorrFilter_cfi')
from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.hcalLaserEventsSingleMu = multiEventFilter.clone(
    file = cms.FileInPath('RA2Classic/AdditionalInputFiles/data/HCALLaserEventList_20Nov2012-v2_SingleMu.txt'))

from SandBox.Skims.jetMHTDPhiFilter_cfi  import *
process.photonDPhiFilter   = jetMHTDPhiFilter.clone(MHTSource = cms.InputTag("mhtPFchsNoPhotFitTemplate"),
                                                    JetSource = cms.InputTag("patJetsPFNoPhotonFitTemplateSpecialPt30"))
from SandBox.Skims.htFilter_cfi  import *
process.photonIDHTFilter      = htFilter.clone(HTSource = cms.InputTag("htPFchsNoPhotID"),
                                               MinHT = cms.double(300))
process.photonIDPFIsoHTFilter     = htFilter.clone(HTSource = cms.InputTag("htPFchsNoPhotIDPFIso"))
process.photonFitTemplateHTFilter = htFilter.clone(HTSource = cms.InputTag("htPFchsNoPhotFitTemplate"))
process.photonJetFakeHTFilter     = htFilter.clone(HTSource = cms.InputTag("htPFchsNoPhotJetFake"))

from SandBox.Skims.mhtFilter_cfi import *
process.photonIDMHTFilter      = mhtFilter.clone(MHTSource = cms.InputTag("mhtPFchsNoPhotID"),
                                                 MinMHT = cms.double(100))
process.photonIDPFIsoMHTFilter     = mhtFilter.clone(MHTSource = cms.InputTag("mhtPFchsNoPhotIDPFIso"))
    'HLT_Photon90_CaloIdVL_v*', 'HLT_Photon30_v*',
    'HLT_Photon30_R9Id90_CaloId_HE10_Iso40_EBOnly_v*')
process.hltHighLevel.andOr = cms.bool(True)
process.hltHighLevel.throw = cms.bool(False)

#Filter
process.load('Calibration.CalibTreeMaker.cleaningSequences_cff')

## sequence with filters
process.filterSequence = cms.Sequence(process.hltHighLevel *
                                      process.stdCleaningSequence)

from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(file=cms.FileInPath(
    'Calibration/CalibTreeMaker/data/HCALLaserEventList_20Nov2012-v2_Jet_JetHT_JetMon.txt'
),
                                                            taggingMode=cms.
                                                            bool(False))
process.filterSequence += process.HCALLaserEvtFilterList2012

process.load("Calibration.CalibTreeMaker.CalibTreeMaker_cff")

process.calibTreeMakerAK5FastPFData.ECALDeadCellBEFilterModuleName = cms.InputTag(
    "EcalDeadCellBoundaryEnergyFilter")
process.calibTreeMakerAK5FastPFData.ECALDeadCellTPFilterModuleName = cms.InputTag(
    "EcalDeadCellTriggerPrimitiveFilter")
process.calibTreeMakerAK5FastPFData.WritePhotons = True
process.calibTreeMakerAK5FastPFData.TreeName = "GammaJetTree"
process.calibTreeMakerAK5PFCHSData.ECALDeadCellBEFilterModuleName = cms.InputTag(
    "EcalDeadCellBoundaryEnergyFilter")
process.calibTreeMakerAK5PFCHSData.ECALDeadCellTPFilterModuleName = cms.InputTag(
예제 #4
0
process.trigger.jet_pt_cut_HT = 50.
process.trigger.jetCollection = 'patJetsPF'
###############################################################################

###############################################################################
# Filters
###############################################################################
from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
process.PBNRFilter = jetIDFailure.clone(
    JetSource = cms.InputTag('patJetsPF'),
    MinJetPt      = cms.double(30.0),
    taggingMode   = cms.bool(False)
    )
from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
    taggingMode = cms.bool(False)
    )

process.load("SandBox.Skims.filterBoolean_cfi")
process.RA2_HBHENoiseFilterRA2    = process.booleanFilter.clone()
process.RA2_HBHENoiseFilterRA2.ResultSource = cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT")
process.RA2_beamHaloFilter        = process.booleanFilter.clone()
process.RA2_beamHaloFilter.ResultSource = cms.InputTag("beamHaloFilter")
process.RA2_eeNoiseFilter         = process.booleanFilter.clone()
process.RA2_eeNoiseFilter.ResultSource = cms.InputTag("eeNoiseFilter")
process.RA2_trackingFailureFilter = process.booleanFilter.clone()
process.RA2_trackingFailureFilter.ResultSource = cms.InputTag("trackingFailureFilter")
process.RA2_inconsistentMuons     = process.booleanFilter.clone()
process.RA2_inconsistentMuons.ResultSource = cms.InputTag("inconsistentMuons")
process.RA2_greedyMuons           = process.booleanFilter.clone()
process.RA2_greedyMuons.ResultSource = cms.InputTag("greedyMuons")
예제 #5
0
def makeTreeFromPAT(process,
                    outFileName,
                    NJetsMin=2,
                    HTMin=0.,
                    MHTMin=0.,
                    globalTag="none",
                    isData=True,
                    hltPath=[],
                    reportEveryEvt=10,
                    testFileName="",
                    numProcessedEvt=100):


    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder = cms.untracked.bool(True)
        )
    process.MessageLogger.cout = cms.untracked.PSet(
        INFO = cms.untracked.PSet(reportEvery = cms.untracked.int32(reportEveryEvt))
        )
    process.options = cms.untracked.PSet(
        wantSummary = cms.untracked.bool(True)
        )


    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input = cms.untracked.int32(numProcessedEvt)
        )
    process.source = cms.Source(
        "PoolSource",
        fileNames = cms.untracked.vstring(testFileName)
        )
        
        
    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service(
        "TFileService",
        fileName = cms.string(outFileName+".root")
        )
    

    ## --- Selection sequences ---------------------------------------------

    # HLT
    process.load('HLTrigger.HLTfilters.hltHighLevel_cfi')
    process.hltHighLevel.HLTPaths = cms.vstring(hltPath)
    process.hltHighLevel.andOr = cms.bool(True)
    process.hltHighLevel.throw = cms.bool(False)

    process.HLTSelection = cms.Sequence(
        process.hltHighLevel
        )
    if not isData:
        print "Running over MC: removing HLT selection"
        process.HLTSelection.remove(process.hltHighLevel)
    elif not hltPath:
        print "Empty list of HLT paths: removing HLT selection"
        process.HLTSelection.remove(process.hltHighLevel)

        
    # Filter-related selection
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(
        JetSource = cms.InputTag('patJetsPF'),
        MinJetPt      = cms.double(30.0),
        taggingMode   = cms.bool(True)
        )

    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file        = cms.FileInPath('RA2Classic/AdditionalInputFiles/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'),
        taggingMode = cms.bool(True)
        )

    process.ResidualNoiseEventFilter = multiEventFilter.clone(
        file        = cms.FileInPath('RA2Classic/AdditionalInputFiles/data/NoiseEventList.txt'),
        taggingMode = cms.bool(True)
        )

    from SandBox.Skims.hoNoiseFilter_cfi import hoNoiseFilter
    process.RA2HONoiseFilter = hoNoiseFilter.clone(
        patJetsInputTag = cms.InputTag('patJetsPF'),
        jetPtMin        = cms.double(30),
        jetEtaMax       = cms.double(5),
        maxHOEfrac      = cms.double(0.4),
        taggingMode     = cms.bool(True)
        )

    # Produce RA2 jets (produces the collections HTJets and MHTJets)
    process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
    process.ProduceRA2Jets = cms.Sequence(
        process.produceRA2JetsPFCHS
        )

    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src       = cms.InputTag('HTJets'),
        minNumber = cms.uint32(NJetsMin)
        )

    # HT selection
    htInputCol = 'htPFchs'
    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(
        HTSource = cms.InputTag(htInputCol),
        MinHT = cms.double(HTMin)
        )

    # MHT selection
    mhtInputCol = 'mhtPFchs'
    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource = cms.InputTag(mhtInputCol),
        MinMHT = cms.double(MHTMin)
        )


    ## --- Compute muon-MT ------------------------------------------------
    from RA2Classic.Utils.mtProducer_cfi import mtProducer 
    process.MuonMT = mtProducer.clone(
        CandidateCollectionTag = cms.InputTag("patMuonsPFIDIso"),
        METTag                 = cms.InputTag("patMETsPF")
        )


    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(testFileName)
    process.WeightProducer.Lumi                       = cms.double(19466)
    process.WeightProducer.PU                         = cms.int32(3) # PU S10
    process.WeightProducer.FileNamePUDataDistribution = cms.string("RA2Classic/WeightProducer/data/DataPileupHistogram_RA2Summer12_190456-208686_ABCD.root")
    
    


    ## --- Setup of TreeMaker ----------------------------------------------
    FilterNames = cms.VInputTag()
    FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
    FilterNames.append(cms.InputTag("beamHaloFilter"))
    FilterNames.append(cms.InputTag("trackingFailureFilter"))
    FilterNames.append(cms.InputTag("inconsistentMuons"))
    FilterNames.append(cms.InputTag("greedyMuons"))
    FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
    FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
    FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
    FilterNames.append(cms.InputTag("ecalLaserCorrFilter"))
    FilterNames.append(cms.InputTag("eeBadScFilter"))
    FilterNames.append(cms.InputTag("PBNRFilter"))
    FilterNames.append(cms.InputTag("HCALLaserEvtFilterList2012"))
    FilterNames.append(cms.InputTag("manystripclus53X"))
    FilterNames.append(cms.InputTag("toomanystripclus53X"))
    FilterNames.append(cms.InputTag("logErrorTooManyClusters"))
    FilterNames.append(cms.InputTag("RA2CaloVsPFMHTFilter"))
    FilterNames.append(cms.InputTag("RA2HONoiseFilter"))
    FilterNames.append(cms.InputTag("ResidualNoiseEventFilter"))

    from RA2Classic.TreeMaker.treemaker_cfi import TreeMaker
    process.RA2TreeMaker = TreeMaker.clone(
        TreeName              = cms.string("RA2PreSelection"),
        VertexCollection      = cms.InputTag('goodVertices'),
        HT                    = cms.InputTag(htInputCol),
        HTJets                = cms.InputTag('HTJets'),
        MHT                   = cms.InputTag(mhtInputCol),
        MHTJets               = cms.InputTag('MHTJets'),
        VarsDouble            = cms.VInputTag(cms.InputTag('WeightProducer:weight')),
        VarsDoubleNamesInTree = cms.vstring('Weight'),
        METs                  = cms.VInputTag(mhtInputCol,'patMETsPF'),
        METNamesInTree        = cms.vstring('PFMHT','patMETsPF'),
        PatJetCollInputTag    = cms.InputTag('patJetsPF'),
        PatJetsMinPt          = cms.double(30.),
        PatJetsNameInTree     = cms.string('MHTJets'),
        CandidateCollections  = cms.VInputTag('patElectronsIDIso','patMuonsPFIDIso'),
        CandidateNamesInTree  = cms.vstring('IsoElectrons','IsoMuons'),
        VarsDoubleV           = cms.VInputTag(cms.InputTag('MuonMT')),
        VarsDoubleNamesInTreeV = cms.vstring('MTIsoMuons'),
        Filters               = FilterNames
        )



    ## --- Final paths ----------------------------------------------------

    process.WriteTree = cms.Path(
        process.HLTSelection *
        process.ProduceRA2Jets *
        process.PBNRFilter * process.HCALLaserEvtFilterList2012 * process.RA2HONoiseFilter * process.ResidualNoiseEventFilter *
        process.NumJetSelection *
        process.HTSelection *
        process.MHTSelection *
        process.MuonMT *
        process.WeightProducer *
        process.RA2TreeMaker
        )
예제 #6
0
def makeLLFromNTuple(
    process,
    outFileName,
    useCHSJets=True,
    invertLeptonVeto=False,
    NJetsMin=2,
    HTMin=500.0,
    MHTMin=200.0,
    reportEveryEvt=10,
    Global_Tag="",
    testFileName=[
        "/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"
    ],
    numProcessedEvt=1000,
):

    process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag

    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(placeholder=cms.untracked.bool(True))
    process.MessageLogger.statistics.append("cout")
    process.MessageLogger.cout = cms.untracked.PSet(
        INFO=cms.untracked.PSet(reportEvery=cms.untracked.int32(reportEveryEvt))
    )

    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(12))
    process.source = cms.Source("EmptySource")

    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service("TFileService", fileName=cms.string(outFileName + ".root"))

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load("RA2Classic.TreeMaker.filterSelection_cff")
    process.load("SandBox.Skims.RA2Leptons_cff")

    process.CleaningSelection = cms.Sequence(process.filterSelection)

    # Filter-related selection
    #    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    #    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    #    process.PBNRFilter = jetIDFailure.clone(
    #        JetSource = cms.InputTag('MHTJets'),
    #        MinJetPt      = cms.double(30.0),
    #        taggingMode   = cms.bool(False)
    #        )
    #    process.filterSelection += process.PBNRFilter
    #    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    #    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    #        file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
    #        taggingMode = cms.bool(False)
    #        )
    #   process.filterSelection += process.HCALLaserEvtFilterList2012

    # Produce RA2 jets
    if useCHSJets:
        process.load("RA2Classic.Utils.produceRA2JetsPFCHS_cff")
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsPFCHS)
    else:
        process.load("RA2Classic.Utils.produceRA2JetsAK5PF_cff")
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsAK5PF)

    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets

    process.NumJetSelection = countPatJets.clone(src=cms.InputTag("HTJets"), minNumber=cms.uint32(NJetsMin))

    # HT selection
    htInputCol = "htPF"
    if useCHSJets:
        htInputCol = "htPFchs"

    from SandBox.Skims.RA2HT_cff import htPFFilter

    process.HTSelection = htPFFilter.clone(HTSource=cms.InputTag(htInputCol), MinHT=cms.double(HTMin))

    # MHT selection
    mhtMin = 0.0
    mhtInputCol = "mhtPF"
    if useCHSJets:
        mhtInputCol = "mhtPFchs"

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter

    process.MHTSelection = mhtPFFilter.clone(MHTSource=cms.InputTag(mhtInputCol), MinMHT=cms.double(MHTMin))

    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure

    process.PBNRFilter = jetIDFailure.clone(
        JetSource=cms.InputTag("MHTJets"), MinJetPt=cms.double(30.0), taggingMode=cms.bool(False)
    )

    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter

    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file=cms.FileInPath("RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt"),
        taggingMode=cms.bool(False),
    )

    process.AdditionalFiltersInTagMode = cms.Sequence(process.PBNRFilter)

    #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.limit_ll_cfi import Limit_ll

    process.limit_ll = Limit_ll.clone()

    #  process.lostLeptonPrediction = llPrediction()

    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")

    process.WriteTree = cms.Path(
        process.limit_ll
        # 	process.RA2TreeMaker
    )
예제 #7
0
def makeTreeFromPAT(process,
                    outFileName,
                    useCHSJets=True,
		    invertLeptonVeto=False,
                    NJetsMin=2,
                    HTMin=500.,
                    MHTMin=200.,
                    reportEveryEvt=10,
		    Global_Tag="",
                    testFileName=["/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"],
                    numProcessedEvt=1000):
    
    
    process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag
    
    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder = cms.untracked.bool(True)
        )
    process.MessageLogger.statistics.append('cout')
    process.MessageLogger.cout = cms.untracked.PSet(
        INFO = cms.untracked.PSet(reportEvery = cms.untracked.int32(reportEveryEvt))
        )


    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input = cms.untracked.int32(numProcessedEvt)
        )
    process.source = cms.Source(
        "PoolSource",
        fileNames = cms.untracked.vstring(testFileName)
        )
        
        
    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service(
        "TFileService",
        fileName = cms.string(outFileName+".root")
        )
    

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    process.load('SandBox.Skims.RA2Leptons_cff')

    process.CleaningSelection = cms.Sequence(
        process.filterSelection
        )
    # Produce RA2 jets
    if useCHSJets:
        process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
        process.ProduceRA2Jets = cms.Sequence(
            process.produceRA2JetsPFCHS
            )
    else:
        process.load('RA2Classic.Utils.produceRA2JetsAK5PF_cff')
        process.ProduceRA2Jets = cms.Sequence(
            process.produceRA2JetsAK5PF
            )
    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src       = cms.InputTag('HTJets'),
        minNumber = cms.uint32(NJetsMin)
        )

    # HT selection
    htInputCol = 'htPF'
    if useCHSJets:
        htInputCol = 'htPFchs'

    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(
        HTSource = cms.InputTag(htInputCol),
        MinHT = cms.double(HTMin)
        )

    # MHT selection
    mhtMin = 0.
    mhtInputCol = 'mhtPF'
    if useCHSJets:
        mhtInputCol = 'mhtPFchs'

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource = cms.InputTag(mhtInputCol),
        MinMHT = cms.double(MHTMin)
        )


    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(
        JetSource = cms.InputTag('MHTJets'),
        MinJetPt      = cms.double(30.0),
        taggingMode   = cms.bool(False)
        )
	
	
    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file        =
        cms.FileInPath('RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'),
        taggingMode = cms.bool(False)
        )
	
	
	
	

    process.AdditionalFiltersInTagMode = cms.Sequence(
        process.PBNRFilter
        )

    FilterNames = cms.VInputTag()
    FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
    FilterNames.append(cms.InputTag("beamHaloFilter"))
    FilterNames.append(cms.InputTag("trackingFailureFilter"))
    FilterNames.append(cms.InputTag("inconsistentMuons"))
    FilterNames.append(cms.InputTag("greedyMuons"))
    FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
    FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
    FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
    FilterNames.append(cms.InputTag("ecalLaserCorrFilter"))
    FilterNames.append(cms.InputTag("eeBadScFilter"))
    FilterNames.append(cms.InputTag("PBNRFilter"))
    FilterNames.append(cms.InputTag("HCALLaserEvtFilterList2012"))
    FilterNames.append(cms.InputTag("manystripclus53X"))
    FilterNames.append(cms.InputTag("toomanystripclus53X"))
    FilterNames.append(cms.InputTag("logErrorTooManyClusters"))
 #   FilterNames.append(cms.InputTag("RA2CaloVsPFMHTFilter"))
    FilterNames.append(cms.InputTag("RA2HONoiseFilter"))






    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(process.source.fileNames[0])
        


    FilterNames = cms.VInputTag()  # All filters in AdditionalFiltersInTagMode
    for f in process.AdditionalFiltersInTagMode.moduleNames():
        FilterNames.append(cms.InputTag(f))
	
	
	# filter used to slecte the RA2 baseline important for efficiency caluclaiton
    from RA2Classic.Utils.RA2Selection_cfi import RA2Selection
    process.RA2Selector = RA2Selection.clone(
    	nJets		= cms.uint32 (3),
	HTMin		= cms.double(500),
	MHTMin		= cms.double(100),
	
	)

   ## ---- Load lost lepton moduels
   # special calo jets for delta R in efficiencies
    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')




 #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.RecoMuon_cfi import RecoMuon
    process.RA2RecoMuon = RecoMuon.clone(
    	HTJets		= cms.InputTag('HTJets'),
	MetTag		= cms.InputTag('patMETsPF'),
	CaloJetTag	= cms.InputTag('ak5CaloJetsL2L3'),
	MuonIsoTag		= cms.InputTag('patMuonsPFIDIso'),
	ElecIsoTag         = cms.InputTag("ra2ElectronsIDIso"),
	MTWCut		= cms.bool(True),
	HTTag	   = cms.InputTag(htInputCol),
 	MHTTag	   = cms.InputTag(mhtInputCol),
    )



 #electrons selectors for ID electrons
    from SandBox.Skims.RA2Leptons_cff import patElectronsIDIso
    process.ra2ElectronsID = patElectronsIDIso.clone()
    process.ra2ElectronsID.DoElectronIsolation = False
    process.ra2ElectronsIDIso = patElectronsIDIso.clone()
 
    from RA2Classic.LostLeptonBkg.ra2Filters_cfi import ra2FilterSelection
    process.RA2Filters = ra2FilterSelection.clone(
    Filters           = FilterNames
    )

    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")
    
    process.WriteTree = cms.Path(
        process.CleaningSelection *
	process.HCALLaserEvtFilterList2012 *
	process.ProduceRA2Jets *
        process.NumJetSelection *
        process.HTSelection *
        process.MHTSelection *
        process.AdditionalFiltersInTagMode *
        process.WeightProducer *
	process.ra2ElectronsID *
	process.ra2ElectronsIDIso *
#	process.jesUp *
#	process.jesDown *
#	process.promtLeptons *
	process.RA2Selector *
	process.RA2Filters *
	process.ak5CaloJetsL2L3 *
 #       process.dump *
#	process.LostLeptonBkgMCEffCalculator *
	process.RA2RecoMuon
#	process.RA2TreeMaker 

        )
예제 #8
0
def makeTreeFromPAT(process,
                    outFileName,
                    useCHSJets=True,
		    invertLeptonVeto=False,
                    NJetsMin=2,
                    HTMin=500.,
                    MHTMin=200.,
                    reportEveryEvt=10,
		    Global_Tag="",
                    testFileName=["/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"],
                    numProcessedEvt=1000):
    
    
    process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag
    
    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder = cms.untracked.bool(True)
        )
    process.MessageLogger.statistics.append('cout')
    process.MessageLogger.cout = cms.untracked.PSet(
        INFO = cms.untracked.PSet(reportEvery = cms.untracked.int32(reportEveryEvt))
        )


    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input = cms.untracked.int32(numProcessedEvt)
        )
    process.source = cms.Source(
        "PoolSource",
        fileNames = cms.untracked.vstring(testFileName)
        )
        
        
    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service(
        "TFileService",
        fileName = cms.string(outFileName+".root")
        )
    

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    process.load('SandBox.Skims.RA2Leptons_cff')

    process.CleaningSelection = cms.Sequence(
        process.filterSelection
        )

    # Filter-related selection
#    process.load('RA2Classic.TreeMaker.filterSelection_cff')
#    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
#    process.PBNRFilter = jetIDFailure.clone(
#        JetSource = cms.InputTag('MHTJets'),
#        MinJetPt      = cms.double(30.0),
#        taggingMode   = cms.bool(False)
#        )
#    process.filterSelection += process.PBNRFilter
#    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
#    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
#        file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
#        taggingMode = cms.bool(False)
#        )
 #   process.filterSelection += process.HCALLaserEvtFilterList2012




    # Produce RA2 jets
    if useCHSJets:
        process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
        process.ProduceRA2Jets = cms.Sequence(
            process.produceRA2JetsPFCHS
            )
    else:
        process.load('RA2Classic.Utils.produceRA2JetsAK5PF_cff')
        process.ProduceRA2Jets = cms.Sequence(
            process.produceRA2JetsAK5PF
            )
	    
	    


    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src       = cms.InputTag('HTJets'),
        minNumber = cms.uint32(NJetsMin)
        )

    # HT selection
    htInputCol = 'htPF'
    if useCHSJets:
        htInputCol = 'htPFchs'

    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(
        HTSource = cms.InputTag(htInputCol),
        MinHT = cms.double(HTMin)
        )

    # MHT selection
    mhtMin = 0.
    mhtInputCol = 'mhtPF'
    if useCHSJets:
        mhtInputCol = 'mhtPFchs'

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource = cms.InputTag(mhtInputCol),
        MinMHT = cms.double(MHTMin)
        )


    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(
        JetSource = cms.InputTag('MHTJets'),
        MinJetPt      = cms.double(30.0),
        taggingMode   = cms.bool(False)
        )
	
	
    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file        =
        cms.FileInPath('RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'),
        taggingMode = cms.bool(False)
        )
	
	
	
	

    process.AdditionalFiltersInTagMode = cms.Sequence(
        process.PBNRFilter
        )

    FilterNames = cms.VInputTag()
    FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
    FilterNames.append(cms.InputTag("beamHaloFilter"))
    FilterNames.append(cms.InputTag("trackingFailureFilter"))
    FilterNames.append(cms.InputTag("inconsistentMuons"))
    FilterNames.append(cms.InputTag("greedyMuons"))
    FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
    FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
    FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
    FilterNames.append(cms.InputTag("ecalLaserCorrFilter"))
    FilterNames.append(cms.InputTag("eeBadScFilter"))
    FilterNames.append(cms.InputTag("PBNRFilter"))
    FilterNames.append(cms.InputTag("HCALLaserEvtFilterList2012"))
    FilterNames.append(cms.InputTag("manystripclus53X"))
    FilterNames.append(cms.InputTag("toomanystripclus53X"))
    FilterNames.append(cms.InputTag("logErrorTooManyClusters"))
 #   FilterNames.append(cms.InputTag("RA2CaloVsPFMHTFilter"))
    FilterNames.append(cms.InputTag("RA2HONoiseFilter"))






    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(process.source.fileNames[0])
        

    ## --- Setup of TreeMaker ----------------------------------------------
    FilterNames = cms.VInputTag()  # All filters in AdditionalFiltersInTagMode
    for f in process.AdditionalFiltersInTagMode.moduleNames():
        FilterNames.append(cms.InputTag(f))

##     FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
##     FilterNames.append(cms.InputTag("beamHaloFilter"))
##     FilterNames.append(cms.InputTag("eeNoiseFilter"))
##     FilterNames.append(cms.InputTag("trackingFailureFilter"))
##     FilterNames.append(cms.InputTag("inconsistentMuons"))
##     FilterNames.append(cms.InputTag("greedyMuons"))
##     FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
##     FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
##     FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
##     FilterNames.append(cms.InputTag("eeBadScFilter"))



    from RA2Classic.TreeMaker.treemaker_cfi import TreeMaker
    process.RA2TreeMaker = TreeMaker.clone(
        TreeName          = cms.string("RA2PreSelection"),
        VertexCollection  = cms.InputTag('goodVertices'),
        HT                = cms.InputTag(htInputCol),
        HTJets            = cms.InputTag('HTJets'),
        MHT               = cms.InputTag(mhtInputCol),
        MHTJets           = cms.InputTag('MHTJets'),
        VarsDouble        = cms.VInputTag(cms.InputTag('WeightProducer:weight'),cms.InputTag('LostLeptonBkgProducer:LostLeptonWeight'),cms.InputTag('LostLeptonBkgProducer:Met'),cms.InputTag('LostLeptonBkgProducer:nMu'),cms.InputTag('LostLeptonBkgProducer:MuPt'),cms.InputTag('LostLeptonBkgProducer:MuEta'),cms.InputTag('LostLeptonBkgProducer:MuPhi' ),cms.InputTag('LostLeptonBkgProducer:deltaRMuJet'),cms.InputTag('LostLeptonBkgProducer:deltaRMuMHT' ),cms.InputTag('LostLeptonBkgProducer:deltaPtMuJet') ),
        VarsDoubleNamesInTree = cms.vstring('Weight','LostLeptonWeight','Met','numberOfMuons','MuPT','MuEta','MuPhi','DeltaRMuJet','DeltaRMuMHT','DeltaPtMuJet'), 
        Filters           = FilterNames
        )
	
	
	
	# filter used to slecte the RA2 baseline important for efficiency caluclaiton
    from RA2Classic.Utils.RA2Selection_cfi import RA2Selection
    process.RA2Selector = RA2Selection.clone(
    	nJets		= cms.uint32 (3),
	HTMin		= cms.double(500),
	MHTMin		= cms.double(100),
	
	)

   ## ---- Load lost lepton moduels
   # special calo jets for delta R in efficiencies
    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')

   
#   from RA2Classic.LostLeptonBkg.llPrediction_cff import llPrediction
 #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.MCEffCalculator_cfi import MCEffCalculator
    process.LostLeptonBkgMCEffCalculator = MCEffCalculator.clone(
        MuonIDTag = cms.InputTag("patMuonsPFID"),
	MuonIDISOTag = cms.InputTag("patMuonsPFIDIso"),
        ElecIDTag = cms.InputTag("ra2ElectronsID"), 
	ElecIDISOTag = cms.InputTag("ra2ElectronsIDIso"),
#        ElecIDTag = cms.InputTag("patElectronsIDIso"), 
#	ElecIDISOTag = cms.InputTag("patElectronsIDIso"),
	HTTag	   = cms.InputTag(htInputCol),
 	MHTTag	   = cms.InputTag(mhtInputCol),
	CaloJetTag	= cms.InputTag('ak5CaloJetsL2L3'),
#	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
    )


    from RA2Classic.LostLeptonBkg.promtisomu_cfi import promtIsoMu
    process.promtLeptons = promtIsoMu.clone(
	MuonIDISOTag = cms.InputTag("patMuonsPFIDIso"),
	CaloJetTag = cms.InputTag("ak5CaloJetsL2L3"),
#	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
    )

 #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.bkglostlepton_cfi import bkglostlepton
    process.LostLeptonBkgProducer = bkglostlepton.clone(
    	HTJets		= cms.InputTag('HTJets'),
	MetTag		= cms.InputTag('patMETsPF'),
	CaloJetTag	= cms.InputTag('ak5CaloJetsL2L3'),
#	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
#	MuonTag		= cms.InputTag('promtLeptons:PromtMuon'),
	MuonTag		= cms.InputTag('patMuonsPFIDIso'),
	ElecTag         = cms.InputTag("ra2ElectronsIDIso"),
#	ElecTag         = cms.InputTag("patElectronsIDIso"),
	MTWCut		= cms.bool(True),
	EfficiencyFileName = cms.string('MCEff.root'),
	HTTag	   = cms.InputTag(htInputCol),
 	MHTTag	   = cms.InputTag(mhtInputCol),
	MetJetTagUp = cms.InputTag('jesUp:METs'),
	MetJetTagDown = cms.InputTag('jesDown:METs'),
	IsoPlots = cms.bool(True),
	TAPUncertaintiesHTNJET = cms.bool(True),
	statErrorEffmaps = cms.bool(True),
    )



 #electrons selectors for ID electrons
    from SandBox.Skims.RA2Leptons_cff import patElectronsID
    from SandBox.Skims.RA2Leptons_cff import patElectronsIDIso
    process.ra2ElectronsID = patElectronsID.clone()
    process.ra2ElectronsIDIso = patElectronsIDIso.clone()
 
 
 # JES variation for MET 
    from RA2Classic.Utils.jesUncertaintyVariation_cfi import jesUncertaintyVariation
    process.jesUp = jesUncertaintyVariation.clone(
        Jets       = cms.InputTag('MHTJets'), # The input jet collection
        JetTypeId  = cms.string('AK5PFchs'),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation  = cms.string('Up')         # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )
    process.jesDown = jesUncertaintyVariation.clone(
        Jets       = cms.InputTag('MHTJets'), # The input jet collection
        JetTypeId  = cms.string('AK5PFchs'),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation  = cms.string('Down')         # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )

    from RA2Classic.LostLeptonBkg.ra2Filters_cfi import ra2FilterSelection
    process.RA2Filters = ra2FilterSelection.clone(
    Filters           = FilterNames
    )




    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")
    
    process.WriteTree = cms.Path(
        process.CleaningSelection *
	process.HCALLaserEvtFilterList2012 *
	process.ProduceRA2Jets *
        process.NumJetSelection *
        process.HTSelection *
        process.MHTSelection *
        process.AdditionalFiltersInTagMode *
        process.WeightProducer *
	process.ra2ElectronsID *
	process.ra2ElectronsIDIso *
#	process.jesUp *
#	process.jesDown *
#	process.promtLeptons *
	process.RA2Selector *
	process.RA2Filters *
	process.ak5CaloJetsL2L3 *
 #       process.dump *
	process.LostLeptonBkgMCEffCalculator *
	process.LostLeptonBkgProducer
#	process.RA2TreeMaker 

        )
process.load('HLTrigger.HLTfilters.hltHighLevel_cfi')
process.hltHighLevel.HLTPaths = cms.vstring('HLT_Photon20_CaloIdVL_IsoL_v*','HLT_Photon30_CaloIdVL_IsoL_v*','HLT_Photon50_CaloIdVL_IsoL_v*','HLT_Photon75_CaloIdVL_IsoL_v*','HLT_Photon90_CaloIdVL_IsoL_v*','HLT_Photon135_v*','HLT_Photon150_v*','HLT_Photon160_v*','HLT_Photon20_CaloIdVL_v*','HLT_Photon30_CaloIdVL_v*','HLT_Photon50_CaloIdVL_v*','HLT_Photon75_CaloIdVL_v*','HLT_Photon90_CaloIdVL_v*','HLT_Photon30_v*','HLT_Photon30_R9Id90_CaloId_HE10_Iso40_EBOnly_v*')
process.hltHighLevel.andOr = cms.bool(True) 
process.hltHighLevel.throw = cms.bool(False)

#Filter
process.load('Calibration.CalibTreeMaker.cleaningSequences_cff')

## sequence with filters
process.filterSequence = cms.Sequence(  process.hltHighLevel *
					process.stdCleaningSequence                                        
                                        )

from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    file        = cms.FileInPath('Calibration/CalibTreeMaker/data/HCALLaserEventList_20Nov2012-v2_Jet_JetHT_JetMon.txt'),
    taggingMode = cms.bool(False)
    )
process.filterSequence += process.HCALLaserEvtFilterList2012

process.load("Calibration.CalibTreeMaker.CalibTreeMaker_cff")


process.calibTreeMakerAK5FastPFData.ECALDeadCellBEFilterModuleName = cms.InputTag("EcalDeadCellBoundaryEnergyFilter")
process.calibTreeMakerAK5FastPFData.ECALDeadCellTPFilterModuleName = cms.InputTag("EcalDeadCellTriggerPrimitiveFilter")
process.calibTreeMakerAK5FastPFData.WritePhotons = True
process.calibTreeMakerAK5FastPFData.TreeName = "GammaJetTree"
process.calibTreeMakerAK5PFCHSData.ECALDeadCellBEFilterModuleName = cms.InputTag("EcalDeadCellBoundaryEnergyFilter")
process.calibTreeMakerAK5PFCHSData.ECALDeadCellTPFilterModuleName = cms.InputTag("EcalDeadCellTriggerPrimitiveFilter")
process.calibTreeMakerAK5PFCHSData.WritePhotons = True
process.calibTreeMakerAK5PFCHSData.TreeName = "GammaJetTree"
예제 #10
0
def makeTreeFromPAT(
        process,
        outFileName,
        useCHSJets=True,
        invertLeptonVeto=False,
        NJetsMin=2,
        HTMin=500.,
        MHTMin=200.,
        reportEveryEvt=10,
        Global_Tag="",
        MC=False,
        RecoLeptonStudyBool=False,
        DebugBool=False,
        testFileName=[
            "/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"
        ],
        numProcessedEvt=1000):

    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag

    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder=cms.untracked.bool(True))
    process.MessageLogger.statistics.append('cout')
    process.MessageLogger.cout = cms.untracked.PSet(INFO=cms.untracked.PSet(
        reportEvery=cms.untracked.int32(reportEveryEvt)))

    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input=cms.untracked.int32(numProcessedEvt))
    process.source = cms.Source("PoolSource",
                                fileNames=cms.untracked.vstring(testFileName))

    hltPath = ['HLT_PFHT350_PFMET100_v*', 'HLT_PFNoPUHT350_PFMET100_v*']
    process.load('HLTrigger.HLTfilters.hltHighLevel_cfi')
    process.hltHighLevel.HLTPaths = cms.vstring(hltPath)
    process.hltHighLevel.andOr = cms.bool(True)
    process.hltHighLevel.throw = cms.bool(False)

    process.HLTSelection = cms.Sequence(process.hltHighLevel)
    if MC:
        print "Running over MC: removing HLT selection"
        process.HLTSelection.remove(process.hltHighLevel)
    elif not hltPath:
        print "Empty list of HLT paths: removing HLT selection"
        process.HLTSelection.remove(process.hltHighLevel)
    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service("TFileService",
                                       fileName=cms.string(outFileName +
                                                           ".root"))

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    process.load('SandBox.Skims.RA2Leptons_cff')

    process.CleaningSelection = cms.Sequence(process.filterSelection)

    # Filter-related selection
    #    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    #    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    #    process.PBNRFilter = jetIDFailure.clone(
    #        JetSource = cms.InputTag('MHTJets'),
    #        MinJetPt      = cms.double(30.0),
    #        taggingMode   = cms.bool(False)
    #        )
    #    process.filterSelection += process.PBNRFilter
    #    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    #    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    #        file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
    #        taggingMode = cms.bool(False)
    #        )
    #   process.filterSelection += process.HCALLaserEvtFilterList2012

    # Produce RA2 jets
    if useCHSJets:
        process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsPFCHS)
    else:
        process.load('RA2Classic.Utils.produceRA2JetsAK5PF_cff')
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsAK5PF)

    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src=cms.InputTag('HTJets'), minNumber=cms.uint32(NJetsMin))

    # HT selection
    htInputCol = 'htPF'
    if useCHSJets:
        htInputCol = 'htPFchs'

    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(HTSource=cms.InputTag(htInputCol),
                                           MinHT=cms.double(HTMin))

    # MHT selection
    mhtMin = 0.
    mhtInputCol = 'mhtPF'
    if useCHSJets:
        mhtInputCol = 'mhtPFchs'

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource=cms.InputTag(mhtInputCol), MinMHT=cms.double(MHTMin))

    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(
        JetSource=cms.InputTag('patJetsPF'),
        MinJetPt=cms.double(30.0),
        taggingMode=cms.bool(False))

    from SandBox.Skims.hoNoiseFilter_cfi import hoNoiseFilter
    process.RA2HoNoiseFitler = hoNoiseFilter.clone(
        patJetsInputTag=cms.InputTag('patJetsPF'))
    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file=cms.FileInPath(
            'RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'
        ),
        taggingMode=cms.bool(False))

    process.AdditionalFiltersInTagMode = cms.Sequence(process.PBNRFilter)

    FilterNames = cms.VInputTag()
    FilterNames.append(
        cms.InputTag("HBHENoiseFilterRA2", "HBHENoiseFilterResult", "PAT"))
    FilterNames.append(cms.InputTag("beamHaloFilter"))
    FilterNames.append(cms.InputTag("trackingFailureFilter"))
    FilterNames.append(cms.InputTag("inconsistentMuons"))
    FilterNames.append(cms.InputTag("greedyMuons"))
    FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
    FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
    FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
    FilterNames.append(cms.InputTag("ecalLaserCorrFilter"))
    FilterNames.append(cms.InputTag("eeBadScFilter"))
    FilterNames.append(cms.InputTag("PBNRFilter"))
    FilterNames.append(cms.InputTag("HCALLaserEvtFilterList2012"))
    FilterNames.append(cms.InputTag("manystripclus53X"))
    FilterNames.append(cms.InputTag("toomanystripclus53X"))
    FilterNames.append(cms.InputTag("logErrorTooManyClusters"))
    #   FilterNames.append(cms.InputTag("RA2CaloVsPFMHTFilter"))
    FilterNames.append(cms.InputTag("RA2HONoiseFilter"))

    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(process.source.fileNames[0])

    ## --- Setup of TreeMaker ----------------------------------------------
    FilterNames = cms.VInputTag()  # All filters in AdditionalFiltersInTagMode
    for f in process.AdditionalFiltersInTagMode.moduleNames():
        FilterNames.append(cms.InputTag(f))

##     FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
##     FilterNames.append(cms.InputTag("beamHaloFilter"))
##     FilterNames.append(cms.InputTag("eeNoiseFilter"))
##     FilterNames.append(cms.InputTag("trackingFailureFilter"))
##     FilterNames.append(cms.InputTag("inconsistentMuons"))
##     FilterNames.append(cms.InputTag("greedyMuons"))
##     FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
##     FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
##     FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
##     FilterNames.append(cms.InputTag("eeBadScFilter"))

    from RA2Classic.TreeMaker.treemaker_cfi import TreeMaker
    process.RA2TreeMaker = TreeMaker.clone(
        TreeName=cms.string("RA2PreSelection"),
        VertexCollection=cms.InputTag('goodVertices'),
        HT=cms.InputTag(htInputCol),
        HTJets=cms.InputTag('HTJets'),
        MHT=cms.InputTag(mhtInputCol),
        MHTJets=cms.InputTag('MHTJets'),
        VarsDouble=cms.VInputTag(
            cms.InputTag('WeightProducer:weight'),
            cms.InputTag('LostLeptonBkgProducer:LostLeptonWeight'),
            cms.InputTag('LostLeptonBkgProducer:Met'),
            cms.InputTag('LostLeptonBkgProducer:nMu'),
            cms.InputTag('LostLeptonBkgProducer:MuPt'),
            cms.InputTag('LostLeptonBkgProducer:MuEta'),
            cms.InputTag('LostLeptonBkgProducer:MuPhi'),
            cms.InputTag('LostLeptonBkgProducer:deltaRMuJet'),
            cms.InputTag('LostLeptonBkgProducer:deltaRMuMHT'),
            cms.InputTag('LostLeptonBkgProducer:deltaPtMuJet')),
        VarsDoubleNamesInTree=cms.vstring('Weight', 'LostLeptonWeight', 'Met',
                                          'numberOfMuons', 'MuPT', 'MuEta',
                                          'MuPhi', 'DeltaRMuJet',
                                          'DeltaRMuMHT', 'DeltaPtMuJet'),
        Filters=FilterNames)

    # filter used to slecte the RA2 baseline important for efficiency caluclaiton
    from RA2Classic.Utils.RA2Selection_cfi import RA2Selection
    process.RA2Selector = RA2Selection.clone(
        nJets=cms.uint32(3),
        HTMin=cms.double(500),
        MHTMin=cms.double(200),
    )

    ## ---- Load lost lepton moduels
    # special calo jets for delta R in efficiencies
    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')

    #   from RA2Classic.LostLeptonBkg.llPrediction_cff import llPrediction
    #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.MCEffCalculator_cfi import MCEffCalculator
    process.LostLeptonBkgMCEffCalculator = MCEffCalculator.clone(
        MuonIDTag=cms.InputTag("patMuonsPFID"),
        MuonIDISOTag=cms.InputTag("patMuonsPFIDIso"),
        ElecIDTag=cms.InputTag("ra2ElectronsID"),
        ElecIDISOTag=cms.InputTag("ra2ElectronsIDIso"),
        #        ElecIDTag = cms.InputTag("patElectronsIDIso"),
        #	ElecIDISOTag = cms.InputTag("patElectronsIDIso"),
        HTTag=cms.InputTag(htInputCol),
        MHTTag=cms.InputTag(mhtInputCol),
        CaloJetTag=cms.InputTag('ak5CaloJetsL2L3'),
        #	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
        UseZResonanze=cms.bool(False),
        debug=DebugBool,
    )

    from RA2Classic.LostLeptonBkg.promtisomu_cfi import promtIsoMu
    process.promtLeptons = promtIsoMu.clone(
        MuonIDISOTag=cms.InputTag("patMuonsPFIDIso"),
        CaloJetTag=cms.InputTag("ak5CaloJetsL2L3"),
        #	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
    )

    #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.bkglostlepton_cfi import bkglostlepton
    process.LostLeptonBkgProducer = bkglostlepton.clone(
        HTJets=cms.InputTag('HTJets'),
        MetTag=cms.InputTag('patMETsPF'),
        CaloJetTag=cms.InputTag('ak5CaloJetsL2L3'),
        #	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
        #	MuonTag		= cms.InputTag('promtLeptons:PromtMuon'),
        MuonTag=cms.InputTag('patMuonsPFIDIso'),
        ElecTag=cms.InputTag("ra2ElectronsIDIso"),
        #	ElecTag         = cms.InputTag("patElectronsIDIso"),
        MTWCut=cms.bool(True),
        EfficiencyFileName=cms.string('MCEff.root'),
        HTTag=cms.InputTag(htInputCol),
        MHTTag=cms.InputTag(mhtInputCol),
        MetJetTagUp=cms.InputTag('jesUp:METs'),
        MetJetTagDown=cms.InputTag('jesDown:METs'),
        IsoPlots=cms.bool(True),
        TAPUncertaintiesHTNJET=cms.bool(False),
        statErrorEffmaps=cms.bool(True),
        debug=DebugBool,
    )

    from RA2Classic.LostLeptonBkg.RecoLeptonStudy_cfi import RecoLeptonStudy
    process.RecoLeptonStudyProducer = RecoLeptonStudy.clone(
        MuonIDTag=cms.InputTag("patMuonsPFID"),
        MuonIDISOTag=cms.InputTag("patMuonsPFIDIso"),
        ElecIDTag=cms.InputTag("ra2ElectronsID"),
        ElecIDISOTag=cms.InputTag("ra2ElectronsIDIso"),
        #        ElecIDTag = cms.InputTag("patElectronsIDIso"),
        #	ElecIDISOTag = cms.InputTag("patElectronsIDIso"),
        HTTag=cms.InputTag(htInputCol),
        MHTTag=cms.InputTag(mhtInputCol),
        CaloJetTag=cms.InputTag('ak5CaloJetsL2L3'),
        #	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
        UseZResonanze=cms.bool(False),
        debug=DebugBool,
    )

    #electrons selectors for ID electrons
    from SandBox.Skims.RA2Leptons_cff import patElectronsID
    from SandBox.Skims.RA2Leptons_cff import patElectronsIDIso
    process.ra2ElectronsID = patElectronsID.clone()
    process.ra2ElectronsIDIso = patElectronsIDIso.clone()

    # JES variation for MET
    from RA2Classic.Utils.jesUncertaintyVariation_cfi import jesUncertaintyVariation
    process.jesUp = jesUncertaintyVariation.clone(
        Jets=cms.InputTag('MHTJets'),  # The input jet collection
        JetTypeId=cms.string(
            'AK5PFchs'
        ),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation=cms.string(
            'Up'
        )  # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )
    process.jesDown = jesUncertaintyVariation.clone(
        Jets=cms.InputTag('MHTJets'),  # The input jet collection
        JetTypeId=cms.string(
            'AK5PFchs'
        ),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation=cms.string(
            'Down'
        )  # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )

    from RA2Classic.LostLeptonBkg.ra2Filters_cfi import ra2FilterSelection
    process.RA2Filters = ra2FilterSelection.clone(Filters=FilterNames)

    process.LostLepton = cms.Sequence()
    if MC:
        process.LostLepton += process.LostLeptonBkgMCEffCalculator
    process.LostLepton += process.LostLeptonBkgProducer
    if RecoLeptonStudyBool:
        process.LostLepton += process.RecoLeptonStudyProducer

    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")

    process.WriteTree = cms.Path(
        process.HLTSelection * process.CleaningSelection *
        process.HCALLaserEvtFilterList2012 * process.ProduceRA2Jets *
        process.NumJetSelection * process.HTSelection * process.MHTSelection *
        process.AdditionalFiltersInTagMode * process.WeightProducer *
        process.ra2ElectronsID * process.ra2ElectronsIDIso *
        #	process.jesUp *
        #	process.jesDown *
        #	process.promtLeptons *
        process.RA2Selector * process.RA2Filters * process.RA2HoNoiseFitler *
        process.ak5CaloJetsL2L3 *
        #       process.dump *
        #	process.LostLeptonBkgMCEffCalculator *
        process.LostLepton
        #	process.RA2TreeMaker
    )
예제 #11
0
def makeTreeFromPAT(process,
                    outFileName,
                    useCHSJets=True,
		    invertLeptonVeto=False,
                    NJetsMin=2,
                    HTMin=500.,
                    MHTMin=200.,
                    reportEveryEvt=10,
		    Global_Tag="",
		    MCTAP=True,
		    Muon=False,
		    muonTrigger="",
                    testFileName=["/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"],
                    numProcessedEvt=1000):
    
    
    process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag
    
    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder = cms.untracked.bool(True)
        )
    process.MessageLogger.statistics.append('cout')
    process.MessageLogger.cout = cms.untracked.PSet(
        INFO = cms.untracked.PSet(reportEvery = cms.untracked.int32(reportEveryEvt))
        )


    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input = cms.untracked.int32(numProcessedEvt)
        )
    process.source = cms.Source(
        "PoolSource",
        fileNames = cms.untracked.vstring(testFileName)
        )
        
        
    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service(
        "TFileService",
        fileName = cms.string(outFileName+".root")
        )
    

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    process.load('SandBox.Skims.RA2Leptons_cff')

    process.CleaningSelection = cms.Sequence(
        process.filterSelection
        )

    # Filter-related selection
#    process.load('RA2Classic.TreeMaker.filterSelection_cff')
#    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
#    process.PBNRFilter = jetIDFailure.clone(
#        JetSource = cms.InputTag('MHTJets'),
#        MinJetPt      = cms.double(30.0),
#        taggingMode   = cms.bool(False)
#        )
#    process.filterSelection += process.PBNRFilter
#    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
#    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
#        file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
#        taggingMode = cms.bool(False)
#        )
 #   process.filterSelection += process.HCALLaserEvtFilterList2012




    # Produce RA2 jets
    if useCHSJets:
        process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
        process.ProduceRA2Jets = cms.Sequence(
            process.produceRA2JetsPFCHS
            )
    else:
        process.load('RA2Classic.Utils.produceRA2JetsAK5PF_cff')
        process.ProduceRA2Jets = cms.Sequence(
            process.produceRA2JetsAK5PF
            )
	    
	    


    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src       = cms.InputTag('HTJets'),
        minNumber = cms.uint32(NJetsMin)
        )

    # HT selection
    htInputCol = 'htPF'
    if useCHSJets:
        htInputCol = 'htPFchs'

    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(
        HTSource = cms.InputTag(htInputCol),
        MinHT = cms.double(HTMin)
        )

    # MHT selection
    mhtMin = 0.
    mhtInputCol = 'mhtPF'
    if useCHSJets:
        mhtInputCol = 'mhtPFchs'

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource = cms.InputTag(mhtInputCol),
        MinMHT = cms.double(MHTMin)
        )


    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(
        JetSource = cms.InputTag('MHTJets'),
        MinJetPt      = cms.double(30.0),
        taggingMode   = cms.bool(False)
        )
	
	
    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file        =
        cms.FileInPath('RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'),
        taggingMode = cms.bool(False)
        )
	
	
	
	

    process.AdditionalFiltersInTagMode = cms.Sequence(
        process.PBNRFilter
        )


    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(process.source.fileNames[0])
        

    ## --- Setup of TreeMaker ----------------------------------------------
    FilterNames = cms.VInputTag()  # All filters in AdditionalFiltersInTagMode
    for f in process.AdditionalFiltersInTagMode.moduleNames():
        FilterNames.append(cms.InputTag(f))

##     FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
##     FilterNames.append(cms.InputTag("beamHaloFilter"))
##     FilterNames.append(cms.InputTag("eeNoiseFilter"))
##     FilterNames.append(cms.InputTag("trackingFailureFilter"))
##     FilterNames.append(cms.InputTag("inconsistentMuons"))
##     FilterNames.append(cms.InputTag("greedyMuons"))
##     FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
##     FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
##     FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
##     FilterNames.append(cms.InputTag("eeBadScFilter"))

    process.load('Configuration.EventContent.EventContent_cff')
    process.load('Configuration.StandardSequences.MagneticField_38T_cff')
    process.load('Configuration.StandardSequences.Reconstruction_cff')
    process.load('Configuration.StandardSequences.EndOfProcess_cff')
    process.load('Configuration.StandardSequences.GeometryDB_cff')
    process.load('Configuration.StandardSequences.Services_cff')

    process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")





    process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff")
    from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import useExistingPATMuons
    useExistingPATMuons(process, "patMuons")

#    process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff")

    triggerProcessName = "HLT"
    triggerPathSelector = "HLT_Ele27_WP80_v*"
    matchedCutsString=' path( "'+triggerPathSelector+'",1,0 )'


	
	
	
	# filter used to slecte the RA2 baseline important for efficiency caluclaiton
    from RA2Classic.Utils.RA2Selection_cfi import RA2Selection
    process.RA2Selector = RA2Selection.clone(
    	nJets		= cms.uint32 (1),
	HTMin		= cms.double(50),
	MHTMin		= cms.double(0),
	
	)

   ## ---- Load lost lepton moduels
   # special calo jets for delta R in efficiencies
    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')

   

    from RA2Classic.LostLeptonBkg.promtisomu_cfi import promtIsoMu
    process.promtLeptons = promtIsoMu.clone(
	MuonIDISOTag = cms.InputTag("patMuonsPFIDIso"),
	CaloJetTag = cms.InputTag("ak5CaloJetsL2L3"),
#	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
    )
    from RA2Classic.LostLeptonBkg.tapTreeProducer_cfi import tapTreeProducer
    process.tapTreeMuId = tapTreeProducer.clone(
	HTTag	   = cms.InputTag(htInputCol),
 	MHTTag	   = cms.InputTag(mhtInputCol),
	MC	   = cms.bool(MCTAP),
	Muon	   = True,
	MuonTrigger     =cms.string(muonTrigger),
	
    )
    process.tapTreeMuIso = process.tapTreeMuId.clone(
       MuElecIdIso    = cms.uint32(1),
       Muon	      = True
    )
    process.tapTreeElecId = process.tapTreeMuId.clone(
       MuElecIdIso    = cms.uint32(2),
       Muon	      = False
    )
    process.tapTreeElecIso = process.tapTreeMuId.clone(
       MuElecIdIso    = cms.uint32(3),
       Muon	      = False
    )
    process.tapTreeElecIdGsf = process.tapTreeMuId.clone(
       MuElecIdIso    = cms.uint32(4),
       Muon	      = False
    )
    


 #electrons selectors for ID electrons
    from SandBox.Skims.RA2Leptons_cff import patElectronsID
    from SandBox.Skims.RA2Leptons_cff import patElectronsIDIso
    process.ra2ElectronsID = patElectronsID.clone()
    process.ra2ElectronsIDIso = patElectronsIDIso.clone()
 
 
 # JES variation for MET 
    from RA2Classic.Utils.jesUncertaintyVariation_cfi import jesUncertaintyVariation
    process.jesUp = jesUncertaintyVariation.clone(
        Jets       = cms.InputTag('MHTJets'), # The input jet collection
        JetTypeId  = cms.string('AK5PFchs'),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation  = cms.string('Up')         # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )
    process.jesDown = jesUncertaintyVariation.clone(
        Jets       = cms.InputTag('MHTJets'), # The input jet collection
        JetTypeId  = cms.string('AK5PFchs'),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation  = cms.string('Down')         # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )



    process.tapProducer = cms.Sequence ()
    if Muon :
	    process.tapProducer+=process.patMuonsWithTriggerSequence
	    process.tapProducer+=process.tapTreeMuId
	    process.tapProducer+=process.tapTreeMuIso
    else :
	    process.tapProducer+=process.patMuonsWithTriggerSequence
	    process.tapProducer+=process.tapTreeElecIdGsf
	    process.tapProducer+=process.tapTreeElecIso
    if MCTAP  :
	    process.tapProducer+=process.tapTreeMuId
	    process.tapProducer+=process.tapTreeMuIso
	    process.tapProducer+=process.tapTreeElecIdGsf
	    process.tapProducer+=process.tapTreeElecIso


    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")
    
    process.WriteTree = cms.Path(
        process.CleaningSelection *
	process.HCALLaserEvtFilterList2012 *
	process.ProduceRA2Jets *
        process.NumJetSelection *
        process.HTSelection *
        process.MHTSelection *
        process.AdditionalFiltersInTagMode *
        process.WeightProducer *
	process.ra2ElectronsID *
	process.ra2ElectronsIDIso *
#	process.jesUp *
#	process.jesDown *
#	process.promtLeptons *
	process.RA2Selector *
#	process.ak5CaloJetsL2L3 *
    	process.tapProducer 
#	process.dump *
#	process.patMuonsWithTriggerSequence *
#	process.LostLeptonBkgMCEffCalculator *
#	process.LostLeptonBkgProducer
#	process.RA2TreeMaker 

        )
예제 #12
0
def makeLLFromNTuple(
        process,
        outFileName,
        useCHSJets=True,
        invertLeptonVeto=False,
        NJetsMin=2,
        HTMin=500.,
        MHTMin=200.,
        reportEveryEvt=10,
        Global_Tag="",
        testFileName=[
            "/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"
        ],
        numProcessedEvt=1000):

    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag

    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder=cms.untracked.bool(True))
    process.MessageLogger.statistics.append('cout')
    process.MessageLogger.cout = cms.untracked.PSet(INFO=cms.untracked.PSet(
        reportEvery=cms.untracked.int32(reportEveryEvt)))

    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(12))
    process.source = cms.Source("EmptySource")

    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service("TFileService",
                                       fileName=cms.string(outFileName +
                                                           ".root"))

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    process.load('SandBox.Skims.RA2Leptons_cff')

    process.CleaningSelection = cms.Sequence(process.filterSelection)

    # Filter-related selection
    #    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    #    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    #    process.PBNRFilter = jetIDFailure.clone(
    #        JetSource = cms.InputTag('MHTJets'),
    #        MinJetPt      = cms.double(30.0),
    #        taggingMode   = cms.bool(False)
    #        )
    #    process.filterSelection += process.PBNRFilter
    #    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    #    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    #        file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
    #        taggingMode = cms.bool(False)
    #        )
    #   process.filterSelection += process.HCALLaserEvtFilterList2012

    # Produce RA2 jets
    if useCHSJets:
        process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsPFCHS)
    else:
        process.load('RA2Classic.Utils.produceRA2JetsAK5PF_cff')
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsAK5PF)

    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src=cms.InputTag('HTJets'), minNumber=cms.uint32(NJetsMin))

    # HT selection
    htInputCol = 'htPF'
    if useCHSJets:
        htInputCol = 'htPFchs'

    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(HTSource=cms.InputTag(htInputCol),
                                           MinHT=cms.double(HTMin))

    # MHT selection
    mhtMin = 0.
    mhtInputCol = 'mhtPF'
    if useCHSJets:
        mhtInputCol = 'mhtPFchs'

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource=cms.InputTag(mhtInputCol), MinMHT=cms.double(MHTMin))

    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(JetSource=cms.InputTag('MHTJets'),
                                            MinJetPt=cms.double(30.0),
                                            taggingMode=cms.bool(False))

    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file=cms.FileInPath(
            'RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'
        ),
        taggingMode=cms.bool(False))

    process.AdditionalFiltersInTagMode = cms.Sequence(process.PBNRFilter)

    #  process.lostLeptonPrediction = llPrediction()
    from RA2Classic.LostLeptonBkg.limit_ll_cfi import Limit_ll
    process.limit_ll = Limit_ll.clone()

    #  process.lostLeptonPrediction = llPrediction()

    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")

    process.WriteTree = cms.Path(process.limit_ll
                                 #	process.RA2TreeMaker
                                 )
예제 #13
0
def makeTreeFromPAT(process,
                    outFileName,
                    NJetsMin=2,
                    HTMin=350.,
                    MHTMin=0.,
                    globalTag="none",
                    isData=True,
                    hltPath=[],
                    reportEveryEvt=10,
                    testFileName="",
                    numProcessedEvt=100):

    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder=cms.untracked.bool(True))
    process.MessageLogger.cout = cms.untracked.PSet(INFO=cms.untracked.PSet(
        reportEvery=cms.untracked.int32(reportEveryEvt)))
    process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(True))

    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input=cms.untracked.int32(numProcessedEvt))
    process.source = cms.Source("PoolSource",
                                fileNames=cms.untracked.vstring(testFileName))

    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service("TFileService",
                                       fileName=cms.string(outFileName +
                                                           ".root"))

    ## --- Selection sequences ---------------------------------------------

    # HLT
    process.load('HLTrigger.HLTfilters.hltHighLevel_cfi')
    process.hltHighLevel.HLTPaths = cms.vstring(hltPath)
    process.hltHighLevel.andOr = cms.bool(True)
    process.hltHighLevel.throw = cms.bool(False)

    process.HLTSelection = cms.Sequence(process.hltHighLevel)
    if not isData:
        print "Running over MC: removing HLT selection"
        process.HLTSelection.remove(process.hltHighLevel)
    elif not hltPath:
        print "Empty list of HLT paths: removing HLT selection"
        process.HLTSelection.remove(process.hltHighLevel)

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(
        JetSource=cms.InputTag('patJetsPF'),
        MinJetPt=cms.double(30.0),
        taggingMode=cms.bool(True))
    process.filterSelection += process.PBNRFilter

    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file=cms.FileInPath(
            'RA2Classic/AdditionalInputFiles/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'
        ),
        taggingMode=cms.bool(True))
    process.filterSelection += process.HCALLaserEvtFilterList2012

    from SandBox.Skims.hoNoiseFilter_cfi import hoNoiseFilter
    process.RA2HONoiseFilter = hoNoiseFilter.clone(
        patJetsInputTag=cms.InputTag('patJetsPF'),
        jetPtMin=cms.double(30),
        jetEtaMax=cms.double(5),
        maxHOEfrac=cms.double(0.4),
        taggingMode=cms.bool(True))
    process.filterSelection += process.RA2HONoiseFilter

    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = globalTag
    process.load('SandBox.Skims.RA2CaloVsPFMHTFilterSequence_cff')
    process.RA2CaloVsPFMHTFilter.TaggingMode = cms.bool(True)
    process.filterSelection += process.RA2CaloVsPFMHTFilterSequence

    process.load('SandBox.Skims.RA2Leptons_cff')
    process.LeptonVeto = cms.Sequence(process.ra2PFMuonVeto *
                                      process.ra2ElectronVeto)

    # Produce RA2 jets (produces the collections HTJets and MHTJets)
    process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
    process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsPFCHS)

    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src=cms.InputTag('HTJets'), minNumber=cms.uint32(NJetsMin))

    # HT selection
    htInputCol = 'htPFchs'
    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(HTSource=cms.InputTag(htInputCol),
                                           MinHT=cms.double(HTMin))

    # MHT selection
    mhtInputCol = 'mhtPFchs'
    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource=cms.InputTag(mhtInputCol), MinMHT=cms.double(MHTMin))

    ## --- HLT decisions --------------------------------------------------
    process.load('RA2Classic.TreeMaker.hltDecisions_cff')

    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(testFileName)
    process.WeightProducer.Lumi = cms.double(19466)
    process.WeightProducer.PU = cms.int32(3)  # PU S10
    process.WeightProducer.FileNamePUDataDistribution = cms.string(
        "RA2Classic/WeightProducer/data/DataPileupHistogram_RA2Summer12_190456-208686_ABCD.root"
    )

    ## --- Setup of TreeMaker ----------------------------------------------
    FilterNames = cms.VInputTag()
    FilterNames.append(
        cms.InputTag("HBHENoiseFilterRA2", "HBHENoiseFilterResult", "PAT"))
    FilterNames.append(cms.InputTag("beamHaloFilter"))
    FilterNames.append(cms.InputTag("trackingFailureFilter"))
    FilterNames.append(cms.InputTag("inconsistentMuons"))
    FilterNames.append(cms.InputTag("greedyMuons"))
    FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
    FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
    FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
    FilterNames.append(cms.InputTag("ecalLaserCorrFilter"))
    FilterNames.append(cms.InputTag("eeBadScFilter"))
    FilterNames.append(cms.InputTag("PBNRFilter"))
    FilterNames.append(cms.InputTag("HCALLaserEvtFilterList2012"))
    FilterNames.append(cms.InputTag("manystripclus53X"))
    FilterNames.append(cms.InputTag("toomanystripclus53X"))
    FilterNames.append(cms.InputTag("logErrorTooManyClusters"))
    FilterNames.append(cms.InputTag("RA2CaloVsPFMHTFilter"))
    FilterNames.append(cms.InputTag("RA2HONoiseFilter"))

    #    for f in process.hltDecisions.moduleNames():
    #        FilterNames.append(cms.InputTag(f))

    from RA2Classic.TreeMaker.treemaker_cfi import TreeMaker
    process.RA2TreeMaker = TreeMaker.clone(
        TreeName=cms.string("RA2PreSelection"),
        VertexCollection=cms.InputTag('goodVertices'),
        HT=cms.InputTag(htInputCol),
        HTJets=cms.InputTag('HTJets'),
        MHT=cms.InputTag(mhtInputCol),
        MHTJets=cms.InputTag('MHTJets'),
        VarsDouble=cms.VInputTag(cms.InputTag('WeightProducer:weight')),
        VarsDoubleNamesInTree=cms.vstring('Weight'),
        METs=cms.VInputTag(mhtInputCol, 'mhtCalo'),
        METNamesInTree=cms.vstring('PFMHT', 'CaloMHT'),
        PatJetCollInputTag=cms.InputTag('patJetsPF'),
        PatJetsMinPt=cms.double(30.),
        PatJetsNameInTree=cms.string('Jets'),
        Filters=FilterNames)

    ## --- Final paths ----------------------------------------------------

    #    process.dump = cms.EDAnalyzer("EventContentAnalyzer")
    process.WriteTree = cms.Path(
        process.HLTSelection *
        #process.hltDecisions *
        process.ProduceRA2Jets *
        #process.filterSelection *
        process.PBNRFilter * process.HCALLaserEvtFilterList2012 *
        process.RA2CaloVsPFMHTFilterSequence * process.RA2HONoiseFilter *
        process.LeptonVeto * process.NumJetSelection * process.HTSelection *
        process.MHTSelection *
        ##        process.dump
        process.WeightProducer * process.RA2TreeMaker)
예제 #14
0
process.trigger.jetCollection = 'patJetsPF'
###############################################################################

###############################################################################
# Filters
###############################################################################
process.load('SandBox.Skims.RA2CaloVsPFMHTFilterSequence_cff')

from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
process.PBNRFilter = jetIDFailure.clone(JetSource=cms.InputTag('patJetsPF'),
                                        MinJetPt=cms.double(30.0),
                                        taggingMode=cms.bool(False))
from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(file=cms.FileInPath(
    'RA2Classic/AdditionalInputFiles/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'
),
                                                            taggingMode=cms.
                                                            bool(False))

process.load("SandBox.Skims.filterBoolean_cfi")
process.RA2_HBHENoiseFilterRA2 = process.booleanFilter.clone()
process.RA2_HBHENoiseFilterRA2.ResultSource = cms.InputTag(
    "HBHENoiseFilterRA2", "HBHENoiseFilterResult", "PAT")
process.RA2_beamHaloFilter = process.booleanFilter.clone()
process.RA2_beamHaloFilter.ResultSource = cms.InputTag("beamHaloFilter")
process.RA2_eeNoiseFilter = process.booleanFilter.clone()
process.RA2_eeNoiseFilter.ResultSource = cms.InputTag("eeNoiseFilter")
process.RA2_trackingFailureFilter = process.booleanFilter.clone()
process.RA2_trackingFailureFilter.ResultSource = cms.InputTag(
    "trackingFailureFilter")
process.RA2_inconsistentMuons = process.booleanFilter.clone()
예제 #15
0
def runTreeMaker(
    process,
    isData=True,
    globalTag="",
    treeName="",
    writePhotons=False,
    writeAdditionalBJetInfos=True,
    hltSelection=[],
    reportEveryEvt=5000,
    testFileName="",
    numProcessedEvt=1000
    ):


    # ---- Configuration ----------------------------------------------------------
    process.load('Configuration.EventContent.EventContent_cff')
    process.load('Configuration.StandardSequences.MagneticField_38T_cff')
    process.load('Configuration.StandardSequences.Reconstruction_cff')
    process.load('Configuration.StandardSequences.EndOfProcess_cff')
    process.load('Configuration.StandardSequences.GeometryDB_cff')
    process.load('Configuration.StandardSequences.Services_cff')
    process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = globalTag

    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
    process.load('RecoBTag.Configuration.RecoBTag_cff')

    process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
    process.load('SimGeneral.MixingModule.mixNoPU_cfi')



    # ---- Message logger ---------------------------------------------------------
    process.load('FWCore.MessageService.MessageLogger_cfi')
    process.load("FWCore.MessageLogger.MessageLogger_cfi")
    process.MessageLogger.cerr.threshold             = 'INFO'
    process.MessageLogger.cerr.FwkReport.reportEvery = reportEveryEvt



    # ---- Input ------------------------------------------------------------------
    process.source = cms.Source(
        "PoolSource",
        fileNames = cms.untracked.vstring(testFileName)	
        )
    process.maxEvents = cms.untracked.PSet(
        input = cms.untracked.int32(numProcessedEvt)
        )
    process.options = cms.untracked.PSet(
        SkipEvent = cms.untracked.vstring('ProductNotFound'),
        Rethrow = cms.untracked.vstring('ProductNotFound'),
        wantSummary = cms.untracked.bool(True)
        )


    
    # ---- Filters ----------------------------------------------------------------
    # HLT
    process.load('HLTrigger.HLTfilters.hltHighLevel_cfi')
    process.hltHighLevel.HLTPaths = cms.vstring(hltSelection)
    process.hltHighLevel.andOr = cms.bool(True)
    process.hltHighLevel.throw = cms.bool(False)

    # standard filter sequence + ecal dead-cell tagger
    process.load('Calibration.CalibTreeMaker.cleaningSequences_cff')
    
    ## Additional event list for Hcal Laser Filter _______________________________||
    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file        = cms.FileInPath('Calibration/CalibTreeMaker/data/HCALLaserEventList_20Nov2012-v2_Jet_JetHT_JetMon.txt'),
        taggingMode = cms.bool(False)
        )

    # sequence with filters
    process.filterSequence = cms.Sequence(
        process.hltHighLevel *
        process.stdCleaningSequence *
        process.HCALLaserEvtFilterList2012 
        )

    if not isData:
        process.filterSequence.remove( process.hltHighLevel )
        process.filterSequence.remove( process.HCALLaserEvtFilterList2012 )



    # ---- Tree makers ------------------------------------------------------------
    process.load("Calibration.CalibTreeMaker.CalibTreeMaker_cff")

    if isData:
        process.tmAK5CaloL1FastJet = process.calibTreeMakerAK5FastCaloData.clone(
            TreeName                       = treeName,
            WritePhotons                   = writePhotons,
            WriteAdditionalBJetInfos       = writeAdditionalBJetInfos
            )
    
        process.tmAK5PFL1FastJet = process.calibTreeMakerAK5FastPFData.clone(
            TreeName                       = process.tmAK5CaloL1FastJet.TreeName,
            WritePhotons                   = process.tmAK5CaloL1FastJet.WritePhotons,
            WriteAdditionalBJetInfos       = process.tmAK5CaloL1FastJet.WriteAdditionalBJetInfos
            )
    
        process.tmAK5PFL1CHS = process.calibTreeMakerAK5PFCHSData.clone(
            TreeName                       = process.tmAK5CaloL1FastJet.TreeName,
            WritePhotons                   = process.tmAK5CaloL1FastJet.WritePhotons,
            WriteAdditionalBJetInfos       = process.tmAK5CaloL1FastJet.WriteAdditionalBJetInfos
            )
    
        process.tmAK5withNuPFL1CHS = process.calibTreeMakerAK5PFCHSData.clone(
            OutputFile                     = cms.string('ak5withNuPFCHS.root'),
            TreeName                       = process.tmAK5CaloL1FastJet.TreeName,
            WritePhotons                   = process.tmAK5CaloL1FastJet.WritePhotons,
            WriteAdditionalBJetInfos       = process.tmAK5CaloL1FastJet.WriteAdditionalBJetInfos
            )
    
        process.products = cms.Sequence(
            process.calibjets *
            process.produceAllCaloMETCorrections *
            process.produceAllPFMETCorrections *
            process.produceAllPFCHSMETCorrections
            )
    if not isData:
        process.tmAK5CaloL1FastJet = process.calibTreeMakerAK5FastCalo.clone(
            NJet_GenJets                   = cms.InputTag("ak5GenJets"),
            TreeName                       = treeName,
            WritePhotons                   = writePhotons,
            WriteAdditionalBJetInfos       = writeAdditionalBJetInfos
            )
    
        process.tmAK5PFL1FastJet = process.calibTreeMakerAK5FastPF.clone(
            NJet_GenJets                   = cms.InputTag("ak5GenJets"),
            TreeName                       = process.tmAK5CaloL1FastJet.TreeName,
            WritePhotons                   = process.tmAK5CaloL1FastJet.WritePhotons,
            WriteAdditionalBJetInfos       = process.tmAK5CaloL1FastJet.WriteAdditionalBJetInfos
            )
    
        process.tmAK5PFL1CHS = process.calibTreeMakerAK5PFCHS.clone(
            NJet_GenJets                   = cms.InputTag("ak5GenJets"),
            TreeName                       = process.tmAK5CaloL1FastJet.TreeName,
            WritePhotons                   = process.tmAK5CaloL1FastJet.WritePhotons,
            WriteAdditionalBJetInfos       = process.tmAK5CaloL1FastJet.WriteAdditionalBJetInfos
            )
    
        process.tmAK5withNuPFL1CHS = process.calibTreeMakerAK5PFCHS.clone(
            OutputFile                     = cms.string('ak5withNuPFCHS.root'),
            NJet_GenJets                   = cms.InputTag("ak5GenJets"),
            TreeName                       = process.tmAK5CaloL1FastJet.TreeName,
            WritePhotons                   = process.tmAK5CaloL1FastJet.WritePhotons,
            WriteAdditionalBJetInfos       = process.tmAK5CaloL1FastJet.WriteAdditionalBJetInfos
            )


        process.products = cms.Sequence(
            process.calibTreeMakerGenJetsNoNuNoMuNoNu *
#            genJetParticles * recoGenJets * recoAllGenJetsNoNu
            process.calibjets *
            process.produceAllCaloMETCorrections *
            process.produceAllPFMETCorrections *
            process.produceAllPFCHSMETCorrections *
            process.genPhotons *
            process.goodGenPhotons *
            process.myPartons *
#            process.JPTJetPartonMatching *
            process.CaloJetPartonMatching *
            process.PFJetPartonMatching *
            process.AK5PFCHSJetPartonMatching
            )



    # ---- Path -------------------------------------------------------------------
    process.dump = cms.EDAnalyzer("EventContentAnalyzer")
    process.makeTrees = cms.Path(
        process.filterSequence *
#        process.dump *
        process.products *
        process.softElectronCands *
#        process.ak5JPTJetsBtag *
#        process.tmAK5JPTL1Offset *
        process.ak5CaloJetsBtag *
        process.tmAK5CaloL1FastJet *
        process.ak5PFJetsBtag *
        process.tmAK5PFL1FastJet *
        process.ak5PFCHSJetsBtag *
        process.tmAK5PFL1CHS*
        process.tmAK5withNuPFL1CHS
        )

    process.schedule = cms.Schedule(process.makeTrees)
예제 #16
0
###############################################################################

###############################################################################
# Filters
###############################################################################
process.load('SandBox.Skims.RA2CaloVsPFMHTFilterSequence_cff')

from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
process.PBNRFilter = jetIDFailure.clone(
    JetSource = cms.InputTag('patJetsPF'),
    MinJetPt      = cms.double(30.0),
    taggingMode   = cms.bool(False)
    )
from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    file        = cms.FileInPath('RA2Classic/AdditionalInputFiles/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'),
    taggingMode = cms.bool(False)
    )

process.load("SandBox.Skims.filterBoolean_cfi")
process.RA2_HBHENoiseFilterRA2    = process.booleanFilter.clone()
process.RA2_HBHENoiseFilterRA2.ResultSource = cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT")
process.RA2_beamHaloFilter        = process.booleanFilter.clone()
process.RA2_beamHaloFilter.ResultSource = cms.InputTag("beamHaloFilter")
process.RA2_eeNoiseFilter         = process.booleanFilter.clone()
process.RA2_eeNoiseFilter.ResultSource = cms.InputTag("eeNoiseFilter")
process.RA2_trackingFailureFilter = process.booleanFilter.clone()
process.RA2_trackingFailureFilter.ResultSource = cms.InputTag("trackingFailureFilter")
process.RA2_inconsistentMuons     = process.booleanFilter.clone()
process.RA2_inconsistentMuons.ResultSource = cms.InputTag("inconsistentMuons")
process.RA2_greedyMuons           = process.booleanFilter.clone()
process.RA2_greedyMuons.ResultSource = cms.InputTag("greedyMuons")
예제 #17
0
def makeTreeFromPAT(
        process,
        outFileName,
        useCHSJets=True,
        invertLeptonVeto=False,
        NJetsMin=2,
        HTMin=500.,
        MHTMin=200.,
        reportEveryEvt=10,
        Global_Tag="",
        MCTAP=True,
        Muon=False,
        muonTrigger="",
        testFileName=[
            "/store/user/kheine/HT/RA2PreSelectionOnData_Run2012A_HT_PromptReco-v1_v5/71cce229addb17644d40a607fa20b5d7/RA2SkimsOnData_99_3_TPC.root"
        ],
        numProcessedEvt=1000):

    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
    process.GlobalTag.globaltag = Global_Tag

    ## --- Log output ------------------------------------------------------
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr = cms.untracked.PSet(
        placeholder=cms.untracked.bool(True))
    process.MessageLogger.statistics.append('cout')
    process.MessageLogger.cout = cms.untracked.PSet(INFO=cms.untracked.PSet(
        reportEvery=cms.untracked.int32(reportEveryEvt)))

    ## --- Files to process ------------------------------------------------
    process.maxEvents = cms.untracked.PSet(
        input=cms.untracked.int32(numProcessedEvt))
    process.source = cms.Source("PoolSource",
                                fileNames=cms.untracked.vstring(testFileName))

    ## --- Output file -----------------------------------------------------
    process.TFileService = cms.Service("TFileService",
                                       fileName=cms.string(outFileName +
                                                           ".root"))

    ## --- Selection sequences ---------------------------------------------

    # Filter-related selection
    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    process.load('SandBox.Skims.RA2Leptons_cff')

    process.CleaningSelection = cms.Sequence(process.filterSelection)

    # Filter-related selection
    #    process.load('RA2Classic.TreeMaker.filterSelection_cff')
    #    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    #    process.PBNRFilter = jetIDFailure.clone(
    #        JetSource = cms.InputTag('MHTJets'),
    #        MinJetPt      = cms.double(30.0),
    #        taggingMode   = cms.bool(False)
    #        )
    #    process.filterSelection += process.PBNRFilter
    #    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    #    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
    #        file        = cms.FileInPath('EventFilter/HcalRawToDigi/data/AllBadHCALLaser.txt'),
    #        taggingMode = cms.bool(False)
    #        )
    #   process.filterSelection += process.HCALLaserEvtFilterList2012

    # Produce RA2 jets
    if useCHSJets:
        process.load('RA2Classic.Utils.produceRA2JetsPFCHS_cff')
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsPFCHS)
    else:
        process.load('RA2Classic.Utils.produceRA2JetsAK5PF_cff')
        process.ProduceRA2Jets = cms.Sequence(process.produceRA2JetsAK5PF)

    # Select events with at least 'NJetsMin' of the above jets
    from PhysicsTools.PatAlgos.selectionLayer1.jetCountFilter_cfi import countPatJets
    process.NumJetSelection = countPatJets.clone(
        src=cms.InputTag('HTJets'), minNumber=cms.uint32(NJetsMin))

    # HT selection
    htInputCol = 'htPF'
    if useCHSJets:
        htInputCol = 'htPFchs'

    from SandBox.Skims.RA2HT_cff import htPFFilter
    process.HTSelection = htPFFilter.clone(HTSource=cms.InputTag(htInputCol),
                                           MinHT=cms.double(HTMin))

    # MHT selection
    mhtMin = 0.
    mhtInputCol = 'mhtPF'
    if useCHSJets:
        mhtInputCol = 'mhtPFchs'

    from SandBox.Skims.RA2MHT_cff import mhtPFFilter
    process.MHTSelection = mhtPFFilter.clone(
        MHTSource=cms.InputTag(mhtInputCol), MinMHT=cms.double(MHTMin))

    ## --- Additional Filters (not tagging mode) ------------------------------
    from RecoMET.METFilters.jetIDFailureFilter_cfi import jetIDFailure
    process.PBNRFilter = jetIDFailure.clone(JetSource=cms.InputTag('MHTJets'),
                                            MinJetPt=cms.double(30.0),
                                            taggingMode=cms.bool(False))

    from RecoMET.METFilters.multiEventFilter_cfi import multiEventFilter
    process.HCALLaserEvtFilterList2012 = multiEventFilter.clone(
        file=cms.FileInPath(
            'RA2Classic/LostLeptonBkg/data/HCALLaserEventList_20Nov2012-v2_HT-HTMHT.txt'
        ),
        taggingMode=cms.bool(False))

    process.AdditionalFiltersInTagMode = cms.Sequence(process.PBNRFilter)

    ## --- Setup WeightProducer -------------------------------------------
    from RA2Classic.WeightProducer.getWeightProducer_cff import getWeightProducer
    process.WeightProducer = getWeightProducer(process.source.fileNames[0])

    ## --- Setup of TreeMaker ----------------------------------------------
    FilterNames = cms.VInputTag()  # All filters in AdditionalFiltersInTagMode
    for f in process.AdditionalFiltersInTagMode.moduleNames():
        FilterNames.append(cms.InputTag(f))

##     FilterNames.append(cms.InputTag("HBHENoiseFilterRA2","HBHENoiseFilterResult","PAT"))
##     FilterNames.append(cms.InputTag("beamHaloFilter"))
##     FilterNames.append(cms.InputTag("eeNoiseFilter"))
##     FilterNames.append(cms.InputTag("trackingFailureFilter"))
##     FilterNames.append(cms.InputTag("inconsistentMuons"))
##     FilterNames.append(cms.InputTag("greedyMuons"))
##     FilterNames.append(cms.InputTag("ra2EcalTPFilter"))
##     FilterNames.append(cms.InputTag("ra2EcalBEFilter"))
##     FilterNames.append(cms.InputTag("hcalLaserEventFilter"))
##     FilterNames.append(cms.InputTag("eeBadScFilter"))

    process.load('Configuration.EventContent.EventContent_cff')
    process.load('Configuration.StandardSequences.MagneticField_38T_cff')
    process.load('Configuration.StandardSequences.Reconstruction_cff')
    process.load('Configuration.StandardSequences.EndOfProcess_cff')
    process.load('Configuration.StandardSequences.GeometryDB_cff')
    process.load('Configuration.StandardSequences.Services_cff')

    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")

    process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff")
    from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import useExistingPATMuons
    useExistingPATMuons(process, "patMuons")

    #    process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff")

    triggerProcessName = "HLT"
    triggerPathSelector = "HLT_Ele27_WP80_v*"
    matchedCutsString = ' path( "' + triggerPathSelector + '",1,0 )'

    # filter used to slecte the RA2 baseline important for efficiency caluclaiton
    from RA2Classic.Utils.RA2Selection_cfi import RA2Selection
    process.RA2Selector = RA2Selection.clone(
        nJets=cms.uint32(1),
        HTMin=cms.double(50),
        MHTMin=cms.double(0),
    )

    ## ---- Load lost lepton moduels
    # special calo jets for delta R in efficiencies
    process.load('JetMETCorrections.Configuration.DefaultJEC_cff')

    from RA2Classic.LostLeptonBkg.promtisomu_cfi import promtIsoMu
    process.promtLeptons = promtIsoMu.clone(
        MuonIDISOTag=cms.InputTag("patMuonsPFIDIso"),
        CaloJetTag=cms.InputTag("ak5CaloJetsL2L3"),
        #	CaloJetTag	= cms.InputTag('cleanPatJetsAK5Calo'),
    )
    from RA2Classic.LostLeptonBkg.tapTreeProducer_cfi import tapTreeProducer
    process.tapTreeMuId = tapTreeProducer.clone(
        HTTag=cms.InputTag(htInputCol),
        MHTTag=cms.InputTag(mhtInputCol),
        MC=cms.bool(MCTAP),
        Muon=True,
        MuonTrigger=cms.string(muonTrigger),
    )
    process.tapTreeMuIso = process.tapTreeMuId.clone(MuElecIdIso=cms.uint32(1),
                                                     Muon=True)
    process.tapTreeElecId = process.tapTreeMuId.clone(
        MuElecIdIso=cms.uint32(2), Muon=False)
    process.tapTreeElecIso = process.tapTreeMuId.clone(
        MuElecIdIso=cms.uint32(3), Muon=False)
    process.tapTreeElecIdGsf = process.tapTreeMuId.clone(
        MuElecIdIso=cms.uint32(4), Muon=False)

    #electrons selectors for ID electrons
    from SandBox.Skims.RA2Leptons_cff import patElectronsID
    from SandBox.Skims.RA2Leptons_cff import patElectronsIDIso
    process.ra2ElectronsID = patElectronsID.clone()
    process.ra2ElectronsIDIso = patElectronsIDIso.clone()

    # JES variation for MET
    from RA2Classic.Utils.jesUncertaintyVariation_cfi import jesUncertaintyVariation
    process.jesUp = jesUncertaintyVariation.clone(
        Jets=cms.InputTag('MHTJets'),  # The input jet collection
        JetTypeId=cms.string(
            'AK5PFchs'
        ),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation=cms.string(
            'Up'
        )  # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )
    process.jesDown = jesUncertaintyVariation.clone(
        Jets=cms.InputTag('MHTJets'),  # The input jet collection
        JetTypeId=cms.string(
            'AK5PFchs'
        ),  # Type of the input jets (to obtain the uncertainty from the data base). 
        Variation=cms.string(
            'Down'
        )  # Either 'Up' or 'Dn' to produce jets with JES +/- 1 sigma, respectively
    )

    process.tapProducer = cms.Sequence()
    if Muon:
        process.tapProducer += process.patMuonsWithTriggerSequence
        process.tapProducer += process.tapTreeMuId
        process.tapProducer += process.tapTreeMuIso
    else:
        process.tapProducer += process.patMuonsWithTriggerSequence
        process.tapProducer += process.tapTreeElecIdGsf
        process.tapProducer += process.tapTreeElecIso
    if MCTAP:
        process.tapProducer += process.tapTreeMuId
        process.tapProducer += process.tapTreeMuIso
        process.tapProducer += process.tapTreeElecIdGsf
        process.tapProducer += process.tapTreeElecIso

    ## --- Final paths ----------------------------------------------------

    process.dump = cms.EDAnalyzer("EventContentAnalyzer")

    process.WriteTree = cms.Path(
        process.CleaningSelection * process.HCALLaserEvtFilterList2012 *
        process.ProduceRA2Jets * process.NumJetSelection *
        process.HTSelection * process.MHTSelection *
        process.AdditionalFiltersInTagMode * process.WeightProducer *
        process.ra2ElectronsID * process.ra2ElectronsIDIso *
        #	process.jesUp *
        #	process.jesDown *
        #	process.promtLeptons *
        process.RA2Selector *
        #	process.ak5CaloJetsL2L3 *
        process.tapProducer
        #	process.dump *
        #	process.patMuonsWithTriggerSequence *
        #	process.LostLeptonBkgMCEffCalculator *
        #	process.LostLeptonBkgProducer
        #	process.RA2TreeMaker
    )