#ifndef __PHUrDilep_h__
#define __PHUrDilep_h__


#include "TObject.h"
#include "TLorentzVector.h"
#include "TClonesArray.h"
#include "TTree.h"

#include "PParticle.h"
#include "PHUrParticle.h"
#include "PHUrAddon.h"
#include "PHUrEventHeader.h"
#include "PHUrCollisionHeader.h"


#include <vector>
#include <map>

using namespace std;

class PHUrReader;


class PHUrDilep : public TObject {

public:

    PHUrReader *reader; //!


    //---------------------------------------
    // ascii io
    FILE *out;
    //---------------------------------------


    //---------------------------------------
    // urqmd structure
    PHUrEventHeader      *evtheader;
    PHUrParticle         *particleIn;
    PHUrParticle         *particleOut;
    PHUrCollisionHeader  *collisionIn;
    PHUrCollisionHeader  *collisionOut;
    TLorentzVector        ep,em;
    //---------------------------------------

    //---------------------------------------
    // particle id etc
    Int_t omega    ;
    Int_t rho      ;
    Int_t phi      ;
    Int_t pion     ;
    Int_t etaprime ;
    Int_t eta      ;
    Int_t delta    ;
    Int_t omegadir ;
    Int_t omegadal ;

    map <Int_t,Int_t> *mUrqmdToPdg;
    //---------------------------------------

    //---------------------------------------
    // flags
    Bool_t outputLeptons;      //!                 // default: kTRUE,  let dileptons decay
    //---------------------------------------

private:


    //---------------------------------------
    // constants
    Double_t  alpha_em       ;
    Double_t  vacmass_pi0    ; // pi0
    Double_t  mass_electron  ; // e-
    Double_t  mass_nucleon   ; // proton
    Double_t  vacmass_eta    ; // eta
    Double_t  vacmass_etaprime; // eta'
    Double_t  vacmass_rho     ; // rho0
    Double_t  vacmass_omega   ; // omega
    Double_t  vacmass_phi     ; // phi
    Double_t  vacmass_delta   ; // D+

    Double_t  gev            ;
    Double_t  g              ;     // delta


    Double_t  lambda_omega   ;
    Double_t  gamma_omega    ;
    Double_t  gamma_photon   ;

    Double_t  br_pi0         ;
    Double_t  b_pi0          ;

    Double_t  lambda_eta     ;
    Double_t  br_eta         ;

    Double_t  lambda_etaprime ;
    Double_t  gamma_etaprime  ;
    Double_t  br_etaprime     ;
    //---------------------------------------

    void dalpi       (Double_t mx, Double_t& dgamma);
    void daleta      (Double_t mx, Double_t& dgamma);
    void daletaprime (Double_t mx, Double_t& dgamma);
    void daldelta (Double_t tau, Double_t mx, Double_t mres, Double_t& dgamma);
    void dalomega (Double_t tau, Double_t mx, Double_t &dgamma);
    void diromega (Double_t tau, Double_t mres, Int_t multi, Double_t& weight);
    void dirphi   (Double_t tau, Double_t mres, Int_t multi, Double_t& weight);
    void dirrho   (Double_t tau, Double_t mres, Int_t multi, Double_t& weight);
    void lobo_dal (Double_t p0_gstar, Double_t p0_particle,
		   Double_t m_gstar,  Double_t beta, Double_t gamma,
		   Double_t x_gstar,  Double_t y_gstar, Double_t z_gstar, Double_t t_gstar,
		   Double_t x_particle, Double_t y_particle, Double_t z_particle,
		   Double_t m_res);
    void lobo_dir(Double_t beta, Double_t gamma, Double_t m_res);

    void  dgamma_sum(Int_t ityp, Double_t tau, Int_t multi,
		     Double_t& weight,
		     Double_t& smin, Double_t& smax, Double_t& tmax);

    void dgamma_sum_delta(Double_t tau, Double_t mres, Int_t multi,
			  Double_t& weight_delta,
			  Double_t& smin_del, Double_t& smax_del, Double_t& tmax_del);

    void  gamma_star(Double_t smin, Double_t smax, Double_t tmax,
		     Double_t& s, Double_t& t,
		     Double_t& xgstar, Double_t& ygstar, Double_t& zgstar, Double_t& tgstar,
		     Double_t& xparticle, Double_t& yparticle, Double_t& zparticle, Double_t& tparticle);

    void t_delta(Double_t tau, Double_t mres, Int_t multi, Double_t& tmax_del);

    void t_omega(Double_t tau, Int_t multi, Double_t& smin_omega, Double_t& smax_omega, Double_t& tmax_omega);
    Double_t rndfunc();

    void Output(Int_t ityp, Double_t weight, Double_t mres, Int_t multi, Double_t tau);
    void OutputROOT(Int_t ityp, Double_t weight);


public:
    PHUrDilep();
    ~PHUrDilep();

    void Output(TString infilename, TString outfilename);
    void Dilep();


    ClassDef(PHUrDilep, 0)
};


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