DESY Hbb Analysis Framework
ntuplizer_reco_example.py
Go to the documentation of this file.
1 # For the ntuple production
2 import FWCore.ParameterSet.Config as cms
3 
4 process = cms.Process('Example')
5 
6 process.load('FWCore.MessageService.MessageLogger_cfi')
7 process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(100000)
8 
9 ## Using MINIAOD. GlobalTag just in case jet re-clustering, L1 trigger filter etc is needed to be done
10 process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
11 process.load('Configuration.Geometry.GeometryRecoDB_cff')
12 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
13 from Configuration.AlCa.GlobalTag import GlobalTag
14 process.GlobalTag = GlobalTag(process.GlobalTag, '101X_dataRun2_Prompt_v9')
15 
16 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1000) )
17 
18 ## TFileService
19 output_file = 'ntuple.root'
20 process.TFileService = cms.Service('TFileService',
21  fileName = cms.string(output_file)
22 )
23 
24 ## ============ TRIGGER FILTER ===============
25 ## Enable below at cms.Path if needed - DATA ONLY!!!
26 process.triggerSelection = cms.EDFilter( 'TriggerResultsFilter',
27  triggerConditions = cms.vstring('HLT_ZeroBias_v*'),
28  hltResults = cms.InputTag( 'TriggerResults', '', 'HLT' ),
29  l1tResults = cms.InputTag( '' ),
30  l1tIgnoreMask = cms.bool( False ),
31  l1techIgnorePrescales = cms.bool( False ),
32  daqPartitions = cms.uint32( 1 ),
33  throw = cms.bool( False )
34 )
35 
36 ## ============ EVENT FILTER COUNTER ===============
37 ## Filter counter (maybe more useful for MC)
38 process.TotalEvents = cms.EDProducer('EventCountProducer')
39 process.FilteredEvents = cms.EDProducer('EventCountProducer')
40 
41 ## ============ PRIMARY VERTEX FILTER =============== NEED TO MODIFY FOR RECO
42 # process.primaryVertexFilter = cms.EDFilter('VertexSelector',
43 # src = cms.InputTag('offlinePrimaryVerticesWithBS'), # primary vertex collection name
44 # cut = cms.string('!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2'), # ndof>thr=4 corresponds to sum(track_weigths) > (thr+3)/2 = 3.5 so typically 4 good tracks
45 # filter = cms.bool(True), # otherwise it won't filter the events, just produce an empty vertex collection.
46 # )
47 #
48 
49 ## ============ THE NTUPLIZER!!! ===============
50 process.RecoNtuple = cms.EDAnalyzer('Ntuplizer',
51 
52  MonteCarlo = cms.bool(False),
53  ###################
54  TotalEvents = cms.InputTag ('TotalEvents'),
55  FilteredEvents = cms.InputTag ('FilteredEvents'),
56 # PrimaryVertices = cms.VInputTag(cms.InputTag('offlinePrimaryVerticesWithBS') ),
57  RecoMuons = cms.VInputTag(cms.InputTag('muons1Leg','','RECO') ),
58  RecoTracks = cms.VInputTag(cms.InputTag('ALCARECOTkAlCosmicsCTF0T','','RECO') ),
59 # TriggerResults = cms.VInputTag(cms.InputTag('TriggerResults','','HLT') ),
60 # L1Seeds = cms.vstring ('L1_ZeroBias'),
61 # TriggerPaths = cms.vstring ('HLT_ZeroBias_v'),
62 # L1TMuons = cms.VInputTag(cms.InputTag('gmtStage2Digis','Muon','RECO'), ), # may not work with some ALCA dataset, collection not available
63 # TriggerEvent = cms.VInputTag(cms.InputTag('hltTriggerSummaryAOD','','HLT'), ), # collection with trigger objects in RECO
64 # TriggerObjectLabels = cms.vstring ('hltL1sZeroBias') # list of trigger objects in RECO to be stored in ntuple
65 
66 )
67 
68 process.p = cms.Path(
69  process.TotalEvents *
70  process.triggerSelection *
71  process.FilteredEvents *
72  process.RecoNtuple
73  )
74 
75 
76 readFiles = cms.untracked.vstring()
77 secFiles = cms.untracked.vstring()
78 process.source = cms.Source ('PoolSource',fileNames = readFiles, secondaryFileNames = secFiles)
79 readFiles.extend( [
80 # '/store/data/Run2018A/ZeroBias/RAW-RECO/LogError-PromptReco-v2/000/316/239/00000/0012D71D-5159-E811-984D-FA163E94BBA0.root',
81  '/store/mc/RunIISpring18CosmicDR/TKCosmics_38T/ALCARECO/TkAlCosmics0T-PEAK_100X_mc2017cosmics_realistic_peak_v3-v1/30000/7CF568B9-E433-E811-BA8F-02163E019F9F.root',
82 ] );
83 
84 
85 secFiles.extend( [
86  ] )
87