TLimitDataSource.cxx

Go to the documentation of this file.
00001 // @(#)root/hist:$Id: TLimitDataSource.cxx 35935 2010-09-30 15:41:33Z brun $
00002 // Author: Christophe.Delaere@cern.ch   21/08/2002
00003 
00004 ///////////////////////////////////////////////////////////////////////////
00005 //
00006 // TLimitDataSource
00007 //
00008 // This class serves as interface to feed data into the TLimit routines
00009 //
00010 ///////////////////////////////////////////////////////////////////////////
00011 
00012 #include "TLimitDataSource.h"
00013 #include "TH1.h"
00014 #include "TVectorD.h"
00015 #include "TObjString.h"
00016 #include "TRandom3.h"
00017 
00018 ClassImp(TLimitDataSource)
00019 
00020 TLimitDataSource::TLimitDataSource() 
00021 {
00022    // Default constructor
00023    fDummyTA.SetOwner();
00024    fDummyIds.SetOwner();
00025 }
00026 
00027 TLimitDataSource::TLimitDataSource(TH1 * s, TH1 * b, TH1 * d) 
00028 {
00029    // Another constructor, directly adds one channel
00030    // with signal, background and data given as input.
00031    fDummyTA.SetOwner();
00032    fDummyIds.SetOwner();
00033    AddChannel(s, b, d);
00034 }
00035 
00036 TLimitDataSource::TLimitDataSource(TH1 * s, TH1 * b, TH1 * d,
00037                                    TVectorD * es, TVectorD * eb, TObjArray * names)
00038 {
00039    // Another constructor, directly adds one channel
00040    // with signal, background and data given as input.
00041    fDummyTA.SetOwner();
00042    fDummyIds.SetOwner();
00043    AddChannel(s, b, d, es, eb, names);
00044 }
00045 
00046 void TLimitDataSource::AddChannel(TH1 * s, TH1 * b, TH1 * d)
00047 {
00048    // Adds a channel with signal, background and data given as input.
00049    
00050    TVectorD *empty;
00051    TRandom3 generator;
00052    fSignal.AddLast(s);
00053    fBackground.AddLast(b);
00054    fCandidates.AddLast(d);
00055    char rndname[20];
00056    snprintf(rndname,20, "rndname%f", generator.Rndm());
00057    empty = new TVectorD(1);
00058    fErrorOnSignal.AddLast(empty);
00059    fDummyTA.AddLast(empty);
00060    snprintf(rndname,20, "rndname%f", generator.Rndm());
00061    empty = new TVectorD(1);
00062    fErrorOnBackground.AddLast(empty);
00063    fDummyTA.AddLast(empty);
00064    TObjArray *dummy = new TObjArray(0);
00065    fIds.AddLast(dummy);
00066    fDummyIds.AddLast(dummy);
00067 }
00068 
00069 void TLimitDataSource::AddChannel(TH1 * s, TH1 * b, TH1 * d, TVectorD * es,
00070                                   TVectorD * eb, TObjArray * names)
00071 {
00072    // Adds a channel with signal, background and data given as input.
00073    // In addition, error sources are defined.
00074    // TH1 are here used for convenience: each bin has to be seen as 
00075    // an error source (relative).
00076    // names is an array of strings containing the names of the sources.
00077    // Sources with the same name are correlated.
00078    
00079    fSignal.AddLast(s);
00080    fBackground.AddLast(b);
00081    fCandidates.AddLast(d);
00082    fErrorOnSignal.AddLast(es);
00083    fErrorOnBackground.AddLast(eb);
00084    fIds.AddLast(names);
00085 }
00086 
00087 void TLimitDataSource::SetOwner(bool swtch)
00088 {
00089    // Gives to the TLimitDataSource the ownership of the various objects
00090    // given as input.
00091    // Objects are then deleted by the TLimitDataSource destructor.
00092    
00093    fSignal.SetOwner(swtch);
00094    fBackground.SetOwner(swtch);
00095    fCandidates.SetOwner(swtch);
00096    fErrorOnSignal.SetOwner(swtch);
00097    fErrorOnBackground.SetOwner(swtch);
00098    fIds.SetOwner(swtch);
00099    fDummyTA.SetOwner(!swtch);
00100    fDummyIds.SetOwner(!swtch);
00101 }
00102 

Generated on Tue Jul 5 14:24:21 2011 for ROOT_528-00b_version by  doxygen 1.5.1