Exemplo n.º 1
0
process.selectedPatMuons.cut = cms.string('muonID(\"TMOneStationTight\")'
                    ' && abs(innerTrack.dxy) < 0.3'
                    ' && abs(innerTrack.dz)  < 20.'
                    ' && innerTrack.hitPattern.trackerLayersWithMeasurement > 5'
                    ' && innerTrack.hitPattern.pixelLayersWithMeasurement > 0'
                    ' && innerTrack.quality(\"highPurity\")'
                    )

#make patTracks
from PhysicsTools.PatAlgos.tools.trackTools import makeTrackCandidates
makeTrackCandidates(process,
                    label        = 'TrackCands',                  # output collection
                    tracks       = cms.InputTag('generalTracks'), # input track collection
                    particleType = 'pi+',                         # particle type (for assigning a mass)
                    preselection = 'pt > 0.7',                    # preselection cut on candidates
                    selection    = 'pt > 0.7',                    # selection on PAT Layer 1 objects
                    isolation    = {},                            # isolations to use (set to {} for None)
                    isoDeposits  = [],
                    mcAs         = None                           # replicate MC match as the one used for Muons
)
process.patTrackCands.embedTrack = True

# reduce MC genParticles a la miniAOD
process.load('PhysicsTools.PatAlgos.slimming.genParticles_cff')
process.packedGenParticles.inputVertices = cms.InputTag('offlinePrimaryVertices')

### vtxTagInfo
#
#process.load('RecoBTag/SoftLepton/softLepton_cff')
#
##process.load('RecoBTag/SoftLepton/softPFMuonTagInfos_cfi')
Exemplo n.º 2
0
def OnlyTrack_finderMaker_75X(process, AddCaloMuon = False, runOnMC = True, HIFormat = False, UseGenPlusSim = False, VtxLabel = "hiSelectedVertex", TrkLabel = "hiGeneralTracks"):
	### Set TransientTrackBuilder 
	process.load("TrackingTools/TransientTrack/TransientTrackBuilder_cfi")
	
	##Producing Gen list with SIM particles
	process.genParticlePlusGEANT = cms.EDProducer("GenPlusSimParticleProducer",
	        src           = cms.InputTag("g4SimHits"), # use "famosSimHits" for FAMOS
	        setStatus     = cms.int32(8),             # set status = 8 for GEANT GPs
	        filter        = cms.vstring("pt > 0.0"),  # just for testing (optional)
		    genParticles   = cms.InputTag("genParticles") # original genParticle list
	)
	
	### Setup Pat
#	process.load("PhysicsTools.PatAlgos.patSequences_cff")
	###### Needed in CMSSW7
#	process.particleFlowPtrs.src = "particleFlowTmp"
#	process.pfPileUpIsoPFBRECO.Vertices = cms.InputTag(VtxLabel)
#	process.pfPileUpPFBRECO.Vertices = cms.InputTag(VtxLabel)
	###### Needed in CMSSW7
	
	if HIFormat:
#		process.muonMatch.matched = cms.InputTag("hiGenParticles")
		process.genParticlePlusGEANT.genParticles = cms.InputTag("hiGenParticles")
	
	##Using GEN plus SIM list for matching
