收藏 分享(赏)

ROOT数据分析处理软件.pdf

上传人:精品资料 文档编号:10938190 上传时间:2020-01-22 格式:PDF 页数:55 大小:3.05MB
下载 相关 举报
ROOT数据分析处理软件.pdf_第1页
第1页 / 共55页
ROOT数据分析处理软件.pdf_第2页
第2页 / 共55页
ROOT数据分析处理软件.pdf_第3页
第3页 / 共55页
ROOT数据分析处理软件.pdf_第4页
第4页 / 共55页
ROOT数据分析处理软件.pdf_第5页
第5页 / 共55页
点击查看更多>>
资源描述

1、ContentsA ROOT Guide For Beginners 31 Motivation and Introduction 51.1 Welcome to ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 ROOT Basics 92.1 ROOT as calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2、. . . . . . 92.2 ROOT as Function Plotter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.3 Controlling ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.4 Plotting Measurements . . . . . . . . . . . . . . .

3、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.5 Histograms in ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.6 Interactive ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.7

4、 ROOT Beginners FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.7.1 ROOT type declarations for basic data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.7.2 Configure ROOT at start-up . . . . . . . . . . . . . . . . . . . . . . . . .

5、 . . . . . . . . . . . . 162.7.3 ROOT command history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.7.4 ROOT Global Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 ROOT Macros 193.1 General Remarks on ROOT macros . . .

6、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.2 A more complete example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.3 Summary of Visual effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7、. 223.3.1 Colours and Graph Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.3.2 Arrows and Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.3.3 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

8、. . . . . . . . . . . . . . . . . . . . 233.4 Interpretation and Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.4.1 Compile a Macro with ACLiC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.4.2 Compile a Macro with the C

9、ompiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Graphs 254.1 Read Graph Points from File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.2 Polar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10、. . . . . . . . . . 274.3 2D Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2712 CONTENTS5 Histograms 315.1 Your First Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315.2 Add and Divid

11、e Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.3 Two-dimensional Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Functions and Parameter Estimation 396.1 Fitting Functions to Pseudo Data . . . . .

12、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396.2 Toy Monte Carlo Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 File I/O and Parallel Analysis 457.1 Storing ROOT Objects . . . . . . . . . . . . . . . . . . . . . . . . . . .

13、. . . . . . . . . . . . . . . . . . 457.2 N-tuples in ROOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467.2.1 Storing simple N-tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467.2.2 Reading N-tuples . . . . .

14、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477.2.3 Storing Arbitrary N-tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487.2.4 Processing N-tuples Spanning over Several Files . . . . . . . . . . . . . . . . . . . . . . . . . . 497

15、.2.5 For the advanced user: Processing trees with a selector script . . . . . . . . . . . . . . . . . . . 497.2.6 For power-users: Multi-core processing with PROOF lite . . . . . . . . . . . . . . . . . . . . . 537.2.7 Optimisation Regarding N-tuples . . . . . . . . . . . . . . . . . . . . . . . . .

16、 . . . . . . . . . . 547.3 Concluding Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548 References 55A ROOT Guide For Beginners“Diving Into ROOT”Abstact:ROOT is a software framework for data analysis, a powerful tool to cope with the demanding ta

17、sks typical of stateof the art scientific data analysis. Among its prominent features are an advanced graphical user interface, ideal forinteractive analysis, an interpreter for the C+ programming language, for rapid and efficient prototyping and apersistency mechanism for C+ objects, used also to w

18、rite every year petabytes of data recorded by the Large HadronCollider experiments. This introductory guide illustrates the main features of ROOT, relevant for the typical problemsof data analysis: input and plotting of data from measurements and fitting of analytical functions.34 CONTENTSChapter 1M

19、otivation and IntroductionWelcome to data analysis!1Comparison of measurements to theoretical models is one of the standard tasks in experimental physics. In the mostsimple case, a “model” is just a function providing predictions of measured data. Very often, the model depends onparameters. Such a m

