Histogramas en root

Solo disponible en BuenasTareas
  • Páginas : 44 (10827 palabras )
  • Descarga(s) : 10
  • Publicado : 24 de julio de 2010
Leer documento completo
Vista previa del texto
3 Histograms
This chapter covers the functionality of the histogram classes. We begin with an overview of the histogram classes and their inheritance relationship. Then we give instructions 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 lookunfamiliar to you. These are covered in the chapter ―Input/Output‖.

The Histogram Classes
ROOT supports the following histogram types: 1-D histograms: TH1C: are histograms with one byte per channel. Maximum bin content = 255 TH1S: are histograms with one short per channel. Maximum bin content = 65 535 TH1I: are histograms with one integer per channel. Maximum bin content = 2147483647 TH1F: arehistograms with one float per channel. Maximum precision 7 digits TH1D: are histograms with one double per channel. Maximum precision 14 digits 2-D histograms: TH2C: are histograms with one byte per channel. Maximum bin content = 255 TH2S: are histograms with one short per channel. Maximum bin content = 65 535 TH2I: are histograms with one integer per channel. Maximum bin content = 2147483647TH2F: are histograms with one float per channel. Maximum precision 7 dig TH2D: are histograms with one double per channel. Maximum precision 14 digits 3-D histograms: TH3C: are histograms with one byte per channel. Maximum bin content = 255 TH3S: are histograms with one short per channel. Maximum bin content = 65 535 TH3I: are histograms with one integer per channel. Maximum bin content = 2147483647TH3F: are histograms with one float per channel. Maximum precision 7 digits TH3D: are histograms with one double per channel. Maximum precision 14 digits Profile histograms: TProfile: one dimensional profiles TProfile2D: two dimensional profiles Profile histograms are used to display the mean value of Y and its RMS for each bin in X. Profile histograms are in many cases an elegant replacement oftwo-dimensional histograms. The inter-relation of two measured quantities X and Y can always be visualized with a two-dimensional histogram or scatter-plot. If Y is an unknown but single-valued approximate function of X, it will have greater precisions in a profile histogram than in a scatter plot. Figure 3-1 The class hierarchy of histogram classes
TH1

TH1C TH2

TH1S

TH1I

TH1F

TH1DTProfile

TH3

TH2C

TH2S

TH2I

TH2F

TH2D

TProfile2D

TH3C

TH3S

TH3I

TH3F

TH3D

Histograms

23

All histogram classes are derived from the base class TH1. The figure above shows the class hierarchy. The TH*C classes also inherit from the array class TArrayC. The TH*S classes also inherit from the array class TArrayS. The TH*F classes also inherit from thearray class TArrayF. The TH*D classes also inherit from the array class TArrayD.

Creating Histograms
Histograms are created with constructors: TH1F *h1 = new TH1F("h1","h1 title",100,0,4.4); TH2F *h2 = new TH2F("h2","h2 title",40,0,4,30,-3,3); The parameters of the TH1 constructor are the name of the histogram, the title, the number of bins, the x minimum, and x maximum. Histograms may also becreated by: Calling the Clone method of an existing histogram (see below) Making a projection from a 2-D or 3-D histogram (see below) Reading a histogram from a file When a histogram is created, a reference to it is automatically added to the list of in-memory objects for the current file or directory. This default behavior can be disabled for an individual histogram or for all histograms bysetting a global switch. Here is the syntax to set the directory of the histogram h: // to set the in-memory directory for the current histogram h h->SetDirectory(0); // global switch to disable TH1::AddDirectory(kFALSE); When the histogram is deleted, the reference to it is removed from the list of objects in memory. In addition, when a file is closed, all histograms in memory associated with this...
tracking img