#	if UseGenPlusSim:
#		process.muonMatch.matched = cms.InputTag("genParticlePlusGEANT")
	
	process.load('PhysicsTools/PatAlgos/mcMatchLayer0/muonMatch_cfi')

	## TrackCand
	from PhysicsTools.PatAlgos.tools.trackTools import makeTrackCandidates
	if runOnMC:
	    makeTrackCandidates(process,              # patAODTrackCands
	        label='TrackCands',                   # output collection will be 'allLayer0TrackCands', 'allLayer1TrackCands', 'selectedLayer1TrackCands'
	        tracks=cms.InputTag(TrkLabel), # input track collection
	    	particleType='pi+',                   # particle type (for assigning a mass)
	        preselection='pt > 0.3',              # preselection cut on candidates. Only methods of 'reco::Candidate' are available
	        selection='pt > 0.3',                 # Selection on PAT Layer 1 objects ('selectedLayer1TrackCands')
	    	isolation={},                         # Isolations to use ('source':deltaR; set to {} for None)
	       	isoDeposits=[],
	        mcAs='muon'                           # Replicate MC match as the one used for Muons
	    );                                        # you can specify more than one collection for this
	    ### MC+mcAs+Match/pat_label options
	    #process.patTrackCandsMCMatch.matched = cms.InputTag("hiGenParticles")
	    process.patTrackCandsMCMatch.resolveByMatchQuality = cms.bool(True)
	    process.patTrackCandsMCMatch.resolveAmbiguities = cms.bool(True)
	    process.patTrackCandsMCMatch.checkCharge = cms.bool(True)
	    process.patTrackCandsMCMatch.maxDPtRel = cms.double(0.5)
	    process.patTrackCandsMCMatch.maxDeltaR = cms.double(0.7)
	    process.patTrackCandsMCMatch.mcPdgId = cms.vint32(111, 211, 311, 321)
	    process.patTrackCandsMCMatch.mcStatus = cms.vint32(1)
	    l1cands = getattr(process, 'patTrackCands')
	    l1cands.addGenMatch = True
	
	else :
	    makeTrackCandidates(process,              # patAODTrackCands
	        label='TrackCands',                   # output collection will be 'allLayer0TrackCands', 'allLayer1TrackCands', 'selectedLayer1TrackCands'
	        tracks=cms.InputTag(TrkLabel), # input track collection
	        particleType='pi+',                   # particle type (for assigning a mass)
	        preselection='pt > 0.3',              # preselection cut on candidates. Only methods of 'reco::Candidate' are available
	        selection='pt > 0.3',                 # Selection on PAT Layer 1 objects ('selectedLayer1TrackCands')
	        isolation={},                         # Isolations to use ('source':deltaR; set to {} for None)
	        isoDeposits=[],
	        mcAs=None                             # Replicate MC match as the one used for Muons
	    );                                        # you can specify more than one collection for this
	    l1cands = getattr(process, 'patTrackCands')
	    l1cands.addGenMatch = False
	if runOnMC:
		process.TrackCandSequence = cms.Sequence(process.patAODTrackCandsUnfiltered*process.patAODTrackCands*process.patTrackCandsMCMatch*process.patTrackCands*process.selectedPatTrackCands)
	else:
		process.TrackCandSequence = cms.Sequence(process.patAODTrackCandsUnfiltered*process.patAODTrackCands*process.patTrackCands*process.selectedPatTrackCands)
	
	## patMuonsWithTrigger
