Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-06-25 23:38:37

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