// Author:
// Written: 12/01/2014
// Modified: 
// PGammaConversion Class Header

#ifndef _PGAMMACONVERSION_H_
#define _PGAMMACONVERSION_H_

#include "PBulkInterface.h"

#include "TH2F.h"
#include "TH3F.h"
#include "TH1F.h"
#include "TString.h"

#include <vector>

using namespace std;

#define MAX_GAMMACONVERSION_DILEPTONS 20
#define NEFUNCS 250


class PGammaConversion: public PBulkInterface {

 private:

    PParticle ep, em;
    Float_t Z;
    Double_t x1, y1, z1;
    Float_t convpar[6];
    Float_t ConvProb;

    static Double_t dSde(Double_t *x, Double_t *par); // has to be static to be used by TF1 object
    Float_t ConversionXS(Float_t E);
    TF1 *Elepton[NEFUNCS];

    TRandom3 *RGen;
    TF1 *ulep;


    //------------------------------------
    // histograms
    Int_t nVertex;
    Int_t nbinTheta;
    Int_t nbinR;
    Int_t nbinZ;
    TH3F *hdimension;  // keep one hist for axis ranges
    TH1F *hvertexgeom; // keep target positions
    vector<TH2F*> fhzr;
    Int_t findVertexBin( Float_t zVertexEvt);
    Int_t getThetaBin(Double_t thetadeg);
    TH2F *getHist(Double_t zVertexEvt, Double_t thetadeg);
    //------------------------------------

 
 protected:
    
    
 public:
    
    PGammaConversion();
    PGammaConversion(Float_t Z, Float_t p,Int_t run);
    ~PGammaConversion();
    //void SetAverageCharge(Float_t z) {Z = z;}  // set average atomic charge of converter material
    void    SetConvLookupParameters(Float_t c1, Float_t c2, Float_t c3) {convpar[0]=c1; convpar[1]=c2; convpar[2]=c3;};
    Float_t GetConversionProb(Float_t E, Float_t theta,Int_t run);
    void    SetConversionProb(Float_t p) {ConvProb = (p>0 ? p : 0);}  // fix conversion probability
    Int_t   readHist(TString inputroot);

    void    SetVertex(Double_t x, Double_t y, Double_t z) {
	x1 = x; y1 = y; z1 = z;
    };
    
    Bool_t Modify(PParticle **stack, int *decay_done, int *num, int stacksize);  //bulk interface

    ClassDef(PGammaConversion, 0) // Fast post processing gamma conversion in material
};
#endif 

















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