CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Zmumu_cfg.py
Go to the documentation of this file.
1 import math
2 import json
3 import os
4 from sys import version_info
5 
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 
11 
14 process = cms.Process("TkAlignmentDiMuonValidation")
15 
16 
19 options = VarParsing()
20 options.register("config", "", VarParsing.multiplicity.singleton, VarParsing.varType.string , "AllInOne config")
21 options.parseArguments()
22 
23 
24 valiMode = "StandAlone"
25 
26 
29 with open(options.config, "r") as configFile: if version_info.major == 2:
30  config = _byteify(json.load(configFile, object_hook=_byteify),ignore_dicts=True)
31  else:
32  config = json.load(configFile)
33 
34 
37 readFiles = []
38 
39 with open(config["validation"]["dataset"], "r") as datafiles:
40  for fileName in datafiles.readlines():
41  readFiles.append(fileName.replace("\n", ""))
42 
43 
46 if "goodlumi" in config["validation"]:
47  if os.path.isfile(config["validation"]["goodlumi"]):
48  goodLumiSecs = cms.untracked.VLuminosityBlockRange(LumiList.LumiList(filename = config["validation"]["goodlumi"]).getCMSSWString().split(','))
49 
50  else:
51  print("Does not exist: {}. Continue without good lumi section file.")
52  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
53 
54 else:
55  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
56 
57 
60 process.source = cms.Source("PoolSource",
61  fileNames = cms.untracked.vstring(readFiles),
62  lumisToProcess = goodLumiSecs,
63  skipEvents = cms.untracked.uint32(0)
64  )
65 process.maxEvents = cms.untracked.PSet(
66  input = cms.untracked.int32(config["validation"].get("maxevents", 2000000))
67 )
68 
69 
72 process.options = cms.untracked.PSet(
73  wantSummary = cms.untracked.bool(False),
74  Rethrow = cms.untracked.vstring("ProductNotFound"),
75  fileMode = cms.untracked.string('NOMERGE'),
76 )
77 
78 
81 process.load("FWCore.MessageService.MessageLogger_cfi")
82 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
83 process.load("Configuration.StandardSequences.Services_cff")
84 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
85 process.load("Configuration.StandardSequences.MagneticField_cff")
86 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
87 
88 
91 process.load("FWCore.MessageLogger.MessageLogger_cfi")
92 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
93 
94 
97 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
99 process.TrackRefitter = process.TrackRefitterP5.clone(
100  src = 'ALCARECOTkAlZMuMu',
101  TrajectoryInEvent = True,
102  TTRHBuilder = "WithAngleAndTemplate",
103  NavigationSchool = "",
104 )
105 
106 
109 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
110 from Configuration.AlCa.GlobalTag import GlobalTag
111 process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:run2_data"))
113 
117 if "conditions" in config["alignment"]:
119  for condition in config["alignment"]["conditions"]:
120  setattr(process, "conditionsIn{}".format(condition), poolDBESSource.clone(
121  connect = cms.string(str(config["alignment"]["conditions"][condition]["connect"])),
122  toGet = cms.VPSet(cms.PSet(record = cms.string(str(condition)),
123  tag = cms.string(str(config["alignment"]["conditions"][condition]["tag"]))
124  )
125  )
126  )
127  )
128 
129  setattr(process, "prefer_conditionsIn{}".format(condition), cms.ESPrefer("PoolDBESSource", "conditionsIn{}".format(condition)))
130 
131 
134 from Alignment.OfflineValidation.diMuonValidation_cfi import diMuonValidation as _diMuonValidation
135 process.DiMuonMassValidation = _diMuonValidation.clone(
136  TkTag = 'TrackRefitter',
137  # mu mu mass
138  Pair_mass_min = 80.,
139  Pair_mass_max = 120.,
140  Pair_mass_nbins = 80,
141  Pair_etaminpos = -2.4,
142  Pair_etamaxpos = 2.4,
143  Pair_etaminneg = -2.4,
144  Pair_etamaxneg = 2.4,
145  # cosTheta CS
146  Variable_CosThetaCS_xmin = -1.,
147  Variable_CosThetaCS_xmax = 1.,
148  Variable_CosThetaCS_nbins = 20,
149  # DeltaEta
150  Variable_DeltaEta_xmin = -4.8,
151  Variable_DeltaEta_xmax = 4.8,
152  Variable_DeltaEta_nbins = 20,
153  # EtaMinus
154  Variable_EtaMinus_xmin = -2.4,
155  Variable_EtaMinus_xmax = 2.4,
156  Variable_EtaMinus_nbins = 12,
157  # EtaPlus
158  Variable_EtaPlus_xmin = -2.4,
159  Variable_EtaPlus_xmax = 2.4,
160  Variable_EtaPlus_nbins = 12,
161  # Phi CS
162  Variable_PhiCS_xmin = -math.pi/2.,
163  Variable_PhiCS_xmax = math.pi/2.,
164  Variable_PhiCS_nbins = 20,
165  # Phi Minus
166  Variable_PhiMinus_xmin = -math.pi,
167  Variable_PhiMinus_xmax = math.pi,
168  Variable_PhiMinus_nbins = 16,
169  # Phi Plus
170  Variable_PhiPlus_xmin = -math.pi,
171  Variable_PhiPlus_xmax = math.pi,
172  Variable_PhiPlus_nbins = 16,
173  # mu mu pT
174  Variable_PairPt_xmin = 0.,
175  Variable_PairPt_xmax = 100.,
176  Variable_PairPt_nbins = 100)
178 
181 if valiMode == "StandAlone":
182  # Output file
183  process.TFileService = cms.Service("TFileService",
184  fileName = cms.string("{}/Zmumu.root".format(config["output"])),
185  closeFileFast = cms.untracked.bool(True),
186  )
187 
188 process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter*process.DiMuonMassValidation)
189 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def _byteify(data, ignore_dicts=False)
Definition: utils.py:20
#define str(s)