PageRenderTime 46ms CodeModel.GetById 14ms app.highlight 26ms RepoModel.GetById 1ms app.codeStats 1ms

/ElectroWeakAnalysis/WENu/test/pat_WenuVBTF_ntuple.py

https://github.com/aivanov-cern/cmssw
Python | 274 lines | 225 code | 16 blank | 33 comment | 0 complexity | b0925869b5e9882d1a0a59dcc0ae6bc8 MD5 | raw file
  1##   #########################################################
  2##
  3##   Configuration for the production of the ICHEP VBTF ntuple
  4##   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5##   MC, spring10
  6##
  7##   Nikolaos Rompotis - Imperial College London
  8##   22 June 2010
  9##
 10##   #########################################################
 11import FWCore.ParameterSet.Config as cms
 12
 13process = cms.Process("PAT")
 14
 15
 16
 17process.options = cms.untracked.PSet(
 18    Rethrow = cms.untracked.vstring('ProductNotFound')
 19)
 20
 21#process.MessageLogger = cms.Service(
 22#        "MessageLogger",
 23#            categories = cms.untracked.vstring('info', 'debug','cout')
 24#            )
 25
 26
 27process.load("FWCore.MessageService.MessageLogger_cfi")
 28process.MessageLogger.cerr.threshold = cms.untracked.string("INFO")
 29process.MessageLogger.cerr.FwkSummary = cms.untracked.PSet(
 30       reportEvery = cms.untracked.int32(1000000),
 31          limit = cms.untracked.int32(10000000)
 32       )
 33process.MessageLogger.cerr.FwkReport = cms.untracked.PSet(
 34      reportEvery = cms.untracked.int32(100000),
 35         limit = cms.untracked.int32(10000000)
 36      )
 37process.options = cms.untracked.PSet(
 38       wantSummary = cms.untracked.bool(True)
 39       )
 40
 41
 42
 43
 44# source
 45process.source = cms.Source("PoolSource", 
 46     fileNames = cms.untracked.vstring(
 47    # SOME DATA FILE TO BE PUT HERE
 48    #'rfio:/castor/cern.ch/user/r/rompotis/DATA_STUDIES/Spring10/sample_WminusToENu-CTEQ66-powheg_Spring10-START3X_V26_AODSIM-v2.root',
 49    #'file:rfio:/castor/cern.ch/user/r/rompotis/DATA_STUDIES/Spring10/sample_WenuSpring10START3X_V26_S09-v1_AODSIM.root',
 50
 51    )
 52)
 53process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
 54
 55## Load additional processes
 56process.load("Configuration.StandardSequences.Geometry_cff")
 57process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
 58## global tags:
 59process.GlobalTag.globaltag = cms.string('GR_R_36X_V11A::All') # GLOBAL TAG FOR DATA
 60process.load("Configuration.StandardSequences.MagneticField_cff")
 61
 62
 63################################################################################################
 64###    P r e p a r a t i o n      o f    t h e    P A T    O b j e c t s   f r o m    A O D  ###
 65################################################################################################
 66
 67## pat sequences to be loaded:
 68#process.load("PhysicsTools.PFCandProducer.PF2PAT_cff")
 69process.load("PhysicsTools.PatAlgos.patSequences_cff")
 70#process.load("PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cff")
 71##
 72#
 73## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 74## MET creation     <=== WARNING: YOU MAY WANT TO MODIFY THIS PART OF THE CODE       %%%%%%%%%%%%%
 75##                                specify the names of the MET collections that you need here %%%%
 76##                                                                                             #%%
 77## if you don't specify anything the default MET is the raw Calo MET                           #%%
 78process.caloMET = process.patMETs.clone(                                                       #%%
 79    metSource = cms.InputTag("met","","RECO"),
 80    addTrigMatch = cms.bool(False),
 81    addMuonCorrections = cms.bool(False),
 82    addGenMET = cms.bool(False),
 83)
 84process.tcMET = process.patMETs.clone(                                                         #%%
 85    metSource = cms.InputTag("tcMet","","RECO"),
 86    addTrigMatch = cms.bool(False),
 87    addMuonCorrections = cms.bool(False),
 88    addGenMET = cms.bool(False),
 89)
 90process.pfMET = process.patMETs.clone(                                                         #%%
 91    metSource = cms.InputTag("pfMet","","RECO"),
 92    addTrigMatch = cms.bool(False),
 93    addMuonCorrections = cms.bool(False),
 94    addGenMET = cms.bool(False),
 95)
 96## specify here what you want to have on the plots! <===== MET THAT YOU WANT ON THE PLOTS  %%%%%%%
 97myMetCollection   = 'caloMET'
 98myPfMetCollection =   'pfMET'
 99myTcMetCollection =   'tcMET'
