4 from sys
import version_info
6 import FWCore.ParameterSet.Config
as cms
7 import FWCore.PythonUtilities.LumiList
as LumiList
8 from FWCore.ParameterSet.VarParsing
import VarParsing
9 from Alignment.OfflineValidation.TkAlAllInOneTool.utils
import _byteify
10 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff
import filesDefaultMC_DoubleMuonAlCa_string
15 process = cms.Process(
"TkAlignmentDiMuonValidation")
21 options.register(
"config",
"", VarParsing.multiplicity.singleton, VarParsing.varType.string ,
"AllInOne config")
22 options.parseArguments()
25 valiMode =
"StandAlone" 30 if options.config ==
"":
31 config = {
"validation": {},
34 with open(options.config,
"r") as configFile: 35 if version_info.major == 2:
36 config =
_byteify(json.load(configFile, object_hook=_byteify),ignore_dicts=
True)
38 config = json.load(configFile)
45 if "dataset" in config[
"validation"]:
46 with open(config[
"validation"][
"dataset"],
"r") as datafiles: 47 for fileName
in datafiles.readlines():
48 readFiles.append(fileName.replace(
"\n",
""))
50 readFiles = filesDefaultMC_DoubleMuonAlCa_string
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(
','))
60 print(
"Does not exist: {}. Continue without good lumi section file.")
61 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
64 goodLumiSecs = cms.untracked.VLuminosityBlockRange()
69 process.source = cms.Source(
"PoolSource",
70 fileNames = cms.untracked.vstring(readFiles),
71 lumisToProcess = goodLumiSecs,
72 skipEvents = cms.untracked.uint32(0)
74 process.maxEvents = cms.untracked.PSet(
75 input = cms.untracked.int32(config[
"validation"].get(
"maxevents", 2000000))
81 process.options = cms.untracked.PSet(
82 wantSummary = cms.untracked.bool(
False),
83 Rethrow = cms.untracked.vstring(
"ProductNotFound"),
84 fileMode = cms.untracked.string(
'NOMERGE'),
90 process.load(
"FWCore.MessageService.MessageLogger_cfi")
91 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
92 process.load(
"Configuration.StandardSequences.Services_cff")
93 process.load(
"Configuration.StandardSequences.GeometryRecoDB_cff")
94 process.load(
"Configuration.StandardSequences.MagneticField_cff")
95 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
100 process.load(
"FWCore.MessageLogger.MessageLogger_cfi")
101 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
106 process.load(
"RecoTracker.TrackProducer.TrackRefitters_cff")
108 process.TrackRefitter = process.TrackRefitterP5.clone(
109 src = config[
"validation"].get(
"trackcollection",
"ALCARECOTkAlZMuMu"),
110 TrajectoryInEvent =
True,
111 TTRHBuilder = config[
"validation"].get(
"tthrbuilder",
"WithAngleAndTemplate"),
112 NavigationSchool =
"",
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_2024_realistic"))
126 if "conditions" in config[
"alignment"]:
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(cms.PSet(record = cms.string(
str(condition)),
132 tag = cms.string(
str(config[
"alignment"][
"conditions"][condition][
"tag"]))
138 setattr(process,
"prefer_conditionsIn{}".
format(condition), cms.ESPrefer(
"PoolDBESSource",
"conditionsIn{}".
format(condition)))
143 from Alignment.OfflineValidation.diMuonValidation_cfi
import diMuonValidation
as _diMuonValidation
144 process.DiMuonMassValidation = _diMuonValidation.clone(
145 TkTag =
'TrackRefitter',
148 Pair_mass_max = 120.,
149 Pair_mass_nbins = 80,
150 Pair_etaminpos = -2.4,
151 Pair_etamaxpos = 2.4,
152 Pair_etaminneg = -2.4,
153 Pair_etamaxneg = 2.4,
155 Variable_CosThetaCS_xmin = -1.,
156 Variable_CosThetaCS_xmax = 1.,
157 Variable_CosThetaCS_nbins = 20,
159 Variable_DeltaEta_xmin = -4.8,
160 Variable_DeltaEta_xmax = 4.8,
161 Variable_DeltaEta_nbins = 20,
163 Variable_EtaMinus_xmin = -2.4,
164 Variable_EtaMinus_xmax = 2.4,
165 Variable_EtaMinus_nbins = 12,
167 Variable_EtaPlus_xmin = -2.4,
168 Variable_EtaPlus_xmax = 2.4,
169 Variable_EtaPlus_nbins = 12,
171 Variable_PhiCS_xmin = -math.pi/2.,
172 Variable_PhiCS_xmax = math.pi/2.,
173 Variable_PhiCS_nbins = 20,
175 Variable_PhiMinus_xmin = -math.pi,
176 Variable_PhiMinus_xmax = math.pi,
177 Variable_PhiMinus_nbins = 16,
179 Variable_PhiPlus_xmin = -math.pi,
180 Variable_PhiPlus_xmax = math.pi,
181 Variable_PhiPlus_nbins = 16,
183 Variable_PairPt_xmin = 0.,
184 Variable_PairPt_xmax = 100.,
185 Variable_PairPt_nbins = 100)
190 if valiMode ==
"StandAlone":
192 process.TFileService = cms.Service(
"TFileService",
193 fileName = cms.string(
"{}/Zmumu.root".
format(config.get(
"output", os.getcwd()))),
194 closeFileFast = cms.untracked.bool(
True),
197 process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter*process.DiMuonMassValidation)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def _byteify(data, ignore_dicts=False)