/ElectroWeakAnalysis/WENu/test/pat_WenuVBTF_ntuple_forData.py

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