File indexing completed on 2024-04-06 11:57:20
0001 import glob
0002 import math
0003 import FWCore.ParameterSet.Config as cms
0004 import FWCore.Utilities.FileUtils as FileUtils
0005 from FWCore.ParameterSet.VarParsing import VarParsing
0006 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff import filesDefaultMC_DoubleMuon_string
0007
0008 options = VarParsing('analysis')
0009 options.register('scenario',
0010 'null',
0011 VarParsing.multiplicity.singleton,
0012 VarParsing.varType.string,
0013 "Name of input misalignment scenario")
0014
0015 options.register('globalTag',
0016 "'auto:phase1_2022_realistic",
0017 VarParsing.multiplicity.singleton,
0018 VarParsing.varType.string,
0019 "name of the input Global Tag")
0020
0021 options.register ('myfile',
0022 filesDefaultMC_DoubleMuon_string,
0023 VarParsing.multiplicity.singleton,
0024 VarParsing.varType.string,
0025 "file name")
0026
0027 options.register ('FileList',
0028 '',
0029 VarParsing.multiplicity.singleton,
0030 VarParsing.varType.string,
0031 "FileList in DAS format")
0032
0033 options.parseArguments()
0034
0035 if(options.FileList):
0036 print("FileList: ", options.FileList)
0037 else:
0038 print("inputFile: ", options.myfile)
0039 print("outputFile: ", "ZmmNtuple_MC_GEN-SIM_{fscenario}.root".format(fscenario=options.scenario))
0040 print("conditionGT: ", options.globalTag)
0041 print("max events: ", options.maxEvents)
0042
0043 valid_scenarios = ['-10e-6','-8e-6','-6e-6','-4e-6','-2e-6','0','2e-6','4e-6','6e-6','8e-6','10e-6','null']
0044
0045 if options.scenario not in valid_scenarios:
0046 print("Error: Invalid scenario specified. Please choose from the following list: ")
0047 print(valid_scenarios)
0048 exit(1)
0049
0050 process = cms.Process("SagittaBiasNtuplizer")
0051
0052
0053
0054
0055 process.options.numberOfThreads = 8
0056
0057
0058
0059
0060 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0061 process.MessageLogger.cerr.enable = False
0062 process.MessageLogger.SagittaBiasNtuplizer=dict()
0063 process.MessageLogger.cout = cms.untracked.PSet(
0064 enable = cms.untracked.bool(True),
0065 threshold = cms.untracked.string("INFO"),
0066 default = cms.untracked.PSet(limit = cms.untracked.int32(0)),
0067 FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
0068 reportEvery = cms.untracked.int32(1000)
0069 ),
0070 SagittaBiasNtuplizer = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
0071 enableStatistics = cms.untracked.bool(True)
0072 )
0073
0074
0075
0076
0077 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0078 process.load("Configuration.StandardSequences.Services_cff")
0079 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0080 process.load('Configuration.StandardSequences.MagneticField_cff')
0081 process.load("CondCore.CondDB.CondDB_cfi")
0082
0083
0084
0085
0086 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0087 process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi')
0088 process.load('TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi')
0089 process.load('TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff')
0090
0091
0092
0093
0094 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0095 from Configuration.AlCa.GlobalTag import GlobalTag
0096 process.GlobalTag = GlobalTag(process.GlobalTag,"125X_mcRun3_2022_design_v6", '')
0097 if (options.scenario=='null'):
0098 print("null scenario, do nothing")
0099 pass
0100 elif (options.scenario=='ideal'):
0101 print("ideal scenario, use ideal tags")
0102 process.GlobalTag.toGet = cms.VPSet(cms.PSet(record = cms.string('TrackerAlignmentRcd'),
0103 tag = cms.string("TrackerAlignment_Upgrade2017_design_v4")),
0104 cms.PSet(record = cms.string('TrackerAlignmentErrorExtendedRcd'),
0105 tag = cms.string("TrackerAlignmentErrorsExtended_Upgrade2017_design_v0")),
0106 cms.PSet(record = cms.string('TrackerSurfaceDeformationRcd'),
0107 tag = cms.string("TrackerSurfaceDeformations_zero")))
0108 else :
0109 print("using {} scenario".format(options.scenario))
0110 process.GlobalTag.toGet = cms.VPSet(cms.PSet(connect = cms.string("sqlite_file:/afs/cern.ch/user/m/musich/public/layer_rotation_studies/outputfile_"+options.scenario+".db"),
0111 record = cms.string('TrackerAlignmentRcd'),
0112 tag = cms.string("Alignments")))
0113
0114
0115
0116
0117 if(options.FileList):
0118 print('Loading file list from ASCII file')
0119 filelist = FileUtils.loadListFromFile (options.FileList)
0120 readFiles = cms.untracked.vstring( *filelist)
0121 else:
0122 readFiles = cms.untracked.vstring([options.myfile])
0123
0124 process.source = cms.Source("PoolSource",
0125 fileNames = readFiles)
0126
0127 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents))
0128
0129
0130
0131
0132 import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
0133 process.MuSkimSelector = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
0134 applyBasicCuts = True,
0135 filter = True,
0136 src = "ALCARECOTkAlDiMuon",
0137 ptMin = 17.,
0138 pMin = 17.,
0139 etaMin = -2.5,
0140 etaMax = 2.5,
0141 d0Min = -2.,
0142 d0Max = 2.,
0143 dzMin = -25.,
0144 dzMax = 25.,
0145 nHitMin = 6,
0146 nHitMin2D = 0)
0147
0148
0149
0150
0151 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0152 import RecoTracker.TrackProducer.TrackRefitters_cff
0153 process.refittedMuons = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
0154 src = "ALCARECOTkAlDiMuon",
0155 TrajectoryInEvent = True,
0156 NavigationSchool = '',
0157 TTRHBuilder = "WithAngleAndTemplate")
0158
0159
0160
0161
0162 process.refittedVtxTracks = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
0163 src = "ALCARECOTkAlDiMuonVertexTracks",
0164 TrajectoryInEvent = True,
0165 NavigationSchool = '',
0166 TTRHBuilder = "WithAngleAndTemplate")
0167
0168
0169
0170
0171 process.refittedTracks = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
0172 src = "generalTracks",
0173 TrajectoryInEvent = True,
0174 NavigationSchool = '',
0175 TTRHBuilder = "WithAngleAndTemplate")
0176
0177
0178
0179
0180 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
0181 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
0182
0183 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag("refittedTracks")
0184
0185
0186
0187
0188 process.ZtoMMNtuple = cms.EDAnalyzer("SagittaBiasNtuplizer",
0189
0190 useReco = cms.bool(True),
0191 muons = cms.InputTag('muons'),
0192 doGen = cms.bool(True),
0193 tracks = cms.InputTag('refittedTracks'),
0194 vertices = cms.InputTag('offlinePrimaryVerticesFromRefittedTrks'))
0195
0196 process.DiMuonVertexValidation = cms.EDAnalyzer("DiMuonVertexValidation",
0197 useReco = cms.bool(False),
0198
0199
0200
0201 muonTracks = cms.InputTag('refittedMuons'),
0202 tracks = cms.InputTag(''),
0203 vertices = cms.InputTag('offlinePrimaryVerticesFromRefittedTrks'))
0204
0205 from Alignment.OfflineValidation.diMuonValidation_cfi import diMuonValidation as _diMuonValidation
0206 process.DiMuonMassValidation = _diMuonValidation.clone(
0207 TkTag = 'refittedMuons',
0208
0209
0210 Pair_mass_min = 80.,
0211 Pair_mass_max = 120.,
0212 Pair_mass_nbins = 80,
0213 Pair_etaminpos = -2.4,
0214 Pair_etamaxpos = 2.4,
0215 Pair_etaminneg = -2.4,
0216 Pair_etamaxneg = 2.4,
0217
0218 Variable_CosThetaCS_xmin = -1.,
0219 Variable_CosThetaCS_xmax = 1.,
0220 Variable_CosThetaCS_nbins = 20,
0221
0222 Variable_DeltaEta_xmin = -4.8,
0223 Variable_DeltaEta_xmax = 4.8,
0224 Variable_DeltaEta_nbins = 20,
0225
0226 Variable_EtaMinus_xmin = -2.4,
0227 Variable_EtaMinus_xmax = 2.4,
0228 Variable_EtaMinus_nbins = 12,
0229
0230 Variable_EtaPlus_xmin = -2.4,
0231 Variable_EtaPlus_xmax = 2.4,
0232 Variable_EtaPlus_nbins = 12,
0233
0234 Variable_PhiCS_xmin = -math.pi/2.,
0235 Variable_PhiCS_xmax = math.pi/2.,
0236 Variable_PhiCS_nbins = 20,
0237
0238 Variable_PhiMinus_xmin = -math.pi,
0239 Variable_PhiMinus_xmax = math.pi,
0240 Variable_PhiMinus_nbins = 16,
0241
0242 Variable_PhiPlus_xmin = -math.pi,
0243 Variable_PhiPlus_xmax = math.pi,
0244 Variable_PhiPlus_nbins = 16,
0245
0246 Variable_PairPt_xmin = 0.,
0247 Variable_PairPt_xmax = 100.,
0248 Variable_PairPt_nbins = 100)
0249
0250
0251
0252
0253 process.TFileService = cms.Service("TFileService",
0254 fileName = cms.string("ZmmNtuple_MC_GEN-SIM_"+options.scenario+".root"))
0255
0256
0257
0258
0259 process.p1 = cms.Path(process.offlineBeamSpot
0260
0261
0262 * process.refittedTracks
0263 * process.offlinePrimaryVerticesFromRefittedTrks
0264 * process.ZtoMMNtuple)
0265
0266