File indexing completed on 2024-04-06 11:57:20
0001
0002
0003 '''
0004 cfg to produce ntuples for error scale calibration
0005 here doing refit of tracks and vertices using latest alignment
0006 '''
0007
0008 import FWCore.ParameterSet.Config as cms
0009 from fnmatch import fnmatch
0010 import FWCore.ParameterSet.VarParsing as VarParsing
0011 from pdb import set_trace
0012
0013 process = cms.Process("PrimaryVertexResolution")
0014
0015
0016 def best_match(rcd):
0017
0018 '''
0019 find out where to best match the input conditions
0020 '''
0021 print(rcd)
0022 for pattern, string in connection_map:
0023 print(pattern, fnmatch(rcd, pattern))
0024 if fnmatch(rcd, pattern):
0025 return string
0026
0027 options = VarParsing.VarParsing("analysis")
0028
0029 options.register ('outputRootFile',
0030 "pvresolution_test.root",
0031 VarParsing.VarParsing.multiplicity.singleton,
0032 VarParsing.VarParsing.varType.string,
0033 "output root file")
0034
0035 options.register ('records',
0036 [],
0037 VarParsing.VarParsing.multiplicity.list,
0038 VarParsing.VarParsing.varType.string,
0039 "record:tag names to be used/changed from GT")
0040
0041 options.register ('external',
0042 [],
0043 VarParsing.VarParsing.multiplicity.list,
0044 VarParsing.VarParsing.varType.string,
0045 "record:fle.db picks the following record from this external file")
0046
0047 options.register ('GlobalTag',
0048 'auto:run2_data',
0049 VarParsing.VarParsing.multiplicity.singleton,
0050 VarParsing.VarParsing.varType.string,
0051 "Global Tag to be used")
0052
0053 options.parseArguments()
0054
0055 print("conditionGT : ", options.GlobalTag)
0056 print("conditionOverwrite: ", options.records)
0057 print("external conditions:", options.external)
0058 print("outputFile : ", options.outputRootFile)
0059 print("maxEvents : ", options.maxEvents)
0060
0061 process.load("FWCore.MessageService.MessageLogger_cfi")
0062 process.MessageLogger.cerr = cms.untracked.PSet(enable = cms.untracked.bool(False))
0063 process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet(
0064 reportEvery = cms.untracked.int32(1000)
0065
0066 ))
0067
0068 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) )
0069
0070 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0071 process.load("Configuration.StandardSequences.MagneticField_cff")
0072 process.load('Configuration.Geometry.GeometryRecoDB_cff')
0073
0074 process.load('Configuration/StandardSequences/Services_cff')
0075 process.load('TrackingTools.TransientTrack.TransientTrackBuilder_cfi')
0076
0077 process.source = cms.Source("PoolSource",
0078 fileNames = cms.untracked.vstring(
0079 '/store/express/Run2018C/StreamExpressAlignment/ALCARECO/TkAlMinBias-Express-v1/000/320/039/00000/4C851925-AF8D-E811-96A4-02163E010E90.root',
0080 '/store/express/Run2018C/StreamExpressAlignment/ALCARECO/TkAlMinBias-Express-v1/000/320/040/00000/A8A78033-B18D-E811-9477-02163E019F55.root',
0081 '/store/express/Run2018C/StreamExpressAlignment/ALCARECO/TkAlMinBias-Express-v1/000/320/058/00000/6A45BA9D-F88D-E811-B907-FA163E600F07.root',
0082
0083
0084
0085
0086
0087
0088 )
0089 )
0090
0091
0092
0093 connection_map = [
0094 ('Tracker*', 'frontier://PromptProd/CMS_CONDITIONS'),
0095 ]
0096
0097 if options.external:
0098 connection_map.extend(
0099 (i.split(':')[0], 'sqlite_file:%s' % i.split(':')[1]) for i in options.external
0100 )
0101
0102 connection_map.sort(key=lambda x: -1*len(x[0]))
0103
0104
0105
0106 records = []
0107 if options.records:
0108 for record in options.records:
0109 rcd, tag = tuple(record.split(':'))
0110 records.append(
0111 cms.PSet(
0112 record = cms.string(rcd),
0113 tag = cms.string(tag),
0114 connect = cms.string(best_match(rcd))
0115 )
0116 )
0117
0118 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi")
0119
0120 from Configuration.AlCa.GlobalTag import GlobalTag
0121 process.GlobalTag = GlobalTag(process.GlobalTag, options.GlobalTag, '')
0122 process.GlobalTag.toGet = cms.VPSet(*records)
0123
0124
0125 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0126
0127 process.TrackRefitter.src = 'ALCARECOTkAlMinBias'
0128 process.TrackRefitter.NavigationSchool = ''
0129
0130
0131
0132
0133 process.load("RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi")
0134 process.seqTrackselRefit = cms.Sequence(process.offlineBeamSpot*
0135 process.TrackRefitter,
0136 cms.Task(process.SiPixelTemplateStoreESProducer))
0137
0138
0139
0140
0141 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0142
0143 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
0144 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
0145 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag("TrackRefitter")
0146 process.offlinePrimaryVerticesFromRefittedTrks.vertexCollections.maxDistanceToBeam = 1
0147 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxNormalizedChi2 = 20
0148 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minSiliconLayersWithHits = 5
0149 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Significance = 5.0
0150
0151 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Error = 1.0
0152 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxDzError = 1.0
0153 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minPixelLayersWithHits = 2
0154
0155
0156
0157
0158 from HLTrigger.HLTfilters.triggerResultsFilter_cfi import *
0159 process.HLTFilter = triggerResultsFilter.clone(
0160
0161 triggerConditions = cms.vstring("HLT_HT*"),
0162 hltResults = cms.InputTag( "TriggerResults", "", "HLT" ),
0163 l1tResults = cms.InputTag( "" ),
0164 throw = cms.bool(False)
0165 )
0166
0167
0168
0169 process.myanalysis = cms.EDAnalyzer("GeneralPurposeTrackAnalyzer",
0170 TkTag = cms.InputTag('TrackRefitter'),
0171 isCosmics = cms.bool(False)
0172 )
0173
0174
0175
0176
0177 process.PrimaryVertexResolution = cms.EDAnalyzer('SplitVertexResolution',
0178 storeNtuple = cms.bool(True),
0179 vtxCollection = cms.InputTag("offlinePrimaryVerticesFromRefittedTrks"),
0180 trackCollection = cms.InputTag("TrackRefitter"),
0181 minVertexNdf = cms.untracked.double(10.),
0182 minVertexMeanWeight = cms.untracked.double(0.5),
0183 runControl = cms.untracked.bool(True),
0184 runControlNumber = cms.untracked.vuint32(320040),
0185 sumpTStartScale = cms.untracked.double(1.),
0186 sumpTEndScale = cms.untracked.double(1000.),
0187 nTrackBins = cms.untracked.double(60.),
0188 nVtxBins = cms.untracked.double(40.)
0189 )
0190
0191 process.TFileService = cms.Service("TFileService",
0192 fileName = cms.string(options.outputRootFile),
0193 closeFileFast = cms.untracked.bool(False)
0194 )
0195
0196 process.p = cms.Path(process.HLTFilter +
0197
0198
0199 process.seqTrackselRefit +
0200 process.offlinePrimaryVerticesFromRefittedTrks +
0201 process.PrimaryVertexResolution +
0202 process.myanalysis)
0203
0204