Root documentation pdf
All objects will be drawn in that pad because it is the active one. The ways for changing the active pad are:. Pads are numbered from left to right and from top to bottom. To apply the method cd to the third pad, you would write:. Please note that saving the canvas this way will overwrite the file with the same name without a warning. The user choice is saved for the next time the Save As… dialog shows up. The Print command in the canvas File menu pops-up a print dialog where the user can specify a preferred print command and the printer name.
Both print parameters can be set via the new Print. Command and Print. Printer rootrc resources as follows:. All other parameters will be kept as they are written. You can use the command line to execute multi-line commands. It is more convenient to edit a script than the command line, and if your multi line commands are getting unmanageable, you may want to start with a script instead. The Cling interpreter has several extensions. The interpreter knows all the classes, functions, variables, and user defined types.
This enables ROOT to help users to complete the command line. Its special treatment allows the easy matching of pathnames. The class TRegexp can be used to create a regular expression from an input string. If wildcard is true then the input string contains a wildcard expression. The method finds the first occurrence of the regular expression in the string and returns its position. From the first days of ROOT development, it was decided to use a set of coding conventions.
This allows a consistency throughout the source code. Learning these will help you identify what type of information you are dealing with and enable you to understand the code better and quicker. Of course, you can use whatever convention you want but if you are going to submit some code for inclusion into the ROOT sources, you will need to use these. Constants begin with k : kInitialSize , kRed.
Global variables begin with g : gEnv. Different machines may have different lengths for the same type. The most famous example is the int type. It may be 16 bits on some old machines and 32 bits on some newer ones. To ensure the size of your variables, use these pre defined types in ROOT:. This kind of architecture is also used in the Java language. The main advantage of this approach is that it enforces the common behavior of the derived classes and consequently it ensures the consistency of the whole system.
ROOT has a set of global variables that apply to the session. For example, gDirectory always holds the current directory, and gStyle holds the current style. These methods return a TSeqCollection , meaning a collection of objects, and they can be used to do list operations such as finding an object, or traversing the list and calling a method for each of the members. See the TCollection class description for the full set of methods supported for a collection.
For example, to find a canvas called c1 you can do :. A graphic object is always drawn on the active pad. It is convenient to access the active pad, no matter what it is. For that, we have gPad that is always pointing to the active pad. For example, if you want to change the fill color of the active pad to blue, but you do not know its name, you can use gPad.
This generator is very fast and has very good random proprieties a very long period of 10 Any other value will be used as a constant. The following basic random distributions are provided: Rndm or Uniform min,max , Gaus mean,sigma , Exp tau , BreitWigner mean,sigma , Landau mean,sigma , Poisson mean , Binomial ntot,prob.
You can customize your ROOT session by replacing the random number generator. You can delete gRandom and recreate it with your own. TRandom2 is another generator, which is also very fast and uses only three words for its state. This variable is set by reading the contents of a. See Environment Setup below for more information. The behavior of a ROOT session can be tailored with the options in the. At start-up, ROOT looks for a. If more than one. While in a session, to see current settings, you can do:.
For example, if the flag to use true type fonts is set to true in the system. Removing the UseTTFonts statement in the local. ROOT looks for scripts in the path specified in the. Path variable. You can expand this path to hold your own directories.
The rootlogon. C and rootlogoff. C files are scripts loaded and executed at start-up and shutdown. The rootalias. C file is loaded but not executed. It typically contains small utility functions. For example, the rootalias. This allows the user to call the editor from the command line. You can use the up and down arrow at the command line, to access the previous and next command. It is a text file, and you can edit, cut, and paste from it. You can specify the history file in the system.
History option. You can also turn off the command logging in the system. History: -. The first value defines the maximum of lines kept; once it is reached all, the last HistSave lines will be removed. One can set HistSize to 0 to disable history line management. You can track memory usage and detect leaks by monitoring the number of objects that are created and deleted see TObjectTable. This line will print the list of all active classes and the number of instances for each class.
By comparing consecutive print outs, you can see objects that you forgot to delete. Note that this method cannot show leaks coming from the allocation of non-objects or classes unknown to ROOT. To use this program, you type the shell script command:.
If you do not specify the second parameter, a file name is automatically generated for you. If hbookfile is of the form file. Some HBOOK column-wise ntuples may not be fully converted if the columns are an array of fixed dimension e. In case of row-wise or column-wise ntuples, each column is converted to a branch of a tree. Once you have converted your file, you can look at it and draw histograms or process ntuples using the ROOT command line.
An example of session is shown below:. The chapter on trees explains how to read a tree. In case one of the ntuple columns has a variable length e. Draw "px" will histogram the px column for all tracks in the same histogram.
This chapter covers the functionality of the histogram classes. We begin with an overview of the histogram classes, after which we provide instructions and examples on the histogram features. We have put this chapter ahead of the graphics chapter so that you can begin working with histograms as soon as possible.
Some of the examples have graphics commands that may look unfamiliar to you. ROOT supports histograms up to three dimensions. Separate concrete classes are provided for one-dimensional, two-dimensional and three-dimensional classes. The histogram classes are split into further categories, depending on the set of possible bin values:. ROOT also supports profile histograms, which constitute an elegant replacement of two-dimensional histograms in many cases.
The inter-relation of two measured quantities X and Y can always be visualized with a two-dimensional histogram or scatter-plot. Profile histograms, on the other hand, are used to display the mean value of Y and its RMS for each bin in X.
If Y is an unknown but single-valued approximate function of X, it will have greater precision in a profile histogram than in a scatter plot. This means that two-dimensional and three-dimensional histograms are seen as a type of a one-dimensional histogram, in the same way in which multidimensional C arrays are just an abstraction of a one-dimensional contiguous block of memory.
There are several ways in which you can create a histogram object in ROOT. The straightforward method is to use one of the several constructors provided for each concrete class in the histogram hierarchy. Histograms may also be created by:. The histogram classes provide a variety of ways to construct a histogram, but the most common way is to provide the name and title of histogram and for each dimension: the number of bins, the minimum x lower edge of the first bin and the maximum x upper edge of the last bin.
When employing this constructor, you will create a histogram with constant fixed bin width on each axis. For the example above, the interval [0. If you want to create histograms with variable bin widths, ROOT provides another constructor suited for this purpose. Instead of passing the data interval and the number of bins, you have to pass an array single or double precision of bin edges.
Each histogram object contains three TAxis objects: fXaxis , fYaxis, and fZaxis , but for one-dimensional histograms only the X-axis is relevant, while for two-dimensional histograms the X-axis and Y-axis are relevant. See the class TAxis for a description of all the access methods. The bin edges are always stored internally in double precision. All histogram types support fixed or variable bin sizes. The functions to fill, manipulate, draw, or access histograms are identical in both cases. At any time, a histogram can be re-binned via the TH1 ::Rebin method.
It returns a new histogram with the re-binned contents. If bin errors were stored, they are recomputed during the re-binning. The Fill method computes the bin number corresponding to the given x, y or z argument and increments this bin by the given weight.
The Fill method returns the bin number for 1-D histograms or global bin number for 2-D and 3-D histograms. If TH1 ::Sumw2 has been called before filling, the sum of squares is also stored. By default, the number of bins is computed using the range of the axis.
You can change this to re-bin automatically by setting the automatic re-binning option:. Once this is set, the Fill method will automatically extend the axis range to accommodate the new value specified in the Fill argument. The used method is to double the bin size until the new value fits in the range, merging bins two by two.
The TTree ::Draw method extensively uses this automatic binning option when drawing histograms of variables in TTree with an unknown range. The automatic binning option is supported for 1-D, 2-D and 3-D histograms.
During filling, some statistics parameters are incremented to compute the mean value and root mean square with the maximum precision. TH1 ::FillRandom can be used to randomly fill a histogram using the contents of an existing TF1 function or another TH1 histogram for all dimensions.
For example, the following two statements create and fill a histogram 10 times with a default Gaussian distribution of mean 0 and sigma 1 :. TH1 ::GetRandom can be used to get a random number distributed according the contents of a histogram. To fill a histogram following the distribution in an existing histogram you can use the second signature of TH1 ::FillRandom.
Next code snipped assumes that h is an existing histogram TH1. The distribution contained in the histogram h1 TH1 is integrated over the channel contents. It is normalized to one. The second parameter indicates how many random numbers are generated. You can see below an example of the TH1 ::GetRandom method which can be used to get a random number distributed according the contents of a histogram.
The Add , Divide and Multiply methods also exist to add, divide or multiply a histogram by a function.
Histograms objects not pointers TH1F h1 can be multiplied by a constant using:. If a histogram has associated error bars TH1 ::Sumw2 has been called , the resulting error bars are also computed assuming independent histograms. In case of divisions, binomial errors are also supported. When you call the Draw method of a histogram TH1 ::Draw for the first time, it creates a THistPainter object and saves a pointer to painter as a data member of the histogram.
The THistPainter class specializes in the drawing of histograms. It allows logarithmic axes x, y, z when the CONT drawing option is using. The THistPainter class is separated from the histogram so that one can have histograms without the graphics overhead, for example in a batch program. When a displayed histogram is filled again, you do not have to call the Draw method again. The image is refreshed the next time the pad is updated.
A pad is updated after one of these three actions:. By default, the TH1 ::Draw clears the pad before drawing the new image of the histogram. You can use the "SAME" option to leave the previous display intact and superimpose the new histogram.
The same histogram can be drawn with different graphics options in different pads. When a displayed histogram is deleted, its image is automatically removed from the pad. To create a copy of the histogram when drawing it, you can use TH1 ::DrawClone. This will clone the histogram and allow you to change and delete the original one without affecting the clone.
You can use TH1 ::DrawNormalized to draw a normalized copy of a histogram. A clone of this histogram is normalized to norm and drawn with option.
A pointer to the normalized histogram is returned. The contents of the histogram copy are scaled such that the new sum of weights excluding under and overflow is equal to norm. Note that the returned normalized histogram is not added to the list of histograms in the current directory in memory.
The kCanDelete bit is set for the returned object. If a pad containing this copy is cleared, the histogram will be automatically deleted. Histograms use the current style gStyle , which is the global object of class TStyle. To change the current style for histograms, the TStyle class provides a multitude of methods ranging from setting the fill color to the axis tick marks. Here are a few examples:. When you change the current style and would like to propagate the change to a previously created histogram you can call TH1 ::UseCurrentStyle.
You will need to call UseCurrentStyle on each histogram. When reading many histograms from a file and you wish to update them to the current style, you can use gROOT ::ForceStyle and all histograms read after this call will be updated to use the current style.
When a histogram is automatically created as a result of a TTree ::Draw , the style of the histogram is inherited from the tree attributes and the current style is ignored. The tree attributes are the ones set in the current TStyle at the time the tree was created.
To visualize it without errors use HIST together with the required option e. By default, the histogram is drawn in low resolution in case the number of bins is greater than the number of pixels in the current pad.
Use it when superposing many histograms on the same picture. Most options can be concatenated without spaces or commas, for example, if h is a histogram pointer:. The options are not case sensitive. You can also set the default drawing option with TH1 ::SetOption. To see the current option use TH1 ::GetOption. By default, 2D histograms are drawn as scatter plots. For each cell i,j a number of points proportional to the cell content are drawn. A maximum of points per cell are drawn. If the maximum is above contents are normalized to The ARR option shows the gradient between adjacent cells.
For each cell i,j an arrow is drawn. The orientation of the arrow follows the cell gradient. For each cell i,j a box is drawn with surface proportional to contents. The size of the box is proportional to the absolute value of the cell contents. The cells with negative contents are drawn with an X on top of the boxes. A sunken button is drawn for negative values, a raised one for positive values.
Note that for all options, the line and fill attributes of the histogram are used for the errors or errors contours. The parameter dx is a percentage of bin width for errors along X. For each cell i,j a box is drawn with a color proportional to the cell content. The color table used is defined in the current style gStyle. The default number of contour levels is 20 equidistant levels. It can be changed with TH1 ::SetContour. For one given contour, more than one disjoint poly-line may be generated.
Here we show how to access the first graph in the list. The tutorial macro earth. C uses these four options and produces the following picture:. In a lego plot, the cell contents are drawn as 3D boxes, with the height of the box proportional to the cell content. A lego plot can be represented in several coordinate systems; the default system is Cartesian coordinates. With TStyle ::SetPalette the color palette can be changed.
We suggest you use palette 1 with the call:. In a surface plot, cell contents are represented as a mesh. The height of the mesh is proportional to the cell content. A surface plot can be represented in several coordinate systems. The following picture uses SURF1. If there is not enough space on the right side, you can increase the size of the right margin by calling TPad ::SetRightMargin.
The attributes used to display the palette axis values are taken from the Z axis of the object. For example, you can set the labels size on the palette axis with:. You can set the color palette with TStyle ::SetPalette , e.
For example, the option COL draws a 2-D histogram with cells represented by a box filled with a color index, which is a function of the cell content. If the cell content is N, the color index used will be the color number in colors61815.
If the maximum cell content is greater than ncolors , all cell contents are scaled to ncolors. This palette is recommended for pads, labels. It defines:. The color numbers specified in this palette can be viewed by selecting the menu entry Colors in the View menu of the canvas menu bar. A TPaletteAxis object is used to display the color palette when drawing 2D histograms. It is added to the histogram list of functions. It can be retrieved and its attributes can be changed with:.
The palette can be interactively moved and resized. The context menu can be used to set the axis attributes. For example, to draw the 2-D histogram h2 using all default attributes except the viewing angles, one can do:. Operators can be put in any order in the option and must be separated by a space " ".
No space characters should be put in an operator. All the available operators are described below. The following tables summarize all the possible combinations of both groups:. Next example sets line color to 2, line type to 1 and line width to 2. Note that if pa is not specified, the histogram line attributes are used:. Sometimes the displayed region is rather large.
When displaying all channels the pictures become very dense and complicated. It is very difficult to understand the overall shape of data. Only the channels coinciding with given nodes are displayed.
Allowed values are 0, 90, and degrees. Note that the X and Y axis are always linear. For sophisticated shading Light, Height and LightHeight Display Modes Groups the color palette starts from the basic pen color see pa function.
There is a predefined number of color levels Color in every level is calculated by adding the increments of the r , g , b components to the previous level. Using this function one can change the color increments between two neighboring color levels.
The function does not apply on the Simple Display Modes Group. The default values are: 1,1,1. When the level of a component reaches the limit value one can choose either smooth transition by decreasing the limit value or a sharp modulo transition continuing with 0 value. This allows various visual effects. One can choose from the following set of the algorithms:. This function does not apply on Simple display modes group. Default value is 0. In Light and LightHeight display modes groups the color palette is calculated according to the fictive light source position in 3-d space.
This function does not apply for Simple and Height display modes groups. Default is: lp ,, The surface picture is composed of triangles. The edges of the neighboring triangles can be smoothed shaded.
The shadow can be painted as well. The function does not apply on Simple display modes group. The possible values for shading are:. The function does not apply on other display modes groups and display modes. Default value is: b 0. This function applies only on for the Contours display mode. One can change the width between horizontal slices and thus their density. Default value: cw For LightHeight display modes group one can change the weight between both shading algorithms.
The function does not apply on other display modes groups. Default value is lhw 0. In addition to the surface drawn using any above given algorithm one can display channel marks. One can control the color as well as the width, height in pixels and the style of the marks. The possible styles are:. In addition to the surface drawn using any above given algorithm one can display grid using the color parameter.
The parameter enable can be set to:. By default a 3D scatter plot is drawn. Using a TCutG object, it is possible to draw a 2D histogram sub-range. Up to 16 cuts may be specified in the cut string delimited by "[.. Currently only the following drawing options are sensitive to the cuts option: col , box , scat , hist , lego , surf and cartesian coordinates only.
The following script creates two histograms; the second histogram is the bins integral of the first one. It shows a procedure to draw the two histograms in the same pad and it draws the scale of the second histogram using a new vertical axis on the right side.
By default, a histogram drawing includes the statistics box. The parameter option can contain:. With the option "same" , the statistic box is not redrawn. With the option "sames" , it is re-drawn. If it hides the previous statistics box, you can change its position with the next lines where h is the histogram pointer :. See the description of these classes for the list of options. The TPad ::SetTicks method specifies the type of tick marks on the axis.
Use TPad ::SetTicks tx,ty to set these options. See also the methods of TAxis that set specific axis attributes. If multiple color-filled histograms are drawn on the same pad, the fill area may hide the axis tick marks. One can force the axis redrawing over all the histograms by calling:. Because the axis title is an attribute of the axis, you have to get the axis first and then call TAxis ::SetTitle.
The histogram title and the axis titles can be any TLatex string. The titles are part of the persistent histogram. For example if you wanted to write E with a subscript T you could use this:.
It is also possible to specify the histogram title and the axis titles at creation time. This makes an identical copy of the original histogram including all associated errors and functions:. The following statements create a ROOT file and store a histogram on the file. Because TH1 derives from TNamed , the key identifier on the file is the histogram name:. The parameter option is a character string that specifies:. Bin the KS distances in a histogram, and then take the integral of all the KS values above the value obtained from the original data to Monte Carlo distribution.
The function returns the integral. TH1 ::Smooth - smoothes the bin contents of a 1D histogram. TH1 ::GetMean int axis - returns the mean value along axis. TH1 ::GetStdDev int axis - returns the sigma distribution along axis. Then h3 is created and filled with the asymmetry between h1 and h2 ; h1 and h2 are left intact. TH1 ::Reset - resets the bin contents and errors of a histogram. By default, histogram statistics are computed at fill time using the unbinned data used to update the bin content.
See the documentation on THGetStats. This is useful if you want to keep track of the mean and standard deviation of the dataset you are visualizing with the histogram, but it can lead to some unintuitive results. For example, suppose you have a histogram with one bin between 0 and , then you fill it with a Gaussian dataset with mean 20 and standard deviation Next, zoom in on the Gaussian:.
What happened? Well, GetMean and GetStdDev and many other TH1 functions return the statistics for bins in range ; this is because the histogram only stores the contents of its bins, not the coordinates of the values used to fill it.
This remains true even if you zoom out:. To mark the X axis as having no range, you can call. If you want ROOT to consistently return the statistics of the binned dataset stored in the histogram and not those of the dataset used to fill it, you can call THResetStats. This will delete the statistics originally calculated at fill time and replace them with those calculated from the bins; note that you cannot later retrieve the original statistics—they are lost.
Continuing the example above,. If you fill the histogram again, the statistics will be a mix of binned and unbinned:. By default, a histogram axis is drawn with its numeric bin labels. One can specify alphanumeric labels instead. This can always be done before or after filling. Bin labels will be automatically drawn with the histogram. You change that and draw the value of char[0] as an integer by adding an arithmetic operation to the expression as shown below.
When using the options 2 or 3 above, the labels are automatically added to the list THashList of labels for a given axis. By default, an axis is drawn with the order of bins corresponding to the filling sequence. It is possible to reorder the axis alphabetically or by increasing or decreasing values. When using the option second above, new labels are added by doubling the current number of bins in case one label does not exist yet.
When the filling is terminated, it is possible to trim the number of bins to match the number of active labels by calling:. Here axis may be X, Y, or Z.
This operation is automatic when using TTree ::Draw. The THStack does not own the objects in the list. By default, THStack ::Draw draws the histograms stacked as shown in the left pad in the picture above. If the option "nostack" is used, the histograms are superimposed as if they were drawn one at a time using the "same" draw option.
The right pad in this picture illustrates the THStack drawn with the "nostack" option. TH2Poly is a 2D Histogram class allowing to define polygonal bins of arbitrary shape. TH2PolyBin is a very simple class containing the vertices and contents of the polygonal bin as well as several related functions.
Bins are defined using one of the AddBin methods. The bin definition should be done before filling. Profile histograms are in many cases an elegant replacement of two-dimensional histograms.
The relationship of two quantities X and Y can be visualized by a two-dimensional histogram or a scatter-plot; its representation is not particularly satisfactory, except for sparse data.
If Y is an unknown [but single-valued] function of X, it can be displayed by a profile histogram with much better precision than by a scatter-plot. The following shows the contents [capital letters] and the values shown in the graphics [small letters] of the elements for bin j. When you fill a profile histogram with TProfile. Fill x,y :. In the special case where s[j] is zero, when there is only one entry per bin, e[j] is computed from the average of the s[j] for all bins.
This approximation is used to keep the bin during a fit operation. The TProfile constructor takes up to eight arguments. The first five parameters are similar to TH1D constructor. All values of y are accepted at filling time. To fill a profile histogram, you must use TProfile ::Fill function. Note that when filling the profile histogram the method TProfile ::Fill checks if the variable y is between fYmin and fYmax. If a minimum or maximum value is set for the Y scale before filling, then all values below ylow or above yup will be discarded.
Setting the minimum or maximum value for the Y scale before filling has the same effect as calling the special TProfile constructor above where ylow and yup are specified.
The last parameter is the build option. If a bin has N data points all with the same value Y, which is the case when dealing with integers, the spread in Y for that bin is zero, and the uncertainty assigned is also zero, and the bin is ignored in making subsequent fits. That it is only in the case where the Y variable is some sort of counting statistics, following a Poisson distribution.
This is the default case. An example is an ADC measurement. The next figure shows the graphic output of this simple example of a profile histogram. This will draw the outline of the TProfile. To create a regular histogram from a profile histogram, use the method TProfile ::ProjectionX. The 'prof' and 'profs' options in the TTree ::Draw method generate a profile histogram TProfile , given a two dimensional expression in the tree, or a TProfile2D given a three dimensional expression.
Note that you can specify 'prof' or 'profs' : 'prof' generates a TProfile with error on the mean, 'profs' generates a TProfile with error on the spread. It is in many cases an elegant replacement of a three-dimensional histogram.
The relationship of three measured quantities X, Y and Z can be visualized by a three-dimensional histogram or scatter-plot; its representation is not particularly satisfactory, except for sparse data. If Z is an unknown but single-valued function of X,Y , it can be displayed with a TProfile2D with better precision than by a scatter-plot. The following shows the cumulated contents capital letters and the values displayed small letters of the elements for cell i,j.
When you fill a profile histogram with TProfile2D. Fill x,y,z :. In the special case where s[i,j] is zero, when there is only one entry per cell, e[i,j] is computed from the average of the s[i,j] for all cells. This approximation is used to keep the cell during a fit operation.
The TPie class allows to create a Pie Chart representation of a one dimensional data set. The possible options to draw a TPie are:.
The method SetLabelFormat is used to customize the label format. The format string must contain one of these modifiers:. In combination with some other draw options an outer line is drawn on top of the histogram. The binning tab has two different layouts. One is for a histogram, which is not drawn from an ntuple. The other one is available for a histogram, which is drawn from an ntuple. In this case, the rebin algorithm can create a rebinned histogram from the original data i.
Rebin with a slider and the number of bins shown in the field below the slider. The number of bins can be changed to any number, which divides the number of bins of the original histogram. A click on the Apply button will delete the origin histogram and will replace it by the rebinned one on the screen. A click on the Ignore button will restore the origin histogram. Using this slider the effect of binning the data into bins can be made visible statistical fluctuations.
It is also possible to set the upper and lower limit in fields below the slider. Then the changes on the histogram are only updated, when the Slider is released. This should be activated if the redrawing of the histogram is time consuming. The Rebinning tab has two different layouts. One is for a histogram that is not drawn from an ntuple; the other one is available for a histogram, which is drawn from an ntuple.
To see the differences do for example:. Rebin with sliders one for the x, one for the y-axis and the number of bins shown in the field below them can be changed to any number, which divides the number of bins of the original histogram. Selecting the Apply button will delete the origin histogram and will replace it by the rebinned one on the screen.
Selecting the Ignore the origin histogram will be restored. This should be activated if the redrawing of the histogram is too time consuming. A graph is a graphics object made of two arrays X and Y, holding the x,y coordinates of n points.
The TGraph class supports the general case with non-equidistant points, and the special case with equidistant points. Graphs are created with the TGraph constructor. First, we define the arrays of coordinates and then create the graph.
The coordinates can be arrays of doubles or floats. An alternative constructor takes only the number of points n. It is expected that the coordinates will be set later. The default constructor can also be used.
Further calls to SetPoint will extend the internal vectors. The various drawing options for a graph are explained in TGraph::PaintGraph. They are:. This option only applies to the TGraphAsymmErrors. The options are not case sensitive and they can be concatenated in most cases. Let us look at some examples. This code will only work if n, x, and y is defined.
The previous example defines these. You need to set the fill color, because by default the fill color is white and will not be visible on a white canvas. You also need to give it an axis, or the bar chart will not be displayed properly. This code will only work if n , x , y are defined. The first example defines them.
You also need to give it an axis, or the filled polygon will not be displayed properly. Next is an example:. To control the size of the lines at the end of the error bars when option 1 is chosen use SetEndErrorSize np.
It inherits the various draw format options from TGraph. You can set the following additional options for drawing:. The low value is the length of the error bar to the left and down, the high value is the length of the error bar to the right and up. The TGraphBentErrors is drawn by default with error bars and small horizontal and vertical lines at the end of the error bars.
This option is interesting to superimpose systematic errors on top of a graph with statistical errors. The TGraphPolar class creates a polar graph including error bars. It uses the class TGraphPolargram to draw the polar axis. This is useful to show exclusion zones. This drawing mode is activated when the absolute value of the graph line width set thanks to SetLineWidth is greater than The current fill area attributes are used to draw the hatched zone.
A TGraphQQ allows drawing quantile-quantile plots. Such plots can be drawn for two datasets, or for one dataset and a theoretical distribution function. Quantile-quantile plots are used to determine whether two samples come from the same distribution. A qq-plot draws the quantiles of one dataset against the quantile of the other. The quantiles of the dataset with fewer entries are on Y-axis, with more entries - on X-axis. A straight line, going through 0.
It represents a robust linear fit, not sensitive to the extremes of the datasets. If the datasets come from the same distribution, points of the plot should fall approximately on the 45 degrees line. If they have the same distribution function, but different parameters of location or scale, they should still fall on the straight line, but not the 45 degrees one.
The greater their departure from the straight line, the more evidence there is that the datasets come from different distributions. Quantile-quantile plots are used to determine if the dataset comes from the specified theoretical distribution, such as normal. A qq-plot draws quantiles of the dataset against quantiles of the specified theoretical distribution. Note, that density, not CDF should be specified a straight line, going through 0. It represents a robust linear fit, not sensitive to the extremes of the dataset.
As in the two datasets case, departures from straight line indicate departures from the specified distribution. Next picture shows an example of a qq-plot of a dataset from N 3, 2 distribution and TMath::Gaus 0, 1 theoretical function.
Fitting parameters are estimates of the distribution mean and sigma. Use TMultiGraph::Add to add a new graph to the list. The TMultiGraph owns the objects in the list. The drawing and fitting options are the same as for TGraph. This class is a set of N points x[i] , y[i] , z[i] in a non-uniform grid.
Several visualization techniques are implemented, including Delaunay triangulation. Note that in any of last three cases, the SetPoint method can be used to change a data point or to add a new one. If the data point index i is greater than the size of the internal arrays, they are automatically extended.
A hidden surface drawing technique is used. The surface is painted with the current fill area color. The edges of the triangles are painted with the current line color;. In this case, an intermediate 2D histogram is filled using the Delaunay triangles technique to interpolate the data set.
The existing X,Y,Z points can be randomly scattered. The algorithm works by joining the existing points to make Delaunay triangles in X,Y.
These are then used to define flat planes in X,Y,Z over which to interpolate. The interpolated surface thus takes the form of tessellating triangles at various angles. Output can take the form of a 2D histogram or a vector. The triangles found can be drawn in 3D.
This software cannot be guaranteed to work under all circumstances. It was originally written to work with a few hundred points in an XY space with similar X and Y ranges. C that produces the next figure.
It is useful to perform fits with errors on a 2D graph. The graph Fit method in general works the same way as the THFit. To give the axis of a graph a title you need to draw the graph first, only then does it actually have an axis object. Once drawn, you set the title by getting the axis and calling the TAxis::SetTitle method, and if you want to center it, you can call the TAxis::CenterTitle method. Assuming that n, x, and y are defined.
Next code sets the titles of the x and y axes. C , gerrors. C , zdemo. C , and gerrors2. To zoom a graph you can create a histogram with the desired axis range first. Draw the empty histogram and then draw the graph using the existing axis from the histogram. The class TGraphEditor provides the user interface for setting the following graph attributes interactively:. To fit a histogram you can use the Fit Panel on a visible histogram via the context menu, or you can use the THFit method. The Fit Panel, which is limited, is best for prototyping.
The histogram needs to be drawn in a pad before the Fit Panel is invoked. The method THFit is more powerful and is used in scripts and programs.
To fit a histogram programmatically, you can use the THFit method. Here is the signatures of THFit and an explanation of the parameters:. One can also use the function name.
This name may be one of ROOT pre-defined function names or a user-defined function. See the next paragraph for the list of pre-defined functions. Here is the list of fitting options:.
To be used when the histogram represents counts. To be used when the histogram has been filled with weights different than 1. The expected error is instead estimated from the the square-root of the bin function value. Note that in case of pre-defined functions some default initial values and limits are set. By default, polN functions are fitted by the linear fitter.
By default, the fitted function object is added to the histogram and is drawn in the current pad. The signature for fitting a TGraph is exactly the same as for the TH1.
Here we will show how to create the TF1 class that is used for fitting histograms and graphs. To fit a histogram with a predefined function, simply pass the name of the function in the first parameter of THFit. For example, this line fits histogram object hist with a Gaussian. The initial parameter values and eventual limits for pre-defined functions are set automatically.
For overriding the default limits values use the fit option B. The list of pre-defined functions that can be used with the Fit method is the following:.
There are three ways to create a TF1. Using a function that you have defined. This can be a free function or a functor object or a particular member function of a class. You can also use a TF1 object in the constructor of another TF1. The second way to construct a TF1 is to add parameters to the expression. Here we use two parameters:. The parameter index is enclosed in square brackets. To set the initial parameters explicitly you can use:. This sets parameter 0 to Download the manual here.
This additional documentation for the GenVector package is rather detailed, although it could be that is not completely up to date.
Some new classes added later might be not documented in this manual. Nevertheless it is still very interesting. TSpectrum is a class providing processing and visualization functions: consult its manual here.
This page lists all the manuals related to packages used by or close to the ROOT framework. RooFit The RooFit library provides a toolkit for modeling the expected distribution of events in a physics analysis.
Minuit Minuit was a FORTRAN package conceived as a tool to find the minimum value of a multi-parameter function and analyze the shape of the function around the minimum.
Minuit 2 Minuit2 is a tool to find the minimum value of a multi-parameter function.
0コメント