#	process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff")
#	from MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff import addMCinfo, useL1MatchingWindowForSinglets, changeTriggerProcessName, switchOffAmbiguityResolution, addHLTL1Passthrough
#	#process.patMuonsWithTriggerSequence = cms.Sequence(process.pfParticleSelectionForIsoSequence*process.muonPFIsolationPATSequence*process.patMuonsWithTriggerSequence)
#	process.patMuonsWithTriggerSequence = cms.Sequence(process.patMuonsWithTriggerSequence)
#	process.patMuonsWithoutTrigger.isoDeposits = cms.PSet()
#	process.patMuonsWithoutTrigger.isolationValues = cms.PSet()
#	process.patMuonsWithoutTrigger.pvSrc = cms.InputTag(VtxLabel)
#	if runOnMC:
#		addMCinfo(process)
#		process.muonMatch.maxDeltaR = cms.double(0.05)
#		process.muonMatch.resolveByMatchQuality = True
#
#	changeTriggerProcessName(process, "HLT")
#	switchOffAmbiguityResolution(process) # Switch off ambiguity resolution: allow multiple reco muons to match to the same trigger muon
#	addHLTL1Passthrough(process)
#
#	process.patTrigger.collections.remove("hltL3MuonCandidates")
#	process.patTrigger.collections.append("hltHIL3MuonCandidates")
#
#	process.muonL1Info.maxDeltaR = 0.3
#	process.muonL1Info.fallbackToME1 = True
#	process.muonMatchHLTL1.maxDeltaR = 0.3
#	process.muonMatchHLTL1.fallbackToME1 = True
#	process.muonMatchHLTL2.maxDeltaR = 0.3
#	process.muonMatchHLTL2.maxDPtRel = 10.0
#	process.muonMatchHLTL3.maxDeltaR = 0.1
#	process.muonMatchHLTL3.maxDPtRel = 10.0
#	process.muonMatchHLTCtfTrack.maxDeltaR = 0.1
#	process.muonMatchHLTCtfTrack.maxDPtRel = 10.0
#	process.muonMatchHLTTrackMu.maxDeltaR = 0.1
#	process.muonMatchHLTTrackMu.maxDPtRel = 10.0
#	process.muonMatchHLTL3.matchedCuts = cms.string('coll("hltHIL3MuonCandidates")')
#	
#	# Merge muons, calomuons in a single collection for T&P
#	from RecoMuon.MuonIdentification.calomuons_cfi import calomuons;
#	process.mergedMuons = cms.EDProducer("CaloMuonMerger",                                                                                                                                                  
#	    muons     = cms.InputTag("muons"),
#	    mergeCaloMuons = cms.bool(True),  ### NEEDED TO RUN ON AOD
#	    caloMuons = cms.InputTag("calomuons"),
#	    minCaloCompatibility = cms.double(0.6),
#	    mergeTracks = cms.bool(False),
#	    tracks = cms.InputTag(TrkLabel),
#	)
#	if AddCaloMuon:
#	    #changeRecoMuonInput(process, "mergedMuons")#Add calo muon to the collection
#	    #process.patMuons.muonSource = cms.InputTag("mergedMuons")#Need to use the same collection as they are internally entengled
#	    #process.patMuons.embedCaloMETMuonCorrs = cms.bool(False)
#	    #process.patMuons.embedTcMETMuonCorrs   = cms.bool(False)
#	
#	    #Or we change the muonMatch source of our patMuonsWithoutTrigger
#	    process.patMuonsWithoutTrigger.muonSource = cms.InputTag("mergedMuons")
#	    process.patMuonsWithoutTriggerMatch = PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi.muonMatch.clone( src = cms.InputTag("mergedMuons"))
#	    if runOnMC:
#	        process.patMuonsWithTriggerSequence.replace(process.patMuonsWithoutTrigger, process.patMuonsWithoutTriggerMatch + process.patMuonsWithoutTrigger)
#	        process.patMuonsWithoutTrigger.genParticleMatch = 'patMuonsWithoutTriggerMatch'
#	    process.patMuonsWithTriggerSequence = cms.Sequence(process.mergedMuons*process.patMuonsWithTriggerSequence)
	
	### Set Bfinder option
	process.Bfinder = cms.EDAnalyzer('Bfinder',
		Bchannel 		= cms.vint32(
			1,#RECONSTRUCTION: J/psi + K
			0,#RECONSTRUCTION: J/psi + Pi
			0,#RECONSTRUCTION: J/psi + Ks 
			0,#RECONSTRUCTION: J/psi + K* (K+, Pi-)
			0,#RECONSTRUCTION: J/psi + K* (K-, Pi+)
			0,#RECONSTRUCTION: J/psi + phi
			1,#RECONSTRUCTION: J/psi + pi pi <= psi', X(3872), Bs->J/psi f0
		),
        detailMode = cms.bool(True),
        dropUnusedTracks = cms.bool(True),
	    MuonTriggerMatchingPath = cms.vstring(""),
		MuonTriggerMatchingFilter = cms.vstring(""),
		HLTLabel = cms.InputTag('TriggerResults::HLT'),
	    GenLabel = cms.InputTag('genParticles'),
		MuonLabel = cms.InputTag('patMuonsWithTrigger'),
		TrackLabel = cms.InputTag('patTrackCands'),
        MVAMapLabel = cms.InputTag(TrkLabel),
	    PUInfoLabel = cms.InputTag("addPileupInfo"),
	    BSLabel = cms.InputTag("offlineBeamSpot"),
	    PVLabel = cms.InputTag(VtxLabel),
	    tkPtCut = cms.double(1.0),#before fit
	    tkEtaCut = cms.double(999.0),#before fit
	    jpsiPtCut = cms.double(0.0),#before fit
	    uj_VtxChiProbCut = cms.double(0.01),
	    bPtCut = cms.vdouble(5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0),#before fit
	    bEtaCut = cms.vdouble(2.4, 2.4, 2.4, 2.4, 2.4, 2.4, 2.4),#before fit, not used currently
		VtxChiProbCut = cms.vdouble(0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01),
	    svpvDistanceCut = cms.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
	    MaxDocaCut = cms.vdouble(999., 999., 999., 999., 999., 999., 999.),
	    alphaCut = cms.vdouble(999., 999., 999., 999., 999., 999., 999.),
	    RunOnMC = cms.bool(False),
	    doTkPreCut = cms.bool(True),
	    doMuPreCut = cms.bool(True),
	    makeBntuple = cms.bool(True),
	    doBntupleSkim = cms.bool(False),
	)
	### Set Dfinder option
	process.Dfinder = cms.EDAnalyzer('Dfinder',
		Dchannel 		= cms.vint32(
	        1,#RECONSTRUCTION: K+pi- : D0bar
	        1,#RECONSTRUCTION: K-pi+ : D0
	        0,#RECONSTRUCTION: K-pi+pi+ : D+
	        0,#RECONSTRUCTION: K+pi-pi- : D-
	        0,#RECONSTRUCTION: K-pi-pi+pi+ : D0
	        0,#RECONSTRUCTION: K+pi+pi-pi- : D0bar
	        0,#RECONSTRUCTION: K+K-(Phi)pi+ : Ds+
	        0,#RECONSTRUCTION: K+K-(Phi)pi- : Ds-
	        0,#RECONSTRUCTION: D0(K-pi+)pi+ : D+*
	        0,#RECONSTRUCTION: D0bar(K+pi-)pi- : D-*
	        0,#RECONSTRUCTION: D0(K-pi-pi+pi+)pi+ : D+*
	        0,#RECONSTRUCTION: D0bar(K+pi+pi-pi-)pi- : D-*
		),
        detailMode = cms.bool(False),
        dropUnusedTracks = cms.bool(True),
		HLTLabel = cms.InputTag('TriggerResults::HLT'),
	    GenLabel = cms.InputTag('genParticles'),
		TrackLabel = cms.InputTag('patTrackCands'),
		MVAMapLabel = cms.InputTag(TrkLabel),
	    PUInfoLabel = cms.InputTag("addPileupInfo"),
	    BSLabel = cms.InputTag("offlineBeamSpot"),
	    PVLabel = cms.InputTag(VtxLabel),
	    tkPtCut = cms.double(1.),#before fit
	    tkEtaCut = cms.double(2.0),#before fit
	    dPtCut = cms.vdouble(8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.),#before fit
	    dEtaCut = cms.vdouble(1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5),#before fit, not used currently
		VtxChiProbCut = cms.vdouble(0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),#better not to cut for decay with resonance, cutting on both mother and daughter vertex fit now
	    dCutSeparating_PtVal = cms.vdouble(5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5.),
	    tktkRes_svpvDistanceCut_lowptD = cms.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0, 2.0),#if cut, only cut on last four channels, D*->D0
	    tktkRes_svpvDistanceCut_highptD = cms.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0, 2.0),#if cut, only cut on last four channels, D*->D0
		tktkRes_alphaCut = cms.vdouble(999., 999., 999., 999., 999., 999., 999., 999., 999., 999., 999., 999.),#if cut, only cut on last four channels, D*->D0
	    svpvDistanceCut_lowptD = cms.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
	    svpvDistanceCut_highptD = cms.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
	    MaxDocaCut = cms.vdouble(999., 999., 999., 999., 999., 999., 999., 999., 999., 999., 999., 999.),
	    alphaCut = cms.vdouble(999., 999., 999., 999., 999., 999., 999., 999., 999., 999., 999., 999.),
	    RunOnMC = cms.bool(False),
	    doTkPreCut = cms.bool(True),
	    makeDntuple = cms.bool(True),
	    doDntupleSkim = cms.bool(False),
        printInfo = cms.bool(False),
	)
	if runOnMC:
	    process.Bfinder.RunOnMC = cms.bool(True)
	    process.Dfinder.RunOnMC = cms.bool(True)
	if HIFormat:
		process.Bfinder.GenLabel = cms.InputTag('hiGenParticles')
		process.Dfinder.GenLabel = cms.InputTag('hiGenParticles')
	if UseGenPlusSim:
		process.Bfinder.GenLabel = cms.InputTag('genParticlePlusGEANT')
		process.Dfinder.GenLabel = cms.InputTag('genParticlePlusGEANT')
	
