Skip to content

Commit 910a228

Browse files
committed
small fixes & docu
1 parent c926167 commit 910a228

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

README.md

+25-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Python version 3 is required (tested on 3.9).
88
from fast import *
99
h = get(_file0, "histoX")
1010
h = get(_file0, "histoY")
11-
cnv() # a canvas (can be skipped)
11+
cnv() # a canvas
1212
frame((10, 0, 10), (10, 0, 100)) # define axes ranges (not needed if histograms have reasonable ranges already), but often convenient to use
1313
axis("size [mm]", "count") # label axes (not needed if original histograms have reasonably named axes)
1414
@@ -50,7 +50,7 @@ In addition they key can be supplemented by move/resize directives that are:
5050
* `n` to make object narrower and
5151
* `s` shorter
5252
* `t` taller.
53-
Capital move directives move by 3 quants, i..e LU is the same as llluuu.
53+
Capital move directives move by 3 quants, i.e. LU is the same as llluuu.
5454
# piroot
5555
Is a wrapper of python + ROOT that allows to execute following comamnds:
5656
```
@@ -103,6 +103,29 @@ Some more examples of how to automate plots making can be found in scripts/examp
103103
*Beware, that there is very limited checks of command line options.*
104104
That is, it will not catch typos for you!
105105

106+
# Included scripts
107+
There is couple of "small" scripts included that are ready to be used for making quite a diverse set of plots. First of all `draw.py` can be used to draw same histogram from multiple files, multiple hitograms from one file and nearly all settings of the plot can be customised from command line. See the source code for all the options.
108+
109+
A simpler version, `simple.py` just good for signle histogram an only af few customizations available through command line.
110+
111+
A useful script called `content.py` can be used to list content of the ROOT file like this:
112+
``sh
113+
piroot -q file.root content.py
114+
``
115+
116+
For interactive exploration of the ROOT file with python the `browse.py` script is provided. It repackages ROOT file as full fledged python object. An example of interactive discovery of histogram and plotting is shown below.
117+
``sh
118+
piroot basic_checks.root browse.py
119+
...starting python
120+
- - - - - - - - - - - - - - - - - - - - welcome to piROOT - opening files - - - - - - - - - - - - - - - - - - - -
121+
.opening basic_checks.root
122+
. indexing file content (every / is dir, every * is object )
123+
///../../../../../.......................................................................................... done
124+
. this is interactive browser of the ROOT file
125+
. to browse file with tab completion start with typing: ro. and hit <TAB>
126+
ro.<TAB> << try this
127+
ro.basic_checks.NChR.Draw("hpe")
128+
``
106129

107130

108131

fast/fast.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def _followSubPads(pad, currentdir):
477477
_savePrimitive( obj )
478478

479479

480-
def _save(cnv, name, dumpROOT=False, base ="plots"):
480+
def _save(cnv, name, dumpROOT=False):
481481
anyformat=False
482482
if name.endswith(".pdf"):
483483
anyformat=True
@@ -514,19 +514,21 @@ def _saveToDir( cnv, dirn, name, dumpROOT=False):
514514
ROOT.gSystem.ChangeDirectory(dirn)
515515
# print(".. changed to directory "+dirn)
516516

517-
_save(cnv, name, dumpROOT, "")
517+
_save(cnv, name, dumpROOT)
518518
ROOT.gSystem.ChangeDirectory(startdir)
519519

520520

521-
522521
def save(name, dumpROOT=False):
523522
"""Save the content of current canvas as PDF in plots/ subdir, if dumpROOT is enabled additional ROOT file with all the conntent is made"""
524523
global _cnvs
525524
global _legend
526525
global _legendpos
527526
ROOT.gStyle.SetOptTitle(0)
528527
_cnvs[-1].Update()
529-
_saveToDir(_cnvs[-1], "plots", name, dumpROOT=dumpROOT)
528+
import os
529+
plotsdir = os.environ.get("QPLOTDIR", "plots")
530+
531+
_saveToDir(_cnvs[-1], plotsdir, name, dumpROOT=dumpROOT)
530532

531533
def s(name):
532534
"""A abbreviated save"""
@@ -553,8 +555,8 @@ def _putlabelABS(locx, locy, text, sz=0.1):
553555
locx = 1 + locx
554556
if locy < 0:
555557
locy = 1 + locy
556-
l = ROOT.TLatex(); #l.SetTextAlign(12);
557-
l.SetTextSize(sz);
558+
l = ROOT.TLatex() #l.SetTextAlign(12);
559+
l.SetTextSize(sz)
558560
l.SetNDC()
559561
l.SetTextFont(42)
560562
l.SetTextColor(ROOT.kBlack)

fast/myop.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def run_args(self):
3333

3434
def save(self, filename):
3535
""" Save options for reuse """
36-
fullfname="plots/"+filename+".sh"
36+
import os
37+
fullfname=os.environ.get("QPLOTDIR", "plots")+"/"+filename+".sh"
3738

3839
with open(fullfname, "w") as f:
3940
f.write('piroot ')

0 commit comments

Comments
 (0)