#ifndef __PHUrReader_h__
#define __PHUrReader_h__


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

#include "TString.h"
#include "TClonesArray.h"

#include "PBulkInterface.h"


#include <vector>
#include <map>
#include <fstream>

using namespace std;


class PHUrReader : public PBulkInterface {


private:


    PHUrDilep dilep;       // urqmd dilepton shining code

    //-------------------------------------------------
    // ascii io
    TString     fInputName;
    TString     fOutputName;
    ifstream    fInputAscii;
    FILE       *fOutputAscii;
    //-------------------------------------------------

    //-------------------------------------------------
    // urqmd structure f15
    PHUrEventHeader     evtheader;                //! object to keep eventheader info
    PHUrEventHeader     evtheaderCP;              //! object to keep eventheader info
    PHUrCollisionHeader colheader;                //! object to keep collisonheader info
    vector< vector<PHUrParticle> > collisionsIn;  //! list of in-going particles  of collisions per event (entry i (collision) in vector is a list of particles)
    vector< vector<PHUrParticle> > collisionsOut; //! list of out-going particles of collisions per event (entry i (collision) in vector is a list of particles)
    vector< PHUrCollisionHeader  > collisions;    //! list of collision header  per event (entry i (collision) in vector is a collisionheader)
    //-------------------------------------------------


    //-------------------------------------------------
    // event handling
    Int_t fNumPart;
    Int_t fNumPartAddon;
    Int_t fNumMax;
    static TClonesArray *fAdd;
    static TClonesArray *fEvent;        // should be set to PLUTO TREE
    Int_t fEvtCt;                //!
    //-------------------------------------------------

    //-------------------------------------------------
    // particle ids etc
    map    <Int_t,Int_t>   mUrqmdToPdg;
    map    <Int_t,TString> mUrqmdProcess;
    map    <Int_t,Int_t> mapIDs;
    vector <Int_t > funknownIDs;
    map<Int_t , Int_t> fmapIds[3];
    Int_t pdg_param ;
    Int_t pid_param ;
    //-------------------------------------------------


    //-------------------------------------------------
    // flags
    Bool_t printEvtHeader; //!                     // urqmd reader
    Bool_t printColHeader; //!                     // urqmd reader
    Bool_t printParticle ; //!                     // urqmd reader
    Int_t  outputNonDiLeptons; //!                 // default: 0 ,1=put all urqmd stable particles to output 2=put all urqmd particle to output
    Bool_t outputLeptons;      //!                 // default: kTRUE,  let dileptons decay in urqmddilep shining code
    Bool_t outputFreezeoutDiLeptons; //!           // default: kFALSE, take into accout only final stage dileptons
    //-------------------------------------------------

    void          ClearVector(vector<vector<PHUrParticle> >& v);
    Bool_t        ReadEvent();
    const Char_t *GetUrQMDProcess(Int_t);
public:

    PHUrReader(TString inputfile="");
    ~PHUrReader();

    void         Input (TString filename);
    void         Output(TString filename);
    void         SetOutputNonDileptons      (Int_t doit)        { outputNonDiLeptons       = doit;}
    void         SetOutputLeptons           (Bool_t doit=kTRUE) { outputLeptons            = doit;}
    void         SetOutputFreezeoutDileptons(Bool_t doit=kTRUE) { outputFreezeoutDiLeptons = doit;}
    void         SetMaxNumParticles(Int_t max) { fNumMax = max; }
    void         SetMapID(Int_t Id_in,Int_t Id_out) ;

    virtual bool Modify(PParticle **array, int *decay_done, int *num, int maxnum);  //Modify particle bulk
    void         CreateAddonArray(TTree *T, Int_t stacksize);
    PHUrAddon   *CreateAddon(Int_t& index);
    void         CreateParticleArray(TTree *T, Int_t stacksize);
    PParticle   *CreateParticle(Int_t &index);
    Int_t        GetNFreeSlots()    { return  fNumMax - fEvent->GetEntries() ;}
    static TClonesArray *getAddon() { return fAdd  ;}
    static TClonesArray *getEvent() { return fEvent;}

    static Int_t UserAnalysis(PParticle**, Int_t);

    ClassDef(PHUrReader, 0)
};


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