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 
114 
115 #######################
116 ## insert Alignables ##
117 #######################
118 
119 # # to run a high-level alignment on real data (including TOB centering; use
120 # # pixel-barrel centering for MC) of the whole tracker you can use the
121 # # following configuration:
122 #
123 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
124 # "SelectorRigid,RigidBody",
125 # ]
126 #
127 # # Define the high-level structure alignables
128 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
129 # alignParams = cms.vstring(
130 # "TrackerP1PXBHalfBarrel,111111",
131 # "TrackerP1PXECHalfCylinder,111111",
132 # "TrackerTIBHalfBarrel,111111",
133 # "TrackerTOBHalfBarrel,rrrrrr",
134 # "TrackerTIDEndcap,111111",
135 # "TrackerTECEndcap,111111",
136 # )
137 # )
138 
139 
140 # # to run a module-level alignment on real data (including TOB centering; use
141 # # pixel-barrel centering for MC) of the whole tracker (including surface
142 # # deformations) you can use the following configuration (read comments on
143 # # multi-IOV alignment below):
144 #
145 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
146 # "SelectorRigid,RigidBody",
147 # "SelectorBowed,BowedSurface",
148 # "SelectorTwoBowed,TwoBowedSurfaces",
149 # ]
150 #
151 # # Define the high-level structure alignables
152 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
153 # alignParams = cms.vstring(
154 # "TrackerP1PXBHalfBarrel,111111",
155 # "TrackerP1PXECHalfCylinder,111111",
156 # "TrackerTIBHalfBarrel,111111",
157 # "TrackerTOBHalfBarrel,rrrrrr",
158 # "TrackerTIDEndcap,111111",
159 # "TrackerTECEndcap,111111",
160 # )
161 # )
162 #
163 # # Define the module-level alignables (for single modules)
164 # process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(
165 # alignParams = cms.vstring(
166 # "TrackerP1PXBModule,111111 111",
167 # "TrackerP1PXECModule,111111 111",
168 # "TrackerTIBModuleUnit,101111 111",
169 # "TrackerTIDModuleUnit,111111 111",
170 # "TrackerTECModuleUnit,111111 111,tecSingleSens",
171 # ),
172 # tecSingleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(1,4))),
173 # )
174 #
175 # process.AlignmentProducer.ParameterBuilder.SelectorTwoBowed = cms.PSet(
176 # alignParams = cms.vstring(
177 # "TrackerTOBModuleUnit,101111 111 101111 111",
178 # "TrackerTECModuleUnit,111111 111 111111 111,tecDoubleSens",
179 # ),
180 # tecDoubleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(5,7))),
181 # )
182 #
183 # # IOV definition
184 # # - defaults to single-IOV starting at "1", if omitted
185 # # - alignables have to match high-level structures above
186 # # -> except for 'rrrrrr' alignables
187 # process.AlignmentProducer.RunRangeSelection = [
188 # cms.PSet(
189 # RunRanges = cms.vstring(
190 # "290550",
191 # "300000",
192 # ),
193 # selector = cms.vstring(
194 # "TrackerP1PXBHalfBarrel,111111",
195 # "TrackerP1PXECHalfCylinder,111111",
196 # "TrackerTIBHalfBarrel,111111",
197 # "TrackerTIDEndcap,111111",
198 # "TrackerTECEndcap,111111",
199 # )
200 # )
201 # ] # end of process.AlignmentProducer.RunRangeSelection
202 
203 
204 #########################
205 ## insert Pedesettings ##
206 #########################
207 
208 # # reasonable pede settings are already defined in
209 # # 'confAliProducer.setConfiguration' above
210 # #
211 # # if you want obtain alignment errors, use "inversion 3 0.8" as
212 # # process.AlignmentProducer.algoConfig.pedeSteerer.method
213 # #
214 # # a list of possible options is documented here:
215 # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
216 # #
217 # # you can change or drop pede settings as follows:
218 #
219 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
220 # helper.set_pede_option(process, "entries 50 10 2")
221 # helper.set_pede_option(process, "compress", drop = True)
222 
223 
224 #################
225 ## add filters ##
226 #################
227 
228 # # please add any EDFilter here that should run before processing the event,
229 # # e.g. add the following lines to ensure that only 3.8T events are selected
230 #
231 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
232 # process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
233 # process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
234 # helper.add_filter(process, process.magneticFieldFilter)
235 
236 
237 
238 ################################################################################
239 # Mille-procedure
240 # ------------------------------------------------------------------------------
241 if setupAlgoMode == "mille":
242  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
243  mille.setup(process,
244  input_files = readFiles,
245  collection = setupCollection,
246  json_file = setupJson,
247  cosmics_zero_tesla = setupCosmicsZeroTesla,
248  cosmics_deco_mode = setupCosmicsDecoMode)
249 
250 ################################################################################
251 # Pede-procedure
252 # ------------------------------------------------------------------------------
253 else:
254  # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
255  merge_binary_files = ['placeholder_binaryList']
256  merge_tree_files = ['placeholder_treeList']
257 
258  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
259  pede.setup(process,
260  binary_files = merge_binary_files,
261  tree_files = merge_tree_files,
262  run_start_geometry = setupRunStartGeometry)