CMS 3D CMS Logo

Zmumu_cfg.py
Go to the documentation of this file.
1 import math
2 import json
3 import os
4 
5 import FWCore.ParameterSet.Config as cms
6 import FWCore.PythonUtilities.LumiList as LumiList
7 from FWCore.ParameterSet.VarParsing import VarParsing
8 from Alignment.OfflineValidation.TkAlAllInOneTool.utils import _byteify
9 
10 
13 process = cms.Process("TkAlignmentDiMuonValidation")
14 
15 
18 options = VarParsing()
19 options.register("config", "", VarParsing.multiplicity.singleton, VarParsing.varType.string , "AllInOne config")
20 options.parseArguments()
21 
22 
23 valiMode = "StandAlone"
24 
25 
28 with open(options.config, "r") as configFile: config = _byteify(json.load(configFile, object_hook=_byteify),ignore_dicts=True)
29 
30 
33 readFiles = []
34 
35 with open(config["validation"]["dataset"], "r") as datafiles:
36  for fileName in datafiles.readlines():
37  readFiles.append(fileName.replace("\n", ""))
38 
39 
42 if "goodlumi" in config["validation"]:
43  if os.path.isfile(config["validation"]["goodlumi"]):
44  goodLumiSecs = cms.untracked.VLuminosityBlockRange(LumiList.LumiList(filename = config["validation"]["goodlumi"]).getCMSSWString().split(','))
45 
46  else:
47  print("Does not exist: {}. Continue without good lumi section file.")
48  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
49 
50 else:
51  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
52 
53 
56 process.source = cms.Source("PoolSource",
57  fileNames = cms.untracked.vstring(readFiles),
58  lumisToProcess = goodLumiSecs,
59  skipEvents = cms.untracked.uint32(0)
60  )
61 process.maxEvents = cms.untracked.PSet(
62  input = cms.untracked.int32(config["validation"].get("maxevents", 2000000))
63 )
64 
65 
68 process.options = cms.untracked.PSet(
69  wantSummary = cms.untracked.bool(False),
70  Rethrow = cms.untracked.vstring("ProductNotFound"),
71  fileMode = cms.untracked.string('NOMERGE'),
72 )
73 
74 
77 process.load("FWCore.MessageService.MessageLogger_cfi")
78 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
79 process.load("Configuration.StandardSequences.Services_cff")
80 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
81 process.load("Configuration.StandardSequences.MagneticField_cff")
82 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
83 
84 
87 process.load("FWCore.MessageLogger.MessageLogger_cfi")
88 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
89 
90 
93 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
95 process.TrackRefitter = process.TrackRefitterP5.clone(
96  src = 'ALCARECOTkAlZMuMu',
97  TrajectoryInEvent = True,
98  TTRHBuilder = "WithAngleAndTemplate",
99  NavigationSchool = "",
100 )
101 
102 
105 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
106 from Configuration.AlCa.GlobalTag import GlobalTag
107 process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:run2_data"))
109 
113 if "conditions" in config["alignment"]:
115  for condition in config["alignment"]["conditions"]:
116  setattr(process, "conditionsIn{}".format(condition), poolDBESSource.clone(
117  connect = cms.string(str(config["alignment"]["conditions"][condition]["connect"])),
118  toGet = cms.VPSet(cms.PSet(record = cms.string(str(condition)),
119  tag = cms.string(str(config["alignment"]["conditions"][condition]["tag"]))
120  )
121  )
122  )
123  )
124 
125  setattr(process, "prefer_conditionsIn{}".format(condition), cms.ESPrefer("PoolDBESSource", "conditionsIn{}".format(condition)))
126 
127 
130 from Alignment.OfflineValidation.diMuonValidation_cfi.py import diMuonValidation as _diMuonValidation
131 process.DiMuonMassValidation = _diMuonValidation.clone(
132  TkTag = 'TrackRefitter',
133  # mu mu mass
134  Pair_mass_min = 80.,
135  Pair_mass_max = 120.,
136  Pair_mass_nbins = 80,
137  Pair_etaminpos = -1,
138  Pair_etamaxpos = 1,
139  Pair_etaminneg = -1,
140  Pair_etamaxneg = 1,
141  # cosTheta CS
142  Variable_CosThetaCS_xmin = -1.,
143  Variable_CosThetaCS_xmax = 1.,
144  Variable_CosThetaCS_nbins = 20,
145  # DeltaEta
146  Variable_DeltaEta_xmin = -4.8,
147  Variable_DeltaEta_xmax = 4.8,
148  Variable_DeltaEta_nbins = 20,
149  # EtaMinus
150  Variable_EtaMinus_xmin = -2.4,
151  Variable_EtaMinus_xmax = 2.4,
152  Variable_EtaMinus_nbins = 12,
153  # EtaPlus
154  Variable_EtaPlus_xmin = -2.4,
155  Variable_EtaPlus_xmax = 2.4,
156  Variable_EtaPlus_nbins = 12,
157  # Phi CS
158  Variable_PhiCS_xmin = -math.pi/2.,
159  Variable_PhiCS_xmax = math.pi/2.,
160  Variable_PhiCS_nbins = 20,
161  # Phi Minus
162  Variable_PhiMinus_xmin = -math.pi,
163  Variable_PhiMinus_xmax = math.pi,
164  Variable_PhiMinus_nbins = 16,
165  # Phi Plus
166  Variable_PhiPlus_xmin = -math.pi,
167  Variable_PhiPlus_xmax = math.pi,
168  Variable_PhiPlus_nbins = 16,
169  # mu mu pT
170  Variable_PairPt_xmin = 0.,
171  Variable_PairPt_xmax = 100.,
172  Variable_PairPt_nbins = 100)
174 
177 if valiMode == "StandAlone":
178  # Output file
179  process.TFileService = cms.Service("TFileService",
180  fileName = cms.string("{}/Zmumu.root".format(config["output"])),
181  closeFileFast = cms.untracked.bool(True),
182  )
183 
184 process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter*process.DiMuonMassValidation)
185 
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)