// @(#)root/roostats:$Id$
// Author: Kyle Cranmer   21/07/2008

/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef RooStats_SPlot
#define RooStats_SPlot

class RooAbsReal;
class RooAbsPdf;
class RooFitResult;
class RooRealVar;
class RooSimultaneous;


#ifndef ROO_MSG_SERVICE
#include "RooMsgService.h"
#endif 

#include "RooFitResult.h"
#include "RooRealVar.h"
#include "RooHist.h"
#include "RooPlot.h"
#include "RooDataSet.h"

namespace RooStats{


/**

   \ingroup Roostats

   This class calculates sWeights used to create an sPlot.  
   The code is based on 
   ``SPlot: A statistical tool to unfold data distributions,'' 
   Nucl. Instrum. Meth. A 555, 356 (2005) [arXiv:physics/0402083].

   An SPlot gives us  the distribution of some variable, x in our 
   data sample for a given species (eg. signal or background).  
   The result is similar to a likelihood projection plot, but no cuts are made, 
   so every event contributes to the distribution.

   To use this class, you first must have a pdf that includes
   yields for (possibly several) different species.
   Create an instance of the class by supplying a data set,
   the pdf, and a list of the yield variables.  The SPlot Class
   will calculate SWeights and include these as columns in the RooDataSet.
   
*/

  
  class SPlot: public TNamed {

  public:

    ~SPlot();
    SPlot();
    SPlot(const SPlot &other);
    SPlot(const char* name, const char* title);
    SPlot(const char* name, const char* title, const RooDataSet &data);
    SPlot(const char* name, const char* title,RooDataSet& data, RooAbsPdf* pdf, 
	  const RooArgList &yieldsList,const RooArgSet &projDeps=RooArgSet(), 
	  bool includeWeights=kTRUE, bool copyDataSet = kFALSE, const char* newName = "");
    
    RooDataSet* SetSData(RooDataSet* data);

    RooDataSet* GetSDataSet() const;    

    RooArgList GetSWeightVars() const;
    
    Int_t GetNumSWeightVars() const;
    
    void AddSWeight(RooAbsPdf* pdf, const RooArgList &yieldsTmp,
		    const RooArgSet &projDeps=RooArgSet(), bool includeWeights=kTRUE);
    
    Double_t GetSumOfEventSWeight(Int_t numEvent) const;
    
    Double_t GetYieldFromSWeight(const char* sVariable) const;

    Double_t GetSWeight(Int_t numEvent, const char* sVariable) const;


    
  protected:

     enum { 
        kOwnData = BIT(20)
     };
     
    RooArgList fSWeightVars;

    //  RooListProxy fSWeightVars;
    
    RooDataSet* fSData;

    ClassDef(SPlot,1)   // Class used for making sPlots
      
      
      };
  
}
#endif
 SPlot.h:1
 SPlot.h:2
 SPlot.h:3
 SPlot.h:4
 SPlot.h:5
 SPlot.h:6
 SPlot.h:7
 SPlot.h:8
 SPlot.h:9
 SPlot.h:10
 SPlot.h:11
 SPlot.h:12
 SPlot.h:13
 SPlot.h:14
 SPlot.h:15
 SPlot.h:16
 SPlot.h:17
 SPlot.h:18
 SPlot.h:19
 SPlot.h:20
 SPlot.h:21
 SPlot.h:22
 SPlot.h:23
 SPlot.h:24
 SPlot.h:25
 SPlot.h:26
 SPlot.h:27
 SPlot.h:28
 SPlot.h:29
 SPlot.h:30
 SPlot.h:31
 SPlot.h:32
 SPlot.h:33
 SPlot.h:34
 SPlot.h:35
 SPlot.h:36
 SPlot.h:37
 SPlot.h:38
 SPlot.h:39
 SPlot.h:40
 SPlot.h:41
 SPlot.h:42
 SPlot.h:43
 SPlot.h:44
 SPlot.h:45
 SPlot.h:46
 SPlot.h:47
 SPlot.h:48
 SPlot.h:49
 SPlot.h:50
 SPlot.h:51
 SPlot.h:52
 SPlot.h:53
 SPlot.h:54
 SPlot.h:55
 SPlot.h:56
 SPlot.h:57
 SPlot.h:58
 SPlot.h:59
 SPlot.h:60
 SPlot.h:61
 SPlot.h:62
 SPlot.h:63
 SPlot.h:64
 SPlot.h:65
 SPlot.h:66
 SPlot.h:67
 SPlot.h:68
 SPlot.h:69
 SPlot.h:70
 SPlot.h:71
 SPlot.h:72
 SPlot.h:73
 SPlot.h:74
 SPlot.h:75
 SPlot.h:76
 SPlot.h:77
 SPlot.h:78
 SPlot.h:79
 SPlot.h:80
 SPlot.h:81
 SPlot.h:82
 SPlot.h:83
 SPlot.h:84
 SPlot.h:85
 SPlot.h:86
 SPlot.h:87
 SPlot.h:88
 SPlot.h:89
 SPlot.h:90
 SPlot.h:91
 SPlot.h:92
 SPlot.h:93
 SPlot.h:94
 SPlot.h:95
 SPlot.h:96
 SPlot.h:97
 SPlot.h:98
 SPlot.h:99
 SPlot.h:100
 SPlot.h:101
 SPlot.h:102
 SPlot.h:103
 SPlot.h:104
 SPlot.h:105
 SPlot.h:106
 SPlot.h:107
 SPlot.h:108