Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
import FWCore.ParameterSet.Config as cms
import FWCore.ParameterSet.VarParsing as VarParsing

process = cms.Process("Alignment")

options = VarParsing.VarParsing()
options.register ('algoMode',
                  "mille", # default value
                  VarParsing.VarParsing.multiplicity.singleton,
                  VarParsing.VarParsing.varType.string,
                  "algo mode")

options.register ('useLapack',
                  False, # default value
                  VarParsing.VarParsing.multiplicity.singleton,
                  VarParsing.VarParsing.varType.bool,
                  "use lapack?")
options.parseArguments()

################################################################################
# Variables edited by mps_alisetup.py. Used in functions below.
# You can change them manually as well.
# ------------------------------------------------------------------------------
setupGlobaltag = "140X_dataRun3_ForTkAlReReco_v1"
setupCollection = "ALCARECOTkAlZMuMu"
setupCosmicsDecoMode  = False
setupCosmicsZeroTesla = False
setupPrimaryWidth     = -1.0
setupRecoGeometry     = "" # empty string defaults to DB
setupJson = ""
setupRunStartGeometry = 362350

################################################################################
# Variables edited by MPS (mps_setup and mps_merge). Be careful.
# ------------------------------------------------------------------------------
# Default is "mille". Gets changed to "pede" by mps_merge.
setupAlgoMode         = options.algoMode

# MPS looks specifically for the string "101" so don't change this.
setupMonitorFile      = "millePedeMonitor101.root"
setupBinaryFile       = "milleBinary101.dat"

# Input files. Edited by mps_splice.py
readFiles = cms.untracked.vstring()
readFiles.extend([
    '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/362/00000/d6641b44-f4e4-4054-b5b0-f038e567c61e.root',
    '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/433/00000/1f93221e-23ce-4731-906a-48c9fe405515.root',
    '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/435/00000/df6e27d1-5367-4192-83ed-2be9303d7837.root',
    '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/437/00000/7ce5bac8-0b29-40f3-a63b-fd0813d5678d.root',
    '/store/data/Run2022G/Muon/ALCARECO/TkAlZMuMu-PromptReco-v1/000/362/437/00000/ea6b065d-1912-491e-9cce-732eaf6fa038.root'])
################################################################################

################################################################################
# General setup
# ------------------------------------------------------------------------------
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla, setupRecoGeometry)

################################################################################
# setup alignment producer
# ------------------------------------------------------------------------------
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer

confAliProducer.setConfiguration(process,
    collection   = setupCollection,
    mode         = setupAlgoMode,
    monitorFile  = setupMonitorFile,
    binaryFile   = setupBinaryFile,
    primaryWidth = setupPrimaryWidth,
    cosmicsZeroTesla = setupCosmicsZeroTesla)

################################################################################
# Configure the MessageLogger service to dump information to cout (instead of alignment.log)
# see https://github.com/cms-sw/cmssw/issues/47963 for more information
# ------------------------------------------------------------------------------
process.MessageLogger.destinations = cms.untracked.vstring('cout')
process.MessageLogger.statistics = cms.untracked.vstring('cout')
# Copy all parameters from the existing 'alignment' PSet to a new 'cout' PSet
if hasattr(process.MessageLogger, 'alignment'):
    alignment_pset = process.MessageLogger.alignment
    process.MessageLogger.cout = alignment_pset

    # Optionally delete the old 'alignment' PSet
    delattr(process.MessageLogger, 'alignment')

################################################################################
# Overwrite some conditions in global tag
# ------------------------------------------------------------------------------
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter

#######################
## insert Alignables ##
#######################

# # to run a high-level alignment on real data (including TOB centering; use
# # pixel-barrel centering for MC) of the whole tracker you can use the
# # following configuration:
#
process.AlignmentProducer.ParameterBuilder.parameterTypes = [
     "SelectorRigid,RigidBody",
     #"SelectorBowed,BowedSurface", 
     #"SelectorTwoBowed,TwoBowedSurfaces",
     ]

