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