Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:34

0001 from builtins import range
0002 import os
0003 import FWCore.ParameterSet.Config as cms
0004 
0005 def checked_out_MPS():
0006     """Checks if MPS is checked out locally or taken from the release."""
0007 
0008     checked_out_packages = os.path.join(os.environ["CMSSW_BASE"], "src", ".git",
0009                                         "info", "sparse-checkout")
0010     checked_out = False
0011     git_initialized = False
0012     try:
0013         with open(checked_out_packages, "r") as f:
0014             packages = ("/Alignment/", "/Alignment/MillePedeAlignmentAlgorithm/","/*/")
0015             for line in f:
0016                 if line.strip() in packages:
0017                     checked_out = True
0018                     break
0019         git_initialized = True  # since the sparse checkout file is there
0020     except IOError as e:
0021         if e.args != (2, 'No such file or directory'): raise
0022 
0023     return checked_out, git_initialized
0024 
0025 
0026 def set_pede_option(process, option, drop = False):
0027     """Utility function to set or override pede `option` defined in `process`.
0028 
0029     Arguments:
0030     - `process`: cms.Process object
0031     - `option`: option string
0032     - `drop`: if set to 'True' the `option` is dropped completely
0033     """
0034 
0035     existing_options = process.AlignmentProducer.algoConfig.pedeSteerer.options
0036 
0037     exists = False
0038     for i in range(len(existing_options)):
0039         if existing_options[i].split()[0] == option.split()[0]:
0040            existing_options[i] = option.strip()
0041            exists = True
0042            if drop: existing_options.pop(i)
0043            break
0044 
0045     if not exists and not drop: existing_options.append(option.strip())
0046 
0047 
0048 def add_filter(process, ed_filter):
0049     """
0050     Adds EDFilter to the supplied cms.Process object and returns complete filter
0051     sequence.
0052 
0053     Arguments:
0054     - `process`: cms.Process object
0055     - `ed_filter`: EDFilter
0056     """
0057 
0058     if not hasattr(process, "mps_filters"): process.mps_filters = cms.Sequence()
0059     process.mps_filters += ed_filter
0060     return process.mps_filters