20、odel may simply state “the current I is proportional to the voltage U”, and the task of theexperimentalist consists of determining the resistance, R, from a set of measurements.As a first step, a visualisation of the data is needed. Next, some manipulations typically have to be applied,e.g. correcti

21、ons or parameter transformations. Quite often, these manipulations are complex ones, and a powerfullibrary of mathematical functions and procedures should be provided - think for example of an integral or peak-searchor a Fourier transformation applied to an input spectrum to obtain the actual measur

22、ement described by the model.One specialty of experimental physics are the inevitable errors affecting each measurement, and visualisation tools haveto include these. In subsequent analysis, the statistical nature of the errors must be handled properly.As the last step, measurements are compared to

23、models, and free model parameters need to be determined in thisprocess. See Figure 1.1 for an example of a function (model) fit to data points. Several standard methods are available,and a data analysis tool should provide easy access to more than one of them. Means to quantify the level of agreemen

24、tbetween measurements and model must also be available.Quite often, the data volume to be analyzed is large - think of fine-granular measurements accumulated with the aid ofcomputers. A usable tool therefore must contain easy-to-use and efficient methods for data handling.In Quantum mechanics, model

25、s typically only predict the probability density function (“pdf”) of measurementsdepending on a number of parameters, and the aim of the experimental analysis is to extract the parameters from theobserved distribution of frequencies at which certain values of the measurement are observed. Measuremen

26、ts of thiskind require means to generate and visualize frequency distributions, so-called histograms, and stringent statisticaltreatment to extract the model parameters from purely statistical distributions.Simulation of expected data is another important aspect in data analysis. By repeated generat

27、ion of “pseudo-data”,which are analysed in the same manner as intended for the real data, analysis procedures can be validated or compared.In many cases, the distribution of the measurement errors is not precisely known, and simulation offers the possibilityto test the effects of different assumptio

28、ns.1.1 Welcome to ROOTA powerful software framework addressing all of the above requirements is ROOT (Brun, Ren and Rademakers, Fons1997), an open source project coordinated by the European Organisation for Nuclear Research, CERN in Geneva.ROOT is very flexible and provides both a programming interf

29、ace to use in own applications and a graphical userinterface for interactive data analysis. The purpose of this document is to serve as a beginners guide and providesextendable examples for your own use cases, based on typical problems addressed in student labs. This guide willhopefully lay the grou

30、nd for more complex applications in your future scientific work building on a modern, state-ofthe art tool for data analysis.This guide in form of a tutorial is intended to introduce you to the ROOT package in about 30 pages. This goal willbe accomplished using concrete examples, according to the “l

31、earning by doing” principle. Also because of this reason,this guide cannot cover the complexity of the ROOT package. Nevertheless, once you feel confident with the concepts1This guide was prepared for the ROOT IRMM Tutorial adapting “A ROOT Guide for Students” http:/www-ekp.physik.uni-karlsruhe.de/q

32、uast, a document by D. Piparo, G. Quast and M. Zeise.56 CHAPTER 1. MOTIVATION AND INTRODUCTIONFigure 1.1: Measured data points with error bars and fitted quadratic function.1.1. WELCOME TO ROOT 7presented in the following chapters, you will be able to appreciate the ROOT Users Guide (The ROOT Team 2

33、013a)and navigate through the Class Reference (The ROOT Team 2013b) to find all the details you might be interested in.You can even look at the code itself, since ROOT is a free, open-source product. Use these documents in parallel tothis tutorial!The ROOT Data Analysis Framework itself is written i

34、n and heavily relys on the programming language C+, andtherefore some knowledge about C and C+ is required. Eventually, just profit from the immense available literatureabout C+ if you do not have any idea of what object oriented programming could be.ROOT is available for many platforms (Linux, Mac

35、OS X, Windows.), but in this guide we will implicitly assumethat you are using Linux. The first thing you need to do with ROOT is install it, dont you? Obtaining the latestROOT version is straightforward. Just seek the “Pro” version on this webpage http:/root.cern.ch/drupal/content/downloading-root.

