CMS 3D CMS Logo

helper.py
Go to the documentation of this file.
1 from builtins import range
2 import os
3 import FWCore.ParameterSet.Config as cms
4 
6  """Checks if MPS is checked out locally or taken from the release."""
7 
8  checked_out_packages = os.path.join(os.environ["CMSSW_BASE"], "src", ".git",
9  "info", "sparse-checkout")
10  checked_out = False
11  git_initialized = False
12  try:
13  with open(checked_out_packages, "r") as f:
14  packages = ("/Alignment/", "/Alignment/MillePedeAlignmentAlgorithm/")
15  for line in f:
16  if line.strip() in packages:
17  checked_out = True
18  break
19  git_initialized = True # since the sparse checkout file is there
20  except IOError as e:
21  if e.args != (2, 'No such file or directory'): raise
22 
23  return checked_out, git_initialized
24 
25 
26 def set_pede_option(process, option, drop = False):
27  """Utility function to set or override pede `option` defined in `process`.
28 
29  Arguments:
30  - `process`: cms.Process object
31  - `option`: option string
32  - `drop`: if set to 'True' the `option` is dropped completely
33  """
34 
35  existing_options = process.AlignmentProducer.algoConfig.pedeSteerer.options
36 
37  exists = False
38  for i in range(len(existing_options)):
39  if existing_options[i].split()[0] == option.split()[0]:
40  existing_options[i] = option.strip()
41  exists = True
42  if drop: existing_options.pop(i)
43  break
44 
45  if not exists and not drop: existing_options.append(option.strip())
46 
47 
48 def add_filter(process, ed_filter):
49  """
50  Adds EDFilter to the supplied cms.Process object and returns complete filter
51  sequence.
52 
53  Arguments:
54  - `process`: cms.Process object
55  - `ed_filter`: EDFilter
56  """
57 
58  if not hasattr(process, "mps_filters"): process.mps_filters = cms.Sequence()
59  process.mps_filters += ed_filter
60  return process.mps_filters
def checked_out_MPS()
Definition: helper.py:5
def add_filter(process, ed_filter)
Definition: helper.py:48
def set_pede_option(process, option, drop=False)
Definition: helper.py:26
double split
Definition: MVATrainer.cc:139