Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:23

0001 from __future__ import print_function
0002 import os
0003 import FWCore.ParameterSet.Config as cms
0004 
0005 
0006 ##
0007 ## Setup command line options
0008 ##
0009 import FWCore.ParameterSet.VarParsing as VarParsing
0010 import sys
0011 options = VarParsing.VarParsing ('standard')
0012 options.register('sample', 'data1', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Input sample")
0013 options.register('useTrackList', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Use list of preselected tracks")
0014 options.register('isTest', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Test run")
0015 
0016 # get and parse the command line arguments
0017 options.parseArguments()
0018 
0019 print("Input sample: ", options.sample)
0020 print("Use list of preselected tracks: ", options.useTrackList)
0021 print("Test run: ", options.isTest)
0022 
0023 
0024 ##
0025 ## Process definition
0026 ##
0027 process = cms.Process("ApeSkim")
0028 
0029 
0030 
0031 ##
0032 ## Message Logger
0033 ##
0034 process.load("FWCore.MessageService.MessageLogger_cfi")
0035 process.MessageLogger.AlignmentTrackSelector=dict()
0036 process.MessageLogger.cerr.INFO.limit = 0
0037 process.MessageLogger.cerr.default.limit = -1
0038 process.MessageLogger.cerr.AlignmentTrackSelector = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0039 process.MessageLogger.cerr.FwkReport.reportEvery = 1000 ## really show only every 1000th
0040 
0041 
0042 
0043 ##
0044 ## Process options
0045 ##
0046 process.options = cms.untracked.PSet(
0047     wantSummary = cms.untracked.bool(True),
0048 )
0049 
0050 
0051 ##
0052 ## Start of Configuration
0053 ##
0054 
0055 maxEvents = -1
0056 outputName = "defaultOutputName.root"
0057 outputPath = None
0058 outputFileSize = 350000
0059 
0060 ##
0061 ## TrackSelection can be SingleMu, DoubleMu, MinBias, Cosmics
0062 ## The choice affects which AlignmentTrackSelector is used.
0063 ## Currently, DoubleMu means ZToMuMu, so if there is the need 
0064 ## for UpsilonToMuMu or JPsiToMuMu, these have to be added first
0065 ##
0066 trackSelection = "SingleMu"
0067 globalTag = None
0068 outputPath = None # can also be specified. If that is done, files are copied to this path afterwards
0069 
0070 if "iov" in options.sample:
0071     ## Configure here for campaigns with many different datasets (such as multi-IOV)
0072     iovNo = options.sample.split("iov")[1]
0073     process.load("Alignment.APEEstimation.samples.")
0074     outputName = ".root"
0075     outputPath = None
0076     trackSelection = "SingleMu"
0077 if options.sample == 'data1':
0078     process.load("Alignment.APEEstimation.samples.Data_TkAlMinBias_Run2018C_PromptReco_v3_cff")
0079     outputName = 'MinBias.root'
0080     #outputPath = "workingArea"
0081     trackSelection = "MinBias"
0082 if options.sample == 'data2': 
0083     process.load("Alignment.APEEstimation.samples.Data_TkAlMinBias_Run2018C_PromptReco_v3_cff")
0084     outputName = 'MinBias1.root'
0085     #outputPath = "workingArea"
0086     trackSelection = "MinBias"
0087 if options.sample == 'data3':
0088     process.load("Alignment.APEEstimation.samples.Data_TkAlMuonIsolated_22Jan2013C_v1_cff")
0089     outputName = 'Data_TkAlMuonIsolated_22Jan2013C.root'
0090     trackSelection = "SingleMu"
0091 if options.sample == 'data4':
0092     process.load("Alignment.APEEstimation.samples.Data_TkAlMuonIsolated_22Jan2013D_v1_cff")
0093     outputName = 'Data_TkAlMuonIsolated_22Jan2013D.root'
0094     trackSelection = "SingleMu"
0095 # The following options are used for MC samples
0096 if options.sample == 'qcd':
0097     globalTag = "auto:run2_mc"
0098     process.load("Alignment.APEEstimation.samples.MC_UL16_ttbar_cff")
0099     outputPath = '/eos/cms/store/caf/user/mteroerd/Skims/MC/UL16'    
0100     outputName = 'MC_UL16_ttbar.root'
0101     trackSelection = "GenSim"
0102 if options.sample == 'wlnu':
0103     process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_2016UL_cff")
0104     outputPath = '/eos/cms/store/caf/user/jschulz/Skims/MC/UL2016ReRecoRealistic'
0105     outputName = 'Mc_TkAlMuonIsolated_WJetsToLNu_2016.root'
0106     trackSelection = "SingleMu"
0107 if options.sample == 'zmumu': 
0108     process.load("")
0109     outputName = ''
0110     trackSelection = "DoubleMu"
0111 if options.sample == 'zmumu10': 
0112     process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer12_zmumu10_cff")
0113     outputName = 'Mc_TkAlMuonIsolated_Summer12_zmumu10.root'
0114     trackSelection = "DoubleMu"
0115 if options.sample == 'zmumu20': 
0116     process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer12_zmumu20_cff")
0117     outputName = 'Mc_TkAlMuonIsolated_Summer12_zmumu20.root'
0118     trackSelection = "DoubleMu"
0119 if options.sample == 'zmumu50':
0120     process.load("Alignment.APEEstimation.samples.DYToMuMu_M-50_Tune4C_13TeV-pythia8_Spring14dr-TkAlMuonIsolated-castor_PU_S14_POSTLS170_V6-v1_ALCARECO_cff")
0121     outputName = 'Mc_DYToMuMu_M-50_Tune4C_13TeV-pythia8_Spring14dr-TkAlMuonIsolated-castor_PU_S14_POSTLS170_V6-v1.root'
0122     trackSelection = "DoubleMu"
0123 
0124 
0125 print("Using output name %s"%(outputName))
0126 if outputPath:
0127     print("Using output path %s"%(outputPath))
0128 
0129 ##
0130 ## Choice of GlobalTag
0131 ##
0132 
0133 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0134 from Configuration.AlCa.GlobalTag import GlobalTag
0135 
0136 if globalTag == None:
0137     print("No global tag specified, is this intended?")
0138 else:   
0139     process.GlobalTag = GlobalTag(process.GlobalTag, globalTag, '')
0140 print("Using global tag "+process.GlobalTag.globaltag._value)
0141 
0142 process.load("Configuration.StandardSequences.Services_cff")
0143 process.load("Configuration.Geometry.GeometryRecoDB_cff")
0144 process.load("Configuration.StandardSequences.MagneticField_cff")
0145 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0146 
0147 ##
0148 ## Number of Events (should be after input file)
0149 ##
0150 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(maxEvents) )
0151 if options.isTest: process.maxEvents.input = 1001
0152 
0153 
0154 ##
0155 ## Skim tracks
0156 ##
0157 
0158 
0159 
0160 import Alignment.APEEstimation.AlignmentTrackSelector_cff as AlignmentTrackSelector
0161 
0162 
0163 # Determination of which AlignmentTrackSelector to use
0164 if trackSelection == "SingleMu":
0165     trackSelector = AlignmentTrackSelector.MuSkimSelector
0166 elif trackSelection == "GenSim":
0167     trackSelector = AlignmentTrackSelector.genSimSkimSelector    
0168 elif trackSelection == "DoubleMu":
0169     trackSelector = AlignmentTrackSelector.DoubleMuSkimSelector
0170 elif trackSelection == "MinBias":
0171     trackSelector = AlignmentTrackSelector.MinBiasSkimSelector
0172 elif trackSelection == "Cosmics":
0173     trackSelector = AlignmentTrackSelector.CosmicsSkimSelector
0174 else: # Extend list here with custom track selectors
0175     print("Unknown trackSelection %s, exiting"%(trackSelection))
0176     exit(1)
0177 
0178 process.MuSkim = trackSelector
0179 
0180 ##
0181 ## If preselected track list is used
0182 ##
0183 if options.useTrackList:
0184     process.MuSkim.src = 'TrackList'
0185     process.TriggerSelectionSequence *= process.TrackList
0186 
0187 import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRefit
0188 process.seqTrackselRefit = trackselRefit.getSequence(process, trackSelector.src.getModuleLabel())
0189 
0190 
0191 ##
0192 ## Path
0193 ##
0194 process.path = cms.Path(
0195     process.offlineBeamSpot*
0196     process.seqTrackselRefit*
0197     process.MuSkim
0198 )
0199 
0200 ##
0201 ## Define event selection from path
0202 ##
0203 EventSelection = cms.PSet(
0204     SelectEvents = cms.untracked.PSet(
0205         SelectEvents = cms.vstring('path')
0206     )
0207 )
0208 
0209 
0210 ##
0211 ## configure output module
0212 ##
0213 process.out = cms.OutputModule("PoolOutputModule",
0214     ## Parameters directly for PoolOutputModule
0215     fileName = cms.untracked.string(outputName),
0216     # Maximum size per file before a new one is created
0217     maxSize = cms.untracked.int32(outputFileSize),
0218     dropMetaData = cms.untracked.string("DROPPED"),
0219     ## Parameters for inherited OutputModule
0220     SelectEvents = EventSelection.SelectEvents,
0221     outputCommands = cms.untracked.vstring(
0222         'drop *',
0223     ),
0224 )
0225 process.load("Alignment.APEEstimation.PrivateSkim_EventContent_cff")
0226 process.out.outputCommands.extend(process.ApeSkimEventContent.outputCommands)
0227 
0228 
0229 if options.isTest:
0230   process.out.fileName = os.environ['CMSSW_BASE'] + '/src/Alignment/APEEstimation/hists/test_apeSkim.root'
0231 
0232 
0233 ##
0234 ## Outpath
0235 ##
0236 process.outpath = cms.EndPath(process.out)