Opened 15 years ago
Closed 15 years ago
#48 closed task (fixed)
ASCII format for histogram (aim: ROOT/gnuplot analysis)
Reported by: | Juergen Reuter | Owned by: | Christian Speckner |
---|---|---|---|
Priority: | P3 | Milestone: | v2.0.3 |
Component: | interfaces | Version: | |
Severity: | normal | Keywords: | ROOT interface |
Cc: | daniel.wiesler@… |
Description
Add an interface for ROOT/DELPHES.
Change History (6)
comment:1 Changed 15 years ago by
Milestone: | v2.0.0final → golden-classics |
---|
comment:2 Changed 15 years ago by
Milestone: | golden-classics → v2.0.2 |
---|---|
Owner: | changed from jr_reuter, wiesler to Christian Speckner |
Summary: | Interface for ROOT/DELPHES → ASCII format for histogram (aim: ROOT/gnuplot analysis) |
comment:3 Changed 15 years ago by
Milestone: | v2.0.2 → v2.0.3 |
---|---|
Status: | new → assigned |
As this is probably a bit too big and involved to hasten and merge it into 2.0.2, I've moved my changes to a branch speckner/histograms and rescheduled this ticket to 2.0.3.
What I am doing is implementing a new command
write_analysis_data format ([id, id, ...]) [{ options }]
which writes the plots / histograms identified by id, id, ...
(or all of them if no specification is present) into datafiles. Available formats are csv
(x, y, yerr, xerr as comma separated values), ascii
(the same separated by blanks) and custom
. In custom
mode, the command iterates over all histogram / plot entries like a loop, calling the contents of two special variables histogram_writer
or plot_writer
with local variables communicating the information on the bins / plot points. These user-defined macros can use a new command write
for line-oriented output to the datafile.
Independent of the format, a header is written which includes plot labels and such. This behavior can be changed by the user through redefining the comment prefix (a "#" by default) or by switching of headers altogether.
I think this is flexible enough to accommodate a large variety of crazy output formats and even allows for some postprocessing. Of course, I am still taking suggestions or criticism ;)
comment:4 Changed 15 years ago by
As of r2530, CSV and ASCII work - now plots can be created via gnuplot (or openoffice if somebody wants it - yuk) :) As an example, the following script generates a sinus curve in a file six.dat
plot sinx (0, 360) scan real xv = (0 => 360 /+ 1) { record sinx (xv, sin (xv * 1 degree)) } write_analysis_data ascii ()
The empty braces cause all defined histograms and plots to be written to files - instead, an explicit list of all desired objects could have been passed. There are three variables which influence write_analysis_data
?write_header
: Write the header comment (on by default)$comment_prefix
: Comment symbol (default: "#")$datafile
: The behavior of this depends: if a single tag has been given, this is the name of the datafile; otherwise, it defines the suffix, the generated filenames(s) being thentag // suffix
. If$datafile
is unset or blank, the names are autogenerated with the suffix ".dat" in all cases.
comment:5 Changed 15 years ago by
Done in the branch in r2536. If I don't find any more bugs, I'll merge it after the 2.0.2 has been branched off. Instead of tedious explanations, here's a small example for the custom
format which uses all local variables accessible in histogram_writer
and plot_writer
:
model = SM process eeww = "e+", "e-" => "W+", "W-" compile sqrts = 200 GeV integrate (eeww) histogram his1 (-1, 1, 0.1) histogram his2 (0, 360 degree, 18 degree) plot plot1 (0, 360 degree) scan real xval = (0 => 360 degree /+ 18 degree) { record plot1 (xval, sin(xval)) } analysis = record his1 (eval cos (Theta) ["W+"]); record his2 (eval Theta ["W+"]) n_events = 10000 simulate (eeww) write_analysis_data custom () { $datafile = ".verbose.dat" histogram_writer = { if (bin_index == 1) then write $("start histogram dump") endif write $("") write sprintf "bin index: %i of %i" (bin_index, bins_total) write sprintf "bin width: %e" (bin_width) write sprintf "bin sum: %e +- %e" (bin_sum, bin_error) write sprintf "bin excess: %e" (bin_excess) if (bin_index == bins_total) then write $("") write $("end histogram dump") endif } plot_writer = { if (plot_index == 1) then write $("start plot dump") write $("") endif write sprintf "plot point %i: ( %e +- %e / %e +- %e )" (plot_index, plot_x, plot_xerr, plot_y, plot_yerr) if (plot_index == plot_points_total) then write $("") write $("end plot dump") endif } }
The macros are executed inside a private scope which inherits from the write_analysis_data
option scope and which is wiped between different analysis objects, so local variables should allow for fancy postprocessing (e.g. "rendering" histograms stroke-by-stroke) once #323 is improved :)
For DELPHES the ticket is void, as the only reasonable input for DELPHES are HepMC or LHEF or StdHEP files. For ROOT, the only option to be implemented will be an ASCII format for tables and histograms which is more independent from the GAMELN structure.