CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SplitV_cfg.py
Go to the documentation of this file.
1 import json
2 import os
3 import FWCore.ParameterSet.Config as cms
4 import FWCore.PythonUtilities.LumiList as LumiList
5 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff import filesDefaultMC_NoPU
6 from FWCore.ParameterSet.VarParsing import VarParsing
7 from Alignment.OfflineValidation.TkAlAllInOneTool.utils import _byteify
8 
9 
12 process = cms.Process("PrimaryVertexResolution")
13 
14 
17 options = VarParsing()
18 options.register("config", "", VarParsing.multiplicity.singleton, VarParsing.varType.string , "AllInOne config")
19 options.parseArguments()
20 
21 
24 if options.config == "":
25  config = {"validation": {},
26  "alignment": {}}
27 else:
28  with open(options.config, "r") as configFile:
29  config = json.load(configFile)
30 
31 
34 readFiles = []
35 
36 if "dataset" in config["validation"]:
37  with open(config["validation"]["dataset"], "r") as datafiles:
38  for fileName in datafiles.readlines():
39  readFiles.append(fileName.replace("\n", ""))
40 
41  process.source = cms.Source("PoolSource",
42  fileNames = cms.untracked.vstring(readFiles),
43  skipEvents = cms.untracked.uint32(0)
44  )
45 else:
46  print(">>>>>>>>>> SplitV_cfg.py: msg%-i: config not specified! Loading default MC simulation -> filesDefaultMC_NoPU!")
47  process.source = cms.Source("PoolSource",
48  fileNames = filesDefaultMC_NoPU,
49  skipEvents = cms.untracked.uint32(0)
50  )
51 
52 
55 if "goodlumi" in config["validation"]:
56  if os.path.isfile(config["validation"]["goodlumi"]):
57  goodLumiSecs = cms.untracked.VLuminosityBlockRange(LumiList.LumiList(filename = config["validation"]["goodlumi"]).getCMSSWString().split(','))
58  else:
59  print("Does not exist: {}. Continue without good lumi section file.")
60  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
61 
62 else:
63  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
64 
65 
68 runboundary = config["validation"].get("runboundary", 1)
69 isMultipleRuns=False
70 if(isinstance(runboundary, (list, tuple))):
71  isMultipleRuns=True
72  print("Multiple Runs are selected")
73 if(isMultipleRuns):
74  process.source.firstRun = cms.untracked.uint32(runboundary[0])
75 else:
76  process.source.firstRun = cms.untracked.uint32(runboundary)
77 
78 
81 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(config["validation"].get("maxevents", 1)))
82 
83 
86 process.options = cms.untracked.PSet(
87  wantSummary = cms.untracked.bool(False),
88  Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal
89  fileMode = cms.untracked.string('NOMERGE'), # no ordering needed, but calls endRun/beginRun etc. at file boundaries
90 )
91 
92 
95 process.load("FWCore.MessageLogger.MessageLogger_cfi")
96 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
97 process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True)
98 
99 
102 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
103 process.load("Configuration.Geometry.GeometryDB_cff")
104 process.load('Configuration.StandardSequences.Services_cff')
105 process.load("Configuration.StandardSequences.MagneticField_cff")
106 
107 
110 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
111 process.TrackRefitter.src = config["validation"].get("trackcollection", "generalTracks")
112 process.TrackRefitter.TTRHBuilder = config["validation"].get("tthrbuilder", "WithAngleAndTemplate")
113 process.TrackRefitter.NavigationSchool = ""
114 
115 
118 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
119 from Configuration.AlCa.GlobalTag import GlobalTag
120 process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:phase1_2017_realistic"))
121 
122 
125 if "conditions" in config["alignment"]:
127 
128  for condition in config["alignment"]["conditions"]:
129  setattr(process, "conditionsIn{}".format(condition), poolDBESSource.clone(
130  connect = cms.string(str(config["alignment"]["conditions"][condition]["connect"])),
131  toGet = cms.VPSet(
132  cms.PSet(
133  record = cms.string(str(condition)),
134  tag = cms.string(str(config["alignment"]["conditions"][condition]["tag"]))
135  )
136  )
137  )
138  )
139 
140  setattr(process, "prefer_conditionsIn{}".format(condition), cms.ESPrefer("PoolDBESSource", "conditionsIn{}".format(condition)))
141 
142 
146 process.theHLTFilter = triggerResultsFilter.clone(
147  triggerConditions = cms.vstring(config["validation"].get("triggerBits", "*")),
148  hltResults = cms.InputTag( "TriggerResults", "", "HLT" ),
149  l1tResults = cms.InputTag( "" ),
150  throw = cms.bool(False)
151 )
152 
153 
156 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
157 
158 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
159 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
160 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag("TrackRefitter")
161 process.offlinePrimaryVerticesFromRefittedTrks.vertexCollections.maxDistanceToBeam = 1
162 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxNormalizedChi2 = 20
163 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minSiliconLayersWithHits = 5
164 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Significance = 5.0
165 # as it was prior to https://github.com/cms-sw/cmssw/commit/c8462ae4313b6be3bbce36e45373aa6e87253c59
166 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxD0Error = 1.0
167 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.maxDzError = 1.0
168 process.offlinePrimaryVerticesFromRefittedTrks.TkFilterParameters.minPixelLayersWithHits = 2
169 
170 # Use compressions settings of TFile
171 # see https://root.cern.ch/root/html534/TFile.html#TFile:SetCompressionSettings
172 # settings = 100 * algorithm + level
173 # level is from 1 (small) to 9 (large compression)
174 # algo: 1 (ZLIB), 2 (LMZA)
175 # see more about compression & performance: https://root.cern.ch/root/html534/guides/users-guide/InputOutput.html#compression-and-performance
176 compressionSettings = 207
177 
178 
181 from Alignment.OfflineValidation.splitVertexResolution_cfi import splitVertexResolution as _splitVertexResolution
182 process.PrimaryVertexResolution = _splitVertexResolution.clone(
183  compressionSettings = compressionSettings,
184  storeNtuple = False,
185  vtxCollection = "offlinePrimaryVerticesFromRefittedTrks",
186  trackCollection = "TrackRefitter",
187  minVertexNdf = 10.,
188  minVertexMeanWeight = 0.5,
189  runControl = config["validation"].get("runControl", False),
190  runControlNumber = [runboundary]
191 )
192 
193 process.TFileService = cms.Service("TFileService",
194  fileName = cms.string("{}/SplitV.root".format(config.get("output", os.getcwd()))),
195  closeFileFast = cms.untracked.bool(True)
196  )
197 print("Saving the output at %s" % process.TFileService.fileName.value())
198 
199 process.theValidSequence = cms.Sequence(process.offlineBeamSpot +
200  process.TrackRefitter +
201  process.offlinePrimaryVerticesFromRefittedTrks +
202  process.PrimaryVertexResolution)
203 
204 HLTSel = config["validation"].get("HLTselection", False)
205 
206 if (HLTSel):
207  process.p = cms.Path(process.theHLTFilter + process.theValidSequence)
208 else:
209  process.p = cms.Path(process.theValidSequence)
210 
211 print("Done")
The trigger filter module.
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)
if(threadIdxLocalY==0 &&threadIdxLocalX==0)