欧洲核子研究中心(CERN)成立于 1954 年 9 月 29 日,总部位于瑞士日内瓦的法瑞边境上,欧洲核子研究中心拥有世界上最大的粒子物理学实验室,也是万维网的发源地。CERN 现在已经聘用大约三千名的全职员工。并有来自 80 个国籍的大约 6500 位科学家和工程师,代表 500 余所大学机构,在 CERN 进行试验。这大约占了世界上的粒子物理学圈子的一半。

由 CERN 开发的科学分析 PB级数据的强大工具 ROOT 已经成为最著名的开源数据分析框架之一,支持 C语言与 python语言,用户可通过ROOT官网和查阅手册来学习使用方法。

CERN LOGO

CERN LOGO

ROOT LOGO

ROOT LOGO

安装和使用

ROOT 支持全平台,Mac 上安装 ROOT 使用 homebrew,其他操作系统安装方式参考官方说明

ROOT 有命令行模式、脚本模式、图形界面模式

经常使用图形界面会使用户很快遗忘各种类和成员函数的名称和使用方法,这在使用脚本模式处理大量数据时是非常不利的。

基本命令

安装 ROOT 后,在终端中输入root打开,并用.q命令退出:

[zhangzh@node01 ~]$ root
 ------------------------------------------------------------------
| Welcome to ROOT 6.22/02                        <https://root.cern> |
| (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Aug 17 2020, 12:46:52                 |
| From tags/v6-22-02@v6-22-02                                      |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
 ------------------------------------------------------------------
root [0] .q
[zhangzh@node01 ~]$

ROOT 元命令都以.开头:

.L <文件名>                // 加载给定的文件或库
.(x|X) <文件名>[args]      // 与 .L 相同并运行带有参数的函数
.U <文件名>                // 卸载给定的文件
.I [path]                 // 显示包含路径
.help                     // 显示此信息
.q                        // 退出程序
.pwd                      // 显示当前目录、pad 和样式
.ls                       // 列出当前目录的内容
.which [file]             // 显示宏文件的路径
.help Class               // 打开该类的参考指南
.help Class::Member       // 打开函数/成员的参考指南

ROOT 也和其他 Linux 命令一样有参数可选,如:

[zhangzh@node01 ~]$ root -l -q filename
waiting...[zhangzh@node01 latitude]$ root --helpusage: root [-b B] [-x X] [-e E] [-n N] [-t T] [-q Q] [-l L] [-a A] [-config CONFIG] [-memstat MEMSTAT]
            [-h HELP] [--version VERSION] [--notebook NOTEBOOK] [--web WEB] [--web=<browser> WEB=<BROWSER>]
            [dir] [file:data.root] [file1.C...fileN.C]OPTIONS:  -b                             Run in batch mode without graphics
  -x                             Exit on exceptions
  -e                             Execute the command passed between single quotes
  -n                             Do not execute logon and logoff macros as specified in .rootrc
  -t                             Enable thread-safety and implicit multi-threading (IMT)  -q                             Exit after processing command line macro files
  -l                             Do not show the ROOT banner
  -a                             Show the ROOT splash screen
  -config                        print ./configure options
  -memstat                       run with memory usage monitoring
  -h, -?, --help                 Show summary of options
  --version                      Show the ROOT version
  --notebook                     Execute ROOT notebook
  --web                          Display graphics in a default web browser
  --web=<browser>                Display graphics in specified web browser
  [dir]                          if dir is a valid directory cd to it before executing
  [file:data.root]               Open the ROOT file data.root
  [file1.C...fileN.C]            Execute the the ROOT macro file1.C ... fileN.C

终端中输入root filename打开 root 格式文件或脚本/宏,并于 ROOT 中查看或运行。ROOT 中同样可以使用系统命令,命令前添加.!。E.g.

[zhangzh@node01 orbitAnisotropyLatitude]$ rl
root [0] .!pwd
/home/users/z/zhangzh/grb/orbitAnisotropyLatituderoot [1] .!ls
addFileAndReadMC.c         hpatimer_moon_sun_radec_1.cc   Moon.c
addFileAndReadTimesSr550.c     hpatimer_moon_sun_radec_1.exe      myMacro.log
root [2] .!ls -l总用量 459072292
-rw-r--r-- 1 zhangzh ybj        1159 4月   8 10:10 addFileAndReadMC.c
-rw-r--r-- 1 zhangzh ybj        4736 4月   7 00:56 addFileAndReadTimesSr550.c
-rw-r--r-- 1 zhangzh ybj        2528 3月  19 22:14 hpatimer_moon_sun_radec_1.cc
-rwxr-xr-x 1 zhangzh ybj       66744 3月  19 22:17 hpatimer_moon_sun_radec_1.exe
-rw-r--r-- 1 zhangzh ybj        9051 3月  19 22:10 Moon.c
-rw-r--r-- 1 zhangzh ybj         111 3月  27 22:04 myMacro.log
root [3]

多命令行