Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-05-07 01:49:28

0001 import FWCore.ParameterSet.Config as cms
0002 import FWCore.ParameterSet.VarParsing as VarParsing
0003 
0004 process = cms.Process("Alignment")
0005 
0006 options = VarParsing.VarParsing()
0007 options.register ('algoMode',
0008                   "mille", # default value
0009                   VarParsing.VarParsing.multiplicity.singleton,
0010                   VarParsing.VarParsing.varType.string,
0011                   "algo mode")
0012 
0013 options.register ('useLapack',
0014                   False, # default value
0015                   VarParsing.VarParsing.multiplicity.singleton,
0016                   VarParsing.VarParsing.varType.bool,
0017                   "use lapack?")
0018 options.parseArguments()
0019 
0020 ################################################################################
0021 # Variables edited by mps_alisetup.py. Used in functions below.
0022 # You can change them manually as well.
0023 # ------------------------------------------------------------------------------
0024 setupGlobaltag = "140X_dataRun3_ForTkAlReReco_v1"
0025 setupCollection = "ALCARECOTkAlZMuMu"
0026 setupCosmicsDecoMode  = False
0027 setupCosmicsZeroTesla = False
0028 setupPrimaryWidth     = -1.0
0029 setupRecoGeometry     = "" # empty string defaults to DB
0030 setupJson = ""
0031 setupRunStartGeometry = 362350
0032 
0033 ################################################################################
0034 # Variables edited by MPS (mps_setup and mps_merge). Be careful.
0035 # ------------------------------------------------------------------------------
0036 # Default is "mille". Gets changed to "pede" by mps_merge.
0037 setupAlgoMode         = options.algoMode
0038 
0039 # MPS looks specifically for the string "101" so don't change this.
0040 setupMonitorFile      = "millePedeMonitor101.root"
0041 setupBinaryFile       = "milleBinary101.dat"
0042 
0043 # Input files. Edited by mps_splice.py
0044 readFiles = cms.untracked.vstring()
0045 readFiles.extend([
0046     '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/362/00000/d6641b44-f4e4-4054-b5b0-f038e567c61e.root',
0047     '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/433/00000/1f93221e-23ce-4731-906a-48c9fe405515.root',
0048     '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/435/00000/df6e27d1-5367-4192-83ed-2be9303d7837.root',
0049     '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/437/00000/7ce5bac8-0b29-40f3-a63b-fd0813d5678d.root',
0050     '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/437/00000/ea6b065d-1912-491e-9cce-732eaf6fa038.root'])
0051 ################################################################################
0052 
0053 ################################################################################
0054 # General setup
0055 # ------------------------------------------------------------------------------
0056 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
0057 generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla, setupRecoGeometry)
0058 
0059 ################################################################################
0060 # setup alignment producer
0061 # ------------------------------------------------------------------------------
0062 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer
0063 
0064 confAliProducer.setConfiguration(process,
0065     collection   = setupCollection,
0066     mode         = setupAlgoMode,
0067     monitorFile  = setupMonitorFile,
0068     binaryFile   = setupBinaryFile,
0069     primaryWidth = setupPrimaryWidth,
0070     cosmicsZeroTesla = setupCosmicsZeroTesla)
0071 
0072 ################################################################################
0073 # Configure the MessageLogger service to dump information to cout (instead of alignment.log)
0074 # see https://github.com/cms-sw/cmssw/issues/47963 for more information
0075 # ------------------------------------------------------------------------------
0076 process.MessageLogger.destinations = cms.untracked.vstring('cout')
0077 process.MessageLogger.statistics = cms.untracked.vstring('cout')
0078 # Copy all parameters from the existing 'alignment' PSet to a new 'cout' PSet
0079 if hasattr(process.MessageLogger, 'alignment'):
0080     alignment_pset = process.MessageLogger.alignment
0081     process.MessageLogger.cout = alignment_pset
0082 
0083     # Optionally delete the old 'alignment' PSet
0084     delattr(process.MessageLogger, 'alignment')
0085 
0086 ################################################################################
0087 # Overwrite some conditions in global tag
0088 # ------------------------------------------------------------------------------
0089 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter
0090 
0091 #######################
0092 ## insert Alignables ##
0093 #######################
0094 
0095 # # to run a high-level alignment on real data (including TOB centering; use
0096 # # pixel-barrel centering for MC) of the whole tracker you can use the
0097 # # following configuration:
0098 #
0099 process.AlignmentProducer.ParameterBuilder.parameterTypes = [
0100      "SelectorRigid,RigidBody",
0101      #"SelectorBowed,BowedSurface", 
0102      #"SelectorTwoBowed,TwoBowedSurfaces",
0103      ]
0104 
0105 # # Define the high-level structure alignables
0106 process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
0107      alignParams = cms.vstring(
0108          "TrackerP1PXBLadder,111111",
0109          "TrackerP1PXECPanel,111111",
0110          "TrackerTIBHalfBarrel,111111",
0111          "TrackerTOBHalfBarrel,rrrrrr",
0112          "TrackerTIDEndcap,111111",
0113          "TrackerTECEndcap,111111",
0114      )
0115 )
0116 
0117 process.AlignmentProducer.RunRangeSelection = [
0118     cms.PSet(
0119         RunRanges = cms.vstring(
0120             "362350",
0121             "362440",
0122             "362446",
0123             "362617",
0124             "362632",
0125             "362640",
0126             "362641",
0127             "362645",
0128             "362663",
0129             "362670",
0130             "362679",
0131             "362683",
0132             "362697",
0133             "362711",
0134             "362744"
0135         ),
0136         selector = cms.vstring(
0137             "TrackerP1PXBLadder,111111",
0138             "TrackerP1PXECPanel,111111"
0139         )
0140     ),
0141     
0142     cms.PSet(
0143         RunRanges = cms.vstring(
0144             "362350",
0145             "362520"
0146         ),
0147         selector = cms.vstring(
0148             "TrackerTIBHalfBarrel,111111",
0149             "TrackerTIDEndcap,111111",
0150             "TrackerTECEndcap,111111"
0151         )
0152     )
0153 ] # end of process.AlignmentProducer.RunRangeSelection
0154 
0155 #########################
0156 ## insert Pedesettings ##
0157 #########################
0158 
0159 # # reasonable pede settings are already defined in
0160 # # 'confAliProducer.setConfiguration' above
0161 # #
0162 
0163 if(options.algoMode == "pede"):
0164     if(options.useLapack):
0165         # LAPACK
0166         print("I am going to run fullLAPACK 3 0.8")
0167         process.AlignmentProducer.algoConfig.pedeSteerer.method = "fullLAPACK 3 0.8"
0168         process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; MKL_THREADING_LAYER=GNU; export OMP_NUM_THREADS=10; export MKL_NUM_THREADS=10; \
0169         export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/projects.cern.ch/intelsw/oneAPI/linux/x86_64/2022/mkl/2022.1.0/lib/intel64;"
0170     else:
0171         # MINRES
0172         print("I am going to run sparseMINRES 6 0.8")
0173         process.AlignmentProducer.algoConfig.pedeSteerer.method = "sparseMINRES 6 0.8"
0174         process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; pede"
0175 else:
0176     pass
0177         
0178 # # if you want to obtain alignment errors, use the following setting:
0179 # #
0180 # # a list of possible options is documented here:
0181 # # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
0182 # #
0183 # # if you need to request a larger stack size for individual threads when
0184 # # running pede, you can do this with this setting:
0185 # #
0186 # # you can change or drop pede options as follows:
0187 #
0188 import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
0189 helper.set_pede_option(process, "threads 10")
0190 helper.set_pede_option(process, "entries 100 10 2")
0191 helper.set_pede_option(process, "skipemptycons")
0192 helper.set_pede_option(process, "countrecords")
0193 
0194 #################
0195 ## add filters ##
0196 #################
0197 
0198 # # please add any EDFilter here that should run before processing the event,
0199 # # e.g. add the following lines to ensure that only 3.8T events are selected
0200 #
0201 # import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
0202 # process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
0203 # process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
0204 # helper.add_filter(process, process.magneticFieldFilter)
0205 
0206 ################################################################################
0207 # Mille-procedure
0208 # ------------------------------------------------------------------------------
0209 if setupAlgoMode == "mille":
0210     import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
0211     mille.setup(process,
0212                 input_files        = readFiles,
0213                 collection         = setupCollection,
0214                 json_file          = setupJson,
0215                 cosmics_zero_tesla = setupCosmicsZeroTesla,
0216                 cosmics_deco_mode  = setupCosmicsDecoMode)
0217 
0218 ################################################################################
0219 # Pede-procedure
0220 # ------------------------------------------------------------------------------
0221 else:
0222     # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
0223     merge_binary_files = ['placeholder_binaryList']
0224     merge_tree_files   = ['placeholder_treeList']
0225 
0226     import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
0227     pede.setup(process,
0228                binary_files = merge_binary_files,
0229                tree_files = merge_tree_files,
0230                run_start_geometry = setupRunStartGeometry)