CMS 3D CMS Logo

Functions | Variables
monitorPlot Namespace Reference

Functions

def plot (config)
 

Variables

 IgnoreCommandLineOptions
 

Function Documentation

◆ plot()

def monitorPlot.plot (   config)

Definition at line 17 of file monitorPlot.py.

17 def plot(config):
18  logger = logging.getLogger("mpsvalidate")
19 
20  # adjust the plot style
21  # show the skewness in the legend
22  ROOT.gStyle.SetOptStat("emrs")
23  ROOT.gStyle.SetPadLeftMargin(0.07)
24 
25  # retrieve the weights of the different datasets
26  with open(os.path.join(config.jobDataPath, ".weights.pkl"), "rb") as f:
27  weight_conf = cPickle.load(f)
28 
29  # loop over all millepedemonitor_X.root files
30  for filename in os.listdir("{0}".format(config.jobDataPath)):
31  if (filename.endswith(".root") and filename.startswith("millepedemonitor_")):
32  # get X out of millepedemonitor_X.root files
33  inputname = os.path.splitext(filename.split("millepedemonitor_")[-1])[0]
34 
35  # open file
36  rootfile = ROOT.TFile(os.path.join(config.jobDataPath, filename))
37 
38  plotPaths = ["usedTrackHists/usedptTrack", "usedTrackHists/usedetaTrack",
39  "usedTrackHists/usedphiTrack", "usedTrackHists/usednHitTrack"]
40 
41  # loop over plots which should be plotted
42  for plotNumber, plotPath in enumerate(plotPaths):
43  # get plotname
44  plotName = plotPath.split("/")[1]
45  # get plot
46  plot = rootfile.Get(plotPath)
47 
48  if (plotNumber == 0):
49  # get number of used tracks
50  ntracks = int(plot.GetEntries())
51  weight = [item[1]
52  for item in weight_conf
53  if item[0] == inputname][0]
54  mpsv_classes.MonitorData(inputname.replace("_", " "), ntracks, weight)
55 
56  # create canvas
57  canvas = ROOT.TCanvas("canvas{0}_{1}".format(
58  inputname, plotName), "Monitor", 300, 0, 800, 600)
59  canvas.cd()
60 
61  # set statistics size
62  mpsv_style.setstatsize(canvas, plot, config)
63 
64  # draw
65  plot.Draw()
66 
67  # save as pdf
68  canvas.Print(
69  "{0}/plots/pdf/monitor_{1}_{2}.pdf".format(config.outputPath, inputname.replace(".","_"), plotName))
70 
71  # export as png
72  image = ROOT.TImage.Create()
73  image.FromPad(canvas)
74  image.WriteImage(
75  "{0}/plots/png/monitor_{1}_{2}.png".format(config.outputPath, inputname.replace(".","_"), plotName))
76 
77  # add to output list
78  output = mpsv_classes.OutputData(plottype="monitor", name=inputname.replace("_", " "), number=plotName, filename="monitor_{1}_{2}".format(
79  config.outputPath, inputname.replace(".","_"), plotName))
80  config.outputList.append(output)
81 
82  # reset the plot style
83  ROOT.gStyle.SetOptStat(0)
84  ROOT.gStyle.SetPadLeftMargin(0.17)

References createfilelist.int.

Variable Documentation

◆ IgnoreCommandLineOptions

monitorPlot.IgnoreCommandLineOptions

Definition at line 10 of file monitorPlot.py.

createfilelist.int
int
Definition: createfilelist.py:10
monitorPlot.plot
def plot(config)
Definition: monitorPlot.py:17
format