# # Define the high-level structure alignables
process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
     alignParams = cms.vstring(
         "TrackerP1PXBLadder,111111",
         "TrackerP1PXECPanel,111111",
         "TrackerTIBHalfBarrel,111111",
         "TrackerTOBHalfBarrel,rrrrrr",
         "TrackerTIDEndcap,111111",
         "TrackerTECEndcap,111111",
     )
)

process.AlignmentProducer.RunRangeSelection = [
    cms.PSet(
        RunRanges = cms.vstring(
            "362350",
            "362440",
            "362446",
            "362617",
            "362632",
            "362640",
            "362641",
            "362645",
            "362663",
            "362670",
            "362679",
            "362683",
            "362697",
            "362711",
            "362744"
        ),
        selector = cms.vstring(
            "TrackerP1PXBLadder,111111",
            "TrackerP1PXECPanel,111111"
        )
    ),
    
    cms.PSet(
        RunRanges = cms.vstring(
            "362350",
            "362520"
        ),
        selector = cms.vstring(
            "TrackerTIBHalfBarrel,111111",
            "TrackerTIDEndcap,111111",
            "TrackerTECEndcap,111111"
        )
    )
] # end of process.AlignmentProducer.RunRangeSelection

#########################
## insert Pedesettings ##
#########################

# # reasonable pede settings are already defined in
# # 'confAliProducer.setConfiguration' above
# #

if(options.algoMode == "pede"):
    if(options.useLapack):
        # LAPACK
        print("I am going to run fullLAPACK 3 0.8")
        process.AlignmentProducer.algoConfig.pedeSteerer.method = "fullLAPACK 3 0.8"
        process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; MKL_THREADING_LAYER=GNU; export OMP_NUM_THREADS=10; export MKL_NUM_THREADS=10; \
        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/projects.cern.ch/intelsw/oneAPI/linux/x86_64/2022/mkl/2022.1.0/lib/intel64;"
    else:
        # MINRES
        print("I am going to run sparseMINRES 6 0.8")
        process.AlignmentProducer.algoConfig.pedeSteerer.method = "sparseMINRES 6 0.8"
        process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand = "export OMP_STACKSIZE=20M; pede"
else:
    pass
        
# # if you want to obtain alignment errors, use the following setting:
# #
# # a list of possible options is documented here:
# # http://www.desy.de/~kleinwrt/MP2/doc/html/option_page.html#sec-cmd
# #
# # if you need to request a larger stack size for individual threads when
# # running pede, you can do this with this setting:
# #
# # you can change or drop pede options as follows:
#
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
helper.set_pede_option(process, "threads 10")
helper.set_pede_option(process, "entries 100 10 2")
helper.set_pede_option(process, "skipemptycons")
helper.set_pede_option(process, "countrecords")

#################
## add filters ##
#################

# # please add any EDFilter here that should run before processing the event,
# # e.g. add the following lines to ensure that only 3.8T events are selected
#
# import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
# process.load("Alignment.CommonAlignment.magneticFieldFilter_cfi")
# process.magneticFieldFilter.magneticField = 38 # in units of kGauss (=0.1T)
# helper.add_filter(process, process.magneticFieldFilter)

################################################################################
# Mille-procedure
# ------------------------------------------------------------------------------
if setupAlgoMode == "mille":
    import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
    mille.setup(process,
                input_files        = readFiles,
                collection         = setupCollection,
                json_file          = setupJson,
                cosmics_zero_tesla = setupCosmicsZeroTesla,
                cosmics_deco_mode  = setupCosmicsDecoMode)

################################################################################
# Pede-procedure
# ------------------------------------------------------------------------------
else:
    # placeholers get replaced by mps_merge.py, which is called in mps_setup.pl
    merge_binary_files = ['placeholder_binaryList']
    merge_tree_files   = ['placeholder_treeList']

    import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
    pede.setup(process,
               binary_files = merge_binary_files,
               tree_files = merge_tree_files,
               run_start_geometry = setupRunStartGeometry)