2 cfg to produce alignment validation plots from JetHT sample 3 here doing refit of tracks and vertices using latest alignment 7 import FWCore.ParameterSet.Config
as cms
8 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff
import filesDefaultData_JetHTRun2018D
9 process = cms.Process(
"JetHTAnalyzer")
12 import FWCore.ParameterSet.VarParsing
as VarParsing
15 options.register (
'config',
17 VarParsing.VarParsing.multiplicity.singleton,
18 VarParsing.VarParsing.varType.string,
20 options.register (
'runType',
22 VarParsing.VarParsing.multiplicity.singleton,
23 VarParsing.VarParsing.varType.string,
25 options.register (
'jobNumber',
27 VarParsing.VarParsing.multiplicity.singleton,
28 VarParsing.VarParsing.varType.int,
30 options.parseArguments()
37 if options.config ==
"":
38 configuration = {
"validation": {},
41 with open(options.config,
"r") as configFile: 42 configuration = json.load(configFile) 45 useMC = configuration[
"validation"].get(
"mc",
False)
46 printTriggers = configuration[
"validation"].get(
"printTriggers",
False)
47 triggerFilter =
str(configuration[
"validation"].get(
"triggerFilter",
"nothing"))
48 iovListFile =
str(configuration[
"validation"].get(
"iovListFile",
"nothing"))
49 iovListList = configuration[
"validation"].get(
"iovList", [0,500000])
50 ptBorders = configuration[
"validation"].get(
"profilePtBorders", [3,5,10,20,50,100])
51 trackCollection =
str(configuration[
"validation"].get(
"trackCollection",
"ALCARECOTkAlMinBias"))
52 maxEventsToRun = configuration[
"validation"].get(
"maxevents", 1)
53 filesPerJob = configuration[
"validation"].get(
"filesPerJob", 5)
54 runsInFiles = configuration.get(
"runsInFiles",[])
57 globalTag =
str(configuration[
"alignment"].get(
"globaltag",
"auto:run2_data"))
60 alignmentFile =
str(configuration[
"validation"].get(
"TrackerAlignmentRcdFile",
"nothing"))
61 alignmentErrorFile =
str(configuration[
"validation"].get(
"TrackerAlignmentErrorFile",
"nothing"))
65 if not (iovListFile ==
"nothing" or iovListFile ==
""):
68 iovListFile = iovListFile.replace(
"CMSSW_BASE", os.environ[
"CMSSW_BASE"])
72 iovReader = open(iovListFile,
"r") 73 iovContents = iovReader.readlines() 75 for line
in iovContents:
76 lineContents = line.split()
77 iovListList.append(
int(lineContents[0]))
80 iovListList.append(iovListList[-1]+100)
86 process.load(
"FWCore.MessageService.MessageLogger_cfi")
87 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
88 process.MessageLogger.cout.enableStatistics = cms.untracked.bool(
True)
91 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(maxEventsToRun) )
96 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
97 process.load(
"Configuration.Geometry.GeometryDB_cff")
98 process.load(
'Configuration.StandardSequences.Services_cff')
99 process.load(
"Configuration.StandardSequences.MagneticField_cff")
104 if "dataset" in configuration[
"validation"]:
107 if re.match(
r'^/[^/.]+/[^/.]+/[^/.]+$', configuration[
"validation"][
"dataset"] ):
110 process.source = cms.Source(
"PoolSource",
111 fileNames = cms.untracked.vstring(
"dummy.dat"),
112 skipEvents = cms.untracked.uint32(0)
117 with open(configuration[
"validation"][
"dataset"],
"r") as datafiles: 118 for fileName
in datafiles.readlines():
119 readFiles.append(fileName.replace(
"\n",
""))
122 if len(runsInFiles) > 0:
124 for line
in readFiles:
125 runAndFile = line.split()
126 if runsInFiles[options.jobNumber] == runAndFile[0]:
127 newFiles.append(runAndFile[1])
131 process.source = cms.Source(
"PoolSource",
132 fileNames = cms.untracked.vstring(readFiles),
133 eventsToProcess = cms.untracked.VEventRange(
"{}:1-{}:max".
format(runsInFiles[options.jobNumber], runsInFiles[options.jobNumber]))
137 elif options.jobNumber >= 0:
139 numberOfFiles = len(readFiles)
140 firstIndex = filesPerJob * options.jobNumber
141 for fileIndex
in range(firstIndex, firstIndex+filesPerJob):
142 if fileIndex >= numberOfFiles:
144 newFiles.append(readFiles[fileIndex])
148 process.source = cms.Source(
"PoolSource",
149 fileNames = cms.untracked.vstring(readFiles),
150 skipEvents = cms.untracked.uint32(0)
156 process.source = cms.Source(
"PoolSource",
157 fileNames = cms.untracked.vstring(readFiles),
158 skipEvents = cms.untracked.uint32(0)
163 print(
">>>>>>>>>> JetHT_cfg.py: msg%-i: dataset not specified in configuration! Loading default file!")
166 print(
">>>>>>>>>> JetHT_cfg.py: msg%-i: Default file for 2018 MC from 170-300 pT hat bin.")
167 process.source = cms.Source(
"PoolSource",
168 fileNames = cms.untracked.vstring(
'root://xrootd-cms.infn.it//store/mc/RunIIWinter19PFCalibDRPremix/QCD_Pt_170to300_TuneCP5_13TeV_pythia8/ALCARECO/TkAlMinBias-2018Conditions_105X_upgrade2018_realistic_v4-v1/270000/C42688BC-7401-3A41-9008-7CD1CA4B09E1.root')
171 print(
">>>>>>>>>> JetHT_cfg.py: msg%-i: Default file read from 2018D JetHT dataset.")
172 process.source = cms.Source(
"PoolSource",
173 fileNames = filesDefaultData_JetHTRun2018D)
178 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
179 from Configuration.AlCa.GlobalTag
import GlobalTag
180 process.GlobalTag =
GlobalTag(process.GlobalTag, globalTag)
189 if "conditions" in configuration[
"alignment"]:
192 for condition
in configuration[
"alignment"][
"conditions"]:
193 setattr(process,
"conditionsIn{}".
format(condition), poolDBESSource.clone(
194 connect = cms.string(
str(configuration[
"alignment"][
"conditions"][condition][
"connect"])),
197 record = cms.string(
str(condition)),
198 tag = cms.string(
str(configuration[
"alignment"][
"conditions"][condition][
"tag"]))
204 setattr(process,
"prefer_conditionsIn{}".
format(condition), cms.ESPrefer(
"PoolDBESSource",
"conditionsIn{}".
format(condition)))
207 if not (alignmentFile ==
"nothing" or alignmentFile ==
""):
208 process.conditionsInTrackerAlignmentRcd = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
209 connect = cms.string(
"sqlite_file:" + alignmentFile),
210 toGet = cms.VPSet(cms.PSet(record = cms.string(
'TrackerAlignmentRcd'),
211 tag = cms.string(
'Alignments')
215 process.prefer_conditionsInTrackerAlignmentRcd = cms.ESPrefer(
"PoolDBESSource",
"conditionsInTrackerAlignmentRcd")
218 if not (alignmentErrorFile ==
"nothing" or alignmentErrorFile ==
""):
219 process.conditionsInTrackerAlignmentErrorExtendedRcd = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
220 connect = cms.string(
"sqlite_file:" + alignmentErrorFile),
221 toGet = cms.VPSet(cms.PSet(record = cms.string(
'TrackerAlignmentErrorExtendedRcd'),
222 tag = cms.string(
'APEs')
226 process.prefer_conditionsInTrackerAlignmentErrorExtendedRcd = cms.ESPrefer(
"PoolDBESSource",
"conditionsInTrackerAlignmentErrorExtendedRcd")
234 process.load(
"RecoTracker.TrackProducer.TrackRefitters_cff")
236 process.TrackRefitter.src = trackCollection
237 process.TrackRefitter.NavigationSchool =
"" 240 process.load(
"TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
243 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
244 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag(
"TrackRefitter")
245 process.offlinePrimaryVerticesFromRefittedTrks.vertexCollections.maxDistanceToBeam = 1
246 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxNormalizedChi2 = 20
247 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minSiliconLayersWithHits = 5
248 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Significance = 5.0
249 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minPixelLayersWithHits = 2
255 if not (triggerFilter ==
"nothing" or triggerFilter ==
""):
256 triggerPath = triggerFilter
257 process.HLTFilter = triggerResultsFilter.clone(
258 triggerConditions = cms.vstring(triggerPath),
259 hltResults = cms.InputTag(
"TriggerResults",
"",
"HLT" ),
260 l1tResults = cms.InputTag(
"" ),
261 throw = cms.bool(
False)
267 from Alignment.OfflineValidation.jetHTAnalyzer_cfi
import jetHTAnalyzer
as _jetHTAnalyzer
268 process.jetHTAnalyzer = _jetHTAnalyzer.clone(
269 vtxCollection =
"offlinePrimaryVerticesFromRefittedTrks",
270 trackCollection =
"TrackRefitter",
271 triggerResults = (
"TriggerResults",
"",
"HLT"),
272 printTriggerTable = printTriggers,
274 minVertexMeanWeight = 0.5,
275 profilePtBorders = ptBorders,
276 iovList = iovListList)
279 if options.jobNumber >= 0:
280 jobNumberString =
"_{}".
format(options.jobNumber)
282 outputName =
"{}/JetHTAnalysis{}.root".
format(configuration.get(
"output", os.getcwd()), jobNumberString)
283 if options.runType ==
"crab":
284 outputName =
"JetHTAnalysis.root" 286 process.TFileService = cms.Service(
"TFileService",
287 fileName = cms.string(outputName),
288 closeFileFast = cms.untracked.bool(
False)
292 if (triggerFilter ==
"nothing" or triggerFilter ==
""):
293 process.p = cms.Path(process.offlineBeamSpot +
294 process.TrackRefitter +
295 process.offlinePrimaryVerticesFromRefittedTrks +
296 process.jetHTAnalyzer)
298 process.p = cms.Path(process.HLTFilter +
299 process.offlineBeamSpot +
300 process.TrackRefitter +
301 process.offlinePrimaryVerticesFromRefittedTrks +
302 process.jetHTAnalyzer)
The trigger filter module.
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)