CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
mps_validate Namespace Reference

Functions

def main
 

Function Documentation

def mps_validate.main ( )

Definition at line 31 of file mps_validate.py.

References trackerTree.check(), pdfCreator.create(), htmlCreator.create(), beamerCreator.create(), reco.if(), dumpparser.parse(), monitorPlot.plot(), bigStructure.plot(), bigModule.plot(), timeStructure.plot(), and style.setgstyle().

31 
32 def main():
33  # config logging module
34  logging.basicConfig(level=logging.INFO, format="%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s", datefmt="%H:%M:%S")
35  logger = logging.getLogger("mpsvalidate")
36 
37  # run ROOT in batchmode
38  gROOT.SetBatch()
39 
40  # ArgumentParser
41  parser = argparse.ArgumentParser(description="Validate your Alignment.")
42  parser.add_argument(
43  "-j", "--job", help="chose jobmX directory (default: ini-file)", default=-1, type=int)
44  parser.add_argument(
45  "-t", "--time", help="chose MillePedeUser_X Tree (default: ini-file)", default=-1, type=int)
46  parser.add_argument("-i", "--ini", help="specify a ini file", default="-1")
47  parser.add_argument("-m", "--message",
48  help="identification on every plot", default="")
49  parser.add_argument("-p", "--jobdatapath",
50  help="path to the jobm directory", default="")
51  parser.add_argument("-o", "--outputpath",
52  help="outputpath", default="")
53  parser.add_argument("-l", "--logging",
54  help="if this argument is given a logging file (validation.log) is saved in the current directory", action="store_true")
55  parser.add_argument("-c", "--copy",
56  help="creates a copy of the validation_user.ini file in the current directory", action="store_true")
57  args = parser.parse_args()
58 
59  # create config object
60  config = ConfigData()
61 
62  # create logging handler
63  if(args.logging):
64  handler = logging.FileHandler("validation.log", mode="w")
65  handler.setLevel(logging.DEBUG)
66  formatter = logging.Formatter("%(levelname)s %(asctime)s (%(pathname)s line %(lineno)d): %(message)s",
67  datefmt="%H:%M:%S")
68  handler.setFormatter(formatter)
69  logger.addHandler(handler)
70 
71  # parse default ini file
72  logger.info("start to parse the default.ini")
73  config.parseConfig(os.path.join(config.mpspath, "default.ini"))
74 
75  # copy of ini file in current directory
76  if (args.copy):
77  logger.info("create copy of validation_user.ini in current directory")
78  shutil.copy2(os.path.join(config.mpspath, "default.ini"), "validation_user.ini")
79  sys.exit()
80 
81 
82  # parse user ini file
83  if (args.ini != "-1"):
84  logger.info("start to parse the user ini: {0}".format(args.ini))
85  config.parseConfig(args.ini)
86 
87  # override ini configs with consol parameter
88  config.parseParameter(args)
89 
90  # create output directories
91  logger.info("create the output directories")
92  if not os.path.exists(os.path.join(config.outputPath, "plots/pdf")):
93  os.makedirs(os.path.join(config.outputPath, "plots/pdf"))
94  if not os.path.exists(os.path.join(config.outputPath, "plots/png")):
95  os.makedirs(os.path.join(config.outputPath, "plots/png"))
96 
97  # open root file and get TTree MillePedeUser_X
98  logger.info("try to open the root file: {0}".format(os.path.join(config.jobDataPath, "treeFile_merge.root")))
99  treeFile = TFile(os.path.join(config.jobDataPath, "treeFile_merge.root"))
100  MillePedeUser = treeFile.Get("MillePedeUser_{0}".format(config.jobTime))
101  if not MillePedeUser:
102  logger.error("Could not open TTree File MillePedeUser_{0} in {1}".format(
103  config.jobTime, os.path.join(config.jobDataPath, "treeFile_merge.root")))
104  return
105 
106  # set gStyle
107  setgstyle()
108 
109  # create alignables object
110  alignables = Alignables(config)
111 
112  # check if there is the TrackerTree.root file and if not create it
113  trackerTree.check(config)
114 
115  ##########################################################################
116  # draw the plots of the millePedeMonitor_merge.root file
117  #
118 
119  if (config.showmonitor == 1):
120  try:
121  logger.info("start to collect the plots of the millePedeMonitor_merge.root file")
122  monitorPlot.plot(config)
123  except Exception as e:
124  logging.error("millePedeMonitor_merge.root failure - {0} {1}".format(type(e), e))
125  raise
126 
127  ##########################################################################
128  # parse the alignment_merge.py file
129  #
130 
131  if (config.showadditional == 1):
132  logger.info("start to parse the alignment_merge.py file")
133  try:
134  additionalData = additionalparser.AdditionalData()
135  additionalData.parse(
136  config, os.path.join(config.jobDataPath, "alignment_merge.py"))
137  except Exception as e:
138  logging.error("alignment_merge.py parser failure - {0} {1}".format(type(e), e))
139  raise
140 
141  ##########################################################################
142  # parse the file pede.dump.gz and return a PedeDumpData Object
143  #
144 
145  if (config.showdump == 1):
146  try:
147  logger.info("start to parse the pede.dump.gz file")
148  pedeDump = dumpparser.parse(
149  os.path.join(config.jobDataPath, "pede.dump.gz"), config)
150  except Exception as e:
151  logging.error("pede.dump.gz parser failure - {0} {1}".format(type(e), e))
152  raise
153 
154  ##########################################################################
155  # time dependend big structures
156  #
157 
158  if (config.showtime == 1):
159  try:
160  logger.info("create the time dependent plots")
161  timeStructure.plot(treeFile, alignables, config)
162  except Exception as e:
163  logging.error("time dependent plots failure - {0} {1}".format(type(e), e))
164  raise
165 
166  ##########################################################################
167  # big structures
168  #
169 
170  if (config.showhighlevel == 1):
171  try:
172  logger.info("create the high level plots")
173  bigStructure.plot(MillePedeUser, alignables, config)
174  except Exception as e:
175  logging.error("high level plots failure - {0} {1}".format(type(e), e))
176  raise
177 
178  ##########################################################################
179  # modules of a hole structure
180  # and part of structure
181  #
182 
183  if (config.showmodule == 1):
184  try:
185  logger.info("create the module plots")
186  bigModule.plot(MillePedeUser, alignables, config)
187  except Exception as e:
188  logging.error("module plots failure - {0} {1}".format(type(e), e))
189  raise
190 
191  ##########################################################################
192  # create TEX, beamer
193  #
194 
195  if (config.showtex == 1):
196  try:
197  logger.info("create the latex file")
198  pdfCreator.create(alignables, pedeDump,
199  additionalData, config.latexfile, config)
200  except Exception as e:
201  logging.error("latex creation failure - {0} {1}".format(type(e), e))
202  raise
203 
204  if (config.showbeamer == 1):
205  try:
206  logger.info("create the latex beamer file")
207  beamerCreator.create(alignables, pedeDump, additionalData, "beamer.tex", config)
208  except Exception as e:
209  logging.error("beamer latex failure - {0} {1}".format(type(e), e))
210  raise
211 
212  # delete latex temporary files
213  for extension in ["aux", "log", "nav", "out", "snm", "toc"]:
214  extension = "*." + extension
215  pattern = os.path.join(config.outputPath, extension)
216  logger.info("Remove temporary latex files: "+pattern)
217  map(os.remove, glob.glob(pattern))
218 
219  if (config.showhtml == 1):
220  try:
221  logger.info("create the HTML file")
222  htmlCreator.create(alignables, pedeDump, additionalData, "html_file.html", config)
223  except Exception as e:
224  logging.error("HTML creation failure - {0} {1}".format(type(e), e))
225  raise
std::vector< Alignable * > Alignables
Definition: Alignable.h:251
def setgstyle
set gstyle by https://github.com/mschrode/AwesomePlots/blob/master/Style.cc
Definition: style.py:50
def plot
Definition: bigModule.py:19
def create
Definition: pdfCreator.py:22
if(dp >Float(M_PI)) dp-