Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:09

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