// Author: I. Froehlich
// Written: 31.1.2008
// Revised: 

#ifndef _PTCROSSWEIGHT_H_
#define _PTCROSSWEIGHT_H_

#define TCROSS_MAX_DAUGHTERS 10

#include "TF1.h"
#include "TF2.h"
#include "PChannelModel.h"
#include "TLorentzVector.h"
#include "TGraph.h"
#include "TSpline.h"

class PTCrossWeight : public PChannelModel  {
  
 public:
    PTCrossWeight();
    PTCrossWeight(const Char_t *id, const Char_t *de, Int_t key);
    PDistribution* Clone(const char*delme=NULL) const;

    Bool_t Init(void);
    
    using PChannelModel::GetWeight;
	
    Double_t GetWeight(void);
    Double_t GetWeight(Double_t *mass, Int_t *didx=NULL);
	
    void SetCrossSection(TF1 *c) {
	//Sets cross section as a function of excess energy
	tcross = c;
    };

    void SetCrossSection(TGraph *f, Bool_t useSpline=kFALSE) {
	//Sets cross section as a function of excess energy
	tcrossg = f;
	spline  = useSpline;
	if (spline) g_spline = new TSpline3("", f);
    };

    void SetCrossSection(Double_t f) {
	//Sets cross section as a constant -> overrides everything
	tcross  = NULL;
	tcrossg = NULL;
	tcrossc = f;
    };

    void SetScaling(Double_t scal) {
	scaling = scal;
    };

    void SetExcessEnergy(Bool_t a, Bool_t b) {
	isExcessEnergy = a;
	isMevEnergy    = b;
    };

 private:

    TF1      *tcross;
    TGraph   *tcrossg;
    Double_t  tcrossc;
    TSpline3 *g_spline;
    Bool_t    spline;
    Double_t  scaling;

    Bool_t isExcessEnergy, isMevEnergy;
    
    PParticle *daughters[TCROSS_MAX_DAUGHTERS], *beam, *target, *parent; 
    int daughter_pos;

    ClassDef(PTCrossWeight, 0)  //Total cross section weights

};

#endif


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