36、 You will find precompiled versions for the different architectures, or the ROOT source code tocompile yourself. Just pick up the flavour you need and follow the installation instructions.Lets dive into ROOT!8 CHAPTER 1. MOTIVATION AND INTRODUCTIONChapter 2ROOT BasicsNow that you have installed ROOT

37、, whats this interactive shell thing youre running ? Its like this: ROOT leadsa double life. It has an interpreter for macros (Cint (Goto 2005) that you can run from the command line or runlike applications. But it is also an interactive shell that can evaluate arbitrary statements and expressions.

38、This isextremely useful for debugging, quick hacking and testing. Let us first have a look at some very simple examples.2.1 ROOT as calculatorYou can even use the ROOT interactive shell in lieu of a calculator! Launch the ROOT interactive shell with thecommand rooton your Linux box. The prompt shoul

39、d appear shortly:root 1and lets dive in with the steps shown here:root 0 1+1(const int)2root 1 2*(4+2)/12.(const double)1.00000000000000000e+00root 2 sqrt(3)(const double)1.73205080756887719e+00root 3 1 2(const int)0root 4 TMath:Pi()(Double_t)3.14159265358979312e+00root 5 TMath:Erf(.2)(Double_t)2.22

40、702589210478447e-01Not bad. You can see that ROOT offers you the possibility not only to type in C+ statements, but also advancedmathematical functions, which live in the TMath namespace.Now lets do something more elaborated. A numerical example with the well known geometrical series:root 6 double x

41、=.5root 7 int N=30root 8 double geom_series=0root 9 for (int i=0;iDraw();f1 is a pointer to an instance of a TF1 class, the arguments are used in the constructor; the first one of type string isa name to be entered in the internal ROOT memory management system, the second string type parameter defin

42、esthe function, here sin(x)/x, and the two parameters of type double define the range of the variable x. The Draw()method, here without any parameters, displays the function in a window which should pop up after you typed theabove two lines. Note again differences between Cint and C+: you could have

43、 omitted the “;” at the end of lines, Cintwoud also have accepted the “.” to access the method Draw(). However, it is best to stick to standard C+ syntax andavoid Cint-specific code, as will become clear in a moment.A slightly extended version of this example is the definition of a function with par

44、ameters, called 0, 1 and so on inthe ROOT formula syntax. We now need a way to assign values to these parameters; this is achieved with the methodSetParameter(,) of class TF1. Here is an example:root 13 TF1 *f1 = new TF1(“f2“,“0*sin(1*x)/x“,0.,10.);root 14 f1-SetParameter(0,1);root 15 f1-SetParamete

45、r(1,1);root 16 f1-Draw();Of course, this version shows the same results as the initial one. Try playing with the parameters and plot the functionagain. The class TF1 has a large number of very useful methods, including integration and differentiation. To makefull use of this and other ROOT classes,

46、visit the documentation on the Internet under http:/root.cern.ch/drupal/content/reference-guide. Formulae in ROOT are evaluated using the class TFormula, so also look up the relevant classdocumentation for examples, implemented functions and syntax.You should definitely download this guide to your o

47、wn system to have it at you disposal whenever you need it.To extend a little bit on the above example, consider a more complex function you would like to define. You can alsodo this using standard C or C+ code. In many cases this is the only practical way, as the ROOT formula interpreterhas clear li

48、mitations concerning complexity and speed of evaluation.Consider the example below, which calculates and displays the interference pattern produced by light falling on amultiple slit. Please do not type in the example below at the ROOT command line, there is a much simpler way: Makesure you have the

49、 file slits.C on disk, and type root slits.C in the shell. This will start root and make it read the“macro” slits.C, i.e. all the lines in the file will be executed one after the other.1 / Example drawing the interference pattern of light2 / falling on a grid with n slits and ratio r of slit3 / width over distance between slits.45 / function code in C6 double single(double *x, double *par) 7 double const pi=4*atan(1.);8 return pow(sin(pi*par0*x0)/(pi*par0*x0),2);9 1011 double nslit0(double *x,double *par)12 double co

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报