File indexing completed on 2024-04-06 11:57:11
0001 import json
0002 import os
0003 import FWCore.ParameterSet.Config as cms
0004 import FWCore.PythonUtilities.LumiList as LumiList
0005 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff import filesDefaultMC_NoPU
0006 from FWCore.ParameterSet.VarParsing import VarParsing
0007 from Alignment.OfflineValidation.TkAlAllInOneTool.utils import _byteify
0008
0009
0010
0011
0012 process = cms.Process("PrimaryVertexResolution")
0013
0014
0015
0016
0017 options = VarParsing()
0018 options.register("config", "", VarParsing.multiplicity.singleton, VarParsing.varType.string , "AllInOne config")
0019 options.parseArguments()
0020
0021
0022
0023
0024 if options.config == "":
0025 config = {"validation": {},
0026 "alignment": {}}
0027 else:
0028 with open(options.config, "r") as configFile:
0029 config = json.load(configFile)
0030
0031
0032
0033
0034 readFiles = []
0035
0036 if "dataset" in config["validation"]:
0037 with open(config["validation"]["dataset"], "r") as datafiles:
0038 for fileName in datafiles.readlines():
0039 readFiles.append(fileName.replace("\n", ""))
0040
0041 process.source = cms.Source("PoolSource",
0042 fileNames = cms.untracked.vstring(readFiles),
0043 skipEvents = cms.untracked.uint32(0)
0044 )
0045 else:
0046 print(">>>>>>>>>> SplitV_cfg.py: msg%-i: config not specified! Loading default MC simulation -> filesDefaultMC_NoPU!")
0047 process.source = cms.Source("PoolSource",
0048 fileNames = filesDefaultMC_NoPU,
0049 skipEvents = cms.untracked.uint32(0)
0050 )
0051
0052
0053
0054
0055 if "goodlumi" in config["validation"]:
0056 if os.path.isfile(config["validation"]["goodlumi"]):
0057 goodLumiSecs = cms.untracked.VLuminosityBlockRange(LumiList.LumiList(filename = config["validation"]["goodlumi"]).getCMSSWString().split(','))
0058 else:
0059 print("Does not exist: {}. Continue without good lumi section file.")
0060 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
0061
0062 else:
0063 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
0064
0065
0066
0067
0068 runboundary = config["validation"].get("runboundary", 1)
0069 isMultipleRuns=False
0070 if(isinstance(runboundary, (list, tuple))):
0071 isMultipleRuns=True
0072 print("Multiple Runs are selected")
0073 if(isMultipleRuns):
0074 process.source.firstRun = cms.untracked.uint32(runboundary[0])
0075 else:
0076 process.source.firstRun = cms.untracked.uint32(runboundary)
0077
0078
0079
0080
0081 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(config["validation"].get("maxevents", 1)))
0082
0083
0084
0085
0086 process.options = cms.untracked.PSet(
0087 wantSummary = cms.untracked.bool(False),
0088 Rethrow = cms.untracked.vstring("ProductNotFound"),
0089 fileMode = cms.untracked.string('NOMERGE'),
0090 )
0091
0092
0093
0094
0095 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0096 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
0097 process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True)
0098
0099
0100
0101
0102 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0103 process.load("Configuration.Geometry.GeometryDB_cff")
0104 process.load('Configuration.StandardSequences.Services_cff')
0105 process.load("Configuration.StandardSequences.MagneticField_cff")
0106
0107
0108
0109
0110 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0111 process.TrackRefitter.src = config["validation"].get("trackcollection", "generalTracks")
0112 process.TrackRefitter.TTRHBuilder = config["validation"].get("tthrbuilder", "WithAngleAndTemplate")
0113 process.TrackRefitter.NavigationSchool = ""
0114
0115
0116
0117
0118 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0119 from Configuration.AlCa.GlobalTag import GlobalTag
0120 process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:phase1_2017_realistic"))
0121
0122
0123
0124
0125 if "conditions" in config["alignment"]:
0126 from CalibTracker.Configuration.Common.PoolDBESSource_cfi import poolDBESSource
0127
0128 for condition in config["alignment"]["conditions"]:
0129 setattr(process, "conditionsIn{}".format(condition), poolDBESSource.clone(
0130 connect = cms.string(str(config["alignment"]["conditions"][condition]["connect"])),
0131 toGet = cms.VPSet(
0132 cms.PSet(
0133 record = cms.string(str(condition)),
0134 tag = cms.string(str(config["alignment"]["conditions"][condition]["tag"]))
0135 )
0136 )
0137 )
0138 )
0139
0140 setattr(process, "prefer_conditionsIn{}".format(condition), cms.ESPrefer("PoolDBESSource", "conditionsIn{}".format(condition)))
0141
0142
0143
0144
0145 from HLTrigger.HLTfilters.triggerResultsFilter_cfi import *
0146 process.theHLTFilter = triggerResultsFilter.clone(
0147 triggerConditions = cms.vstring(config["validation"].get("triggerBits", "*")),
0148 hltResults = cms.InputTag( "TriggerResults", "", "HLT" ),
0149 l1tResults = cms.InputTag( "" ),
0150 throw = cms.bool(False)
0151 )
0152
0153
0154
0155
0156 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0157
0158 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
0159 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
0160 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag("TrackRefitter")
0161 process.offlinePrimaryVerticesFromRefittedTrks.vertexCollections.maxDistanceToBeam = 1
0162 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxNormalizedChi2 = 20
0163 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minSiliconLayersWithHits = 5
0164 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Significance = 5.0
0165
0166 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Error = 1.0
0167 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxDzError = 1.0
0168 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minPixelLayersWithHits = 2
0169
0170
0171
0172
0173
0174
0175
0176 compressionSettings = 207
0177
0178
0179
0180
0181 from Alignment.OfflineValidation.splitVertexResolution_cfi import splitVertexResolution as _splitVertexResolution
0182 process.PrimaryVertexResolution = _splitVertexResolution.clone(
0183 compressionSettings = compressionSettings,
0184 storeNtuple = False,
0185 vtxCollection = "offlinePrimaryVerticesFromRefittedTrks",
0186 trackCollection = "TrackRefitter",
0187 minVertexNdf = 10.,
0188 minVertexMeanWeight = 0.5,
0189 runControl = config["validation"].get("runControl", False),
0190 runControlNumber = [runboundary]
0191 )
0192
0193 process.TFileService = cms.Service("TFileService",
0194 fileName = cms.string("{}/SplitV.root".format(config.get("output", os.getcwd()))),
0195 closeFileFast = cms.untracked.bool(True)
0196 )
0197 print("Saving the output at %s" % process.TFileService.fileName.value())
0198
0199 process.theValidSequence = cms.Sequence(process.offlineBeamSpot +
0200 process.TrackRefitter +
0201 process.offlinePrimaryVerticesFromRefittedTrks +
0202 process.PrimaryVertexResolution)
0203
0204 HLTSel = config["validation"].get("HLTselection", False)
0205
0206 if (HLTSel):
0207 process.p = cms.Path(process.theHLTFilter + process.theValidSequence)
0208 else:
0209 process.p = cms.Path(process.theValidSequence)
0210
0211 print("Done")