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 20 of file monitorPlot.py.

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

References createfilelist.int.

Variable Documentation

◆ IgnoreCommandLineOptions

monitorPlot.IgnoreCommandLineOptions

Definition at line 13 of file monitorPlot.py.

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