CMS 3D CMS Logo

ElectronMVANtuplizer_cfg.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
4 from Configuration.AlCa.GlobalTag import GlobalTag
5 
6 process = cms.Process("ElectronMVANtuplizer")
7 
8 process.load("FWCore.MessageService.MessageLogger_cfi")
9 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
10 
11 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')
12 
13 # File with the ID variables to include in the Ntuplizer
14 mvaVariablesFile = "RecoEgamma/ElectronIdentification/data/ElectronIDVariables.txt"
15 
16 outputFile = "electron_ntuple.root"
17 
18 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
19 
20 process.source = cms.Source("PoolSource",
21  fileNames = cms.untracked.vstring(
22  '/store/mc/RunIIFall17MiniAOD/DYJetsToLL_M-50_TuneCP5_13TeV-madgraphMLM-pythia8/MINIAODSIM/RECOSIMstep_94X_mc2017_realistic_v10-v1/00000/0293A280-B5F3-E711-8303-3417EBE33927.root'
23  )
24 )
25 
26 useAOD = False
27 
29 # turn on VID producer, indicate data format to be
30 # DataFormat.AOD or DataFormat.MiniAOD, as appropriate
31 if useAOD == True :
32  dataFormat = DataFormat.AOD
33 else :
34  dataFormat = DataFormat.MiniAOD
35 
36 switchOnVIDElectronIdProducer(process, dataFormat)
37 
38 # define which IDs we want to produce
39 my_id_modules = [
40  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V2_cff',
41  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V2_cff',
42  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_noIso_V1_cff',
43  'RecoEgamma.ElectronIdentification.Identification.mvaElectronID_Fall17_iso_V1_cff',
44  ]
45 
46 #add them to the VID producer
47 for idmod in my_id_modules:
48  setupAllVIDIdsInModule(process,idmod,setupVIDElectronSelection)
49 
50 process.ntuplizer = cms.EDAnalyzer('ElectronMVANtuplizer',
51  # AOD case
52  src = cms.InputTag('gedGsfElectrons'),
53  vertices = cms.InputTag('offlinePrimaryVertices'),
54  pileup = cms.InputTag('addPileupInfo'),
55  genParticles = cms.InputTag('genParticles'),
56  # miniAOD case
57  srcMiniAOD = cms.InputTag('slimmedElectrons'),
58  verticesMiniAOD = cms.InputTag('offlineSlimmedPrimaryVertices'),
59  pileupMiniAOD = cms.InputTag('slimmedAddPileupInfo'),
60  genParticlesMiniAOD = cms.InputTag('prunedGenParticles'),
61  #
62  eleMVAs = cms.untracked.vstring(
63  "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp80",
64  "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wpLoose",
65  "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V2-wp90",
66  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpHZZ",
67  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp80",
68  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wpLoose",
69  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V2-wp90",
70  "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp90",
71  "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wp80",
72  "egmGsfElectronIDs:mvaEleID-Fall17-noIso-V1-wpLoose",
73  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp90",
74  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wp80",
75  "egmGsfElectronIDs:mvaEleID-Fall17-iso-V1-wpLoose",
76  ),
77  eleMVALabels = cms.untracked.vstring(
78  "Fall17noIsoV2wp80",
79  "Fall17noIsoV2wpLoose",
80  "Fall17noIsoV2wp90",
81  "Fall17isoV2wpHZZ",
82  "Fall17isoV2wp80",
83  "Fall17isoV2wpLoose",
84  "Fall17isoV2wp90",
85  "Fall17noIsoV1wp90",
86  "Fall17noIsoV1wp80",
87  "Fall17noIsoV1wpLoose",
88  "Fall17isoV1wp90",
89  "Fall17isoV1wp80",
90  "Fall17isoV1wpLoose",
91  ),
92  eleMVAValMaps = cms.untracked.vstring(
93  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2Values",
94  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV2RawValues",
95  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2Values",
96  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV2RawValues",
97  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17IsoV1Values",
98  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Values",
99  ),
100  eleMVAValMapLabels = cms.untracked.vstring(
101  "Fall17NoIsoV2Vals",
102  "Fall17NoIsoV2RawVals",
103  "Fall17IsoV2Vals",
104  "Fall17IsoV2RawVals",
105  "Fall17IsoV1Vals",
106  "Fall17NoIsoV1Vals",
107  ),
108  eleMVACats = cms.untracked.vstring(
109  "electronMVAValueMapProducer:ElectronMVAEstimatorRun2Fall17NoIsoV1Categories",
110  ),
111  eleMVACatLabels = cms.untracked.vstring(
112  "EleMVACats",
113  ),
114  #
115  variableDefinition = cms.string(mvaVariablesFile),
116  isMC = cms.bool(True),
117  deltaR = cms.double(0.1),
118  )
119 
120 process.TFileService = cms.Service("TFileService",
121  fileName = cms.string( outputFile )
122  )
123 
124 process.p = cms.Path(process.egmGsfElectronIDSequence * process.ntuplizer)
def switchOnVIDElectronIdProducer(process, dataFormat, task=None)
Electrons.
Definition: vid_id_tools.py:66
def setupAllVIDIdsInModule(process, id_module_name, setupFunction, patProducer=None, addUserData=True, task=None)
Definition: vid_id_tools.py:49