CMS 3D CMS Logo

DMR_cfg.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 import FWCore.PythonUtilities.LumiList as LumiList
3 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff import filesDefaultMC_NoPU
4 
5 from FWCore.ParameterSet.VarParsing import VarParsing
6 
7 import json
8 import os
9 
10 
11 process = cms.Process("OfflineValidator")
12 
13 
14 options = VarParsing()
15 options.register("config", "", VarParsing.multiplicity.singleton, VarParsing.varType.string , "AllInOne config")
16 
17 options.parseArguments()
18 
19 
20 if options.config == "":
21  config = {"validation": {},
22  "alignment": {}}
23 else:
24  with open(options.config, "r") as configFile:
25  config = json.load(configFile)
26 
27 print(config)
28 
29 
30 readFiles = []
31 
32 if "dataset" in config["validation"]:
33  with open(config["validation"]["dataset"], "r") as datafiles:
34  for fileName in datafiles.readlines():
35  readFiles.append(fileName.replace("\n", ""))
36 
37 
38  process.source = cms.Source("PoolSource",
39  fileNames = cms.untracked.vstring(readFiles),
40  skipEvents = cms.untracked.uint32(0)
41  )
42 else:
43  print(">>>>>>>>>> DMR_cfg.py: msg%-i: config not specified! Loading default MC simulation -> filesDefaultMC_NoPU!")
44  process.source = cms.Source("PoolSource",
45  fileNames = filesDefaultMC_NoPU,
46  skipEvents = cms.untracked.uint32(0)
47  )
48 
49 
50 if "goodlumi" in config["validation"]:
51  if os.path.isfile(config["validation"]["goodlumi"]):
52  goodLumiSecs = cms.untracked.VLuminosityBlockRange(LumiList.LumiList(filename = config["validation"]["goodlumi"]).getCMSSWString().split(','))
53 
54  else:
55  print("Does not exist: {}. Continue without good lumi section file.")
56  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
57 
58 else:
59  goodLumiSecs = cms.untracked.VLuminosityBlockRange()
60 
61 process.source.lumisToProcess = goodLumiSecs
62 
63 
64 process.maxEvents = cms.untracked.PSet(
65  input = cms.untracked.int32(config["validation"].get("maxevents", 1))
66 )
67 
68 
69 process.options = cms.untracked.PSet(
70  wantSummary = cms.untracked.bool(False),
71  Rethrow = cms.untracked.vstring("ProductNotFound"),
72  fileMode = cms.untracked.string('NOMERGE'),
73 )
74 
75 process.load("FWCore.MessageLogger.MessageLogger_cfi")
76 process.MessageLogger = cms.Service("MessageLogger",
77  destinations = cms.untracked.vstring('cerr'),
78  cerr = cms.untracked.PSet(
79  threshold = cms.untracked.string('ERROR')
80  )
81 
82 )
83 
84 
85 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
86 process.load("Configuration.Geometry.GeometryDB_cff")
87 process.load('Configuration.StandardSequences.Services_cff')
88 process.load("Configuration.StandardSequences.MagneticField_cff")
89 
90 
91 import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRefit
92 process.seqTrackselRefit = trackselRefit.getSequence(process,
93  config["validation"].get("trackcollection", "generalTracks"),
94  isPVValidation = False,
95  TTRHBuilder = config["validation"].get("tthrbuilder", "WithAngleAndTemplate"),
96  usePixelQualityFlag=config["validation"].get("usePixelQualityFlag", True),
97  openMassWindow = False,
98  cosmicsDecoMode = True,
99  cosmicsZeroTesla=config["validation"].get("cosmicsZeroTesla", False),
100  momentumConstraint = None,
101  cosmicTrackSplitting = False,
102  use_d0cut = True,
103 )
104 
105 #Global tag
106 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
107 from Configuration.AlCa.GlobalTag import GlobalTag
108 process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:phase1_2017_realistic"))
109 
110 
111 if "conditions" in config["alignment"]:
113 
114  for condition in config["alignment"]["conditions"]:
115  setattr(process, "conditionsIn{}".format(condition), poolDBESSource.clone(
116  connect = cms.string(str(config["alignment"]["conditions"][condition]["connect"])),
117  toGet = cms.VPSet(
118  cms.PSet(
119  record = cms.string(str(condition)),
120  tag = cms.string(str(config["alignment"]["conditions"][condition]["tag"]))
121  )
122  )
123  )
124  )
125 
126  setattr(process, "prefer_conditionsIn{}".format(condition), cms.ESPrefer("PoolDBESSource", "conditionsIn{}".format(condition)))
127 
128 
129 process.oneGoodVertexFilter = cms.EDFilter("VertexSelector",
130  src = cms.InputTag(config["validation"].get("vertexcollection", "offlinePrimaryVertices")),
131  cut = cms.string("!isFake && ndof > 4 && abs(z) <= 15 && position.Rho <= 2"),
132  filter = cms.bool(True),
133 )
134 process.FilterGoodEvents=cms.Sequence(process.oneGoodVertexFilter)
135 
136 process.noScraping= cms.EDFilter("FilterOutScraping",
137  src=cms.untracked.InputTag(config["validation"].get("trackcollection", "generalTracks")),
138  applyfilter = cms.untracked.bool(True),
139  debugOn = cms.untracked.bool(False),
140  numtrack = cms.untracked.uint32(10),
141  thresh = cms.untracked.double(0.25),
142 )
143 
144 
145 process.TrackerOfflineValidation = cms.EDAnalyzer("TrackerOfflineValidation",
146  useInDqmMode = cms.bool(False),
147  moduleDirectoryInOutput = cms.string(""),
148  Tracks = cms.InputTag("FinalTrackRefitter"),
149  trajectoryInput = cms.string('FinalTrackRefitter'), # Only needed in DQM mode
150  localCoorHistosOn = cms.bool(False),
151  moduleLevelHistsTransient = config["validation"].get("moduleLevelHistsTransient", cms.bool(False)),
152  moduleLevelProfiles = config["validation"].get("moduleLevelProfiles", cms.bool(True)),
153  localCoorProfilesOn = cms.bool(False),
154  stripYResiduals = cms.bool(config["validation"].get("stripYResiduals", False)),
155  useFwhm = cms.bool(True),
156  useFit = cms.bool(False),
157  useCombinedTrajectory = cms.bool(False),
158  useOverflowForRMS = cms.bool(False),
159  maxTracks = cms.uint64(config["validation"].get("maxtracks", 1)),
160  chargeCut = cms.int32(config["validation"].get("chargecut", 0)),
161  # Normalized X Residuals, normal local coordinates (Strip)
162  TH1NormXResStripModules = cms.PSet(
163  Nbinx = cms.int32(100), xmin = cms.double(-5.0), xmax = cms.double(5.0)
164  ),
165 
166  # X Residuals, normal local coordinates (Strip)
167  TH1XResStripModules = cms.PSet(
168  Nbinx = cms.int32(100), xmin = cms.double(-0.5), xmax = cms.double(0.5)
169  ),
170 
171  # Normalized X Residuals, native coordinates (Strip)
172  TH1NormXprimeResStripModules = cms.PSet(
173  Nbinx = cms.int32(120), xmin = cms.double(-3.0), xmax = cms.double(3.0)
174  ),
175 
176  # X Residuals, native coordinates (Strip)
177  TH1XprimeResStripModules = cms.PSet(
178  Nbinx = cms.int32(5000), xmin = cms.double(-0.05), xmax = cms.double(0.05)
179  ),
180 
181  # Normalized Y Residuals, native coordinates (Strip -> hardly defined)
182  TH1NormYResStripModules = cms.PSet(
183  Nbinx = cms.int32(120), xmin = cms.double(-3.0), xmax = cms.double(3.0)
184  ),
185  # -> very broad distributions expected
186  TH1YResStripModules = cms.PSet(
187  Nbinx = cms.int32(5000), xmin = cms.double(-11.0), xmax = cms.double(11.0)
188  ),
189 
190  # Normalized X residuals normal local coordinates (Pixel)
191  TH1NormXResPixelModules = cms.PSet(
192  Nbinx = cms.int32(100), xmin = cms.double(-5.0), xmax = cms.double(5.0)
193  ),
194  # X residuals normal local coordinates (Pixel)
195  TH1XResPixelModules = cms.PSet(
196  Nbinx = cms.int32(100), xmin = cms.double(-0.5), xmax = cms.double(0.5)
197  ),
198  # Normalized X residuals native coordinates (Pixel)
199  TH1NormXprimeResPixelModules = cms.PSet(
200  Nbinx = cms.int32(120), xmin = cms.double(-3.0), xmax = cms.double(3.0)
201  ),
202  # X residuals native coordinates (Pixel)
203  TH1XprimeResPixelModules = cms.PSet(
204  Nbinx = cms.int32(5000), xmin = cms.double(-0.05), xmax = cms.double(0.05)
205  ),
206  # Normalized Y residuals native coordinates (Pixel)
207  TH1NormYResPixelModules = cms.PSet(
208  Nbinx = cms.int32(120), xmin = cms.double(-3.0), xmax = cms.double(3.0)
209  ),
210  # Y residuals native coordinates (Pixel)
211  TH1YResPixelModules = cms.PSet(
212  Nbinx = cms.int32(5000), xmin = cms.double(-0.05), xmax = cms.double(0.05)
213  ),
214  # X Residuals vs reduced local coordinates (Strip)
215  TProfileXResStripModules = cms.PSet(
216  Nbinx = cms.int32(34), xmin = cms.double(-1.02), xmax = cms.double(1.02)
217  ),
218  # X Residuals vs reduced local coordinates (Strip)
219  TProfileYResStripModules = cms.PSet(
220  Nbinx = cms.int32(34), xmin = cms.double(-1.02), xmax = cms.double(1.02)
221  ),
222  # X Residuals vs reduced local coordinates (Pixel)
223  TProfileXResPixelModules = cms.PSet(
224  Nbinx = cms.int32(17), xmin = cms.double(-1.02), xmax = cms.double(1.02)
225  ),
226  # X Residuals vs reduced local coordinates (Pixel)
227  TProfileYResPixelModules = cms.PSet(
228  Nbinx = cms.int32(17), xmin = cms.double(-1.02), xmax = cms.double(1.02)
229  ),
230 )
231 
232 
233 process.TFileService = cms.Service("TFileService",
234  fileName = cms.string("{}/DMR.root".format(config.get("output", os.getcwd()))),
235  closeFileFast = cms.untracked.bool(True),
236 )
237 
238 seqTrackerOfflineValidation = cms.Sequence(process.TrackerOfflineValidation)
239 
240 
241 process.p = cms.Path(process.seqTrackselRefit*seqTrackerOfflineValidation)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)