CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
additionalparser.AdditionalData Class Reference

Public Member Functions

def __init__
 
def parse
 

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

Member Function Documentation

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

Definition at line 33 of file additionalparser.py.

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

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

Member Data Documentation

additionalparser.AdditionalData.pattern

Definition at line 27 of file additionalparser.py.

Referenced by produceOfflineValidationTex.PageLayout.fit(), additionalparser.AdditionalData.parse(), and dataset.BaseDataset.printFiles().

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.