1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | // //
|
---|
27 | // MBinning //
|
---|
28 | // //
|
---|
29 | //////////////////////////////////////////////////////////////////////////////
|
---|
30 | #include "MBinning.h"
|
---|
31 |
|
---|
32 | #include <fstream.h>
|
---|
33 |
|
---|
34 | #include "MH.h"
|
---|
35 |
|
---|
36 | ClassImp(MBinning);
|
---|
37 |
|
---|
38 | // --------------------------------------------------------------------------
|
---|
39 | //
|
---|
40 | // Default Constructor. It sets name and title only. Typically you won't
|
---|
41 | // need to change this.
|
---|
42 | //
|
---|
43 | MBinning::MBinning(const char *name, const char *title)
|
---|
44 | {
|
---|
45 | //
|
---|
46 | // set the name and title of this object
|
---|
47 | //
|
---|
48 | fName = name ? name : "MBinning";
|
---|
49 | fTitle = title ? title : "Container describing the binning of an axis";
|
---|
50 |
|
---|
51 | SetEdges(10, 0, 1);
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Apply this binning to the given histogram.
|
---|
58 | // (By definition this works only for 1D-histograms. For 2D- and 3D-
|
---|
59 | // histograms use MH::SetBinning directly)
|
---|
60 | //
|
---|
61 | void MBinning::Apply(TH1 &h)
|
---|
62 | {
|
---|
63 | MH::SetBinning(&h, this);
|
---|
64 | }
|
---|
65 |
|
---|
66 | // --------------------------------------------------------------------------
|
---|
67 | //
|
---|
68 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
---|
69 | // to a macro. In the original root implementation it is used to write
|
---|
70 | // gui elements to a macro-file.
|
---|
71 | //
|
---|
72 | void MBinning::SavePrimitive(ofstream &out, Option_t *o)
|
---|
73 | {
|
---|
74 | out << " TArrayD dummy;" << endl;
|
---|
75 | for (int i=0; i<fEdges.GetSize(); i++)
|
---|
76 | out << " dummy[" << i << "]=" << fEdges[i] << ";" << endl;
|
---|
77 | out << " MBinning " << ToLower(fName) << "(\"";
|
---|
78 | out << fName << "\", \"" << fTitle << "\");" << endl;
|
---|
79 | out << " " << ToLower(fName) << ".SetEdges(dummy);" << endl;
|
---|
80 | }
|
---|