File indexing completed on 2024-04-06 11:58:39
0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 import os, sys, imp, re
0004 import FWCore.ParameterSet.VarParsing as VarParsing
0005 import subprocess
0006 import copy
0007
0008 from PhysicsTools.PatAlgos.tools.helpers import cloneProcessingSnippet
0009
0010
0011
0012
0013
0014 options = VarParsing.VarParsing('standard')
0015 options.register('isCrab',
0016 1,
0017 VarParsing.VarParsing.multiplicity.singleton,
0018 VarParsing.VarParsing.varType.int,
0019 "change files path in case of local test: isCrab=0 if you are running it locally with cmsRun")
0020 options.register ('type',
0021 "ALCARAW",
0022 VarParsing.VarParsing.multiplicity.singleton,
0023 VarParsing.VarParsing.varType.string,
0024 "type of operations: ALCARAW, ALCARERECO, ALCARECO, ALCARECOSIM, AOD, RECO, SKIMEFFTEST")
0025 options.register ('tagFile',
0026 "",
0027 VarParsing.VarParsing.multiplicity.singleton,
0028 VarParsing.VarParsing.varType.string,
0029 "path of the file with the reReco tags")
0030 options.register('skim',
0031 "",
0032 VarParsing.VarParsing.multiplicity.singleton,
0033 VarParsing.VarParsing.varType.string,
0034 "type of skim: ZSkim, WSkim, ZHLTSkim, partGun, ZmmgSkim, EleSkim (at least one electron), ''")
0035 options.register('jsonFile',
0036 "",
0037 VarParsing.VarParsing.multiplicity.singleton,
0038 VarParsing.VarParsing.varType.string,
0039 "path and name of the json file")
0040 options.register('doTree',
0041 0,
0042 VarParsing.VarParsing.multiplicity.singleton,
0043 VarParsing.VarParsing.varType.int,
0044 "doTree=0: no tree; 1: standard tree; 2: onlyExtraTree; 3: standard+extra; 4:only eleID; 5:eleID+standard; 6: eleID+extra; 7: standard+extra+eleID")
0045 options.register('doTreeOnly',
0046 0,
0047 VarParsing.VarParsing.multiplicity.singleton,
0048 VarParsing.VarParsing.varType.int,
0049 "bool: doTreeOnly=1 true, doTreeOnly=0 false")
0050 options.register('pdfSyst',
0051 0,
0052 VarParsing.VarParsing.multiplicity.singleton,
0053 VarParsing.VarParsing.varType.int,
0054 "bool: pdfSyst=1 true, pdfSyst=0 false")
0055
0056
0057 options.output="alcaSkimALCARAW.root"
0058 options.secondaryOutput="ntuple.root"
0059 options.files= ""
0060 options.maxEvents = -1
0061
0062 options.parseArguments()
0063
0064 print(options)
0065
0066
0067
0068
0069
0070 HLTFilter = False
0071 ZSkim = False
0072 WSkim = False
0073 ZmmgSkim = False
0074
0075 if(options.skim=="ZSkim"):
0076 ZSkim=True
0077 elif(options.skim=="WSkim"):
0078 WSkim=True
0079 elif(options.skim=="ZHLTSkim"):
0080 HLTFilter=True
0081 elif(options.skim=="ZmmgSkim"):
0082 ZmmgSkim=True
0083 else:
0084 if(options.type=="ALCARAW"):
0085 print("[ERROR] no skim selected")
0086 sys.exit(-1)
0087
0088
0089 MC = False
0090 if(options.type == "ALCARAW"):
0091 processName = 'ALCASKIM'
0092 elif(options.type == "ALCARERECO"):
0093 processName = 'ALCARERECO'
0094 elif(options.type == "ALCARECOSIM"):
0095 processName = 'ALCARECO'
0096 MC = True
0097 elif(options.type == "ALCARECO"):
0098 processName = 'ALCARECO'
0099 MC = False
0100 elif(options.type == 'SKIMEFFTEST'):
0101 processName = 'SKIMEFFTEST'
0102 MC = True
0103 else:
0104 print("[ERROR] wrong type defined")
0105 sys.exit(-1)
0106
0107 doTreeOnly=False
0108 if(options.doTree>0 and options.doTreeOnly==1):
0109 print("doTreeOnly")
0110 doTreeOnly=True
0111 processName = processName+'DUMP'
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 CMSSW_VERSION=os.getenv("CMSSW_VERSION")
0125 CMSSW_BASE=os.getenv("CMSSW_BASE")
0126
0127 process = cms.Process(processName)
0128
0129
0130 process.load('Configuration.StandardSequences.Services_cff')
0131 process.load('Configuration.StandardSequences.RawToDigi_Data_cff')
0132 process.load('Configuration.StandardSequences.L1Reco_cff')
0133 process.load('Configuration.StandardSequences.Reconstruction_Data_cff')
0134 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0135 process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0136 process.load('FWCore.MessageService.MessageLogger_cfi')
0137 process.load('Configuration.StandardSequences.GeometryDB_cff')
0138 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0139 process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
0140 process.load('Configuration.EventContent.EventContent_cff')
0141
0142
0143 process.load('Calibration.EcalAlCaRecoProducers.ALCARECOEcalCalIsolElectron_Output_cff')
0144 process.load('Calibration.EcalAlCaRecoProducers.ALCARECOEcalUncalIsolElectron_Output_cff')
0145 from Calibration.EcalAlCaRecoProducers.sandboxRerecoOutput_cff import *
0146
0147
0148 process.load('Calibration.EcalAlCaRecoProducers.ALCARECOEcalCalIsolElectron_cff')
0149 process.load("Calibration.EcalAlCaRecoProducers.PUDumper_cfi")
0150 if (re.match("CMSSW_5_.*",CMSSW_VERSION) or re.match("CMSSW_6_.*",CMSSW_VERSION)):
0151 process.load('Calibration.EcalAlCaRecoProducers.ALCARECOEcalUncalIsolElectron_cff')
0152
0153
0154
0155
0156 process.load('Calibration.EcalAlCaRecoProducers.sandboxRerecoSeq_cff')
0157
0158
0159
0160
0161
0162
0163 process.load('Calibration.ZNtupleDumper.ntupledumper_cff')
0164
0165
0166
0167 process.load('RecoEcal.EgammaClusterProducers.interestingDetIdCollectionProducer_cfi')
0168
0169
0170 process.load('Calibration.EcalAlCaRecoProducers.pdfSystematics_cff')
0171
0172 process.MessageLogger.cerr = cms.untracked.PSet(
0173 INFO = cms.untracked.PSet(
0174 limit = cms.untracked.int32(0)
0175 ),
0176 noTimeStamps = cms.untracked.bool(False),
0177 FwkReport = cms.untracked.PSet(
0178 reportEvery = cms.untracked.int32(1000),
0179 limit = cms.untracked.int32(10000000)
0180 ),
0181 default = cms.untracked.PSet(
0182 limit = cms.untracked.int32(10000000)
0183 ),
0184 Root_NoDictionary = cms.untracked.PSet(
0185 limit = cms.untracked.int32(0)
0186 ),
0187 FwkSummary = cms.untracked.PSet(
0188 reportEvery = cms.untracked.int32(1),
0189 limit = cms.untracked.int32(10000000)
0190 ),
0191 threshold = cms.untracked.string('INFO')
0192 )
0193
0194 if(options.isCrab==0):
0195 process.MessageLogger.cerr.FwkReport.reportEvery = 1
0196
0197 process.maxEvents = cms.untracked.PSet(
0198 input = cms.untracked.int32(options.maxEvents)
0199 )
0200
0201 process.source = cms.Source("PoolSource",
0202 fileNames = cms.untracked.vstring(options.files),
0203 secondaryFileNames = cms.untracked.vstring(options.secondaryFiles)
0204 )
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 process.options = cms.untracked.PSet(
0217 wantSummary = cms.untracked.bool(True)
0218 )
0219
0220
0221
0222
0223 if(len(options.tagFile)>0):
0224 execfile(options.tagFile)
0225 process.GlobalTag = RerecoGlobalTag
0226 else:
0227 if(options.type=="ALCARERECO" and not doTreeOnly):
0228 print("******************************")
0229 print("[ERROR] no file with tags specified, but rereco requested")
0230 sys.exit(1)
0231
0232 if(re.match("CMSSW_4_2_.*",CMSSW_VERSION)):
0233 if (MC):
0234 print("[INFO] Using GT START42_V17::All")
0235 process.GlobalTag.globaltag = 'START42_V17::All'
0236 else:
0237 print("[INFO] Using GT FT_R_42_V24::All")
0238 process.GlobalTag.globaltag = 'FT_R_42_V24::All'
0239 elif(re.match("CMSSW_4_4_.*", CMSSW_VERSION)):
0240 if (MC):
0241 print("[INFO] Using GT START44_V13::All")
0242 process.GlobalTag.globaltag = 'START44_V13::All'
0243 else:
0244 print("[INFO] Using GT GR_R_44_V15C::All")
0245
0246 process.GlobalTag.globaltag = 'GR_R_44_V15C::All'
0247 elif(re.match("CMSSW_5_2_.*",CMSSW_VERSION)):
0248 if(MC):
0249 print("[INFO] Using GT START52_V16::All")
0250 process.GlobalTag.globaltag = 'START52_V16::All'
0251 else:
0252 process.GlobalTag.globaltag = 'GR_P_V32::All'
0253
0254 elif(re.match("CMSSW_5_3_11_patch3",CMSSW_VERSION)):
0255 if(MC):
0256 print("[INFO] Using GT START53_LV4::All")
0257 process.GlobalTag.globaltag = 'START53_V7C::All'
0258
0259 else:
0260 process.GlobalTag.globaltag = 'FT_R_53_V21::All'
0261 elif(re.match("CMSSW_5_3_.*",CMSSW_VERSION)):
0262 if(MC):
0263 print("[INFO] Using GT START53_V7N::All")
0264 process.GlobalTag.globaltag = 'START53_V7N::All'
0265
0266
0267 else:
0268 print("[INFO] Using GT FT_R_53_V21N::All")
0269 process.GlobalTag.globaltag = 'FT_R_53_V21::All'
0270
0271
0272 if(options.files==""):
0273 process.source.fileNames=[ 'root://cms-xrd-global.cern.ch//store/data/Run2012A/DoubleElectron/AOD/22Jan2013-v1/20000/003EC246-5E67-E211-B103-00259059642E.root' ]
0274 elif(re.match("CMSSW_6_1_.*",CMSSW_VERSION)):
0275 if(MC):
0276 print("[INFO] Using GT START61_V11::All")
0277 process.GlobalTag.globaltag = 'START61_V11::All'
0278 else:
0279 process.GlobalTag.globaltag = 'GR_P_V42B::All'
0280 elif(re.match("CMSSW_7_0_.*",CMSSW_VERSION)):
0281 if(MC):
0282 print("[INFO] Using GT POSTLS162_V5::All")
0283 process.GlobalTag.globaltag = 'POSTLS162_V5::All'
0284 else:
0285 process.GlobalTag.globaltag = 'GR_R_62_V3::All'
0286 if(options.files==""):
0287 process.source.fileNames=[ 'root://cms-xrd-global.cern.ch//store/data/Run2012D/DoubleElectron/AOD/15Apr2014-v1/00000/0EA11D35-0CD5-E311-862E-0025905A6070.root' ]
0288 elif(re.match("CMSSW_7_4_.*",CMSSW_VERSION)):
0289 if(MC):
0290 print("[INFO] Using GT POSTLS162_V5::All")
0291 process.GlobalTag.globaltag = 'POSTLS162_V5::All'
0292 else:
0293 from Configuration.AlCa.GlobalTag import GlobalTag
0294 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '')
0295 if(options.files==""):
0296 process.source.fileNames=[ 'root://cms-xrd-global.cern.ch//store/data/Run2012D/DoubleElectron/AOD/15Apr2014-v1/00000/0EA11D35-0CD5-E311-862E-0025905A6070.root' ]
0297 else:
0298 print("[ERROR]::Global Tag not set for CMSSW_VERSION: ", CMSSW_VERSION)
0299 sys.exit(1)
0300
0301 if(re.match("CMSSW_7_.*",CMSSW_VERSION)):
0302 myEleCollection = cms.InputTag("gedGsfElectrons")
0303 else:
0304 myEleCollection = cms.InputTag("gsfElectrons")
0305
0306
0307
0308
0309
0310 process.pfIsoEgamma = cms.Sequence()
0311 if((options.type=='ALCARECO' or options.type=='ALCARECOSIM' or options.type=='ALCARAW') and not re.match("CMSSW_7_.*_.*",CMSSW_VERSION)):
0312 from CommonTools.ParticleFlow.Tools.pfIsolation import setupPFElectronIso, setupPFMuonIso
0313 process.eleIsoSequence = setupPFElectronIso(process, 'gsfElectrons', 'PFIso')
0314 process.pfIsoEgamma *= (process.pfParticleSelectionSequence + process.eleIsoSequence)
0315 elif((options.type=='ALCARECO' or options.type=='ALCARECOSIM' or options.type=='ALCARAW') and re.match("CMSSW_7_.*_.*",CMSSW_VERSION)):
0316 process.pfisoALCARECO = cms.Sequence()
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327 process.PUDumperSeq = cms.Sequence()
0328
0329 if(MC):
0330
0331 process.TFileService = cms.Service(
0332 "TFileService",
0333 fileName = cms.string("PUDumper.root")
0334 )
0335 process.PUDumperSeq *= process.PUDumper
0336
0337 if(re.match("CMSSW_5_.*", CMSSW_VERSION)):
0338 process.load('Calibration.EcalAlCaRecoProducers.WZElectronSkims53X_cff')
0339 else:
0340 process.load('Calibration.EcalAlCaRecoProducers.WZElectronSkims_cff')
0341
0342 process.load('DPGAnalysis.Skims.ZmmgSkim_cff')
0343
0344 process.MinMuonNumberFilter = cms.EDFilter("CandViewCountFilter",
0345 src = cms.InputTag("muons"),
0346 minNumber = cms.uint32(2))
0347 process.MinPhoNumberFilter = cms.EDFilter("CandViewCountFilter",
0348 src = cms.InputTag("gedPhotons"),
0349 minNumber = cms.uint32(1))
0350 process.MinEleNumberFilter = cms.EDFilter("CandViewCountFilter",
0351 src = myEleCollection,
0352 minNumber = cms.uint32(1))
0353 if (ZmmgSkim==True):
0354 process.filterSeq = cms.Sequence(process.MinMuonNumberFilter * process.MinPhoNumberFilter)
0355 else:
0356 process.filterSeq = cms.Sequence(process.MinEleNumberFilter)
0357
0358 if (HLTFilter):
0359 from HLTrigger.HLTfilters.hltHighLevel_cfi import *
0360 process.ZEEHltFilter = copy.deepcopy(hltHighLevel)
0361 process.ZEEHltFilter.throw = cms.bool(False)
0362 process.ZEEHltFilter.HLTPaths = [ "HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_*"]
0363 process.filterSeq *= process.ZEEHltFilter
0364
0365 from HLTrigger.HLTfilters.hltHighLevel_cfi import *
0366 process.NtupleFilter = copy.deepcopy(hltHighLevel)
0367 process.NtupleFilter.throw = cms.bool(False)
0368 process.NtupleFilter.HLTPaths = [ 'pathALCARECOEcalUncalZElectron', 'pathALCARECOEcalUncalWElectron',
0369 'pathALCARECOEcalCalZElectron', 'pathALCARECOEcalCalWElectron',
0370 'pathALCARECOEcalUncalZSCElectron', 'pathALCARECOEcalCalZSCElectron',
0371 'pathALCARECOEcalUncalSingleElectron', 'pathALCARECOEcalCalSingleElectron',
0372 ]
0373 process.NtupleFilter.TriggerResultsTag = cms.InputTag("TriggerResults","","ALCARECO")
0374
0375
0376 process.NtupleFilterSeq = cms.Sequence()
0377
0378 if(ZSkim):
0379 process.NtupleFilterSeq = cms.Sequence(process.WZFilter)
0380
0381 process.NtupleFilter.HLTPaths = [ 'pathALCARECOEcalCalZElectron', 'pathALCARECOEcalUncalZElectron',
0382 'pathALCARECOEcalCalZSCElectron', 'pathALCARECOEcalUncalZSCElectron',
0383 ]
0384 elif(WSkim):
0385 process.NtupleFilterSeq = cms.Sequence(process.WZFilter)
0386
0387 process.NtupleFilter.HLTPaths = [ 'pathALCARECOEcalCalWElectron', 'pathALCARECOEcalUncalWElectron' ]
0388 elif(ZmmgSkim):
0389 process.NtupleFilterSeq = cms.Sequence(process.ZmmgSkimSeq)
0390 process.NtupleFilter.HLTPaths = [ 'pathALCARECOEcalCalZmmgPhoton', 'pathALCARECOEcalUncalZmmgPhoton' ]
0391
0392 elif(options.skim=="no" or options.skim=="NO" or options.skim=="none" or options.skim=="NONE"):
0393 process.NtupleFilterSeq = cms.Sequence()
0394
0395
0396 if(options.skim=="partGun"):
0397 process.zNtupleDumper.isPartGun = cms.bool(True)
0398
0399
0400
0401
0402
0403 process.load("RecoEcal.EgammaClusterProducers.reducedRecHitsSequence_cff")
0404 process.reducedEcalRecHitsES.scEtThreshold = cms.double(0.)
0405
0406 process.reducedEcalRecHitsES.EcalRecHitCollectionES = cms.InputTag('ecalPreshowerRecHit','EcalRecHitsES')
0407 process.reducedEcalRecHitsES.noFlag = cms.bool(True)
0408 process.reducedEcalRecHitsES.OutputLabel_ES = cms.string('alCaRecHitsES')
0409
0410
0411
0412
0413
0414 try:
0415 EcalTrivialConditionRetriever
0416 except NameError:
0417
0418 process.trivialCond = cms.Sequence()
0419 else:
0420 print("** TrivialConditionRetriver defined")
0421 process.trivialCond = cms.Sequence( EcalTrivialConditionRetriever )
0422
0423
0424 if(re.match("CMSSW_6_.*", CMSSW_VERSION) or re.match("CMSSW_7_.*", CMSSW_VERSION)):
0425 process.alcarerecoSeq=cms.Sequence( process.trivialCond * process.sandboxPFRerecoSeq * (process.seqALCARECOEcalCalElectronRECO + process.reducedEcalRecHitsES))
0426 else:
0427 process.alcarerecoSeq=cms.Sequence( process.trivialCond * process.sandboxRerecoSeq * (process.seqALCARECOEcalCalElectronRECO + process.reducedEcalRecHitsES))
0428
0429
0430 process.rhoFastJetSeq = cms.Sequence()
0431 process.jsonFilter = cms.Sequence()
0432
0433 if((not options.type=="ALCARERECO") ):
0434 process.rhoFastJetSeq = cms.Sequence(process.kt6PFJetsForRhoCorrection)
0435
0436 if (options.skim=="ZmmgSkim"):
0437 process.patSequence=cms.Sequence( (process.muonSelectionProducers * process.phoSelectionProducers) * process.patMuons * process.patPhotons )
0438 process.patSequenceMC=cms.Sequence( process.muonMatch * process.photonMatch * (process.muonSelectionProducers * process.phoSelectionProducers ) * process.patMuons * process.patPhotons )
0439 if(MC):
0440 process.ntupleSeq = cms.Sequence(process.jsonFilter * process.patSequenceMC)
0441 else:
0442 process.ntupleSeq = cms.Sequence(process.jsonFilter * process.patSequence)
0443
0444 if(options.doTree==2 or options.doTree==4 or options.doTree==6 or options.doTree==8):
0445 process.zNtupleDumper.doStandardTree = cms.bool(False)
0446 if(options.doTree==2 or options.doTree==3 or options.doTree==6 or options.doTree==7 or options.doTree==10 or options.doTree==11 or options.doTree==14 or options.doTree==15):
0447 process.zNtupleDumper.doExtraCalibTree=cms.bool(True)
0448 if(options.doTree==4 or options.doTree==5 or options.doTree==6 or options.doTree==7 or options.doTree==12 or options.doTree==13 or options.doTree==14 or options.doTree==15):
0449 process.zNtupleDumper.doEleIDTree=cms.bool(True)
0450
0451 if(MC and options.pdfSyst==1):
0452 process.pdfWeightsSeq = cms.Sequence(process.pdfWeights + process.weakWeight + process.fsrWeight)
0453
0454 process.zNtupleDumper.pdfWeightCollections = cms.VInputTag(cms.InputTag('pdfWeights:cteq66'), cms.InputTag("pdfWeights:MRST2006nnlo"), cms.InputTag('pdfWeights:NNPDF10'))
0455 else:
0456 process.pdfWeightsSeq = cms.Sequence()
0457
0458
0459
0460
0461
0462
0463 fileName = cms.untracked.string(options.output)
0464
0465 process.outputALCARAW = cms.OutputModule("PoolOutputModule",
0466
0467 maxSize = cms.untracked.int32(5120000),
0468 outputCommands = process.OutALCARECOEcalUncalElectron.outputCommands,
0469
0470 fileName = cms.untracked.string('alcaraw.root'),
0471 SelectEvents = process.OutALCARECOEcalUncalElectron.SelectEvents,
0472 dataset = cms.untracked.PSet(
0473 filterName = cms.untracked.string(''),
0474 dataTier = cms.untracked.string('ALCARECO')
0475 )
0476 )
0477
0478 process.outputALCARECO = cms.OutputModule("PoolOutputModule",
0479
0480 maxSize = cms.untracked.int32(5120000),
0481 outputCommands = process.OutALCARECOEcalCalElectron.outputCommands,
0482 fileName = cms.untracked.string('alcareco.root'),
0483 SelectEvents = process.OutALCARECOEcalCalElectron.SelectEvents,
0484 dataset = cms.untracked.PSet(
0485 filterName = cms.untracked.string(''),
0486 dataTier = cms.untracked.string('ALCARECO')
0487 )
0488 )
0489
0490 process.zNtupleDumper.SelectEvents = process.NtupleFilter.HLTPaths
0491
0492 process.outputALCARERECO = cms.OutputModule("PoolOutputModule",
0493
0494 maxSize = cms.untracked.int32(5120000),
0495 outputCommands = process.OutALCARECOEcalCalElectron.outputCommands,
0496 fileName = cms.untracked.string('alcarereco.root'),
0497 SelectEvents = cms.untracked.PSet(
0498 SelectEvents = cms.vstring('pathALCARERECOEcalCalElectron')
0499 ),
0500 dataset = cms.untracked.PSet(
0501 filterName = cms.untracked.string(''),
0502 dataTier = cms.untracked.string('ALCARECO')
0503 )
0504 )
0505
0506 process.outputRECO = cms.OutputModule("PoolOutputModule",
0507
0508 maxSize = cms.untracked.int32(5120000),
0509 outputCommands = cms.untracked.vstring('keep *'),
0510 fileName = cms.untracked.string('RECO.root'),
0511 SelectEvents = process.OutALCARECOEcalCalElectron.SelectEvents,
0512 dataset = cms.untracked.PSet(
0513 filterName = cms.untracked.string(''),
0514 dataTier = cms.untracked.string('RECO')
0515 )
0516 )
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531 process.raw2digi_step = cms.Path(process.RawToDigi)
0532 process.L1Reco_step = cms.Path(process.L1Reco)
0533 process.reconstruction_step = cms.Path(process.reconstruction)
0534 process.endjob_step = cms.EndPath(process.endOfProcess)
0535
0536
0537
0538
0539
0540 process.GenSkimFilter = cms.EDFilter("SkimCheck",
0541 type=cms.int32(0)
0542 )
0543 process.GenZSCSkimFilter = cms.EDFilter("SkimCheck",
0544 type= cms.int32(2)
0545 )
0546 process.GenWSkimFilter = cms.EDFilter("SkimCheck",
0547 type= cms.int32(1)
0548 )
0549 process.GenZmmgSkimFilter = cms.EDFilter("SkimCheck",
0550 type= cms.int32(1)
0551 )
0552
0553
0554 process.pathZElectronSkimGen = cms.Path(process.filterSeq * process.FilterSeq *
0555 process.GenSkimFilter *
0556 process.ZeeFilter
0557 )
0558 process.pathZSCElectronSkimGen = cms.Path(process.filterSeq * process.FilterSeq * process.MinZSCNumberFilter *
0559 process.GenZSCSkimFilter *
0560 ~process.ZeeFilter * process.ZSCFilter
0561 )
0562 process.pathWElectronSkimGen = cms.Path(process.filterSeq * process.FilterSeq *
0563 process.GenWSkimFilter *
0564 ~process.ZeeFilter * ~process.ZSCFilter * process.WenuFilter
0565 )
0566 process.pathZElectronSkim = cms.Path(process.filterSeq * process.FilterSeq *
0567 process.ZeeFilter
0568
0569 )
0570 process.pathZmmgSkim = cms.Path(process.filterSeq * process.FilterMuSeq * process.ZmmgSkimSeq *
0571 process.GenZmmgSkimFilter *
0572 ~process.ZeeFilter * ~process.ZSCFilter * ~process.WenuFilter * process.ZmmgSkimSeq
0573 )
0574
0575 process.pathZSCElectronSkim = cms.Path(process.filterSeq * process.FilterSeq * process.MinZSCNumberFilter *
0576 ~process.ZeeFilter * process.ZSCFilter
0577
0578 )
0579 process.pathWElectronSkim = cms.Path(process.filterSeq * process.FilterSeq *
0580 ~process.ZeeFilter * ~process.ZSCFilter * process.WenuFilter
0581
0582 )
0583 process.pathZmmgSkim = cms.Path(process.filterSeq * process.ZmmgSkimSeq *
0584 ~process.ZeeFilter * ~process.ZSCFilter * ~process.WenuFilter * process.ZmmgSkimSeq
0585 )
0586
0587 process.pathZElectronGen = cms.Path(process.filterSeq * process.FilterSeq *
0588 process.GenSkimFilter
0589 )
0590 process.pathZSCElectronGen = cms.Path(process.filterSeq * process.FilterSeq * process.MinZSCNumberFilter *
0591 process.GenZSCSkimFilter
0592 )
0593 process.pathWElectronGen = cms.Path(process.filterSeq * process.FilterSeq *
0594 process.GenWSkimFilter
0595 )
0596 process.pathZmmgGen = cms.Path(process.filterSeq * process.FilterMuSeq * process.ZmmgSkimSeq *
0597 process.GenZmmgSkimFilter
0598 )
0599
0600
0601
0602
0603 if (re.match("CMSSW_7_.*",CMSSW_VERSION)):
0604 uncalibRecHitSeq = cms.Sequence( (ecalDigis + ecalPreshowerDigis) * ecalUncalibRecHitSequence)
0605
0606 process.pathALCARECOEcalUncalSingleElectron = cms.Path(process.PUDumperSeq * process.filterSeq *
0607 process.pfIsoEgamma *
0608 (process.ALCARECOEcalCalElectronPreSeq +
0609 uncalibRecHitSeq ))
0610 process.pathALCARECOEcalUncalZElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0611 process.pfIsoEgamma *
0612 (process.ALCARECOEcalCalElectronPreSeq +
0613 uncalibRecHitSeq ))
0614 process.pathALCARECOEcalUncalZSCElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0615 process.pfIsoEgamma *
0616 ~process.ZeeFilter * process.ZSCFilter *
0617 (process.ALCARECOEcalCalElectronPreSeq +
0618 uncalibRecHitSeq ))
0619 process.pathALCARECOEcalUncalWElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0620 process.pfIsoEgamma *
0621 ~process.ZeeFilter * ~process.ZSCFilter * process.WenuFilter *
0622 (process.ALCARECOEcalCalElectronPreSeq +
0623 uncalibRecHitSeq ))
0624 process.pathALCARECOEcalUncalZmmgPhoton = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterMuSeq * process.ZmmgSkimSeq *
0625 process.pfIsoEgamma *
0626 ~process.ZeeFilter * ~process.ZSCFilter * ~process.WenuFilter *
0627 (process.ALCARECOEcalCalElectronPreSeq +
0628 uncalibRecHitSeq ))
0629
0630 else:
0631
0632 process.pathALCARECOEcalUncalSingleElectron = cms.Path(process.PUDumperSeq * process.filterSeq *
0633 process.pfIsoEgamma *
0634 (process.ALCARECOEcalCalElectronPreSeq +
0635 process.seqALCARECOEcalUncalElectron ))
0636 process.pathALCARECOEcalUncalZElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0637 process.pfIsoEgamma *
0638 (process.ALCARECOEcalCalElectronPreSeq +
0639 process.seqALCARECOEcalUncalElectron ))
0640 process.pathALCARECOEcalUncalZSCElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0641 process.pfIsoEgamma *
0642 ~process.ZeeFilter * process.ZSCFilter *
0643 (process.ALCARECOEcalCalElectronPreSeq +
0644 process.seqALCARECOEcalUncalElectron ))
0645 process.pathALCARECOEcalUncalWElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0646 process.pfIsoEgamma *
0647 ~process.ZeeFilter * ~process.ZSCFilter * process.WenuFilter *
0648 (process.ALCARECOEcalCalElectronPreSeq +
0649 process.seqALCARECOEcalUncalElectron ))
0650 process.pathALCARECOEcalCalZmmgPhoton = cms.Path( process.PUDumperSeq *
0651 process.filterSeq * process.FilterMuSeq * process.ZmmgSkimSeq *
0652 ~process.ZeeFilter * ~process.ZSCFilter * ~process.WenuFilter *
0653 process.pfIsoEgamma *
0654 process.seqALCARECOEcalUncalElectron )
0655
0656
0657
0658 process.pathALCARERECOEcalCalElectron = cms.Path(process.alcarerecoSeq)
0659 if(options.doTree>0):
0660 process.pathALCARERECOEcalCalElectron+=cms.Sequence( process.pdfWeightsSeq * process.ntupleSeq)
0661
0662
0663 process.pathALCARECOEcalCalSingleElectron = cms.Path(process.PUDumperSeq * process.filterSeq *
0664 process.pfIsoEgamma *
0665 process.seqALCARECOEcalCalElectron)
0666 process.pathALCARECOEcalCalZElectron = cms.Path( process.PUDumperSeq * process.filterSeq * process.FilterSeq *
0667 process.ZeeFilter *
0668 process.pfIsoEgamma *
0669 process.seqALCARECOEcalCalElectron)
0670 process.pathALCARECOEcalCalWElectron = cms.Path( process.PUDumperSeq * process.filterSeq *
0671 process.FilterSeq *
0672 ~process.ZeeFilter * ~process.ZSCFilter * process.WenuFilter *
0673 process.pfIsoEgamma *
0674 process.seqALCARECOEcalCalElectron)
0675 process.pathALCARECOEcalCalZSCElectron = cms.Path( process.PUDumperSeq *
0676 process.filterSeq * process.FilterSeq *
0677 ~process.ZeeFilter * process.ZSCFilter *
0678
0679 process.pfIsoEgamma *
0680 process.seqALCARECOEcalCalElectron )
0681 process.pathALCARECOEcalCalZmmgPhoton = cms.Path( process.PUDumperSeq *
0682 process.filterSeq * process.FilterMuSeq * process.ZmmgSkimSeq *
0683 process.pfIsoEgamma *
0684 process.seqALCARECOEcalCalPhoton )
0685
0686 if (options.skim=="ZmmgSkim"):
0687 process.NtuplePath = cms.Path(process.filterSeq * process.FilterMuSeq * process.NtupleFilterSeq
0688
0689
0690 * process.pdfWeightsSeq * process.ntupleSeq)
0691 else:
0692 process.NtuplePath = cms.Path(process.filterSeq * process.FilterSeq * process.NtupleFilterSeq
0693
0694
0695 * process.pdfWeightsSeq * process.ntupleSeq)
0696
0697 process.NtupleEndPath = cms.EndPath( process.zNtupleDumper)
0698
0699
0700 if(not doTreeOnly):
0701 process.ALCARECOoutput_step = cms.EndPath(process.outputALCARECO )
0702 if(options.type=="ALCARERECO"):
0703 process.ALCARERECOoutput_step = cms.EndPath(process.outputALCARERECO)
0704 if(options.type=="ALCARAW"):
0705 process.ALCARAWoutput_step = cms.EndPath(process.outputALCARAW)
0706
0707
0708
0709
0710 if((options.doTree>0 and options.doTreeOnly==0)):
0711
0712 process.jsonFilter.jsonFileName = cms.string(options.jsonFile)
0713 else:
0714 if(len(options.jsonFile)>0):
0715
0716 import FWCore.PythonUtilities.LumiList as LumiList
0717 process.source.lumisToProcess = LumiList.LumiList(filename = options.jsonFile).getVLuminosityBlockRange()
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728 if(options.skim=='WSkim'):
0729 process.outputALCARAW.SelectEvents = cms.untracked.PSet(
0730 SelectEvents = cms.vstring('pathALCARECOEcalUncalWElectron')
0731 )
0732 process.outputALCARECO.SelectEvents = cms.untracked.PSet(
0733 SelectEvents = cms.vstring('pathALCARECOEcalCalWElectron')
0734 )
0735 elif(options.skim=='ZSkim'):
0736 process.outputALCARAW.SelectEvents = cms.untracked.PSet(
0737 SelectEvents = cms.vstring('pathALCARECOEcalUncalZElectron', 'pathALCARECOEcalUncalZSCElectron')
0738 )
0739 process.outputALCARECO.SelectEvents = cms.untracked.PSet(
0740 SelectEvents = cms.vstring('pathALCARECOEcalCalZElectron', 'pathALCARECOEcalCalZSCElectron')
0741 )
0742 elif(options.skim=='ZmmgSkim'):
0743 process.outputALCARAW.SelectEvents = cms.untracked.PSet(
0744 SelectEvents = cms.vstring('pathALCARECOEcalUncalZmmgPhoton')
0745 )
0746 process.outputALCARECO.SelectEvents = cms.untracked.PSet(
0747 SelectEvents = cms.vstring('pathALCARECOEcalCalZmmgPhoton')
0748 )
0749 else:
0750
0751 process.outputALCARAW.SelectEvents = cms.untracked.PSet(
0752 SelectEvents = cms.vstring('pathALCARECOEcalUncalSingleElectron')
0753 )
0754 process.outputALCARECO.SelectEvents = cms.untracked.PSet(
0755 SelectEvents = cms.vstring('pathALCARECOEcalCalSingleElectron')
0756 )
0757
0758 if(options.type=='ALCARAW'):
0759 process.schedule = cms.Schedule(
0760
0761
0762 process.pathALCARECOEcalUncalZElectron, process.pathALCARECOEcalUncalWElectron,
0763 process.pathALCARECOEcalUncalZSCElectron,
0764 process.pathALCARECOEcalUncalZmmgPhoton,
0765 process.ALCARAWoutput_step,
0766 process.pathALCARECOEcalCalZElectron, process.pathALCARECOEcalCalWElectron,
0767 process.pathALCARECOEcalCalZSCElectron,
0768 process.pathALCARECOEcalCalZmmgPhoton,
0769 process.ALCARECOoutput_step, process.NtuplePath)
0770
0771
0772 elif(options.type=='ALCARERECO'):
0773 if(doTreeOnly):
0774 process.NtuplePath = cms.Path(process.pdfWeightsSeq * process.ntupleSeq)
0775 process.schedule = cms.Schedule(process.NtuplePath, process.NtupleEndPath)
0776 else:
0777 process.pathALCARERECOEcalCalElectron += process.zNtupleDumper
0778 process.schedule = cms.Schedule(process.pathALCARERECOEcalCalElectron, process.ALCARERECOoutput_step,
0779 )
0780 elif(options.type=='ALCARECO' or options.type=='ALCARECOSIM'):
0781 if(doTreeOnly):
0782 process.schedule = cms.Schedule(process.NtuplePath, process.NtupleEndPath)
0783 else:
0784 if(options.doTree==0):
0785 process.schedule = cms.Schedule(process.pathALCARECOEcalCalZElectron, process.pathALCARECOEcalCalWElectron,
0786 process.pathALCARECOEcalCalZSCElectron, process.pathALCARECOEcalCalZmmgPhoton,
0787 process.ALCARECOoutput_step
0788 )
0789 else:
0790 process.schedule = cms.Schedule(process.pathALCARECOEcalCalZElectron, process.pathALCARECOEcalCalWElectron,
0791 process.pathALCARECOEcalCalZSCElectron, process.pathALCARECOEcalCalZmmgPhoton,
0792 process.ALCARECOoutput_step, process.NtuplePath, process.NtupleEndPath
0793 )
0794 if(options.skim=="" or options.skim=="ZHLTSkim" or options.skim=="partGun"):
0795 process.schedule += cms.Schedule(process.pathALCARECOEcalCalSingleElectron)
0796 elif(options.type=='SKIMEFFTEST'):
0797 process.schedule = cms.Schedule(process.pathWElectronSkimGen, process.pathZSCElectronSkimGen, process.pathZElectronSkimGen,
0798 process.pathWElectronSkim, process.pathZSCElectronSkim, process.pathZElectronSkim,
0799 process.pathWElectronGen, process.pathZSCElectronGen, process.pathZElectronGen,
0800 )
0801
0802 process.zNtupleDumper.foutName=options.secondaryOutput
0803
0804
0805
0806 if(options.isCrab==1):
0807 pathPrefix=""
0808 else:
0809 pathPrefix=CMSSW_BASE+'/'
0810 print("[INFO] Running locally: pathPrefix="+pathPrefix)
0811
0812 process.eleNewEnergiesProducer.regrPhoFile=pathPrefix+process.eleNewEnergiesProducer.regrPhoFile.value()
0813 process.eleNewEnergiesProducer.regrEleFile=pathPrefix+process.eleNewEnergiesProducer.regrEleFile.value()
0814 process.eleNewEnergiesProducer.regrEleFile_fra=pathPrefix+process.eleNewEnergiesProducer.regrEleFile_fra.value()
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834 process.eleRegressionEnergy.energyRegressionType=cms.uint32(2)
0835 if(re.match("CMSSW_4_4_.*", CMSSW_VERSION)):
0836 process.eleRegressionEnergy.regressionInputFile = cms.string("EgammaAnalysis/ElectronTools/data/eleEnergyReg2011Weights_V1.root")
0837 if(re.match("CMSSW_4_2_.*", CMSSW_VERSION)):
0838 pathPrefix=CMSSW_BASE+'/src/Calibration/EleNewEnergiesProducer/'
0839 print('[INFO] Using v2 regression for CMSSW_4_2_X')
0840 process.eleNewEnergiesProducer.regrPhoFile=cms.string(pathPrefix+'data/gbrv2ph.root')
0841 process.eleNewEnergiesProducer.regrEleFile=cms.string(pathPrefix+'data/gbrv2ele.root')
0842 process.eleNewEnergiesProducer.regrEleFile_fra=cms.string('nocorrections')
0843
0844
0845
0846
0847
0848
0849
0850
0851
0852
0853
0854
0855 process.selectedElectrons.src = myEleCollection
0856 if(re.match("CMSSW_5_.*", CMSSW_VERSION)):
0857 process.PassingVeryLooseId.src = myEleCollection
0858 process.PassingMediumId.src = myEleCollection
0859 process.PassingTightId.src = myEleCollection
0860 else:
0861 process.PassingVetoId.src = myEleCollection
0862 process.PassingHLT.InputProducer = myEleCollection
0863
0864 process.eleRegressionEnergy.inputElectronsTag = myEleCollection
0865 process.patElectrons.electronSource = myEleCollection
0866
0867 process.electronMatch.src = myEleCollection
0868 process.eleNewEnergiesProducer.electronCollection = myEleCollection
0869 process.alCaIsolatedElectrons.electronLabel = myEleCollection
0870 if (options.skim=="ZmmgSkim"):
0871 process.alCaIsolatedElectrons.photonLabel = cms.InputTag("gedPhotons")
0872 process.alcaElectronTracksReducer.electronLabel = myEleCollection
0873
0874
0875
0876
0877
0878
0879 process.electronRecalibSCAssociator.electronSrc = myEleCollection
0880
0881
0882
0883 process.eleNewEnergiesProducer.recHitCollectionEB = cms.InputTag("alCaIsolatedElectrons", "alcaBarrelHits")
0884 process.eleNewEnergiesProducer.recHitCollectionEE = cms.InputTag("alCaIsolatedElectrons", "alcaEndcapHits")
0885
0886 if(options.type=="ALCARERECO"):
0887 if(re.match("CMSSW_7_.*",CMSSW_VERSION)):
0888 process.ecalRecHit.EBuncalibRecHitCollection = cms.InputTag("ecalMultiFitUncalibRecHit","EcalUncalibRecHitsEB")
0889 process.ecalRecHit.EEuncalibRecHitCollection = cms.InputTag("ecalMultiFitUncalibRecHit","EcalUncalibRecHitsEE")
0890 else:
0891 process.ecalRecHit.EBuncalibRecHitCollection = cms.InputTag("ecalGlobalUncalibRecHit","EcalUncalibRecHitsEB")
0892 process.ecalRecHit.EEuncalibRecHitCollection = cms.InputTag("ecalGlobalUncalibRecHit","EcalUncalibRecHitsEE")
0893
0894 process.correctedHybridSuperClusters.corectedSuperClusterCollection = 'recalibSC'
0895 process.correctedMulti5x5SuperClustersWithPreshower.corectedSuperClusterCollection = 'endcapRecalibSC'
0896 if(re.match("CMSSW_5_.*",CMSSW_VERSION) or re.match("CMSSW_6_.*", CMSSW_VERSION) or re.match("CMSSW_7_.*", CMSSW_VERSION)):
0897 process.multi5x5PreshowerClusterShape.endcapSClusterProducer = "correctedMulti5x5SuperClustersWithPreshower:endcapRecalibSC"
0898
0899
0900 process.reducedEcalRecHitsES.EndcapSuperClusterCollection= cms.InputTag('correctedMulti5x5SuperClustersWithPreshower','endcapRecalibSC',processName)
0901 recalibElectronSrc = cms.InputTag("electronRecalibSCAssociator")
0902 process.alCaIsolatedElectrons.electronLabel = recalibElectronSrc
0903 process.alCaIsolatedElectrons.ebRecHitsLabel = cms.InputTag("ecalRecHit","EcalRecHitsEB")
0904 process.alCaIsolatedElectrons.eeRecHitsLabel = cms.InputTag("ecalRecHit","EcalRecHitsEE")
0905 process.alCaIsolatedElectrons.EESuperClusterCollection = process.reducedEcalRecHitsES.EndcapSuperClusterCollection
0906
0907 process.eleRegressionEnergy.inputElectronsTag = recalibElectronSrc
0908 process.eleSelectionProducers.electronCollection = recalibElectronSrc
0909 process.eleNewEnergiesProducer.electronCollection = recalibElectronSrc
0910 process.patElectrons.electronSource = recalibElectronSrc
0911 process.eleSelectionProducers.chIsoVals = cms.InputTag('elPFIsoValueCharged03PFIdRecalib')
0912 process.eleSelectionProducers.emIsoVals = cms.InputTag('elPFIsoValueGamma03PFIdRecalib')
0913 process.eleSelectionProducers.nhIsoVals = cms.InputTag('elPFIsoValueNeutral03PFIdRecalib')
0914
0915 process.outputALCARECO.outputCommands += sandboxRerecoOutputCommands
0916 process.outputALCARECO.fileName=cms.untracked.string('alcarereco.root')
0917 process.MinEleNumberFilter.src = recalibElectronSrc
0918 process.zNtupleDumper.WZSkimResultsCollection = cms.InputTag('TriggerResults::ALCASKIM')
0919 process.zNtupleDumper.SelectEvents = []
0920 process.zNtupleDumper.EESuperClusterCollection = cms.InputTag('correctedMulti5x5SuperClustersWithPreshower','endcapRecalibSC', 'ALCARERECO')
0921
0922
0923 process.patElectrons.reducedBarrelRecHitCollection = process.eleNewEnergiesProducer.recHitCollectionEB
0924 process.patElectrons.reducedEndcapRecHitCollection = process.eleNewEnergiesProducer.recHitCollectionEE
0925 process.zNtupleDumper.recHitCollectionEB = process.eleNewEnergiesProducer.recHitCollectionEB
0926 process.zNtupleDumper.recHitCollectionEE = process.eleNewEnergiesProducer.recHitCollectionEE
0927 process.eleRegressionEnergy.recHitCollectionEB = process.eleNewEnergiesProducer.recHitCollectionEB.value()
0928 process.eleRegressionEnergy.recHitCollectionEE = process.eleNewEnergiesProducer.recHitCollectionEE.value()
0929
0930
0931
0932
0933
0934
0935 processDumpFile = open('processDump.py', 'w')
0936 print(process.dumpPython(), file=processDumpFile)