#	if runOnMC and UseGenPlusSim:
#		process.patMuonsWithTriggerSequence *= process.genParticlePlusGEANT
	
#	process.BfinderSequence = cms.Sequence(process.patMuonsWithTriggerSequence*process.TrackCandSequence*process.Bfinder)
	process.DfinderSequence = cms.Sequence(process.TrackCandSequence*process.Dfinder)
Exemplo n.º 3
0
def CompactSkim(process,inFileNames,outFileName,Global_Tag='auto:run2_mc',MC=True,Filter=True):

   patAlgosToolsTask = getPatAlgosToolsTask(process)

   process.load('Configuration.StandardSequences.Services_cff')
   process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
   process.load('FWCore.MessageService.MessageLogger_cfi')
   process.load('Configuration.EventContent.EventContent_cff')
   process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
   process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
   process.load('Configuration.StandardSequences.EndOfProcess_cff')
   patAlgosToolsTask.add(process.MEtoEDMConverter)
   process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff')

   process.MessageLogger.cerr.FwkReport.reportEvery = 100
   process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) )
   process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring(inFileNames))
   process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

   from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
   process.GlobalTag = GlobalTag(process.GlobalTag, Global_Tag, '')

   # make patCandidates, select and clean them
   process.load('PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff')
   patAlgosToolsTask.add(process.patCandidatesTask)
   process.load('PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff')
   patAlgosToolsTask.add(process.selectedPatCandidatesTask)
   process.load('PhysicsTools.PatAlgos.cleaningLayer1.cleanPatCandidates_cff')
   patAlgosToolsTask.add(process.cleanPatCandidatesTask)
   process.patMuons.embedTrack  = True

   process.selectedPatMuons.cut = cms.string('muonID(\"TMOneStationTight\")'
                    ' && abs(innerTrack.dxy) < 0.3'
                    ' && abs(innerTrack.dz)  < 20.'
                    ' && innerTrack.hitPattern.trackerLayersWithMeasurement > 5'
                    ' && innerTrack.hitPattern.pixelLayersWithMeasurement > 0'
                    ' && innerTrack.quality(\"highPurity\")'
                    )

   #make patTracks
   from PhysicsTools.PatAlgos.tools.trackTools import makeTrackCandidates
   makeTrackCandidates(process,
                       label        = 'TrackCands',                  # output collection
                       tracks       = cms.InputTag('generalTracks'), # input track collection
                       particleType = 'pi+',                         # particle type (for assigning a mass)
                       preselection = 'pt > 0.7',                    # preselection cut on candidates
                       selection    = 'pt > 0.7',                    # selection on PAT Layer 1 objects
                       isolation    = {},                            # isolations to use (set to {} for None)
                       isoDeposits  = [],
                       mcAs         = None                           # replicate MC match as the one used for Muons
   )
   process.patTrackCands.embedTrack = True

   # dimuon = Onia2MUMU
   process.load('HeavyFlavorAnalysis.Onia2MuMu.onia2MuMuPAT_cfi')
   patAlgosToolsTask.add(process.onia2MuMuPAT)
   process.onia2MuMuPAT.muons=cms.InputTag('cleanPatMuons')
   process.onia2MuMuPAT.primaryVertexTag=cms.InputTag('offlinePrimaryVertices')
   process.onia2MuMuPAT.beamSpotTag=cms.InputTag('offlineBeamSpot')

   process.onia2MuMuPATCounter = cms.EDFilter('CandViewCountFilter',
      src = cms.InputTag('onia2MuMuPAT'),
      minNumber = cms.uint32(1),
      filter = cms.bool(True)
   )

   # reduce MC genParticles a la miniAOD
   process.load('PhysicsTools.PatAlgos.slimming.genParticles_cff')
   patAlgosToolsTask.add(process.genParticlesTask)
   process.packedGenParticles.inputVertices = cms.InputTag('offlinePrimaryVertices')

   # make photon candidate conversions for P-wave studies
   process.load('HeavyFlavorAnalysis.Onia2MuMu.OniaPhotonConversionProducer_cfi')
   patAlgosToolsTask.add(process.PhotonCandidates)

   # add v0 with tracks embed
   process.load('HeavyFlavorAnalysis.Onia2MuMu.OniaAddV0TracksProducer_cfi')
   patAlgosToolsTask.add(process.oniaV0Tracks)

   # Pick branches you want to keep
   SlimmedEventContent = [
                     'keep recoVertexs_offlinePrimaryVertices_*_*',
                     'keep *_inclusiveSecondaryVertices_*_*',
                     'keep *_offlineBeamSpot_*_*',
                     'keep *_TriggerResults_*_HLT',
                     'keep *_gtDigis_*_RECO',
                     'keep *_cleanPatTrackCands_*_*',
                     'keep *_PhotonCandidates_*_*',
                     'keep *_onia2MuMuPAT_*_*',
                     'keep *_generalV0Candidates_*_*',
                     'keep *_oniaV0Tracks_*_*',
                     'keep PileupSummaryInfos_*_*_*'
   ]

   if not MC:
      from PhysicsTools.PatAlgos.tools.coreTools import runOnData
      runOnData( process, outputModules = [] )
   else :
      SlimmedEventContent += [
                     'keep patPackedGenParticles_packedGenParticles_*_*',
                     'keep recoGenParticles_prunedGenParticles_*_*',
                     'keep GenFilterInfo_*_*_*',
                     'keep GenEventInfoProduct_generator_*_*',
                     'keep GenRunInfoProduct_*_*_*'
      ]

   process.FilterOutput = cms.Path(process.onia2MuMuPATCounter)

   process.out = cms.OutputModule('PoolOutputModule',
      fileName = cms.untracked.string(outFileName),
      outputCommands = cms.untracked.vstring('drop *', *SlimmedEventContent),
      SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring('FilterOutput')) if Filter else cms.untracked.PSet()
   )
   
   process.outpath = cms.EndPath(process.out, patAlgosToolsTask)
