Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-07 06:12:25

0001 ###### Universal configuration template for tracker alignment
0002 #
0003 #  Usage:
0004 #
0005 #    Make a copy of this file and insert Startgeometry, Alignables and
0006 #    Pedesettings directly into it.
0007 #
0008 #    Specify the path to this config-Template in the alignment_setup.ini
0009 #
0010 #    The scripts mps_alisetup.py and mps_setup.py set the Variables at the top (setup*).
0011 #
0012 #        Collection specifies the type of Tracks. Currently these are supported:
0013 #          - ALCARECOTkAlMinBias       -> Minimum Bias
0014 #          - ALCARECOTkAlCosmicsCTF0T  -> Cosmics, either at 0T or 3.8T
0015 #          - ALCARECOTkAlMuonIsolated  -> Isolated Muon
0016 #          - ALCARECOTkAlZMuMu         -> Z decay to two Muons
0017 #          - ALCARECOTkAlUpsilonMuMu   -> Upsilon decay to two Muons
0018 #          - generalTracks             -> general tracks treated like Minimum Bias
0019 #          - ALCARECOTkAlCosmicsInCollisions -> Cosmics taken during collisions
0020 #
0021 #        Globaltag specifies the detector conditions.
0022 #        Parts of the Globaltag are overwritten in Startgeometry.
0023 #
0024 #        monitorFile and binaryFile are automatically set by mps_setup.
0025 #        e.g. millePedeMonitor004.root and milleBinary004.dat
0026 #
0027 #        AlgoMode specifies mode of AlignmentProducer.algoConfig -> mille or pede
0028 #        mille is default. Pede mode is automatically set when merge config is created by MPS
0029 #
0030 #        CosmicsDecoMode and CosmicsZeroTesla are only relevant if collection
0031 #        is ALCARECOTkAlCosmicsCTF0T
0032 #
0033 #        If primaryWidth is bigger than 0.0 it overwrites
0034 #        process.AlignmentProducer.algoConfig.TrajectoryFactory.ParticleProperties.PrimaryWidth = ...
0035 #        if primaryWidth<=0.0 it has no effect at all.
0036 
0037 ################################################################################
0038 # Variables edited by mps_alisetup.py. Used in functions below.
0039 # You can change them manually as well.
0040 # ------------------------------------------------------------------------------
0041 setupGlobaltag        = "placeholder_globaltag"
0042 setupCollection       = "placeholder_collection"
0043 setupCosmicsDecoMode  = False
0044 setupCosmicsZeroTesla = False
0045 setupRecoGeometry     = "placeholder_recogeometry"
0046 setupPrimaryWidth     = -1.0
0047 setupJson             = "placeholder_json"
0048 setupRunStartGeometry = -1
0049 
0050 import FWCore.ParameterSet.Config as cms
0051 if not setupRecoGeometry:  # empty string defaults to DB
0052     from Configuration.Eras.Era_Run3_cff import Run3
0053     process = cms.Process("Alignment", Run3)
0054 else:
0055     import Configuration.Geometry.defaultPhase2ConditionsEra_cff as _settings
0056     # need to remove "Extended from the setupRecoGeometry because of defaultPhase2ConditionsEra interface"
0057     _PH2_GLOBAL_TAG, _PH2_ERA = _settings.get_era_and_conditions(setupRecoGeometry.replace("Extended", ""))
0058     process = cms.Process("Alignment",_PH2_ERA)
0059 
0060 ################################################################################
0061 # Variables edited by MPS (mps_setup and mps_merge). Be careful.
0062 # ------------------------------------------------------------------------------
0063 # Default is "mille". Gets changed to "pede" by mps_merge.
0064 setupAlgoMode         = "mille"
0065 
0066 # MPS looks specifically for the string "ISN" so don't change this.
0067 setupMonitorFile      = "millePedeMonitorISN.root"
0068 setupBinaryFile       = "milleBinaryISN.dat"
0069 
0070 # Input files. Edited by mps_splice.py
0071 readFiles = cms.untracked.vstring()
0072 ################################################################################
0073 
0074 
0075 ################################################################################
0076 # General setup
0077 # ------------------------------------------------------------------------------
0078 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
0079 generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla, setupRecoGeometry)
0080 
0081 
0082 ################################################################################
0083 # setup alignment producer
0084 # ------------------------------------------------------------------------------
0085 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer
0086 
0087 confAliProducer.setConfiguration(process,
0088     collection   = setupCollection,
0089     mode         = setupAlgoMode,
0090     monitorFile  = setupMonitorFile,
0091     binaryFile   = setupBinaryFile,
0092     primaryWidth = setupPrimaryWidth,
0093     cosmicsZeroTesla = setupCosmicsZeroTesla)
0094 
0095 
0096 ################################################################################
0097 # Overwrite some conditions in global tag
0098 # ------------------------------------------------------------------------------
0099 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter
0100 
0101 ##########################
0102 ## insert Startgeometry ##
0103 ##########################
0104 
0105 # # You can use tagwriter.setCondition() to overwrite conditions in globaltag
0106 # #
0107 # # Examples (ideal phase-1 tracker-alignment conditions):
0108 # tagwriter.setCondition(process,
0109 #       connect = "frontier://FrontierProd/CMS_CONDITIONS",
0110 #       record = "TrackerAlignmentRcd",
0111 #       tag = "TrackerAlignment_Upgrade2017_design_v4")
0112 # tagwriter.setCondition(process,
0113 #       connect = "frontier://FrontierProd/CMS_CONDITIONS",
0114 #       record = "TrackerSurfaceDeformationRcd",
0115 #       tag = "TrackerSurfaceDeformations_zero")
0116 # tagwriter.setCondition(process,
0117 #       connect = "frontier://FrontierProd/CMS_CONDITIONS",
0118 #       record = "TrackerAlignmentErrorExtendedRcd",
0119 #       tag = "TrackerAlignmentErrorsExtended_Upgrade2017_design_v0")
0120 # tagwriter.setCondition(process,
0121 #       connect = "frontier://FrontierProd/CMS_CONDITIONS",
0122 #       record = "SiPixelLorentzAngleRcd",
0123 #       label = "fromAlignment",
0124 #       tag = "SiPixelLorentzAngle_fromAlignment_phase1_mc_v1")
0125 
0126 
0127 #######################
0128 ## insert Alignables ##
0129 #######################
0130 
0131 # # to run a high-level alignment on real data (including TOB centering; use
0132 # # pixel-barrel centering for MC) of the whole tracker you can use the
0133 # # following configuration:
0134 #
0135 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
0136 #     "SelectorRigid,RigidBody",
0137 #     ]
0138 #
0139 # # Define the high-level structure alignables
0140 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
0141 #     alignParams = cms.vstring(
0142 #         "TrackerP1PXBHalfBarrel,111111",
0143 #         "TrackerP1PXECHalfCylinder,111111",
0144 #         "TrackerTIBHalfBarrel,111111",
0145 #         "TrackerTOBHalfBarrel,rrrrrr",
0146 #         "TrackerTIDEndcap,111111",
0147 #         "TrackerTECEndcap,111111",
0148 #     )
0149 # )
0150 
0151 
0152 # # to run a module-level alignment on real data (including TOB centering; use
0153 # # pixel-barrel centering for MC) of the whole tracker (including surface
0154 # # deformations) you can use the following configuration (read comments on
0155 # # multi-IOV alignment below):
0156 #
0157 # process.AlignmentProducer.ParameterBuilder.parameterTypes = [
0158 #     "SelectorRigid,RigidBody",
0159 #     "SelectorBowed,BowedSurface",
0160 #     "SelectorTwoBowed,TwoBowedSurfaces",
0161 # ]
0162 #
0163 # # Define the high-level structure alignables
0164 # process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
0165 #     alignParams = cms.vstring(
0166 #         "TrackerP1PXBHalfBarrel,111111",
0167 #         "TrackerP1PXECHalfCylinder,111111",
0168 #         "TrackerTIBHalfBarrel,111111",
0169 #         "TrackerTOBHalfBarrel,rrrrrr",
0170 #         "TrackerTIDEndcap,111111",
0171 #         "TrackerTECEndcap,111111",
0172 #     )
0173 # )
0174 #
0175 # # Define the module-level alignables (for single modules)
0176 # process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(
0177 #     alignParams = cms.vstring(
0178 #         "TrackerP1PXBModule,111111 111",
0179 #         "TrackerP1PXECModule,111111 111",
0180 #         "TrackerTIBModuleUnit,101111 111",
0181 #         "TrackerTIDModuleUnit,111111 111",
0182 #         "TrackerTECModuleUnit,111111 111,tecSingleSens",
0183 #     ),
0184 #     tecSingleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(1,4))),
0185 # )
0186 #
0187 # process.AlignmentProducer.ParameterBuilder.SelectorTwoBowed = cms.PSet(
0188 #     alignParams = cms.vstring(
0189 #         "TrackerTOBModuleUnit,101111 111 101111 111",
0190 #         "TrackerTECModuleUnit,111111 111 111111 111,tecDoubleSens",
0191 #     ),
0192 #     tecDoubleSens = cms.PSet(tecDetId = cms.PSet(ringRanges = cms.vint32(5,7))),
0193 # )
0194 #
0195 # # IOV definition
0196 # #  - defaults to single-IOV starting at "1", if omitted
0197 # #  - alignables have to match high-level structures above
0198 # #    -> except for 'rrrrrr' alignables
0199 # process.AlignmentProducer.RunRangeSelection = [
0200 #     cms.PSet(
0201 #         RunRanges = cms.vstring(
0202 #             "290550",
0203 #             "300000",
0204 #         ),
0205 #         selector = cms.vstring(
0206 #             "TrackerP1PXBHalfBarrel,111111",
0207 #             "TrackerP1PXECHalfCylinder,111111",
0208 #             "TrackerTIBHalfBarrel,111111",
0209 #             "TrackerTIDEndcap,111111",
0210 #             "TrackerTECEndcap,111111",
0211 #         )
0212 #     )
0213 # ] # end of process.AlignmentProducer.RunRangeSelection
0214 
0215 # # To run simultaneous calibrations of the pixel Lorentz angle you need to
0216 # # include the corresponding config fragment and configure the granularity and
0217 # # IOVs (must be consistent with input LA/template/alignment IOVs) for it.
0218 # # Note: There are different version of the LA record available in the global
0219 # #       tag. Depending on the TTRHBuilder, one has to set a label to configure
0220 # #       which of them is to be used. The default TTRHBuilder uses pixel
0221 # #       templates which ignores the unlabelled LA record and uses only the one
0222 # #       labelled "fromAlignment". This is also the default value in the
0223 # #       integrated LA calibration. If you are using the generic CPE instead of
0224 # #       the template CPE you have to use the following setting:
0225 # #
0226 # #       siPixelLA.lorentzAngleLabel = ""
0227 #
0228 # from Alignment.CommonAlignmentAlgorithm.SiPixelLorentzAngleCalibration_cff \
0229 #     import SiPixelLorentzAngleCalibration as siPixelLA
0230 # siPixelLA.LorentzAngleModuleGroups.Granularity = cms.VPSet()
0231 # siPixelLA.LorentzAngleModuleGroups.RunRange = cms.vuint32(290550,
0232 #                                                           295000,
0233 #                                                           298100)
0234 #
0235 # siPixelLA.LorentzAngleModuleGroups.Granularity.extend([
0236 #     cms.PSet(
0237 #         levels = cms.PSet(
0238 #             alignParams = cms.vstring(
0239 #                 'TrackerP1PXBModule,,RINGLAYER'
0240 #             ),
0241 #             RINGLAYER = cms.PSet(
0242 #                 pxbDetId  = cms.PSet(
0243 #                     moduleRanges = cms.vint32(ring, ring),
0244 #                     layerRanges = cms.vint32(layer, layer)
0245 #                 )
0246 #             )
0247 #         )
0248 #     )
0249 #     for ring in xrange(1,9) # [1,8]
0250 #     for layer in xrange(1,5) # [1,4]
0251 # ])
0252 # siPixelLA.LorentzAngleModuleGroups.Granularity.append(
0253 #     cms.PSet(
0254 #         levels = cms.PSet(
0255 #             alignParams = cms.vstring('TrackerP1PXECModule,,posz'),
0256 #             posz = cms.PSet(zRanges = cms.vdouble(-9999.0, 9999.0))
0257 #         )
0258 #     )
0259 # )
0260 #
0261 # process.AlignmentProducer.calibrations.append(siPixelLA)
0262 
0263 
0264 #########################
0265 ## insert Pedesettings ##
0266 #########################
0267 
0268 # # reasonable pede settings are already defined in
0269 # # 'confAliProducer.setConfiguration' above
0270 # #
0271 # # if you want to obtain alignment errors, use the following setting:
0272 # # process.AlignmentProducer.algoConfig.pedeSteerer.method = "inversion 3 0.8"
0273 # #
0274 # # a list of possible options is documented here:
0275 # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
0276 # #
0277 # # if you need to request a larger stack size for individual threads when
0278 # # running pede, you can do this with this setting: 
0279 # # process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; pede"
0280 # #
0281 # # you can change or drop pede options as follows:
0282 #
0283 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
0284 # helper.set_pede_option(process, "entries 50 10 2")
0285 # helper.set_pede_option(process, "compress", drop = True)
0286 
0287 
0288 #################
0289 ## add filters ##
0290 #################
0291 
0292 # # please add any EDFilter here that should run before processing the event,
0293 # # e.g. add the following lines to ensure that only 3.8T events are selected
0294 #
0295 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
0296 # process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
0297 # process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
0298 # helper.add_filter(process, process.magneticFieldFilter)
0299 
0300 
0301 
0302 ################################################################################
0303 # Mille-procedure
0304 # ------------------------------------------------------------------------------
0305 if setupAlgoMode == "mille":
0306     import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
0307     mille.setup(process,
0308                 input_files        = readFiles,
0309                 collection         = setupCollection,
0310                 json_file          = setupJson,
0311                 cosmics_zero_tesla = setupCosmicsZeroTesla,
0312                 cosmics_deco_mode  = setupCosmicsDecoMode)
0313 
0314 ################################################################################
0315 # Pede-procedure
0316 # ------------------------------------------------------------------------------
0317 else:
0318     # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
0319     merge_binary_files = ['placeholder_binaryList']
0320     merge_tree_files   = ['placeholder_treeList']
0321 
0322     import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
0323     pede.setup(process,
0324                binary_files = merge_binary_files,
0325                tree_files = merge_tree_files,
0326                run_start_geometry = setupRunStartGeometry)