1 from __future__
import print_function
2 from fnmatch
import fnmatch
3 import FWCore.ParameterSet.Config
as cms
4 import FWCore.PythonUtilities.LumiList
as LumiList
5 import FWCore.Utilities.FileUtils
as FileUtils
6 from FWCore.ParameterSet.VarParsing
import VarParsing
7 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff
import filesDefaultMC_DoubleMuon_string
16 process = cms.Process(
"DiMuonVertexValidation")
22 options.register(
"config",
"", VarParsing.multiplicity.singleton, VarParsing.varType.string ,
"AllInOne config")
24 options.parseArguments()
29 if options.config ==
"":
30 config = {
"validation": {},
33 with open(options.config,
"r") as configFile: 34 config = json.load(configFile) 36 isMC = config["validation"].get(
"ismc",
True)
43 if "dataset" in config[
"validation"]:
44 with open(config[
"validation"][
"dataset"],
"r") as datafiles: 45 for fileName
in datafiles.readlines():
46 readFiles.append(fileName.replace(
"\n",
""))
48 process.source = cms.Source(
"PoolSource",
49 fileNames = cms.untracked.vstring(readFiles),
50 skipEvents = cms.untracked.uint32(0))
52 process.source = cms.Source(
"PoolSource",
53 fileNames = cms.untracked.vstring(filesDefaultMC_DoubleMuon_string),
54 skipEvents = cms.untracked.uint32(0))
59 if "goodlumi" in config[
"validation"]:
60 if os.path.isfile(config[
"validation"][
"goodlumi"]):
61 goodLumiSecs = cms.untracked.VLuminosityBlockRange(
LumiList.LumiList(filename = config[
"validation"][
"goodlumi"]).getCMSSWString().
split(
','))
64 print(
"Does not exist: {}. Continue without good lumi section file.")
65 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
68 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
73 process.source.lumisToProcess = goodLumiSecs
78 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(config[
"validation"].get(
"maxevents", 100)))
83 process.options = cms.untracked.PSet(
84 wantSummary = cms.untracked.bool(
False),
85 Rethrow = cms.untracked.vstring(
"ProductNotFound"),
86 fileMode = cms.untracked.string(
'NOMERGE'),
92 process.load(
'FWCore.MessageService.MessageLogger_cfi')
93 process.MessageLogger.cerr.enable =
False 94 process.MessageLogger.TrackRefitter=dict()
95 process.MessageLogger.PrimaryVertexProducer=dict()
96 process.MessageLogger.DiMuonVertexValidation=dict()
97 process.MessageLogger.DiLeptonHelpCounts=dict()
98 process.MessageLogger.PlotsVsKinematics=dict()
99 process.MessageLogger.cout = cms.untracked.PSet(
100 enable = cms.untracked.bool(
True),
101 threshold = cms.untracked.string(
"INFO"),
102 default = cms.untracked.PSet(limit = cms.untracked.int32(0)),
103 FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
104 reportEvery = cms.untracked.int32(100)
106 DiMuonVertexValidation = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
107 DiLeptonHelpCounts = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
108 enableStatistics = cms.untracked.bool(
True)
114 process.load(
'Configuration.StandardSequences.Services_cff')
115 process.load(
'Configuration.StandardSequences.GeometryRecoDB_cff')
116 process.load(
'Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
117 process.load(
'Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
122 process.load(
"TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
123 process.load(
'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorOpposite_cfi')
124 process.load(
'TrackPropagation.SteppingHelixPropagator.SteppingHelixPropagatorAlong_cfi')
125 process.load(
'TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff')
130 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
135 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
136 from Configuration.AlCa.GlobalTag
import GlobalTag
138 process.GlobalTag =
GlobalTag(process.GlobalTag, config[
"alignment"].get(
"globaltag",
"auto:phase1_2022_realistic"))
143 if "conditions" in config[
"alignment"]:
146 for condition
in config[
"alignment"][
"conditions"]:
147 setattr(process,
"conditionsIn{}".
format(condition), poolDBESSource.clone(
148 connect = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"connect"])),
151 record = cms.string(
str(condition)),
152 tag = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"tag"]))
158 setattr(process,
"prefer_conditionsIn{}".
format(condition), cms.ESPrefer(
"PoolDBESSource",
"conditionsIn{}".
format(condition)))
163 process.load(
"RecoTracker.TrackProducer.TrackRefitters_cff")
165 process.refittedMuons = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
166 src = config[
"validation"].get(
"muonTrackcollection",
"ALCARECOTkAlDiMuon"),
167 TrajectoryInEvent =
True,
168 NavigationSchool =
'',
169 TTRHBuilder = config[
"validation"].get(
"tthrbuilder",
"WithAngleAndTemplate"))
174 process.refittedVtxTracks = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone(
175 src = config[
"validation"].get(
"trackcollection",
"generalTracks"),
176 TrajectoryInEvent =
True,
177 NavigationSchool =
'',
178 TTRHBuilder = config[
"validation"].get(
"tthrbuilder",
"WithAngleAndTemplate"))
184 process.offlinePrimaryVerticesFromRefittedTrks = offlinePrimaryVertices.clone()
185 process.offlinePrimaryVerticesFromRefittedTrks.TrackLabel = cms.InputTag(
"refittedVtxTracks")
190 process.seqRefitting = cms.Sequence(process.offlineBeamSpot +
191 process.refittedMuons +
192 process.refittedVtxTracks +
193 process.offlinePrimaryVerticesFromRefittedTrks)
198 process.TFileService = cms.Service(
"TFileService",
199 fileName = cms.string(
"{}/DiMuonVertexValidation.root".
format(config.get(
"output", os.getcwd()))),
200 closeFileFast = cms.untracked.bool(
True))
205 from Alignment.OfflineValidation.diMuonVertexValidation_cfi
import diMuonVertexValidation
206 process.DiMuonVertexValidation = diMuonVertexValidation.clone(useReco = config[
"validation"].get(
"useReco",
True),
207 vertices =
'offlinePrimaryVerticesFromRefittedTrks')
212 if (config[
"validation"].get(
"useReco",
True)):
213 print(
"I AM USING RECO DATA-TIER")
214 process.DiMuonVertexValidation.muons =
'muons' 215 process.DiMuonVertexValidation.tracks =
'refittedVtxTracks' 217 print(
"I AM USING ALCARECO DATA-TIER")
218 if(hasattr(process.DiMuonVertexValidation,
'muons')):
219 delattr(process.DiMuonVertexValidation,
'muons')
220 process.DiMuonVertexValidation.muonTracks = cms.InputTag(
'refittedMuons')
225 process.p = cms.Path(process.seqRefitting +
226 process.offlinePrimaryVerticesFromRefittedTrks +
227 process.DiMuonVertexValidation)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
if(threadIdxLocalY==0 &&threadIdxLocalX==0)