// Author: I. Froehlich
// Written: 3.7.2006
// Revised: 
// Base class for common distributions

#ifndef _PDISTRIBUTIONMANAGER_H_
#define _PDISTRIBUTIONMANAGER_H_

#include "TObjArray.h"
#include "TF1.h"
#include "TF2.h"
#include "PParticle.h"
#include "PDistribution.h"
#include "PDistributionCollection.h"
#include "PStdModels.h"
#include "PDistributionManagerUtil.h"
#include "PBatch.h"
#include "PProjector.h"
#include "PCommandList.h"

#define PDISTRIBUTIONMANAGER_MAX_COLLECT 100

class PDistributionManager;
//R__EXTERN PDistributionManager *gDM;
PDistributionManager &fDistributionManager();
PDistributionManager *makeDistributionManager();

class PDistributionManager : public TObject {
    
 public:
    
    PDistributionManager();
    
    int Add(PDistribution *dist) {
	//Adds user-defined distribution
	return pdmutil->Add(dist);
    };

    int Add(PDistribution *dist, const Char_t *gr) {
	//Adds user-defined distribution
	return pdmutil->Add(dist, gr);
    };

    void AlternativeTo(const char *a, const char *b) {
	pdmutil->AlternativeTo(a, b);
    };

    void Print(const Option_t *delme= "root") const {
	pdmutil->Print(delme);
    };

    int Attach(PChannel *ch);
    //Attach the PChannel to the known distributions

    void Disable(const Char_t *id) {
	//Disable id, if possible
	pdmutil->Disable(id);
    };

    void Enable(const Char_t *id) {
	//Enable id, if possible
	pdmutil->Enable(id);
    };

    PDistribution *GetDistribution(const Char_t *id) {
	return pdmutil->GetDistribution(id);
    };

    void SetVerbose(Int_t v) {
	pdmutil->SetVerbose(v);
    };

    void DisableAddWarning(void) {
	makeDistributionManagerUtil()->no_warning = kTRUE;
    }

    void LinkDB(void) {
	// Link the channel models to data base
	pdmutil->LinkDB();
    };

    void ActivateStdModels(void);

    void ExpandGroup(const char *gr, Int_t ex=1) {
	pdmutil->ExpandGroup(gr, ex);
    };

    int from_pdecaymanager;

    Int_t AddGroup(const Char_t *id, const Char_t *de) {
	return pdmutil->AddGroup(id, de);
    };

    void SetGroup(const Char_t *id) {
	//set standard group for the next Add(PDistribution * dist)
	pdmutil->SetGroup(id);
    };

    Int_t AddSubGroup(const Char_t *id, const Char_t *de, const Char_t *sub) {
	return pdmutil->AddSubGroup(id, de, sub);
    };

    Bool_t AddPlugin(PDistributionCollection *plugin);

    Bool_t Exec(const char *command); 
    Bool_t ExecAll(const char *command = "init");
    Bool_t Activate(const char *name);

    Bool_t Startup(void); //called before event loop
    Bool_t Startup(const char *command); //add commands for startup

    Bool_t Unpack(const char *filename);  //unpack and execute command list

    PProjector *GetLoopFilter(void) {
	return loop_start;
    };

 private:
  

    PDistributionManagerUtil *pdmutil;
    PStdModels *std_models;

    PDistributionCollection *collect[PDISTRIBUTIONMANAGER_MAX_COLLECT];
    Int_t collect_pointer;

    void PluginInfo(const char *info);

    PBatch *batch;
    PProjector *loop_start;

    ClassDef(PDistributionManager,0)  //The main manager for model and distribution handling

};

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