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 # - generalTracks -> general tracks treated like Minimum Bias
18 # - ALCARECOTkAlCosmicsInCollisions -> Cosmics taken during collisions
19 #
20 # Globaltag specifies the detector conditions.
21 # Parts of the Globaltag are overwritten in Startgeometry.
22 #
23 # monitorFile and binaryFile are automatically set by mps_setup.
24 # e.g. millePedeMonitor004.root and milleBinary004.dat
25 #
26 # AlgoMode specifies mode of AlignmentProducer.algoConfig -> mille or pede
27 # mille is default. Pede mode is automatically set when merge config is created by MPS
28 #
29 # CosmicsDecoMode and CosmicsZeroTesla are only relevant if collection
30 # is ALCARECOTkAlCosmicsCTF0T
31 #
32 # If primaryWidth is bigger than 0.0 it overwrites
33 # process.AlignmentProducer.algoConfig.TrajectoryFactory.ParticleProperties.PrimaryWidth = ...
34 # if primaryWidth<=0.0 it has no effect at all.
35 
36 
37 import FWCore.ParameterSet.Config as cms
38 process = cms.Process("Alignment")
39 
40 ################################################################################
41 # Variables edited by mps_alisetup.py. Used in functions below.
42 # You can change them manually as well.
43 # ------------------------------------------------------------------------------
44 setupGlobaltag = "placeholder_globaltag"
45 setupCollection = "placeholder_collection"
46 setupCosmicsDecoMode = False
47 setupCosmicsZeroTesla = False
48 setupPrimaryWidth = -1.0
49 setupJson = "placeholder_json"
50 setupRunStartGeometry = -1
51 
52 ################################################################################
53 # Variables edited by MPS (mps_setup and mps_merge). Be careful.
54 # ------------------------------------------------------------------------------
55 # Default is "mille". Gets changed to "pede" by mps_merge.
56 setupAlgoMode = "mille"
57 
58 # MPS looks specifically for the string "ISN" so don't change this.
59 setupMonitorFile = "millePedeMonitorISN.root"
60 setupBinaryFile = "milleBinaryISN.dat"
61 
62 # Input files. Edited by mps_splice.py
63 readFiles = cms.untracked.vstring()
64 ################################################################################
65 
66 
67 ################################################################################
68 # General setup
69 # ------------------------------------------------------------------------------
70 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
71 generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla)
72 
73 
74 ################################################################################
75 # setup alignment producer
76 # ------------------------------------------------------------------------------
77 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer
78 
79 confAliProducer.setConfiguration(process,
80  collection = setupCollection,
81  mode = setupAlgoMode,
82  monitorFile = setupMonitorFile,
83  binaryFile = setupBinaryFile,
84  primaryWidth = setupPrimaryWidth,
85  cosmicsZeroTesla = setupCosmicsZeroTesla)
86 
87 
88 ################################################################################
89 # Overwrite some conditions in global tag
90 # ------------------------------------------------------------------------------
91 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter
92 
93 ##########################
94 ## insert Startgeometry ##
95 ##########################
96 
97 # You can use tagwriter.setCondition() to overwrite conditions in globaltag
98 #
99 # Example:
100 # tagwriter.setCondition(process,
101 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
102 # record = "TrackerAlignmentErrorExtendedRcd",
103 # tag = "TrackerIdealGeometryErrorsExtended210_mc")
104 
105 
106 #######################
107 ## insert Alignables ##
108 #######################
109 
110 # # to run a high-level alignment on real data (including TOB centering; use
111 # # pixel-barrel centering for MC) of the whole tracker you can use the
112 # # following configuration:
113 #
114 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
115 # "SelectorRigid,RigidBody",
116 # ]
117 # # Define the high-level structure alignables
118 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
119 # alignParams = cms.vstring(
120 # "TrackerP1PXBHalfBarrel,111111",
121 # "TrackerP1PXECHalfCylinder,111111",
122 # "TrackerTIBHalfBarrel,111111",
123 # "TrackerTOBHalfBarrel,rrrrrr",
124 # "TrackerTIDEndcap,111111",
125 # "TrackerTECEndcap,111111",
126 # )
127 # )
128 
129 
130 # # to run a module-level alignment on real data (including TOB centering; use
131 # # pixel-barrel centering for MC) of the whole tracker (including surface
132 # # deformations) you can use the following configuration (read comments on
133 # # multi-IOV alignment below):
134 #
135 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
136 # "SelectorRigid,RigidBody",
137 # "SelectorBowed,BowedSurface",
138 # "SelectorTwoBowed,TwoBowedSurfaces",
139 # ]
140 # # Define the high-level structure alignables
141 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
142 # alignParams = cms.vstring(
143 # "TrackerP1PXBHalfBarrel,111111",
144 # "TrackerP1PXECHalfCylinder,111111",
145 # "TrackerTIBHalfBarrel,111111",
146 # "TrackerTOBHalfBarrel,rrrrrr",
147 # "TrackerTIDEndcap,111111",
148 # "TrackerTECEndcap,111111",
149 # )
150 # )
151 #
152 # # Define the module-level alignables (for single modules)
153 # process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(
154 # alignParams = cms.vstring(
155 # "TrackerP1PXBModule,111111 111",
156 # "TrackerP1PXECModule,111111 111",
157 # "TrackerTIBModuleUnit,101111 111",
158 # "TrackerTIDModuleUnit,111111 111",
159 # "TrackerTECModuleUnit,111111 111,tecSingleSens",
160 # ),
161 # tecSingleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(1,4))),
162 # )
163 #
164 # process.AlignmentProducer.ParameterBuilder.SelectorTwoBowed = cms.PSet(
165 # alignParams = cms.vstring(
166 # "TrackerTOBModuleUnit,101111 111 101111 111",
167 # "TrackerTECModuleUnit,111111 111 111111 111,tecDoubleSens",
168 # ),
169 # tecDoubleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(5,7))),
170 # )
171 #
172 # # IOV definition
173 # # - defaults to single-IOV starting at "1", if omitted
174 # # - alignables have to match high-level structures above
175 # # -> except for 'rrrrrr' alignables
176 # process.AlignmentProducer.RunRangeSelection = [
177 # cms.PSet(
178 # RunRanges = cms.vstring(
179 # "290550",
180 # "300000",
181 # ),
182 # selector = cms.vstring(
183 # "TrackerP1PXBHalfBarrel,111111",
184 # "TrackerP1PXECHalfCylinder,111111",
185 # "TrackerTIBHalfBarrel,111111",
186 # "TrackerTIDEndcap,111111",
187 # "TrackerTECEndcap,111111",
188 # )
189 # )
190 # ] # end of process.AlignmentProducer.RunRangeSelection
191 
192 
193 #########################
194 ## insert Pedesettings ##
195 #########################
196 
197 # # reasonable pede settings are already defined in
198 # # 'confAliProducer.setConfiguration' above
199 # # if you want obtain alignment errors, use "inversion 3 0.8" as
200 # # process.AlignmentProducer.algoConfig.pedeSteerer.method and set
201 # # process.AlignmentProducer.saveApeToDB = True
202 # # a list of possible options is documented here:
203 # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
204 # # you can change pede settings as follows:
205 #
206 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
207 # helper.set_pede_option(process, "entries 50 10 2")
208 
209 
210 #################
211 ## add filters ##
212 #################
213 
214 # # please add any EDFilter here that should run before processing the event,
215 # # e.g. add the following lines to ensure that only 3.8T events are selected
216 #
217 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
218 # process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
219 # process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
220 # helper.add_filter(process, process.magneticFieldFilter)
221 
222 
223 ################################################################################
224 # Mille-procedure
225 # ------------------------------------------------------------------------------
226 if setupAlgoMode == "mille":
227  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
228  mille.setup(process,
229  input_files = readFiles,
230  collection = setupCollection,
231  json_file = setupJson,
232  cosmics_zero_tesla = setupCosmicsZeroTesla,
233  cosmics_deco_mode = setupCosmicsDecoMode)
234 
235 ################################################################################
236 # Pede-procedure
237 # ------------------------------------------------------------------------------
238 else:
239  # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
240  merge_binary_files = ['placeholder_binaryList']
241  merge_tree_files = ['placeholder_treeList']
242 
243  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
244  pede.setup(process,
245  binary_files = merge_binary_files,
246  tree_files = merge_tree_files,
247  run_start_geometry = setupRunStartGeometry)