CMS 3D CMS Logo

universalConfigTemplate.py
Go to the documentation of this file.
1 ###### Universal configuration template for tracker alignment
2 #
3 # Usage:
4 #
5 # Make a copy of this file and insert Startgeometry, Alignables and
6 # Pedesettings directly into it.
7 #
8 # Specify the path to this config-Template in the alignment_setup.ini
9 #
10 # The scripts mps_alisetup.py and mps_setup.py set the Variables at the top (setup*).
11 #
12 # Collection specifies the type of Tracks. Currently these are supported:
13 # - ALCARECOTkAlMinBias -> Minimum Bias
14 # - ALCARECOTkAlCosmicsCTF0T -> Cosmics, either at 0T or 3.8T
15 # - ALCARECOTkAlMuonIsolated -> Isolated Muon
16 # - ALCARECOTkAlZMuMu -> Z decay to two Muons
17 # - ALCARECOTkAlUpsilonMuMu -> Upsilon decay to two Muons
18 # - generalTracks -> general tracks treated like Minimum Bias
19 # - ALCARECOTkAlCosmicsInCollisions -> Cosmics taken during collisions
20 #
21 # Globaltag specifies the detector conditions.
22 # Parts of the Globaltag are overwritten in Startgeometry.
23 #
24 # monitorFile and binaryFile are automatically set by mps_setup.
25 # e.g. millePedeMonitor004.root and milleBinary004.dat
26 #
27 # AlgoMode specifies mode of AlignmentProducer.algoConfig -> mille or pede
28 # mille is default. Pede mode is automatically set when merge config is created by MPS
29 #
30 # CosmicsDecoMode and CosmicsZeroTesla are only relevant if collection
31 # is ALCARECOTkAlCosmicsCTF0T
32 #
33 # If primaryWidth is bigger than 0.0 it overwrites
34 # process.AlignmentProducer.algoConfig.TrajectoryFactory.ParticleProperties.PrimaryWidth = ...
35 # if primaryWidth<=0.0 it has no effect at all.
36 
37 
38 import FWCore.ParameterSet.Config as cms
39 process = cms.Process("Alignment")
40 
41 ################################################################################
42 # Variables edited by mps_alisetup.py. Used in functions below.
43 # You can change them manually as well.
44 # ------------------------------------------------------------------------------
45 setupGlobaltag = "placeholder_globaltag"
46 setupCollection = "placeholder_collection"
47 setupCosmicsDecoMode = False
48 setupCosmicsZeroTesla = False
49 setupPrimaryWidth = -1.0
50 setupJson = "placeholder_json"
51 setupRunStartGeometry = -1
52 
53 ################################################################################
54 # Variables edited by MPS (mps_setup and mps_merge). Be careful.
55 # ------------------------------------------------------------------------------
56 # Default is "mille". Gets changed to "pede" by mps_merge.
57 setupAlgoMode = "mille"
58 
59 # MPS looks specifically for the string "ISN" so don't change this.
60 setupMonitorFile = "millePedeMonitorISN.root"
61 setupBinaryFile = "milleBinaryISN.dat"
62 
63 # Input files. Edited by mps_splice.py
64 readFiles = cms.untracked.vstring()
65 ################################################################################
66 
67 
68 ################################################################################
69 # General setup
70 # ------------------------------------------------------------------------------
71 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
72 generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla)
73 
74 
75 ################################################################################
76 # setup alignment producer
77 # ------------------------------------------------------------------------------
78 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer
79 
80 confAliProducer.setConfiguration(process,
81  collection = setupCollection,
82  mode = setupAlgoMode,
83  monitorFile = setupMonitorFile,
84  binaryFile = setupBinaryFile,
85  primaryWidth = setupPrimaryWidth,
86  cosmicsZeroTesla = setupCosmicsZeroTesla)
87 
88 
89 ################################################################################
90 # Overwrite some conditions in global tag
91 # ------------------------------------------------------------------------------
92 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter
93 
94 ##########################
95 ## insert Startgeometry ##
96 ##########################
97 
98 # # You can use tagwriter.setCondition() to overwrite conditions in globaltag
99 # #
100 # # Examples (ideal phase-1 tracker-alignment conditions):
101 # tagwriter.setCondition(process,
102 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
103 # record = "TrackerAlignmentRcd",
104 # tag = "TrackerAlignment_Upgrade2017_design_v4")
105 # tagwriter.setCondition(process,
106 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
107 # record = "TrackerSurfaceDeformationRcd",
108 # tag = "TrackerSurfaceDeformations_zero")
109 # tagwriter.setCondition(process,
110 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
111 # record = "TrackerAlignmentErrorExtendedRcd",
112 # tag = "TrackerAlignmentErrorsExtended_Upgrade2017_design_v0")
113 # tagwriter.setCondition(process,
114 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
115 # record = "SiPixelLorentzAngleRcd",
116 # label = "fromAlignment",
117 # tag = "SiPixelLorentzAngle_fromAlignment_phase1_mc_v1")
118 
119 
120 #######################
121 ## insert Alignables ##
122 #######################
123 
124 # # to run a high-level alignment on real data (including TOB centering; use
125 # # pixel-barrel centering for MC) of the whole tracker you can use the
126 # # following configuration:
127 #
128 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
129 # "SelectorRigid,RigidBody",
130 # ]
131 #
132 # # Define the high-level structure alignables
133 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
134 # alignParams = cms.vstring(
135 # "TrackerP1PXBHalfBarrel,111111",
136 # "TrackerP1PXECHalfCylinder,111111",
137 # "TrackerTIBHalfBarrel,111111",
138 # "TrackerTOBHalfBarrel,rrrrrr",
139 # "TrackerTIDEndcap,111111",
140 # "TrackerTECEndcap,111111",
141 # )
142 # )
143 
144 
145 # # to run a module-level alignment on real data (including TOB centering; use
146 # # pixel-barrel centering for MC) of the whole tracker (including surface
147 # # deformations) you can use the following configuration (read comments on
148 # # multi-IOV alignment below):
149 #
150 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
151 # "SelectorRigid,RigidBody",
152 # "SelectorBowed,BowedSurface",
153 # "SelectorTwoBowed,TwoBowedSurfaces",
154 # ]
155 #
156 # # Define the high-level structure alignables
157 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
158 # alignParams = cms.vstring(
159 # "TrackerP1PXBHalfBarrel,111111",
160 # "TrackerP1PXECHalfCylinder,111111",
161 # "TrackerTIBHalfBarrel,111111",
162 # "TrackerTOBHalfBarrel,rrrrrr",
163 # "TrackerTIDEndcap,111111",
164 # "TrackerTECEndcap,111111",
165 # )
166 # )
167 #
168 # # Define the module-level alignables (for single modules)
169 # process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(
170 # alignParams = cms.vstring(
171 # "TrackerP1PXBModule,111111 111",
172 # "TrackerP1PXECModule,111111 111",
173 # "TrackerTIBModuleUnit,101111 111",
174 # "TrackerTIDModuleUnit,111111 111",
175 # "TrackerTECModuleUnit,111111 111,tecSingleSens",
176 # ),
177 # tecSingleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(1,4))),
178 # )
179 #
180 # process.AlignmentProducer.ParameterBuilder.SelectorTwoBowed = cms.PSet(
181 # alignParams = cms.vstring(
182 # "TrackerTOBModuleUnit,101111 111 101111 111",
183 # "TrackerTECModuleUnit,111111 111 111111 111,tecDoubleSens",
184 # ),
185 # tecDoubleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(5,7))),
186 # )
187 #
188 # # IOV definition
189 # # - defaults to single-IOV starting at "1", if omitted
190 # # - alignables have to match high-level structures above
191 # # -> except for 'rrrrrr' alignables
192 # process.AlignmentProducer.RunRangeSelection = [
193 # cms.PSet(
194 # RunRanges = cms.vstring(
195 # "290550",
196 # "300000",
197 # ),
198 # selector = cms.vstring(
199 # "TrackerP1PXBHalfBarrel,111111",
200 # "TrackerP1PXECHalfCylinder,111111",
201 # "TrackerTIBHalfBarrel,111111",
202 # "TrackerTIDEndcap,111111",
203 # "TrackerTECEndcap,111111",
204 # )
205 # )
206 # ] # end of process.AlignmentProducer.RunRangeSelection
207 
208 # # To run simultaneous calibrations of the pixel Lorentz angle you need to
209 # # include the corresponding config fragment and configure the granularity and
210 # # IOVs (must be consistent with input LA/template/alignment IOVs) for it.
211 # # Note: There are different version of the LA record available in the global
212 # # tag. Depending on the TTRHBuilder, one has to set a label to configure
213 # # which of them is to be used. The default TTRHBuilder uses pixel
214 # # templates which ignores the unlabelled LA record and uses only the one
215 # # labelled "fromAlignment". This is also the default value in the
216 # # integrated LA calibration. If you are using the generic CPE instead of
217 # # the template CPE you have to use the following setting:
218 # #
219 # # siPixelLA.lorentzAngleLabel = ""
220 #
221 # from Alignment.CommonAlignmentAlgorithm.SiPixelLorentzAngleCalibration_cff \
222 # import SiPixelLorentzAngleCalibration as siPixelLA
223 # siPixelLA.LorentzAngleModuleGroups.Granularity = cms.VPSet()
224 # siPixelLA.LorentzAngleModuleGroups.RunRange = cms.vuint32(290550,
225 # 295000,
226 # 298100)
227 #
228 # siPixelLA.LorentzAngleModuleGroups.Granularity.extend([
229 # cms.PSet(
230 # levels = cms.PSet(
231 # alignParams = cms.vstring(
232 # 'TrackerP1PXBModule,,RINGLAYER'
233 # ),
234 # RINGLAYER = cms.PSet(
235 # pxbDetId = cms.PSet(
236 # moduleRanges = cms.vint32(ring, ring),
237 # layerRanges = cms.vint32(layer, layer)
238 # )
239 # )
240 # )
241 # )
242 # for ring in xrange(1,9) # [1,8]
243 # for layer in xrange(1,5) # [1,4]
244 # ])
245 # siPixelLA.LorentzAngleModuleGroups.Granularity.append(
246 # cms.PSet(
247 # levels = cms.PSet(
248 # alignParams = cms.vstring('TrackerP1PXECModule,,posz'),
249 # posz = cms.PSet(zRanges = cms.vdouble(-9999.0, 9999.0))
250 # )
251 # )
252 # )
253 #
254 # process.AlignmentProducer.calibrations.append(siPixelLA)
255 
256 
257 #########################
258 ## insert Pedesettings ##
259 #########################
260 
261 # # reasonable pede settings are already defined in
262 # # 'confAliProducer.setConfiguration' above
263 # #
264 # # if you want to obtain alignment errors, use the following setting:
265 # # process.AlignmentProducer.algoConfig.pedeSteerer.method = "inversion 3 0.8"
266 # #
267 # # a list of possible options is documented here:
268 # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
269 # #
270 # # you can change or drop pede options as follows:
271 #
272 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
273 # helper.set_pede_option(process, "entries 50 10 2")
274 # helper.set_pede_option(process, "compress", drop = True)
275 
276 
277 #################
278 ## add filters ##
279 #################
280 
281 # # please add any EDFilter here that should run before processing the event,
282 # # e.g. add the following lines to ensure that only 3.8T events are selected
283 #
284 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
285 # process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
286 # process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
287 # helper.add_filter(process, process.magneticFieldFilter)
288 
289 
290 
291 ################################################################################
292 # Mille-procedure
293 # ------------------------------------------------------------------------------
294 if setupAlgoMode == "mille":
295  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
296  mille.setup(process,
297  input_files = readFiles,
298  collection = setupCollection,
299  json_file = setupJson,
300  cosmics_zero_tesla = setupCosmicsZeroTesla,
301  cosmics_deco_mode = setupCosmicsDecoMode)
302 
303 ################################################################################
304 # Pede-procedure
305 # ------------------------------------------------------------------------------
306 else:
307  # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
308  merge_binary_files = ['placeholder_binaryList']
309  merge_tree_files = ['placeholder_treeList']
310 
311  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
312  pede.setup(process,
313  binary_files = merge_binary_files,
314  tree_files = merge_tree_files,
315  run_start_geometry = setupRunStartGeometry)