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

#ifndef _PHADRONDECAYM1N_H_
#define _PHADRONDECAYM1N_H_

#include "TF1.h"
#include "TF2.h"
#include "TGenPhaseSpace.h"
#include "PChannelModel.h"
#include "PDynamicData.h"
#include "PKinematics.h"
#include "PMesh.h"


#define M1N_MAX_DAUGHTERS 10
#define M1N_PARENT_GRID   0.1

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


    Bool_t Prepare(void);
    Bool_t Init(void);
    Bool_t SampleMass(void);
    using  PChannelModel::SampleMass;

    int      GetDepth(int i=0);

    Double_t Eval(Double_t x, Double_t y = 0, Double_t z = 0, Double_t t = 0) const;
    Double_t EvalPar(const Double_t *x, const Double_t *params);
    //TF1 wrapper

    void SubPrint(Int_t opt) const ;  //Print sub-models

 protected:

    //int didx1,didx2,didx3;
    PParticle * parent, *daughters[M1N_MAX_DAUGHTERS], *unstable_particle; 
    Int_t daughter_pos, unstable_daughter;
    PChannelModel *unstable_model;

    Int_t unstable_pos,
	daughter_id[M1N_MAX_DAUGHTERS],
	daughter_didx[M1N_MAX_DAUGHTERS],
	unstable_id, parent_id, unstable_didx;
    Double_t unstable_width, daughter_masses[M1N_MAX_DAUGHTERS], parent_mass, old_parent_mass;
    
    PMesh *mesh;
    TGenPhaseSpace *event;

    void UpdateMesh(void);
    Int_t maxmesh;

    ClassDef(PHadronDecayM1N, 0)  // Decay of Hadron -> 1 unstable + N stable
};

#endif


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