// @(#)root/hist:$Id$
// Author: Christophe.Delaere@cern.ch   21/08/2002

#ifndef ROOT_TLimit
#define ROOT_TLimit

#ifndef ROOT_TObject
#include "TObject.h"
#endif

#include "TVectorDfwd.h"

class TConfidenceLevel;
class TRandom;
class TLimitDataSource;
class TArrayD;
class TOrdCollection;
class TH1;

//____________________________________________________________________
//
// TLimit
//
// This class computes 95% Confidence Levels.
//
// Implemented by C. Delaere from the mclimit code written by Tom Junk.
// reference: HEP-EX/9902006
// See http://cern.ch/thomasj/searchlimits/ecl.html for more details.
//____________________________________________________________________

class TLimit {
 protected:
   static bool Fluctuate(TLimitDataSource * input, TLimitDataSource * output, bool init,TRandom *, bool stat=false);
   static Double_t LogLikelihood(Double_t s, Double_t b, Double_t b2, Double_t d);

public:
   TLimit() {}
   virtual ~TLimit() {}
   static TConfidenceLevel *ComputeLimit(TLimitDataSource * data,
                                         Int_t nmc =50000,
                                         bool stat = false,
                                         TRandom * generator = 0);
   static TConfidenceLevel *ComputeLimit(Double_t s, Double_t b, Int_t d,
                                         Int_t nmc =50000,
                                         bool stat = false,
                                         TRandom * generator = 0);
   static TConfidenceLevel *ComputeLimit(Double_t s, Double_t b, Int_t d, 
                                         TVectorD* se, TVectorD* be, TObjArray*,
                                         Int_t nmc =50000,
                                         bool stat = false,
                                         TRandom * generator = 0);
   static TConfidenceLevel *ComputeLimit(TH1* s, TH1* b, TH1* d,
                                         Int_t nmc =50000,
                                         bool stat = false,
                                         TRandom * generator = 0);
   static TConfidenceLevel *ComputeLimit(TH1* s, TH1* b, TH1* d, 
                                         TVectorD* se, TVectorD* be, TObjArray*,
                                         Int_t nmc =50000,
                                         bool stat = false,
                                         TRandom * generator = 0);
 private:
   static TArrayD *fgTable;              // a log table... just to speed up calculation
   static TOrdCollection *fgSystNames;   // Collection of systematics names
   ClassDef(TLimit, 2)          // Class to compute 95% CL limits
};

#endif

 TLimit.h:1
 TLimit.h:2
 TLimit.h:3
 TLimit.h:4
 TLimit.h:5
 TLimit.h:6
 TLimit.h:7
 TLimit.h:8
 TLimit.h:9
 TLimit.h:10
 TLimit.h:11
 TLimit.h:12
 TLimit.h:13
 TLimit.h:14
 TLimit.h:15
 TLimit.h:16
 TLimit.h:17
 TLimit.h:18
 TLimit.h:19
 TLimit.h:20
 TLimit.h:21
 TLimit.h:22
 TLimit.h:23
 TLimit.h:24
 TLimit.h:25
 TLimit.h:26
 TLimit.h:27
 TLimit.h:28
 TLimit.h:29
 TLimit.h:30
 TLimit.h:31
 TLimit.h:32
 TLimit.h:33
 TLimit.h:34
 TLimit.h:35
 TLimit.h:36
 TLimit.h:37
 TLimit.h:38
 TLimit.h:39
 TLimit.h:40
 TLimit.h:41
 TLimit.h:42
 TLimit.h:43
 TLimit.h:44
 TLimit.h:45
 TLimit.h:46
 TLimit.h:47
 TLimit.h:48
 TLimit.h:49
 TLimit.h:50
 TLimit.h:51
 TLimit.h:52
 TLimit.h:53
 TLimit.h:54
 TLimit.h:55
 TLimit.h:56
 TLimit.h:57
 TLimit.h:58
 TLimit.h:59
 TLimit.h:60
 TLimit.h:61
 TLimit.h:62
 TLimit.h:63
 TLimit.h:64
 TLimit.h:65
 TLimit.h:66
 TLimit.h:67
 TLimit.h:68