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 process = cms.Process(
"JetHTAnalyzer")
11 import FWCore.ParameterSet.VarParsing
as VarParsing
14 options.register (
'config',
16 VarParsing.VarParsing.multiplicity.singleton,
17 VarParsing.VarParsing.varType.string,
19 options.register (
'runType',
21 VarParsing.VarParsing.multiplicity.singleton,
22 VarParsing.VarParsing.varType.string,
24 options.register (
'jobNumber',
26 VarParsing.VarParsing.multiplicity.singleton,
27 VarParsing.VarParsing.varType.int,
29 options.parseArguments()
36 if options.config ==
"":
37 configuration = {
"validation": {},
40 with open(options.config,
"r") as configFile: 41 configuration = json.load(configFile) 44 useMC = configuration[
"validation"].get(
"mc",
False)
45 printTriggers = configuration[
"validation"].get(
"printTriggers",
False)
46 triggerFilter =
str(configuration[
"validation"].get(
"triggerFilter",
"nothing"))
47 iovListFile =
str(configuration[
"validation"].get(
"iovListFile",
"nothing"))
48 iovListList = configuration[
"validation"].get(
"iovList", [0,500000])
49 ptBorders = configuration[
"validation"].get(
"profilePtBorders", [3,5,10,20,50,100])
50 trackCollection =
str(configuration[
"validation"].get(
"trackCollection",
"ALCARECOTkAlMinBias"))
51 maxEventsToRun = configuration[
"validation"].get(
"maxevents", 1)
52 filesPerJob = configuration[
"validation"].get(
"filesPerJob", 5)
53 runsInFiles = configuration.get(
"runsInFiles",[])
56 globalTag =
str(configuration[
"alignment"].get(
"globaltag",
"auto:run2_data"))
59 alignmentFile =
str(configuration[
"validation"].get(
"TrackerAlignmentRcdFile",
"nothing"))
60 alignmentErrorFile =
str(configuration[
"validation"].get(
"TrackerAlignmentErrorFile",
"nothing"))
64 if not (iovListFile ==
"nothing" or iovListFile ==
""):
67 iovListFile = iovListFile.replace(
"CMSSW_BASE", os.environ[
"CMSSW_BASE"])
71 iovReader = open(iovListFile,
"r") 72 iovContents = iovReader.readlines() 74 for line
in iovContents:
75 lineContents = line.split()
76 iovListList.append(
int(lineContents[0]))
79 iovListList.append(iovListList[-1]+100)
85 process.load(
"FWCore.MessageService.MessageLogger_cfi")
86 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
87 process.MessageLogger.cout.enableStatistics = cms.untracked.bool(
True)
90 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(maxEventsToRun) )
95 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
96 process.load(
"Configuration.Geometry.GeometryDB_cff")
97 process.load(
'Configuration.StandardSequences.Services_cff')
98 process.load(
"Configuration.StandardSequences.MagneticField_cff")
103 if "dataset" in configuration[
"validation"]:
106 if re.match(
r'^/[^/.]+/[^/.]+/[^/.]+$', configuration[
"validation"][
"dataset"] ):
109 process.source = cms.Source(
"PoolSource",
110 fileNames = cms.untracked.vstring(
"dummy.dat"),
111 skipEvents = cms.untracked.uint32(0)
116 with open(configuration[
"validation"][
"dataset"],
"r") as datafiles: 117 for fileName
in datafiles.readlines():
118 readFiles.append(fileName.replace(
"\n",
""))
121 if len(runsInFiles) > 0:
123 for line
in readFiles:
124 runAndFile = line.split()
125 if runsInFiles[options.jobNumber] == runAndFile[0]:
126 newFiles.append(runAndFile[1])
130 process.source = cms.Source(
"PoolSource",
131 fileNames = cms.untracked.vstring(readFiles),
132 eventsToProcess = cms.untracked.VEventRange(
"{}:1-{}:max".
format(runsInFiles[options.jobNumber], runsInFiles[options.jobNumber]))
136 elif options.jobNumber >= 0:
138 numberOfFiles = len(readFiles)
139 firstIndex = filesPerJob * options.jobNumber
140 for fileIndex
in range(firstIndex, firstIndex+filesPerJob):
141 if fileIndex >= numberOfFiles:
143 newFiles.append(readFiles[fileIndex])
147 process.source = cms.Source(
"PoolSource",
148 fileNames = cms.untracked.vstring(readFiles),
149 skipEvents = cms.untracked.uint32(0)
155 process.source = cms.Source(
"PoolSource",
156 fileNames = cms.untracked.vstring(readFiles),
157 skipEvents = cms.untracked.uint32(0)
162 print(
">>>>>>>>>> JetHT_cfg.py: msg%-i: dataset not specified in configuration! Loading default file!")
165 print(
">>>>>>>>>> JetHT_cfg.py: msg%-i: Default file for 2018 MC from 170-300 pT hat bin.")
166 process.source = cms.Source(
"PoolSource",
167 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')
170 print(
">>>>>>>>>> JetHT_cfg.py: msg%-i: Default file read from 2018D JetHT dataset.")
171 process.source = cms.Source(
"PoolSource",
172 fileNames = cms.untracked.vstring(
'root://xrootd-cms.infn.it//store/data/Run2018D/JetHT/ALCARECO/TkAlMinBias-12Nov2019_UL2018-v4/00000/009085FF-603B-044D-8879-0599B156831D.root')
179 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
180 from Configuration.AlCa.GlobalTag
import GlobalTag
181 process.GlobalTag =
GlobalTag(process.GlobalTag, globalTag)
190 if "conditions" in configuration[
"alignment"]:
193 for condition
in configuration[
"alignment"][
"conditions"]:
194 setattr(process,
"conditionsIn{}".
format(condition), poolDBESSource.clone(
195 connect = cms.string(
str(configuration[
"alignment"][
"conditions"][condition][
"connect"])),
198 record = cms.string(
str(condition)),
199 tag = cms.string(
str(configuration[
"alignment"][
"conditions"][condition][
"tag"]))
205 setattr(process,
"prefer_conditionsIn{}".
format(condition), cms.ESPrefer(
"PoolDBESSource",
"conditionsIn{}".
format(condition)))
208 if not (alignmentFile ==
"nothing" or alignmentFile ==
""):
209 process.conditionsInTrackerAlignmentRcd = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
210 connect = cms.string(
"sqlite_file:" + alignmentFile),
211 toGet = cms.VPSet(cms.PSet(record = cms.string(
'TrackerAlignmentRcd'),
212 tag = cms.string(
'Alignments')
216 process.prefer_conditionsInTrackerAlignmentRcd = cms.ESPrefer(
"PoolDBESSource",
"conditionsInTrackerAlignmentRcd")
219 if not (alignmentErrorFile ==
"nothing" or alignmentErrorFile ==
""):
220 process.conditionsInTrackerAlignmentErrorExtendedRcd = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
221 connect = cms.string(
"sqlite_file:" + alignmentErrorFile),
222 toGet = cms.VPSet(cms.PSet(record = cms.string(
'TrackerAlignmentErrorExtendedRcd'),
223 tag = cms.string(
'APEs')
227 process.prefer_conditionsInTrackerAlignmentErrorExtendedRcd = cms.ESPrefer(
"PoolDBESSource",
"conditionsInTrackerAlignmentErrorExtendedRcd")
235 process.load(
"RecoTracker.TrackProducer.TrackRefitters_cff")
237 process.TrackRefitter.src = trackCollection
238 process.TrackRefitter.NavigationSchool =
"" 241 process.load(
"TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
244 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
245 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag(
"TrackRefitter")
246 process.offlinePrimaryVerticesFromRefittedTrks.vertexCollections.maxDistanceToBeam = 1
247 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxNormalizedChi2 = 20
248 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minSiliconLayersWithHits = 5
249 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Significance = 5.0
250 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minPixelLayersWithHits = 2
256 if not (triggerFilter ==
"nothing" or triggerFilter ==
""):
257 triggerPath = triggerFilter
258 process.HLTFilter = triggerResultsFilter.clone(
259 triggerConditions = cms.vstring(triggerPath),
260 hltResults = cms.InputTag(
"TriggerResults",
"",
"HLT" ),
261 l1tResults = cms.InputTag(
"" ),
262 throw = cms.bool(
False)
268 process.jetHTAnalyzer = cms.EDAnalyzer(
'JetHTAnalyzer',
269 vtxCollection = cms.InputTag(
"offlinePrimaryVerticesFromRefittedTrks"),
270 trackCollection = cms.InputTag(
"TrackRefitter"),
271 triggerResults = cms.InputTag(
"TriggerResults",
"",
"HLT"),
272 printTriggerTable = cms.untracked.int32(printTriggers),
273 minVertexNdf = cms.untracked.double(10.),
274 minVertexMeanWeight = cms.untracked.double(0.5),
275 profilePtBorders = cms.untracked.vdouble(ptBorders),
276 iovList = cms.untracked.vint32(iovListList)
280 if options.jobNumber >= 0:
281 jobNumberString =
"_{}".
format(options.jobNumber)
283 outputName =
"{}/JetHTAnalysis{}.root".
format(configuration.get(
"output", os.getcwd()), jobNumberString)
284 if options.runType ==
"crab":
285 outputName =
"JetHTAnalysis.root" 287 process.TFileService = cms.Service(
"TFileService",
288 fileName = cms.string(outputName),
289 closeFileFast = cms.untracked.bool(
False)
293 if (triggerFilter ==
"nothing" or triggerFilter ==
""):
294 process.p = cms.Path(process.offlineBeamSpot +
295 process.TrackRefitter +
296 process.offlinePrimaryVerticesFromRefittedTrks +
297 process.jetHTAnalyzer)
299 process.p = cms.Path(process.HLTFilter +
300 process.offlineBeamSpot +
301 process.TrackRefitter +
302 process.offlinePrimaryVerticesFromRefittedTrks +
303 process.jetHTAnalyzer)
The trigger filter module.
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)