Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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