CMS 3D CMS Logo

universalConfigTemplate.py
Go to the documentation of this file.
1 
36 
37 
41 setupGlobaltag = "placeholder_globaltag"
42 setupCollection = "placeholder_collection"
43 setupCosmicsDecoMode = False
44 setupCosmicsZeroTesla = False
45 setupRecoGeometry = "placeholder_recogeometry"
46 setupPrimaryWidth = -1.0
47 setupJson = "placeholder_json"
48 setupRunStartGeometry = -1
49 
50 import FWCore.ParameterSet.Config as cms
51 if not setupRecoGeometry: # empty string defaults to DB
52  from Configuration.Eras.Era_Run3_cff import Run3
53  process = cms.Process("Alignment", Run3)
54 else:
55  import Configuration.Geometry.defaultPhase2ConditionsEra_cff as _settings
56  # need to remove "Extended from the setupRecoGeometry because of defaultPhase2ConditionsEra interface"
57  _PH2_GLOBAL_TAG, _PH2_ERA = _settings.get_era_and_conditions(setupRecoGeometry.replace("Extended", ""))
58  process = cms.Process("Alignment",_PH2_ERA)
59 
60 
64 setupAlgoMode = "mille"
65 
66 # MPS looks specifically for the string "ISN" so don't change this.
67 setupMonitorFile = "millePedeMonitorISN.root"
68 setupBinaryFile = "milleBinaryISN.dat"
69 
70 # Input files. Edited by mps_splice.py
71 readFiles = cms.untracked.vstring()
72 
73 
74 
75 
78 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
79 generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla, setupRecoGeometry)
80 
81 
82 
85 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer
86 
87 confAliProducer.setConfiguration(process,
88  collection = setupCollection,
89  mode = setupAlgoMode,
90  monitorFile = setupMonitorFile,
91  binaryFile = setupBinaryFile,
92  primaryWidth = setupPrimaryWidth,
93  cosmicsZeroTesla = setupCosmicsZeroTesla)
94 
95 
96 
99 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter
100 
101 
104 
105 # # You can use tagwriter.setCondition() to overwrite conditions in globaltag
106 # #
107 # # Examples (ideal phase-1 tracker-alignment conditions):
108 # tagwriter.setCondition(process,
109 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
110 # record = "TrackerAlignmentRcd",
111 # tag = "TrackerAlignment_Upgrade2017_design_v4")
112 # tagwriter.setCondition(process,
113 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
114 # record = "TrackerSurfaceDeformationRcd",
115 # tag = "TrackerSurfaceDeformations_zero")
116 # tagwriter.setCondition(process,
117 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
118 # record = "TrackerAlignmentErrorExtendedRcd",
119 # tag = "TrackerAlignmentErrorsExtended_Upgrade2017_design_v0")
120 # tagwriter.setCondition(process,
121 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
122 # record = "SiPixelLorentzAngleRcd",
123 # label = "fromAlignment",
124 # tag = "SiPixelLorentzAngle_fromAlignment_phase1_mc_v1")
125 
126 
127 
130 
131 # # to run a high-level alignment on real data (including TOB centering; use
132 # # pixel-barrel centering for MC) of the whole tracker you can use the
133 # # following configuration:
134 #
135 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
136 # "SelectorRigid,RigidBody",
137 # ]
138 #
139 # # Define the high-level structure alignables
140 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
141 # alignParams = cms.vstring(
142 # "TrackerP1PXBHalfBarrel,111111",
143 # "TrackerP1PXECHalfCylinder,111111",
144 # "TrackerTIBHalfBarrel,111111",
145 # "TrackerTOBHalfBarrel,rrrrrr",
146 # "TrackerTIDEndcap,111111",
147 # "TrackerTECEndcap,111111",
148 # )
149 # )
150 
151 
152 # # to run a module-level alignment on real data (including TOB centering; use
153 # # pixel-barrel centering for MC) of the whole tracker (including surface
154 # # deformations) you can use the following configuration (read comments on
155 # # multi-IOV alignment below):
156 #
157 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
158 # "SelectorRigid,RigidBody",
159 # "SelectorBowed,BowedSurface",
160 # "SelectorTwoBowed,TwoBowedSurfaces",
161 # ]
162 #
163 # # Define the high-level structure alignables
164 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
165 # alignParams = cms.vstring(
166 # "TrackerP1PXBHalfBarrel,111111",
167 # "TrackerP1PXECHalfCylinder,111111",
168 # "TrackerTIBHalfBarrel,111111",
169 # "TrackerTOBHalfBarrel,rrrrrr",
170 # "TrackerTIDEndcap,111111",
171 # "TrackerTECEndcap,111111",
172 # )
173 # )
174 #
175 # # Define the module-level alignables (for single modules)
176 # process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(
177 # alignParams = cms.vstring(
178 # "TrackerP1PXBModule,111111 111",
179 # "TrackerP1PXECModule,111111 111",
180 # "TrackerTIBModuleUnit,101111 111",
181 # "TrackerTIDModuleUnit,111111 111",
182 # "TrackerTECModuleUnit,111111 111,tecSingleSens",
183 # ),
184 # tecSingleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(1,4))),
185 # )
186 #
187 # process.AlignmentProducer.ParameterBuilder.SelectorTwoBowed = cms.PSet(
188 # alignParams = cms.vstring(
189 # "TrackerTOBModuleUnit,101111 111 101111 111",
190 # "TrackerTECModuleUnit,111111 111 111111 111,tecDoubleSens",
191 # ),
192 # tecDoubleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(5,7))),
193 # )
194 #
195 # # IOV definition
196 # # - defaults to single-IOV starting at "1", if omitted
197 # # - alignables have to match high-level structures above
198 # # -> except for 'rrrrrr' alignables
199 # process.AlignmentProducer.RunRangeSelection = [
200 # cms.PSet(
201 # RunRanges = cms.vstring(
202 # "290550",
203 # "300000",
204 # ),
205 # selector = cms.vstring(
206 # "TrackerP1PXBHalfBarrel,111111",
207 # "TrackerP1PXECHalfCylinder,111111",
208 # "TrackerTIBHalfBarrel,111111",
209 # "TrackerTIDEndcap,111111",
210 # "TrackerTECEndcap,111111",
211 # )
212 # )
213 # ] # end of process.AlignmentProducer.RunRangeSelection
214 
215 # # To run simultaneous calibrations of the pixel Lorentz angle you need to
216 # # include the corresponding config fragment and configure the granularity and
217 # # IOVs (must be consistent with input LA/template/alignment IOVs) for it.
218 # # Note: There are different version of the LA record available in the global
219 # # tag. Depending on the TTRHBuilder, one has to set a label to configure
220 # # which of them is to be used. The default TTRHBuilder uses pixel
221 # # templates which ignores the unlabelled LA record and uses only the one
222 # # labelled "fromAlignment". This is also the default value in the
223 # # integrated LA calibration. If you are using the generic CPE instead of
224 # # the template CPE you have to use the following setting:
225 # #
226 # # siPixelLA.lorentzAngleLabel = ""
227 #
228 # from Alignment.CommonAlignmentAlgorithm.SiPixelLorentzAngleCalibration_cff \
229 # import SiPixelLorentzAngleCalibration as siPixelLA
230 # siPixelLA.LorentzAngleModuleGroups.Granularity = cms.VPSet()
231 # siPixelLA.LorentzAngleModuleGroups.RunRange = cms.vuint32(290550,
232 # 295000,
233 # 298100)
234 #
235 # siPixelLA.LorentzAngleModuleGroups.Granularity.extend([
236 # cms.PSet(
237 # levels = cms.PSet(
238 # alignParams = cms.vstring(
239 # 'TrackerP1PXBModule,,RINGLAYER'
240 # ),
241 # RINGLAYER = cms.PSet(
242 # pxbDetId = cms.PSet(
243 # moduleRanges = cms.vint32(ring, ring),
244 # layerRanges = cms.vint32(layer, layer)
245 # )
246 # )
247 # )
248 # )
249 # for ring in xrange(1,9) # [1,8]
250 # for layer in xrange(1,5) # [1,4]
251 # ])
252 # siPixelLA.LorentzAngleModuleGroups.Granularity.append(
253 # cms.PSet(
254 # levels = cms.PSet(
255 # alignParams = cms.vstring('TrackerP1PXECModule,,posz'),
256 # posz = cms.PSet(zRanges = cms.vdouble(-9999.0, 9999.0))
257 # )
258 # )
259 # )
260 #
261 # process.AlignmentProducer.calibrations.append(siPixelLA)
262 
263 
264 
267 
268 # # reasonable pede settings are already defined in
269 # # 'confAliProducer.setConfiguration' above
270 # #
271 # # if you want to obtain alignment errors, use the following setting:
272 # # process.AlignmentProducer.algoConfig.pedeSteerer.method = "inversion 3 0.8"
273 # #
274 # # a list of possible options is documented here:
275 # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
276 # #
277 # # if you need to request a larger stack size for individual threads when
278 # # running pede, you can do this with this setting:
279 # # process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; pede"
280 # #
281 # # you can change or drop pede options as follows:
282 #
283 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
284 # helper.set_pede_option(process, "entries 50 10 2")
285 # helper.set_pede_option(process, "compress", drop = True)
286 
287 
288 
291 
292 # # please add any EDFilter here that should run before processing the event,
293 # # e.g. add the following lines to ensure that only 3.8T events are selected
294 #
295 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
296 # process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
297 # process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
298 # helper.add_filter(process, process.magneticFieldFilter)
299 
300 
301 
302 
305 if setupAlgoMode == "mille":
306  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
307  mille.setup(process,
308  input_files = readFiles,
309  collection = setupCollection,
310  json_file = setupJson,
311  cosmics_zero_tesla = setupCosmicsZeroTesla,
312  cosmics_deco_mode = setupCosmicsDecoMode)
313 
314 
317 else:
318  # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
319  merge_binary_files = ['placeholder_binaryList']
320  merge_tree_files = ['placeholder_treeList']
321 
322  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
323  pede.setup(process,
324  binary_files = merge_binary_files,
325  tree_files = merge_tree_files,
326  run_start_geometry = setupRunStartGeometry)