#process.load("PhysicsTools.PatAlgos.patSequences_cff")

# make patCandidates, select and clean them
process.load('PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff')
process.load('PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff')
process.load('PhysicsTools.PatAlgos.cleaningLayer1.cleanPatCandidates_cff')
#process.patMuons.embedTrack  = True

#make patTracks
from PhysicsTools.PatAlgos.tools.trackTools import makeTrackCandidates
makeTrackCandidates(process,
                    label        = 'TrackCands',                  # output collection
                    tracks       = cms.InputTag('generalTracks'), # input track collection
                   ## particleType = 'pi+',                         # particle type (for assigning a mass)
                    particleType = 'K+',                         # particle type (for assigning a mass)
                    preselection = 'pt > 0.4',                    # preselection cut on candidates
                    selection    = 'pt > 0.4',                    # selection on PAT Layer 1 objects
                    isolation    = {},                            # isolations to use (set to {} for None)
                    isoDeposits  = [],
                    mcAs         = None                           # replicate MC match as the one used for Muons
                    )



process.load('PhysicsTools.PatAlgos.slimming.genParticles_cff')
process.packedGenParticles.inputVertices = cms.InputTag('offlinePrimaryVertices')

from PhysicsTools.PatAlgos.tools.coreTools import runOnData
runOnData( process, outputModules = [] )

