#ifndef ROOT_TMVA_ROCCalc
#define ROOT_TMVA_ROCCalc
#include <vector>
#include <sstream>
#include <iostream>
#include <iomanip>

class TList;
class TTree;
class TString;
class TH1;
class TH2;
class TH2F;
class TSpline;
class TSpline1;

namespace TMVA {

  class MsgLogger;


  class ROCCalc {
    
  public:
    ROCCalc(TH1* mvaS, TH1* mvaB);
    
    ~ROCCalc();
    

    TH1D* GetROC();
    // return the signal eff for a given backgr. efficiency
    Double_t GetEffSForEffBof(Double_t effBref, Double_t &effSerr);
    // return the cut value 
    Double_t GetSignalReferenceCut(){return fSignalCut;} 
    // return the area under the ROC curve
    Double_t GetROCIntegral();
    // return the statistical significance as function of the mva cut value
    TH1* GetSignificance( Int_t nStot, Int_t nBtot);
    TH1* GetPurity(Int_t nStot, Int_t nBtot);
    
    void ApplySignalAndBackgroundStyle( TH1* sig, TH1* bkg, TH1* any = 0 );
    
    TH1* GetMvaSpdf(){return fmvaSpdf;}
    TH1* GetMvaBpdf(){return fmvaBpdf;}
    
  private:
    Double_t        Root(Double_t);
    Double_t        GetEffForRoot( Double_t theCut );
    Int_t           fMaxIter;  // maximum number of iterations
    Double_t        fAbsTol;   // absolute tolerance deviation
    
    UInt_t          fNbins;
    Bool_t          fUseSplines;

    TH1*            fmvaS, *fmvaB;       // the input mva distributions
    TH1*            fmvaSpdf, *fmvaBpdf;       // the normalized (and rebinned) input mva distributions
    Float_t         fXmin, fXmax;       // min and max of the mva distribution  
    Double_t        fNevtS;             // number of signal events (used in error calculation)
    Int_t           fCutOrientation;    //+1 if larger mva value means more signal like, -1 otherwise
    TSpline*        fSplS, *fSplB;
    TSpline*        fSplmvaCumS, *fSplmvaCumB;  // spline of cumulated mva distributions
    TSpline*        fSpleffBvsS;    
    TH1*            fmvaScumul, *fmvaBcumul;
    Int_t           fnStot, fnBtot;
    TH1*            fSignificance;
    TH1*            fPurity;

    Double_t        fSignalCut;  // MVA cut value for last demanded background rejection or signal efficiency

    mutable MsgLogger* fLogger;   //! message logger
    MsgLogger& Log() const { return *fLogger; }                       

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