CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
51 ################################################################################
52 # Variables edited by MPS (mps_setup and mps_merge). Be careful.
53 # ------------------------------------------------------------------------------
54 # Default is "mille". Gets changed to "pede" by mps_merge.
55 setupAlgoMode = "mille"
56 
57 # MPS looks specifically for the string "ISN" so don't change this.
58 setupMonitorFile = "millePedeMonitorISN.root"
59 setupBinaryFile = "milleBinaryISN.dat"
60 
61 # Input files. Edited by mps_splice.py
62 readFiles = cms.untracked.vstring()
63 ################################################################################
64 
65 
66 ################################################################################
67 # General setup
68 # ------------------------------------------------------------------------------
69 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
70 generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla)
71 
72 
73 ################################################################################
74 # setup alignment producer
75 # ------------------------------------------------------------------------------
76 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer
77 
78 confAliProducer.setConfiguration(process,
79  collection = setupCollection,
80  mode = setupAlgoMode,
81  monitorFile = setupMonitorFile,
82  binaryFile = setupBinaryFile,
83  primaryWidth = setupPrimaryWidth,
84  cosmicsZeroTesla = setupCosmicsZeroTesla)
85 
86 
87 ################################################################################
88 # Overwrite some conditions in global tag
89 # ------------------------------------------------------------------------------
90 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter
91 
92 ##########################
93 ## insert Startgeometry ##
94 ##########################
95 
96 # You can use tagwriter.setCondition() to overwrite conditions in globaltag
97 #
98 # Example:
99 # tagwriter.setCondition(process,
100 # connect = "frontier://FrontierProd/CMS_CONDITIONS",
101 # record = "TrackerAlignmentErrorExtendedRcd",
102 # tag = "TrackerIdealGeometryErrorsExtended210_mc")
103 
104 
105 #######################
106 ## insert Alignables ##
107 #######################
108 
109 # # to run a high-level alignment on real data (including TOB centering; use
110 # # pixel-barrel centering for MC) of the whole tracker you can use the
111 # # following configuration:
112 #
113 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
114 # "SelectorRigid,RigidBody",
115 # ]
116 # # Define the high-level structure alignables
117 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
118 # alignParams = cms.vstring(
119 # "TrackerTPBHalfBarrel,111111",
120 # "TrackerTPEHalfCylinder,111111",
121 # "TrackerTIBHalfBarrel,111111",
122 # "TrackerTOBHalfBarrel,rrrrrr",
123 # "TrackerTIDEndcap,111111",
124 # "TrackerTECEndcap,111111"
125 # )
126 # )
127 
128 
129 #########################
130 ## insert Pedesettings ##
131 #########################
132 
133 # # typical pede settings are listed below;
134 # # if you want obtain alignment errors, use "inversion 3 0.8" as
135 # # process.AlignmentProducer.algoConfig.pedeSteerer.method and set
136 # # process.AlignmentProducer.saveApeToDB = True
137 #
138 # process.AlignmentProducer.algoConfig.pedeSteerer.method = "sparseMINRES-QLP 3 0.8"
139 # process.AlignmentProducer.algoConfig.pedeSteerer.options = [
140 # "entries 50 10 2",
141 # "outlierdownweighting 3",
142 # "dwfractioncut 0.1",
143 # "compress",
144 # "threads 10",
145 # "matiter 1",
146 # "printcounts 2",
147 # "chisqcut 30. 6.",
148 # "bandwidth 6 1",
149 # "monitorresiduals",
150 # ]
151 # process.AlignmentProducer.algoConfig.minNumHits = 8
152 
153 
154 ################################################################################
155 # Mille-procedure
156 # ------------------------------------------------------------------------------
157 if setupAlgoMode == "mille":
158  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
159  mille.setup(process,
160  input_files = readFiles,
161  collection = setupCollection,
162  json_file = setupJson,
163  cosmics_zero_tesla = setupCosmicsZeroTesla,
164  cosmics_deco_mode = setupCosmicsDecoMode)
165 
166 ################################################################################
167 # Pede-procedure
168 # ------------------------------------------------------------------------------
169 else:
170  # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
171  merge_binary_files = ['placeholder_binaryList']
172  merge_tree_files = ['placeholder_treeList']
173 
174  import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
175  pede.setup(process,
176  binary_files = merge_binary_files,
177  tree_files = merge_tree_files)