CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
additionalparser.AdditionalData Class Reference

Public Member Functions

def __init__ (self)
 
def parse (self, config, path)
 

Public Attributes

 pattern
 
 pedeSteererCommand
 
 pedeSteererMethod
 
 pedeSteererOptions
 
 selector
 
 selectorTag
 
 selectorThird
 

Detailed Description

stores the additional information of the alignment_merge.py file

Definition at line 10 of file additionalparser.py.

Constructor & Destructor Documentation

def additionalparser.AdditionalData.__init__ (   self)

Definition at line 14 of file additionalparser.py.

14  def __init__(self):
18 
19  # safe the selector information Rigid, Bowed, TwoBowed
20  self.selector = [[] for x in range(3)]
21  self.selectorTag = [[] for x in range(3)]
22  self.selectorThird = [[] for x in range(3)]
23 
24  # string to find the information and variables where to safe the
25  # information (searchstring: [selector list, seletor tag, third element,
26  # name])
27  self.pattern = {
28  "process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(": [self.selector[0], self.selectorTag[0], self.selectorThird[0], "SelectorRigid"],
29  "process.AlignmentProducer.ParameterBuilder.SelectorBowed = cms.PSet(": [self.selector[1], self.selectorTag[1], self.selectorThird[1], "SelectorBowed"],
30  "process.AlignmentProducer.ParameterBuilder.SelectorTwoBowed = cms.PSet(": [self.selector[2], self.selectorTag[2], self.selectorThird[2], "SelectorTwoBowed"]
31  }
32 

Member Function Documentation

def additionalparser.AdditionalData.parse (   self,
  config,
  path 
)

Definition at line 33 of file additionalparser.py.

References any(), mps_alisetup.append, additionalparser.AdditionalData.pattern, additionalparser.AdditionalData.pedeSteererCommand, additionalparser.AdditionalData.pedeSteererMethod, python.rootplot.root2matplotlib.replace(), split, and digi_MixPreMix_cfi.strip.

33  def parse(self, config, path):
34  logger = logging.getLogger("mpsvalidate")
35 
36  # open aligment_merge.py file
37  try:
38  with open(path) as inputFile:
39  mergeFile = inputFile.readlines()
40  except IOError:
41  logger.error("AdditionalData: {0} does not exist".format(path))
42  return
43 
44  # search pattern
45 
46  # loop over lines
47  for index, line in enumerate(mergeFile):
48  try:
49  # search for SelectorRigid, SelectorBowed and SelectorTwoBowed
50  for string in self.pattern:
51  if (string in line):
52  # extract data
53  for lineNumber in range(index + 2, index + 8):
54  mergeFile[lineNumber] = mergeFile[lineNumber].split("#", 1)[0]
55  # break at the end of the SelectorRigid
56  if (")" in mergeFile[lineNumber]):
57  break
58  self.pattern[string][0].append(
59  mergeFile[lineNumber].replace("\"", "'").strip("', \n").split(","))
60  # check if third argument
61  if (len(self.pattern[string][0][-1]) > 2):
62  self.pattern[string][1].append(
63  self.pattern[string][0][-1][2])
64  # check for third arguments
65  if ("'" not in line.replace("\"", "'")):
66  for tag in self.pattern[string][1]:
67  if tag in line:
68  self.pattern[string][2].append(line.strip("\n").replace("#", ""))
69  # add following lines
70  for lineNumber in range(index + 1, index + 5):
71  # new process or blank line
72  if ("process" in mergeFile[lineNumber] or "\n" == mergeFile[lineNumber]):
73  break
74  # different tag
75  if (any(x in mergeFile[lineNumber] for x in self.pattern[string][1])):
76  break
77  self.pattern[string][2].append(mergeFile[lineNumber].strip("\n").replace("#", ""))
78  except Exception as e:
79  logging.error("Selector Parsing error")
80 
81  # search for pedeSteererMethod
82  if ("process.AlignmentProducer.algoConfig.pedeSteerer.method" in line and "#" not in line):
83  try:
84  self.pedeSteererMethod = line.replace("\"", "'").split("'")[1]
85  except Exception as e:
86  logger.error("AdditionalParser: pedeSteererMethod not found - {0}".format(e))
87 
88  # search for pedeSteererOptions
89  if ("process.AlignmentProducer.algoConfig.pedeSteerer.options" in line and "#" not in line):
90  for lineNumber in range(index + 1, index + 15):
91  if (lineNumber<len(mergeFile)):
92  if ("]" in mergeFile[lineNumber]):
93  break
94  self.pedeSteererOptions.append(
95  mergeFile[lineNumber].replace("\"", "'").strip("', \n"))
96 
97  # search for pedeSteererCommand
98  if ("process.AlignmentProducer.algoConfig.pedeSteerer.pedeCommand" in line and "#" not in line):
99  try:
100  self.pedeSteererCommand = line.replace("\"", "'").split("'")[1]
101  except Exception as e:
102  logger.error("AdditionalParser: pedeSteererCommand not found - {0}".format(e))
103 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
def replace(string, replacements)
def parse(self, config, path)
double split
Definition: MVATrainer.cc:139

Member Data Documentation

additionalparser.AdditionalData.pattern
additionalparser.AdditionalData.pedeSteererCommand

Definition at line 17 of file additionalparser.py.

Referenced by additionalparser.AdditionalData.parse().

additionalparser.AdditionalData.pedeSteererMethod

Definition at line 15 of file additionalparser.py.

Referenced by additionalparser.AdditionalData.parse().

additionalparser.AdditionalData.pedeSteererOptions

Definition at line 16 of file additionalparser.py.

additionalparser.AdditionalData.selector

Definition at line 20 of file additionalparser.py.

additionalparser.AdditionalData.selectorTag

Definition at line 21 of file additionalparser.py.

additionalparser.AdditionalData.selectorThird

Definition at line 22 of file additionalparser.py.