1 import FWCore.ParameterSet.Config
as cms
2 import FWCore.PythonUtilities.LumiList
as LumiList
3 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff
import filesDefaultData_MinBias2018B
5 from FWCore.ParameterSet.VarParsing
import VarParsing
7 from Alignment.OfflineValidation.TkAlAllInOneTool.utils
import _byteify
12 process = cms.Process(
"PrimaryVertexValidation")
16 options.register(
"config",
"", VarParsing.multiplicity.singleton, VarParsing.varType.string ,
"AllInOne config")
18 options.parseArguments()
21 if options.config ==
"":
22 config = {
"validation": {},
25 with open(options.config,
"r") as configFile: 26 config = json.load(configFile) 28 isDA = config["validation"].get(
"isda",
True)
29 isMC = config[
"validation"].get(
"ismc",
True)
31 runboundary = config[
"validation"].get(
"runboundary", 1)
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",
""))
41 process.source = cms.Source(
"PoolSource",
42 fileNames = cms.untracked.vstring(readFiles),
43 skipEvents = cms.untracked.uint32(0)
46 print(
">>>>>>>>>> PV_cfg.py: msg%-i: config not specified! Loading default dataset -> filesDefaultData_MinBias2018B!")
47 process.source = cms.Source(
"PoolSource",
48 fileNames = filesDefaultData_MinBias2018B,
49 skipEvents = cms.untracked.uint32(0)
53 if "goodlumi" in config[
"validation"]:
54 if os.path.isfile(config[
"validation"][
"goodlumi"]):
55 goodLumiSecs = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(filename = config[
"validation"][
"goodlumi"]).getCMSSWString().
split(
','))
58 print(
"Does not exist: {}. Continue without good lumi section file.")
59 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
62 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
65 print(
">>>>>>>>>> PV_cfg.py: msg%-i: This is simulation!")
68 process.source.lumisToProcess = goodLumiSecs
71 if(isinstance(runboundary, (list, tuple))):
73 print(
"Multiple Runs are selected")
75 process.source.firstRun = cms.untracked.uint32(runboundary[0])
77 process.source.firstRun = cms.untracked.uint32(runboundary)
80 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(config[
"validation"].get(
"maxevents", 1)))
83 process.options = cms.untracked.PSet(
84 wantSummary = cms.untracked.bool(
False),
85 Rethrow = cms.untracked.vstring(
"ProductNotFound"),
86 fileMode = cms.untracked.string(
'NOMERGE'),
89 process.load(
"FWCore.MessageLogger.MessageLogger_cfi")
90 process.MessageLogger = cms.Service(
"MessageLogger",
91 destinations = cms.untracked.vstring(
'cerr'),
92 cerr = cms.untracked.PSet(threshold = cms.untracked.string(
'INFO'))
96 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
97 process.load(
"Configuration.Geometry.GeometryRecoDB_cff")
98 process.load(
'Configuration.StandardSequences.Services_cff')
99 process.load(
"Configuration.StandardSequences.MagneticField_cff")
104 process.load(
"TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
109 import Alignment.CommonAlignment.tools.trackselectionRefitting
as trackselRefit
110 process.seqTrackselRefit = trackselRefit.getSequence(process,
111 config[
"validation"].get(
"trackcollection",
"ALCARECOTkAlMinBias"),
113 TTRHBuilder=config[
"validation"].get(
"tthrbuilder",
"WithAngleAndTemplate"),
114 usePixelQualityFlag=config[
"validation"].get(
"usePixelQualityFlag",
True),
115 openMassWindow=
False,
116 cosmicsDecoMode=
True,
117 cosmicsZeroTesla=config[
"validation"].get(
"cosmicsZeroTesla",
False),
118 momentumConstraint=
None,
119 cosmicTrackSplitting=
False,
124 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
125 from Configuration.AlCa.GlobalTag
import GlobalTag
126 process.GlobalTag =
GlobalTag(process.GlobalTag, config[
"alignment"].get(
"globaltag",
"auto:phase1_2017_realistic"))
129 if "conditions" in config[
"alignment"]:
132 for condition
in config[
"alignment"][
"conditions"]:
133 setattr(process,
"conditionsIn{}".
format(condition), poolDBESSource.clone(
134 connect = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"connect"])),
137 record = cms.string(
str(condition)),
138 tag = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"tag"]))
144 setattr(process,
"prefer_conditionsIn{}".
format(condition), cms.ESPrefer(
"PoolDBESSource",
"conditionsIn{}".
format(condition)))
149 process.primaryVertexFilter = cms.EDFilter(
"VertexSelector",
150 src = cms.InputTag(config[
"validation"].get(
"vertexcollection",
"offlinePrimaryVertices")),
151 cut = cms.string(
"!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
152 filter = cms.bool(
True)
155 process.noscraping = cms.EDFilter(
"FilterOutScraping",
156 applyfilter = cms.untracked.bool(
True),
157 src = cms.untracked.InputTag(config[
"validation"].get(
"trackcollection",
"ALCARECOTkAlMinBias")),
158 debugOn = cms.untracked.bool(
False),
159 numtrack = cms.untracked.uint32(10),
160 thresh = cms.untracked.double(0.25)
163 process.load(
"Alignment.CommonAlignment.filterOutLowPt_cfi")
164 process.filterOutLowPt.src = cms.untracked.InputTag(config[
"validation"].get(
"trackcollection",
"ALCARECOTkAlMinBias"))
165 process.filterOutLowPt.ptmin = cms.untracked.double(config[
"validation"].get(
"ptCut", 3.))
166 process.filterOutLowPt.runControl =
False 168 process.filterOutLowPt.runControlNumber.extend((runboundary))
170 process.filterOutLowPt.runControlNumber = [runboundary]
173 process.goodvertexSkim = cms.Sequence(process.noscraping + process.filterOutLowPt)
175 process.goodvertexSkim = cms.Sequence(process.primaryVertexFilter + process.noscraping + process.filterOutLowPt)
183 FilteringParams = offlinePrimaryVertices.TkFilterParameters.clone(
184 maxNormalizedChi2 = 5.0,
185 maxD0Significance = 5.0,
190 from RecoVertex.PrimaryVertexProducer.TkClusParameters_cff
import DA_vectParameters
191 DAClusterizationParams = DA_vectParameters.clone()
193 GapClusterizationParams = cms.PSet(algorithm = cms.string(
'gap'),
194 TkGapClusParameters = cms.PSet(zSeparation = cms.double(0.2))
202 print(
">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running DA Algorithm!")
203 return DAClusterizationParams
205 print(
">>>>>>>>>> testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!")
206 return GapClusterizationParams
211 process.PVValidation = cms.EDAnalyzer(
"PrimaryVertexValidation",
212 TrackCollectionTag = cms.InputTag(
"FinalTrackRefitter"),
213 VertexCollectionTag = cms.InputTag(config[
"validation"].get(
"vertexcollection",
"offlinePrimaryVertices")),
214 Debug = cms.bool(
False),
215 storeNtuple = cms.bool(
False),
216 useTracksFromRecoVtx = cms.bool(
False),
217 isLightNtuple = cms.bool(
True),
218 askFirstLayerHit = cms.bool(
False),
219 forceBeamSpot = cms.untracked.bool(config[
"validation"].get(
"forceBeamSpot",
False)),
220 probePt = cms.untracked.double(config[
"validation"].get(
"ptCut", 3)),
221 probeEta = cms.untracked.double(config[
"validation"].get(
"etaCut", 2.5)),
222 minPt = cms.untracked.double(config[
"validation"].get(
"minPt", 1.)),
223 maxPt = cms.untracked.double(config[
"validation"].get(
"maxPt", 30.)),
224 doBPix = cms.untracked.bool(config[
"validation"].get(
"doBPix",
True)),
225 doFPix = cms.untracked.bool(config[
"validation"].get(
"doFPix",
True)),
226 numberOfBins = cms.untracked.int32(config[
"validation"].get(
"numberOfBins", 48)),
227 runControl = cms.untracked.bool(config[
"validation"].get(
"runControl",
False)),
228 runControlNumber = cms.untracked.vuint32(runboundary),
229 TkFilterParameters = FilteringParams,
236 process.TFileService = cms.Service(
"TFileService",
237 fileName = cms.string(
"{}/PVValidation_{}_{}.root".
format(config.get(
"output", os.getcwd()), config[
"alignment"].get(
"name",
""), config[
"validation"].get(
"IOV", 1.))),
238 closeFileFast = cms.untracked.bool(
True),
244 process.p = cms.Path(process.goodvertexSkim*process.seqTrackselRefit*process.PVValidation)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def switchClusterizerParameters(da)
Deterministic annealing clustering or Gap clustering.