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
import FWCore.ParameterSet.Config as cms
from  FWCore.ParameterSet.Config import ModifierChain,Modifier

class Eras (object):
    """
    Dummy container for all the cms.Modifier instances that config fragments
    can use to selectively configure depending on what scenario is active.
    """
    def __init__(self):
        allEras=['Run1_pA',
                 'Run1_peripheralPbPb',
                 'Run2_50ns',
                 'Run2_50ns_HIPM',
                 'Run2_25ns',
                 'Run2_25ns_HIPM',
                 'Run2_25ns_peripheralPbPb',
                 'Run2_HI',
                 'Run2_2016',
                 'Run2_2016_HIPM',
                 'Run2_2016_trackingLowPU',
                 'Run2_2016_pA',
                 'Run2_2016_UPC',
                 'Run2_2017',
                 'Run2_2017_noMkFit',
                 'Run2_2017_FastSim', #new modifier for Phase1 FastSim, skips the muon GEM sequence
                 'Run2_2017_trackingRun2',
                 'Run2_2017_trackingLowPU',
                 'Run2_2017_pp_on_XeXe',
                 'Run2_2017_ppRef',
                 'Run2_2018',
                 'Run2_2018_FastSim', #new modifier for Phase1 FastSim, skips the muon GEM sequence
                 'Run2_2018_pp_on_AA',
                 'Run2_2018_pp_on_AA_noHCALmitigation',
                 'Run2_2018_highBetaStar',
                 'Run2_2018_noMkFit',
                 'Run3',
                 'Run3_2023',
                 'Run3_2024',
                 'Run3_2025',
                 'Run3_noMkFit',
                 'Run3_pp_on_PbPb',
                 'Run3_pp_on_PbPb_approxSiStripClusters',
                 'Run3_pp_on_PbPb_2023',
                 'Run3_pp_on_PbPb_approxSiStripClusters_2023',
                 'Run3_pp_on_PbPb_2024',
                 'Run3_pp_on_PbPb_approxSiStripClusters_2024',
                 'Run3_pp_on_PbPb_2025',
                 'Run3_pp_on_PbPb_approxSiStripClusters_2025',
                 'Run3_dd4hep',
                 'Run3_DDD',
                 'Run3_FastSim',
                 'Run3_2023_FastSim',
                 'Run3_2023_ZDC',
                 'Run3_2023_UPC',
                 'Run3_2024_ppRef',
                 'Run3_2024_UPC',
                 'Run3_2024_FastSim',
                 'Run3_2025_UPC',
                 'Run3_2025_OXY',
                 'Run3_2025_UPC_OXY',
                 'Run3_2025_FastSim',
                 'Phase2',
                 'Phase2_noMkFit',
                 'Phase2C9',
                 'Phase2C9_noMkFit',
                 'Phase2C10',
                 'Phase2C10_noMkFit',
                 'Phase2C11',
                 'Phase2C11_noMkFit',
                 'Phase2C12',
                 'Phase2C12_noMkFit',
                 'Phase2C9_dd4hep',
                 'Phase2C9_dd4hep_noMkFit',
                 'Phase2C10_dd4hep',
                 'Phase2C10_dd4hep_noMkFit',
                 'Phase2C11_dd4hep',
                 'Phase2C11_dd4hep_noMkFit',
                 'Phase2C11I13',
                 'Phase2C11I13_noMkFit',
                 'Phase2C12_dd4hep',
                 'Phase2C12_dd4hep_noMkFit',
                 'Phase2C11M9',
                 'Phase2C11M9_noMkFit',
                 'Phase2C11I13M9',
                 'Phase2C11I13M9_noMkFit',
                 'Phase2C11I13T25M9',
                 'Phase2C11I13T25M9_noMkFit',
                 'Phase2C11I13T26M9',
                 'Phase2C11I13T26M9_noMkFit',
                 'Phase2C17I13M9',
                 'Phase2C17I13M9_noMkFit',
                 'Phase2C20I13M9',
                 'Phase2C20I13M9_noMkFit', 
                 'Phase2C22I13M9',
                 'Phase2C22I13M9_noMkFit'
        ]

        internalUseMods = ['run2_common', 'run2_25ns_specific',
                           'run2_50ns_specific', 'run2_HI_specific',
                           'stage1L1Trigger', 'fastSim',
                           'peripheralPbPb', 'pA_2016',
                           'run2_HE_2017', 'stage2L1Trigger', 'stage2L1Trigger_2017', 'stage2L1Trigger_2018', 'stage2L1Trigger_2021',
                           'run2_HF_2017', 'run2_HCAL_2017', 'run2_HEPlan1_2017', 'run2_HB_2018','run2_HE_2018',
                           'run3_HB', 'run3_HFSL', 'run3_common', 'run3_RPC',
                           'phase1Pixel', 'run3_GEM', 'run2_GEM_2017',
                           'run3_SiPixel_2025',
                           'run2_CSC_2018',
                           'phase2_common', 'phase2_tracker',
                           'phase2_muon', 'phase2_GEM', 'phase2_GE0',
                           'phase2_hgcal', 'phase2_timing', 'phase2_hfnose', 'phase2_hgcalV10', 'phase2_hgcalV11', 'phase2_hgcalV12',
                           'phase2_timing_layer', 'phase2_etlV4', 'phase2_hcal', 'phase2_ecal','phase2_ecal_devel', 'phase2_ecalTP_devel',
                           'phase2_trigger',
                           'phase2_squarePixels', 'phase2_3DPixels',
                           'trackingLowPU', 'trackingPhase1',
                           'ctpps', 'ctpps_2016', 'ctpps_2017', 'ctpps_2018', 'ctpps_2022',
                           'trackingPhase2PU140','highBetaStar',
                           'tracker_apv_vfp30_2016', 'pf_badHcalMitigationOff',
                           'run2_nanoAOD_106Xv2',
                           'run3_nanoAOD_pre142X',
                           'run3_ecal_devel',
                           'run3_upc', 'run3_oxygen',
                           'hcalHardcodeConditions', 'hcalSkipPacker',
                           'run2_HLTconditions_2016','run2_HLTconditions_2017','run2_HLTconditions_2018',
                           'bParking']
        internalUseModChains = ['run2_2017_noTrackingModifier', 'trackingMkFitProd']

        self.pythonCfgLines = {}

        for e in allEras:
            eObj=getattr(__import__('Configuration.Eras.Era_'+e+'_cff',globals(),locals(),[e],0),e)
            self.addEra(e,eObj)
            self.pythonCfgLines[e] = 'from Configuration.Eras.Era_'+e+'_cff import '+e

        for e in internalUseMods:
            eObj=getattr(__import__('Configuration.Eras.Modifier_'+e+'_cff',globals(),locals(),[e],0),e)
            self.addEra(e,eObj)
            self.pythonCfgLines[e] = 'from Configuration.Eras.Modifier_'+e+'_cff import '+e

        for e in internalUseModChains:
            eObj=getattr(__import__('Configuration.Eras.ModifierChain_'+e+'_cff',globals(),locals(),[e],0),e)
            self.addEra(e,eObj)
            self.pythonCfgLines[e] = 'from Configuration.Eras.ModifierChain_'+e+'_cff import '+e


    def addEra(self,name,obj):
        setattr(self,name,obj)

    def inspectModifier(self,m,details):
        print('      ',m.__dict__ ['_Modifier__processModifiers'])

    def inspectEra(self,e,details):
        print('\nEra:',e)
        print('   isChosen:',getattr(self,e)._isChosen())
        if details: print('   Modifiers:')
        nmod=0
        for value in getattr(self,e).__dict__['_ModifierChain__chain']:
            if isinstance(value, Modifier):
                nmod=nmod+1
                if details: self.inspectModifier(value,details)
        print('   ',nmod,'modifiers defined')

    def inspect(self,name=None,onlyChosen=False,details=True):
        if name==None:
            print('Inspecting the known eras', end=' ')
            if onlyChosen: print(' (all active)')
            else: print('(all eras defined)')
        else:
            print('Inspecting the '+name+' era', end=' ')

        allEras=[]
        for key, value in self.__dict__.items():
            if isinstance(value, ModifierChain): allEras.append(key)

        for e in allEras:
            if name is not None and name==e:
                self.inspectEra(e,details)
            if name is None:
                if not onlyChosen or getattr(self,e).isChosen():
                    self.inspectEra(e,details)

eras=Eras()


#eras.inspect()