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 from Alignment.OfflineValidation.trackerOfflineValidation_cfi import trackerOfflineValidation as _trackerOfflineValidation
146 process.TrackerOfflineValidation = _trackerOfflineValidation.clone(
147  useInDqmMode = False,
148  moduleDirectoryInOutput = "",
149  Tracks = "FinalTrackRefitter",
150  trajectoryInput = "FinalTrackRefitter", # Only needed in DQM mode
151  localCoorHistosOn = False,
152  moduleLevelHistsTransient = config["validation"].get("moduleLevelHistsTransient", False),
153  moduleLevelProfiles = config["validation"].get("moduleLevelProfiles", True),
154  stripYResiduals = config["validation"].get("stripYResiduals", False),
155  useFwhm = True,
156  useFit = False,
157  useOverflowForRMS = False,
158  maxTracks = config["validation"].get("maxtracks", 1),
159  chargeCut = config["validation"].get("chargecut", 0),
160 
161  # Normalized X Residuals, normal local coordinates (Strip)
162  TH1NormXResStripModules = dict(Nbinx = 100, xmin = -5.0, xmax = 5.0),
163 
164  # X Residuals, normal local coordinates (Strip)
165  TH1XResStripModules = dict(Nbinx = 100, xmin = -0.5, xmax = 0.5),
166 
167  # Normalized X Residuals, native coordinates (Strip)
168  TH1NormXprimeResStripModules = dict(Nbinx = 120, xmin = -3.0, xmax = 3.0),
169 
170  # X Residuals, native coordinates (Strip)
171  TH1XprimeResStripModules = dict(Nbinx = 5000, xmin = -0.05, xmax = 0.05),
172 
173  # Normalized Y Residuals, native coordinates (Strip -> hardly defined)
174  TH1NormYResStripModules = dict(Nbinx = 120, xmin = -3.0, xmax = 3.0),
175 
176  # -> very broad distributions expected
177  TH1YResStripModules = dict(Nbinx = 5000, xmin = -11.0, xmax = 11.0),
178 
179  # Normalized X residuals normal local coordinates (Pixel)
180  TH1NormXResPixelModules = dict(Nbinx = 100, xmin = -5.0, xmax = 5.0),
181 
182  # X residuals normal local coordinates (Pixel)
183  TH1XResPixelModules = dict(Nbinx = 100, xmin = -0.5, xmax = 0.5),
184 
185  # Normalized X residuals native coordinates (Pixel)
186  TH1NormXprimeResPixelModules = dict(Nbinx = 120, xmin = -3.0, xmax = 3.0),
187 
188  # X residuals native coordinates (Pixel)
189  TH1XprimeResPixelModules = dict(Nbinx = 5000, xmin = -0.05, xmax = 0.05),
190 
191  # Normalized Y residuals native coordinates (Pixel)
192  TH1NormYResPixelModules = dict(Nbinx = 120, xmin = -3.0, xmax = 3.0),
193 
194  # Y residuals native coordinates (Pixel)
195  TH1YResPixelModules = dict(Nbinx = 5000, xmin = -0.05, xmax = 0.05),
196 
197  # X Residuals vs reduced local coordinates (Strip)
198  TProfileXResStripModules = dict(Nbinx = 34, xmin = -1.02, xmax = 1.02),
199 
200  # X Residuals vs reduced local coordinates (Strip)
201  TProfileYResStripModules = dict(Nbinx = 34, xmin = -1.02, xmax = 1.02),
202 
203  # X Residuals vs reduced local coordinates (Pixel)
204  TProfileXResPixelModules = dict(Nbinx = 17, xmin = -1.02, xmax = 1.02),
205 
206  # X Residuals vs reduced local coordinates (Pixel)
207  TProfileYResPixelModules = dict(Nbinx = 17, xmin = -1.02, xmax = 1.02)
208 )
209 
210 
211 process.TFileService = cms.Service("TFileService",
212  fileName = cms.string("{}/DMR.root".format(config.get("output", os.getcwd()))),
213  closeFileFast = cms.untracked.bool(True),
214 )
215 
216 seqTrackerOfflineValidation = cms.Sequence(process.TrackerOfflineValidation)
217 
218 
219 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)