test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CompactSkim_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 def CompactSkim(process,inFileNames,outFileName,Global_Tag='auto:run2_mc',MC=True,Filter=True):
4 
5  process.load('Configuration.StandardSequences.Services_cff')
6  process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
7  process.load('FWCore.MessageService.MessageLogger_cfi')
8  process.load('Configuration.EventContent.EventContent_cff')
9  process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
10  process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
11  process.load('Configuration.StandardSequences.EndOfProcess_cff')
12  process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff')
13 
14  process.MessageLogger.cerr.FwkReport.reportEvery = 100
15  process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) )
16  process.options.allowUnscheduled = cms.untracked.bool(True)
17  process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring(inFileNames))
18  process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
19 
20  from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
21  process.GlobalTag = GlobalTag(process.GlobalTag, Global_Tag, '')
22 
23  # make patCandidates, select and clean them
24  process.load('PhysicsTools.PatAlgos.producersLayer1.patCandidates_cff')
25  process.load('PhysicsTools.PatAlgos.selectionLayer1.selectedPatCandidates_cff')
26  process.load('PhysicsTools.PatAlgos.cleaningLayer1.cleanPatCandidates_cff')
27  process.patMuons.embedTrack = True
28 
29  process.selectedPatMuons.cut = cms.string('muonID(\"TMOneStationTight\")'
30  ' && abs(innerTrack.dxy) < 0.3'
31  ' && abs(innerTrack.dz) < 20.'
32  ' && innerTrack.hitPattern.trackerLayersWithMeasurement > 5'
33  ' && innerTrack.hitPattern.pixelLayersWithMeasurement > 0'
34  ' && innerTrack.quality(\"highPurity\")'
35  )
36 
37  #make patTracks
38  from PhysicsTools.PatAlgos.tools.trackTools import makeTrackCandidates
39  makeTrackCandidates(process,
40  label = 'TrackCands', # output collection
41  tracks = cms.InputTag('generalTracks'), # input track collection
42  particleType = 'pi+', # particle type (for assigning a mass)
43  preselection = 'pt > 0.7', # preselection cut on candidates
44  selection = 'pt > 0.7', # selection on PAT Layer 1 objects
45  isolation = {}, # isolations to use (set to {} for None)
46  isoDeposits = [],
47  mcAs = None # replicate MC match as the one used for Muons
48  )
49  process.patTrackCands.embedTrack = True
50 
51  # dimuon = Onia2MUMU
52  process.load('HeavyFlavorAnalysis.Onia2MuMu.onia2MuMuPAT_cfi')
53  process.onia2MuMuPAT.muons=cms.InputTag('cleanPatMuons')
54  process.onia2MuMuPAT.primaryVertexTag=cms.InputTag('offlinePrimaryVertices')
55  process.onia2MuMuPAT.beamSpotTag=cms.InputTag('offlineBeamSpot')
56 
57  process.onia2MuMuPATCounter = cms.EDFilter('CandViewCountFilter',
58  src = cms.InputTag('onia2MuMuPAT'),
59  minNumber = cms.uint32(1),
60  filter = cms.bool(True)
61  )
62 
63  # reduce MC genParticles a la miniAOD
64  process.load('PhysicsTools.PatAlgos.slimming.genParticles_cff')
65  process.packedGenParticles.inputVertices = cms.InputTag('offlinePrimaryVertices')
66 
67  # make photon candidate conversions for P-wave studies
68  process.load('HeavyFlavorAnalysis.Onia2MuMu.OniaPhotonConversionProducer_cfi')
69 
70  # add v0 with tracks embed
71  process.load('HeavyFlavorAnalysis.Onia2MuMu.OniaAddV0TracksProducer_cfi')
72 
73  # Pick branches you want to keep
74  SlimmedEventContent = [
75  'keep recoVertexs_offlinePrimaryVertices_*_*',
76  'keep *_inclusiveSecondaryVertices_*_*',
77  'keep *_offlineBeamSpot_*_*',
78  'keep *_TriggerResults_*_HLT',
79  'keep *_gtDigis_*_RECO',
80  'keep *_cleanPatTrackCands_*_*',
81  'keep *_PhotonCandidates_*_*',
82  'keep *_onia2MuMuPAT_*_*',
83  'keep *_generalV0Candidates_*_*',
84  'keep *_oniaV0Tracks_*_*',
85  'keep PileupSummaryInfos_*_*_*'
86  ]
87 
88  if not MC:
89  from PhysicsTools.PatAlgos.tools.coreTools import runOnData
90  runOnData( process, outputModules = [] )
91  else :
92  SlimmedEventContent += [
93  'keep patPackedGenParticles_packedGenParticles_*_*',
94  'keep recoGenParticles_prunedGenParticles_*_*',
95  'keep GenFilterInfo_*_*_*',
96  'keep GenEventInfoProduct_generator_*_*',
97  'keep GenRunInfoProduct_*_*_*'
98  ]
99 
100  process.FilterOutput = cms.Path(process.onia2MuMuPATCounter)
101 
102  process.out = cms.OutputModule('PoolOutputModule',
103  fileName = cms.untracked.string(outFileName),
104  outputCommands = cms.untracked.vstring('drop *', *SlimmedEventContent),
105  SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring('FilterOutput')) if Filter else cms.untracked.PSet()
106  )
107 
108  process.outpath = cms.EndPath(process.out)