100## modify the sequence of the MET creation:                                                    #%%
101process.makePatMETs = cms.Sequence(process.caloMET*process.tcMET*process.pfMET)
102## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103## modify the final pat sequence: keep only electrons + METS (muons are needed for met corrections)
104process.load("RecoEgamma.EgammaIsolationAlgos.egammaIsolationSequence_cff")
105#process.patElectronIsolation = cms.Sequence(process.egammaIsolationSequence)
106
107process.patElectrons.isoDeposits = cms.PSet()
108process.patElectrons.userIsolation = cms.PSet()
109process.patElectrons.addElectronID = cms.bool(True)
110process.patElectrons.electronIDSources = cms.PSet(
111    simpleEleId95relIso= cms.InputTag("simpleEleId95relIso"),
112    simpleEleId90relIso= cms.InputTag("simpleEleId90relIso"),
113    simpleEleId85relIso= cms.InputTag("simpleEleId85relIso"),
114    simpleEleId80relIso= cms.InputTag("simpleEleId80relIso"),
115    simpleEleId70relIso= cms.InputTag("simpleEleId70relIso"),
116    simpleEleId60relIso= cms.InputTag("simpleEleId60relIso"),
117    simpleEleId95cIso= cms.InputTag("simpleEleId95cIso"),
118    simpleEleId90cIso= cms.InputTag("simpleEleId90cIso"),
119    simpleEleId85cIso= cms.InputTag("simpleEleId85cIso"),
120    simpleEleId80cIso= cms.InputTag("simpleEleId80cIso"),
121    simpleEleId70cIso= cms.InputTag("simpleEleId70cIso"),
122    simpleEleId60cIso= cms.InputTag("simpleEleId60cIso"),    
123    )
124##
125process.patElectrons.addGenMatch = cms.bool(False)
126process.patElectrons.embedGenMatch = cms.bool(False)
127process.patElectrons.usePV = cms.bool(False)
128##
129process.load("ElectroWeakAnalysis.WENu.simpleEleIdSequence_cff")
130# you have to tell the ID that it is data
131process.simpleEleId95relIso.dataMagneticFieldSetUp = cms.bool(True)
132process.simpleEleId90relIso.dataMagneticFieldSetUp = cms.bool(True)
133process.simpleEleId85relIso.dataMagneticFieldSetUp = cms.bool(True)
134process.simpleEleId80relIso.dataMagneticFieldSetUp = cms.bool(True)
135process.simpleEleId70relIso.dataMagneticFieldSetUp = cms.bool(True)
136process.simpleEleId60relIso.dataMagneticFieldSetUp = cms.bool(True)
137process.simpleEleId95cIso.dataMagneticFieldSetUp = cms.bool(True)
138process.simpleEleId90cIso.dataMagneticFieldSetUp = cms.bool(True)
139process.simpleEleId85cIso.dataMagneticFieldSetUp = cms.bool(True)
140process.simpleEleId80cIso.dataMagneticFieldSetUp = cms.bool(True)
141process.simpleEleId70cIso.dataMagneticFieldSetUp = cms.bool(True)
142process.simpleEleId60cIso.dataMagneticFieldSetUp = cms.bool(True)
143#
144process.patElectronIDs = cms.Sequence(process.simpleEleIdSequence)
145process.makePatElectrons = cms.Sequence(process.patElectronIDs*process.patElectrons)
146# process.makePatMuons may be needed depending on how you calculate the MET
147process.makePatCandidates = cms.Sequence(process.makePatElectrons+process.makePatMETs)
148process.patDefaultSequence = cms.Sequence(process.makePatCandidates)
149##
150##  ################################################################################
151##
152##  the filter to select the candidates from the data samples
153##
154##
155## WARNING: you may want to modify this item:
156HLT_process_name = "HLT"   # REDIGI for the Spring10 production traditional MC / HLT for the powheg samples or data
157# trigger path selection
158HLT_path_name     = "HLT_Photon10_L1R" #= "HLT_Ele15_LW_L1R" #
159# trigger filter name
160HLT_filter_name  =  "hltL1NonIsoHLTNonIsoSinglePhotonEt10HcalIsolFilter"
161#
162HLT_path_name_extra   = "HLT_Photon15_L1R" #= "HLT_Ele15_LW_L1R" #
163HLT_filter_name_extra = "hltL1NonIsoHLTNonIsoSinglePhotonEt15HcalIsolFilter"
164
165
166process.wenuFilter = cms.EDFilter('WenuCandidateFilter',
167                                  ### the input collections needed:
168                                  electronCollectionTag = cms.untracked.InputTag("patElectrons","","PAT"),
169                                  metCollectionTag = cms.untracked.InputTag(myMetCollection,"","PAT"),
170                                  pfMetCollectionTag = cms.untracked.InputTag(myPfMetCollection,"","PAT"),
171                                  tcMetCollectionTag = cms.untracked.InputTag(myTcMetCollection,"","PAT"),
172                                  triggerCollectionTag = cms.untracked.InputTag("TriggerResults","",HLT_process_name),
173                                  triggerEventTag = cms.untracked.InputTag("hltTriggerSummaryAOD","",HLT_process_name),
174                                  hltpath = cms.untracked.string(HLT_path_name), 
175                                  hltpathFilter = cms.untracked.InputTag(HLT_filter_name,"",HLT_process_name),
176                                  ebRecHits = cms.untracked.InputTag("reducedEcalRecHitsEB"),
177                                  eeRecHits = cms.untracked.InputTag("reducedEcalRecHitsEE"),
178                                  PrimaryVerticesCollection = cms.untracked.InputTag("offlinePrimaryVertices"),
179                                  ### here the preselection is applied
180                                  # fiducial cuts:
181                                  BarrelMaxEta = cms.untracked.double(1.4442),
182                                  EndCapMinEta = cms.untracked.double(1.566),
183                                  EndCapMaxEta = cms.untracked.double(2.5),
184                                  # demand ecal driven electron:
185                                  useEcalDrivenElectrons = cms.untracked.bool(True),
186                                  # demand offline spike cleaning with the Swiss Cross criterion:
187                                  useSpikeRejection = cms.untracked.bool(True),
188                                  spikeCleaningSwissCrossCut = cms.untracked.double(0.95),
189                                  # demand geometrically matched to an HLT object with ET>15GeV
190                                  useTriggerInfo = cms.untracked.bool(True),
191                                  electronMatched2HLT = cms.untracked.bool(True),
192                                  electronMatched2HLT_DR = cms.untracked.double(0.1),
193                                  useHLTObjectETCut = cms.untracked.bool(True),
194                                  hltObjectETCut = cms.untracked.double(15.),
195                                  useExtraTrigger = cms.untracked.bool(True),
196                                  hltpathExtra = cms.untracked.string(HLT_path_name_extra),
197                                  hltpathFilterExtra = cms.untracked.InputTag(HLT_filter_name_extra,"",HLT_process_name),
198                                  # ET Cut in the SC
199                                  ETCut = cms.untracked.double(20.),                                  
200                                  METCut = cms.untracked.double(0.),
201                                  # reject events with a 2nd electron with ET > 20 that passes the WP95%
202                                  vetoSecondElectronEvents = cms.untracked.bool(False),
203                                  storeSecondElectron = cms.untracked.bool(True),
204                                  ETCut2ndEle = cms.untracked.double(20.),
205                                  vetoSecondElectronIDType = cms.untracked.string("simpleEleId95relIso"),
206                                  vetoSecondElectronIDSign = cms.untracked.string("="),
207                                  vetoSecondElectronIDValue = cms.untracked.double(7.),
208                                  # Other parameters of the code - leave them as they are
209                                  useValidFirstPXBHit = cms.untracked.bool(False),
210                                  useConversionRejection = cms.untracked.bool(False),
211                                  useExpectedMissingHits = cms.untracked.bool(False),
212                                  maxNumberOfExpectedMissingHits = cms.untracked.int32(1),
213                                  # calculate some new cuts
214                                  calculateValidFirstPXBHit = cms.untracked.bool(True),
215                                  calculateConversionRejection = cms.untracked.bool(True),
216                                  calculateExpectedMissingHits = cms.untracked.bool(True),
217                                  # we are dealing with DATA
218                                  dataMagneticFieldSetUp = cms.untracked.bool(True),
219                                  dcsTag = cms.untracked.InputTag("scalersRawToDigi"),
220                                  )
221####################################################################################
222##
223## the W selection that you prefer included in another cfg
224from ElectroWeakAnalysis.WENu.simpleCutBasedSpring10SelectionBlocks_cfi import *
225
226selection_inverse = cms.PSet (
227    deta_EB_inv = cms.untracked.bool(True),
228    deta_EE_inv = cms.untracked.bool(True)
229    )
230
231####################################################################################
232#
233# we need to store jet information, hence we have to produce the jets:
234process.load("JetMETCorrections.Configuration.DefaultJEC_cff")
235
236process.jetSequence = cms.Sequence( process.ak5CaloJetsL2L3  )
237process.pfjetAK5Sequence = cms.Sequence( process.ak5PFJetsL2L3 )
238
239process.ourJetSequence = cms.Sequence( process.jetSequence * process.pfjetAK5Sequence )
240
241
242
243##
244## and the plot creator
245process.plotter = cms.EDAnalyzer('WenuPlots',
246                                 # selection in use: wont be used - we have usePrecalcID true later
247                                 selection_80relIso,
248                                 selection_inverse,
249                                 # The selection to be used here:
250                                 usePrecalcID = cms.untracked.bool(True),
251                                 usePrecalcIDType = cms.untracked.string('simpleEleId80relIso'),
252                                 usePrecalcIDSign = cms.untracked.string('='),
253                                 usePrecalcIDValue = cms.untracked.double(7),
254                                 # some extra information on the ntuple production:
255                                 includeJetInformationInNtuples = cms.untracked.bool(True),
256                                 caloJetCollectionTag = cms.untracked.InputTag('ak5CaloJetsL2L3'),
257                                 pfJetCollectionTag = cms.untracked.InputTag('ak5PFJetsL2L3'),
258                                 DRJetFromElectron = cms.untracked.double(0.3),
259                                 #
260                                 wenuCollectionTag = cms.untracked.InputTag("wenuFilter","selectedWenuCandidates","PAT"),
261                                 WENU_VBTFselectionFileName = cms.untracked.string("WENU_VBTFselection.root"),
262                                 WENU_VBTFpreseleFileName = cms.untracked.string("WENU_VBTFpreselection.root"),
263                                 DatasetTag =  cms.untracked.int32(100),
264                                 storeSecondElectronInformation = cms.untracked.bool(True),
265                                 )
266#
267# if you run on data then you have to do misalignment  corrections first!!!
268# not to be used with MC!!
269process.load("RecoEgamma.EgammaTools.correctedElectronsProducer_cfi")
270process.p = cms.Path( process.gsfElectrons*process.ourJetSequence*
271                      process.patDefaultSequence*process.wenuFilter*process.plotter)
272#process.p = cms.Path( process.ourJetSequence * process.patDefaultSequence +process.wenuFilter + process.plotter)
273
274