#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;
TString fInputName;
TString fOutputName;
ifstream fInputAscii;
FILE *fOutputAscii;
PHUrEventHeader evtheader;
PHUrEventHeader evtheaderCP;
PHUrCollisionHeader colheader;
vector< vector<PHUrParticle> > collisionsIn;
vector< vector<PHUrParticle> > collisionsOut;
vector< PHUrCollisionHeader > collisions;
Int_t fNumPart;
Int_t fNumPartAddon;
Int_t fNumMax;
static TClonesArray *fAdd;
static TClonesArray *fEvent;
Int_t fEvtCt;
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 ;
Bool_t printEvtHeader;
Bool_t printColHeader;
Bool_t printParticle ;
Int_t outputNonDiLeptons;
Bool_t outputLeptons;
Bool_t outputFreezeoutDiLeptons;
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);
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