1 |
auterman |
1.1 |
// @(#)root/hist:$Id: TLimitDataSource.cxx 20882 2007-11-19 11:31:26Z rdm $
|
2 |
|
|
// Author: Christophe.Delaere@cern.ch 21/08/2002
|
3 |
|
|
|
4 |
|
|
///////////////////////////////////////////////////////////////////////////
|
5 |
|
|
//
|
6 |
|
|
// TLimitDataSource
|
7 |
|
|
//
|
8 |
|
|
// This class serves as interface to feed data into the TLimit routines
|
9 |
|
|
//
|
10 |
|
|
///////////////////////////////////////////////////////////////////////////
|
11 |
|
|
|
12 |
|
|
#include "TLimitDataSource.h"
|
13 |
|
|
#include "TH1.h"
|
14 |
|
|
#include "TVectorD.h"
|
15 |
|
|
#include "TObjString.h"
|
16 |
|
|
#include "TRandom3.h"
|
17 |
|
|
|
18 |
|
|
ClassImp(TLimitDataSource)
|
19 |
|
|
|
20 |
|
|
TLimitDataSource::TLimitDataSource()
|
21 |
|
|
{
|
22 |
|
|
// Default constructor
|
23 |
|
|
fDummyTA.SetOwner();
|
24 |
|
|
fDummyIds.SetOwner();
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
TLimitDataSource::TLimitDataSource(TH1 * s, TH1 * b, TH1 * d)
|
28 |
|
|
{
|
29 |
|
|
// Another constructor, directly adds one channel
|
30 |
|
|
// with signal, background and data given as input.
|
31 |
|
|
fDummyTA.SetOwner();
|
32 |
|
|
fDummyIds.SetOwner();
|
33 |
|
|
AddChannel(s, b, d);
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
TLimitDataSource::TLimitDataSource(TH1 * s, TH1 * b, TH1 * d,
|
37 |
|
|
TVectorD * es, TVectorD * eb, TObjArray * names)
|
38 |
|
|
{
|
39 |
|
|
// Another constructor, directly adds one channel
|
40 |
|
|
// with signal, background and data given as input.
|
41 |
|
|
fDummyTA.SetOwner();
|
42 |
|
|
fDummyIds.SetOwner();
|
43 |
|
|
AddChannel(s, b, d, es, eb, names);
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
void TLimitDataSource::AddChannel(TH1 * s, TH1 * b, TH1 * d)
|
47 |
|
|
{
|
48 |
|
|
// Adds a channel with signal, background and data given as input.
|
49 |
|
|
|
50 |
|
|
TVectorD *empty;
|
51 |
|
|
TRandom3 generator;
|
52 |
|
|
fSignal.AddLast(s);
|
53 |
|
|
fBackground.AddLast(b);
|
54 |
|
|
fCandidates.AddLast(d);
|
55 |
|
|
char rndname[20];
|
56 |
|
|
sprintf(rndname, "rndname%f", generator.Rndm());
|
57 |
|
|
empty = new TVectorD(1);
|
58 |
|
|
fErrorOnSignal.AddLast(empty);
|
59 |
|
|
fDummyTA.AddLast(empty);
|
60 |
|
|
sprintf(rndname, "rndname%f", generator.Rndm());
|
61 |
|
|
empty = new TVectorD(1);
|
62 |
|
|
fErrorOnBackground.AddLast(empty);
|
63 |
|
|
fDummyTA.AddLast(empty);
|
64 |
|
|
TObjArray *dummy = new TObjArray(0);
|
65 |
|
|
fIds.AddLast(dummy);
|
66 |
|
|
fDummyIds.AddLast(dummy);
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
void TLimitDataSource::AddChannel(TH1 * s, TH1 * b, TH1 * d, TVectorD * es,
|
70 |
|
|
TVectorD * eb, TObjArray * names)
|
71 |
|
|
{
|
72 |
|
|
// Adds a channel with signal, background and data given as input.
|
73 |
|
|
// In addition, error sources are defined.
|
74 |
|
|
// TH1 are here used for convenience: each bin has to be seen as
|
75 |
|
|
// an error source (relative).
|
76 |
|
|
// names is an array of strings containing the names of the sources.
|
77 |
|
|
// Sources with the same name are correlated.
|
78 |
|
|
|
79 |
|
|
fSignal.AddLast(s);
|
80 |
|
|
fBackground.AddLast(b);
|
81 |
|
|
fCandidates.AddLast(d);
|
82 |
|
|
fErrorOnSignal.AddLast(es);
|
83 |
|
|
fErrorOnBackground.AddLast(eb);
|
84 |
|
|
fIds.AddLast(names);
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
void TLimitDataSource::SetOwner(bool swtch)
|
88 |
|
|
{
|
89 |
|
|
// Gives to the TLimitDataSource the ownership of the various objects
|
90 |
|
|
// given as input.
|
91 |
|
|
// Objects are then deleted by the TLimitDataSource destructor.
|
92 |
|
|
|
93 |
|
|
fSignal.SetOwner(swtch);
|
94 |
|
|
fBackground.SetOwner(swtch);
|
95 |
|
|
fCandidates.SetOwner(swtch);
|
96 |
|
|
fErrorOnSignal.SetOwner(swtch);
|
97 |
|
|
fErrorOnBackground.SetOwner(swtch);
|
98 |
|
|
fIds.SetOwner(swtch);
|
99 |
|
|
fDummyTA.SetOwner(!swtch);
|
100 |
|
|
fDummyIds.SetOwner(!swtch);
|
101 |
|
|
}
|
102 |
|
|
|