// @(#)root/roostats:$Id$

/*************************************************************************
 * Project: RooStats                                                     *
 * Package: RooFit/RooStats                                              *
 * Authors:                                                              *
 *   Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke       *
 *************************************************************************
 * 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_HLFactory
#define RooStats_HLFactory

#include "TString.h"
#include "RooAbsPdf.h"
#include "RooCategory.h"
#include "RooDataSet.h"
#include "RooWorkspace.h"


// class TString;
// class RooDataSet;

namespace RooStats {

  class HLFactory : public TNamed {

  public:

    /// Constructor 
    HLFactory(const char *name,
              const char *fileName=0,
              bool isVerbose = false);

    /// Constructor with external RooWorkspace
    HLFactory(const char* name,
              RooWorkspace* externalWs,
              bool isVerbose = false);

    /// Default Constructor
    HLFactory();

    /// Default Destructor
    ~HLFactory();

    /// Add channel for the combination
    int AddChannel(const char* label, 
                   const char* SigBkgPdfName,
                   const char* BkgPdfName=0,
                   const char* datasetName=0);

    /// Dump the Workspace content as configuration file
    /* It needs some workspace object list or something..*/
     void DumpCfg(const char* /*cardname*/ ){ /* t.b.i. */ }; // Dump the factory content as configuration file

    /// Get the combined signal plus background pdf
    RooAbsPdf* GetTotSigBkgPdf(); // Get the Signal and Background combined model

    /// Get the combined background pdf
    RooAbsPdf* GetTotBkgPdf(); // Get the Background combined model

    /// Get the combined dataset
    RooDataSet* GetTotDataSet(); // Get the combined dataset

    /// Get the combined dataset
    RooCategory* GetTotCategory(); // Get the category

    /// Get the RooWorkspace containing the models and variables
    RooWorkspace* GetWs(){return fWs;}; // Expose the internal Workspace

    /// Process a configuration file
    int ProcessCard(const char* filename);

  private:

    /// The category of the combination
    RooCategory* fComboCat;

    /// The background model combination
    RooAbsPdf* fComboBkgPdf;

    /// The signal plus background model combination
    RooAbsPdf* fComboSigBkgPdf;

    /// The datasets combination
    RooDataSet* fComboDataset;

    /// Flag to keep trace of the status of the combination
    bool fCombinationDone;

    /// Create the category for the combinations
    void fCreateCategory();

    /// Check the length of the lists
    bool fNamesListsConsistent();

    /// List of channels names to combine for the signal plus background pdfs
    TList fSigBkgPdfNames;

    /// List of channels names to combine for the background pdfs
    TList fBkgPdfNames;

    /// List of channels names to combine for the datasets
    TList fDatasetsNames;

    /// List of channels names to combine for the datasets
    TList fLabelsNames;

    /// The verbosity flag
    bool fVerbose;

    /// Keep trace of the inclusion deepness
    int fInclusionLevel;

    /// The RooWorkspace containing the models and variables
    RooWorkspace* fWs;

    /// Owns workspace
    bool fOwnWs;

    /// Read the actual cfg file
    int fReadFile(const char*fileName, bool is_included = false);

    /// Parse a single line an puts the content in the RooWorkSpace
    int fParseLine(TString& line);


  ClassDef(HLFactory,1)  // The high Level Model Factory to create models from datacards

  };
}

#endif
 HLFactory.h:1
 HLFactory.h:2
 HLFactory.h:3
 HLFactory.h:4
 HLFactory.h:5
 HLFactory.h:6
 HLFactory.h:7
 HLFactory.h:8
 HLFactory.h:9
 HLFactory.h:10
 HLFactory.h:11
 HLFactory.h:12
 HLFactory.h:13
 HLFactory.h:14
 HLFactory.h:15
 HLFactory.h:16
 HLFactory.h:17
 HLFactory.h:18
 HLFactory.h:19
 HLFactory.h:20
 HLFactory.h:21
 HLFactory.h:22
 HLFactory.h:23
 HLFactory.h:24
 HLFactory.h:25
 HLFactory.h:26
 HLFactory.h:27
 HLFactory.h:28
 HLFactory.h:29
 HLFactory.h:30
 HLFactory.h:31
 HLFactory.h:32
 HLFactory.h:33
 HLFactory.h:34
 HLFactory.h:35
 HLFactory.h:36
 HLFactory.h:37
 HLFactory.h:38
 HLFactory.h:39
 HLFactory.h:40
 HLFactory.h:41
 HLFactory.h:42
 HLFactory.h:43
 HLFactory.h:44
 HLFactory.h:45
 HLFactory.h:46
 HLFactory.h:47
 HLFactory.h:48
 HLFactory.h:49
 HLFactory.h:50
 HLFactory.h:51
 HLFactory.h:52
 HLFactory.h:53
 HLFactory.h:54
 HLFactory.h:55
 HLFactory.h:56
 HLFactory.h:57
 HLFactory.h:58
 HLFactory.h:59
 HLFactory.h:60
 HLFactory.h:61
 HLFactory.h:62
 HLFactory.h:63
 HLFactory.h:64
 HLFactory.h:65
 HLFactory.h:66
 HLFactory.h:67
 HLFactory.h:68
 HLFactory.h:69
 HLFactory.h:70
 HLFactory.h:71
 HLFactory.h:72
 HLFactory.h:73
 HLFactory.h:74
 HLFactory.h:75
 HLFactory.h:76
 HLFactory.h:77
 HLFactory.h:78
 HLFactory.h:79
 HLFactory.h:80
 HLFactory.h:81
 HLFactory.h:82
 HLFactory.h:83
 HLFactory.h:84
 HLFactory.h:85
 HLFactory.h:86
 HLFactory.h:87
 HLFactory.h:88
 HLFactory.h:89
 HLFactory.h:90
 HLFactory.h:91
 HLFactory.h:92
 HLFactory.h:93
 HLFactory.h:94
 HLFactory.h:95
 HLFactory.h:96
 HLFactory.h:97
 HLFactory.h:98
 HLFactory.h:99
 HLFactory.h:100
 HLFactory.h:101
 HLFactory.h:102
 HLFactory.h:103
 HLFactory.h:104
 HLFactory.h:105
 HLFactory.h:106
 HLFactory.h:107
 HLFactory.h:108
 HLFactory.h:109
 HLFactory.h:110
 HLFactory.h:111
 HLFactory.h:112
 HLFactory.h:113
 HLFactory.h:114
 HLFactory.h:115
 HLFactory.h:116
 HLFactory.h:117
 HLFactory.h:118
 HLFactory.h:119
 HLFactory.h:120
 HLFactory.h:121
 HLFactory.h:122
 HLFactory.h:123
 HLFactory.h:124
 HLFactory.h:125
 HLFactory.h:126
 HLFactory.h:127
 HLFactory.h:128
 HLFactory.h:129
 HLFactory.h:130
 HLFactory.h:131
 HLFactory.h:132
 HLFactory.h:133
 HLFactory.h:134
 HLFactory.h:135
 HLFactory.h:136
 HLFactory.h:137
 HLFactory.h:138