1 from __future__
import print_function
2 from fnmatch
import fnmatch
3 import FWCore.ParameterSet.Config
as cms
4 import FWCore.Utilities.FileUtils
as FileUtils
5 from FWCore.ParameterSet.VarParsing
import VarParsing
6 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff
import filesDefaultMC_DoubleMuon_string
15 process = cms.Process(
"DiMuonVertexValidation")
21 options.register(
"config",
"", VarParsing.multiplicity.singleton, VarParsing.varType.string ,
"AllInOne config")
23 options.parseArguments()
28 if options.config ==
"":
29 config = {
"validation": {},
32 with open(options.config,
"r") as configFile: 33 config = json.load(configFile) 35 isMC = config["validation"].get(
"ismc",
True)
42 if "dataset" in config[
"validation"]:
43 with open(config[
"validation"][
"dataset"],
"r") as datafiles: 44 for fileName
in datafiles.readlines():
45 readFiles.append(fileName.replace(
"\n",
""))
47 process.source = cms.Source(
"PoolSource",
48 fileNames = cms.untracked.vstring(readFiles),
49 skipEvents = cms.untracked.uint32(0))
51 process.source = cms.Source(
"PoolSource",
52 fileNames = cms.untracked.vstring(filesDefaultMC_DoubleMuon_string),
53 skipEvents = cms.untracked.uint32(0))
58 if "goodlumi" in config[
"validation"]:
59 if os.path.isfile(config[
"validation"][
"goodlumi"]):
60 goodLumiSecs = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(filename = config[
"validation"][
"goodlumi"]).getCMSSWString().
split(
','))
63 print(
"Does not exist: {}. Continue without good lumi section file.")
64 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
67 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
72 process.source.lumisToProcess = goodLumiSecs
77 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(config[
"validation"].get(
"maxevents", 100)))
82 process.options = cms.untracked.PSet(
83 wantSummary = cms.untracked.bool(
False),
84 Rethrow = cms.untracked.vstring(
"ProductNotFound"),
85 fileMode = cms.untracked.string(
'NOMERGE'),
91 process.load(
'FWCore.MessageService.MessageLogger_cfi')
92 process.MessageLogger.cerr.enable =
False 93 process.MessageLogger.TrackRefitter=dict()
94 process.MessageLogger.PrimaryVertexProducer=dict()
95 process.MessageLogger.DiMuonVertexValidation=dict()
96 process.MessageLogger.DiLeptonHelpCounts=dict()
97 process.MessageLogger.PlotsVsKinematics=dict()
98 process.MessageLogger.cout = cms.untracked.PSet(
99 enable = cms.untracked.bool(
True),
100 threshold = cms.untracked.string(
"INFO"),
101 default = cms.untracked.PSet(limit = cms.untracked.int32(0)),
102 FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
103 reportEvery = cms.untracked.int32(100)
105 DiMuonVertexValidation = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
106 DiLeptonHelpCounts = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
107 enableStatistics = cms.untracked.bool(
True)
113 process.load(
'Configuration.StandardSequences.Services_cff')
114 process.load(
'Configuration.StandardSequences.GeometryRecoDB_cff')
115 process.load(
'Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
116 process.load(
'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
121 process.load(
"TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
122 process.load(
'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi')
123 process.load(
'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi')
124 process.load(
'TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff')
129 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
134 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
135 from Configuration.AlCa.GlobalTag
import GlobalTag
137 process.GlobalTag =
GlobalTag(process.GlobalTag, config[
"alignment"].get(
"globaltag",
"auto:phase1_2022_realistic"))
142 if "conditions" in config[
"alignment"]:
145 for condition
in config[
"alignment"][
"conditions"]:
146 setattr(process,
"conditionsIn{}".
format(condition), poolDBESSource.clone(
147 connect = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"connect"])),
150 record = cms.string(
str(condition)),
151 tag = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"tag"]))
157 setattr(process,
"prefer_conditionsIn{}".
format(condition), cms.ESPrefer(
"PoolDBESSource",
"conditionsIn{}".
format(condition)))
162 process.load(
"RecoTracker.TrackProducer.TrackRefitters_cff")
164 process.refittedMuons = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
165 src = config[
"validation"].get(
"muonTrackcollection",
"ALCARECOTkAlDiMuon"),
166 TrajectoryInEvent =
True,
167 NavigationSchool =
'',
168 TTRHBuilder = config[
"validation"].get(
"tthrbuilder",
"WithAngleAndTemplate"))
173 process.refittedVtxTracks = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
174 src = config[
"validation"].get(
"trackcollection",
"generalTracks"),
175 TrajectoryInEvent =
True,
176 NavigationSchool =
'',
177 TTRHBuilder = config[
"validation"].get(
"tthrbuilder",
"WithAngleAndTemplate"))
183 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
184 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag(
"refittedVtxTracks")
189 process.seqRefitting = cms.Sequence(process.offlineBeamSpot +
190 process.refittedMuons +
191 process.refittedVtxTracks +
192 process.offlinePrimaryVerticesFromRefittedTrks)
197 process.TFileService = cms.Service(
"TFileService",
198 fileName = cms.string(
"{}/DiMuonVertexValidation.root".
format(config.get(
"output", os.getcwd()))),
199 closeFileFast = cms.untracked.bool(
True))
204 from Alignment.OfflineValidation.diMuonVertexValidation_cfi
import diMuonVertexValidation
205 process.DiMuonVertexValidation = diMuonVertexValidation.clone(useReco = config[
"validation"].get(
"useReco",
True),
206 vertices =
'offlinePrimaryVerticesFromRefittedTrks')
211 if (config[
"validation"].get(
"useReco",
True)):
212 process.DiMuonVertexValidation.muons =
'muons' 213 process.DiMuonVertexValidation.tracks =
'refittedVtxTracks' 215 process.DiMuonVertexValidation.muonTracks = cms.InputTag(
'refittedMuons')
220 process.p = cms.Path(process.seqRefitting +
221 process.offlinePrimaryVerticesFromRefittedTrks +
222 process.DiMuonVertexValidation)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)