process.ntuple = cms.EDAnalyzer(
Exemplo n.º 5
0
def CompactSkim(process,
                inFileNames,
                outFileName,
                Global_Tag='auto:run2_mc',
                MC=True,
                Filter=True):

    process.load('Configuration.StandardSequences.Services_cff')
    process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
    process.load('FWCore.MessageService.MessageLogger_cfi')
    process.load('Configuration.EventContent.EventContent_cff')
    process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
    process.load(
        'Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
    process.load('Configuration.StandardSequences.EndOfProcess_cff')
    process.load(
        'Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff'
    )

    process.MessageLogger.cerr.FwkReport.reportEvery = 100
    process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(False))
    process.options.allowUnscheduled = cms.untracked.bool(True)
    process.source = cms.Source('PoolSource',
                                fileNames=cms.untracked.vstring(inFileNames))
    process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))

    from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
    process.GlobalTag = GlobalTag(process.GlobalTag, Global_Tag, '')

    # make patCandidates, select and clean them
    process.load('PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff')
    process.load(
        'PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff')
    process.load('PhysicsTools.PatAlgos.cleaningLayer1.cleanPatCandidates_cff')
    process.patMuons.embedTrack = True

    process.selectedPatMuons.cut = cms.string(
        'muonID(\"TMOneStationTight\")'
        ' && abs(innerTrack.dxy) < 0.3'
        ' && abs(innerTrack.dz)  < 20.'
        ' && innerTrack.hitPattern.trackerLayersWithMeasurement > 5'
        ' && innerTrack.hitPattern.pixelLayersWithMeasurement > 0'
        ' && innerTrack.quality(\"highPurity\")')

    #make patTracks
    from PhysicsTools.PatAlgos.tools.trackTools import makeTrackCandidates
    makeTrackCandidates(
        process,
        label='TrackCands',  # output collection
        tracks=cms.InputTag('generalTracks'),  # input track collection
        particleType='pi+',  # particle type (for assigning a mass)
        preselection='pt > 0.7',  # preselection cut on candidates
        selection='pt > 0.7',  # selection on PAT Layer 1 objects
        isolation={},  # isolations to use (set to {} for None)
        isoDeposits=[],
        mcAs=None  # replicate MC match as the one used for Muons
    )
    process.patTrackCands.embedTrack = True

    # dimuon = Onia2MUMU
    process.load('HeavyFlavorAnalysis.Onia2MuMu.onia2MuMuPAT_cfi')
    process.onia2MuMuPAT.muons = cms.InputTag('cleanPatMuons')
    process.onia2MuMuPAT.primaryVertexTag = cms.InputTag(
        'offlinePrimaryVertices')
    process.onia2MuMuPAT.beamSpotTag = cms.InputTag('offlineBeamSpot')

    process.onia2MuMuPATCounter = cms.EDFilter(
        'CandViewCountFilter',
        src=cms.InputTag('onia2MuMuPAT'),
        minNumber=cms.uint32(1),
        filter=cms.bool(True))

    # reduce MC genParticles a la miniAOD
    process.load('PhysicsTools.PatAlgos.slimming.genParticles_cff')
    process.packedGenParticles.inputVertices = cms.InputTag(
        'offlinePrimaryVertices')

    # make photon candidate conversions for P-wave studies
    process.load(
        'HeavyFlavorAnalysis.Onia2MuMu.OniaPhotonConversionProducer_cfi')

    # add v0 with tracks embed
    process.load('HeavyFlavorAnalysis.Onia2MuMu.OniaAddV0TracksProducer_cfi')

    # Pick branches you want to keep
    SlimmedEventContent = [
        'keep recoVertexs_offlinePrimaryVertices_*_*',
        'keep *_inclusiveSecondaryVertices_*_*', 'keep *_offlineBeamSpot_*_*',
        'keep *_TriggerResults_*_HLT', 'keep *_gtDigis_*_RECO',
        'keep *_cleanPatTrackCands_*_*', 'keep *_PhotonCandidates_*_*',
        'keep *_onia2MuMuPAT_*_*', 'keep *_generalV0Candidates_*_*',
        'keep *_oniaV0Tracks_*_*', 'keep PileupSummaryInfos_*_*_*'
    ]

    if not MC:
        from PhysicsTools.PatAlgos.tools.coreTools import runOnData
        runOnData(process, outputModules=[])
    else:
        SlimmedEventContent += [
            'keep patPackedGenParticles_packedGenParticles_*_*',
            'keep recoGenParticles_prunedGenParticles_*_*',
            'keep GenFilterInfo_*_*_*',
            'keep GenEventInfoProduct_generator_*_*',
            'keep GenRunInfoProduct_*_*_*'
        ]

    process.FilterOutput = cms.Path(process.onia2MuMuPATCounter)

    process.out = cms.OutputModule(
        'PoolOutputModule',
        fileName=cms.untracked.string(outFileName),
        outputCommands=cms.untracked.vstring('drop *', *SlimmedEventContent),
        SelectEvents=cms.untracked.PSet(
            SelectEvents=cms.vstring('FilterOutput'))
        if Filter else cms.untracked.PSet())

    process.outpath = cms.EndPath(process.out)
Exemplo n.º 6
0
process.load("PhysicsTools.PatAlgos.cleaningLayer1.genericTrackCleaner_cfi")
process.cleanPatTracks.checkOverlaps.muons.requireNoOverlaps = cms.bool(False)
process.cleanPatTracks.checkOverlaps.electrons.requireNoOverlaps = cms.bool(False)

# muon MC match settings
process.load("PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi")
process.muonMatch.maxDeltaR = cms.double(0.02)
process.muonMatch.resolveByMatchQuality = cms.bool(True)

# make track candidates
makeTrackCandidates(
    process,  # patAODTrackCands
    label="TrackCands",  # output collection
    tracks=cms.InputTag("generalTracks"),  # input track collection
    particleType="pi+",  # particle type (for assigning a mass)
    preselection="pt > 0.1",  # preselection cut on candidates
    selection="pt > 0.1",  # Selection on PAT Layer 1 objects
    isolation={},  # Isolations to use ('source':deltaR; set to {} for None)
    isoDeposits=[],
    mcAs=None,  # Replicate MC match as the one used for Muons
)

# add the muon associators

process.load("MuonAnalysis.MuonAssociators.patMuonsWithTrigger_cff")
addDiMuonTriggers(process)
useExistingPATMuons(process, "cleanPatMuons", addL1Info=False)
changeTriggerProcessName(process, "HLT")
switchOffAmbiguityResolution(
    process
)  # Switch off ambiguity resolution: allow multiple reco muons to match to the same trigger muon