#include <TROOT.h>
#include <fstream.h>
#include <iostream.h>

#define NMAXPART 200000


//these structs are data types for one line in output files
struct pair_part {
   Float_t e;
   Float_t vx;
   Float_t vy;
   Float_t vz;
        Float_t x;
        Float_t y;
        Float_t z;
};

struct hadron_part {
   Float_t e1;
   Float_t e2;
};

struct lumi_part{
   Float_t epos;
   Float_t eele;
   Float_t x;
   Float_t y;
        Float_t z;
};

struct beam1_part{
   Float_t e;
   Float_t tx;
   Float_t ty;
   //Float_t zrel;  //this is an optional value
   Float_t x;
   Float_t y;
};

struct beam2_part{
   Float_t e;
   Float_t tx;
   Float_t ty;
   //Float_t zrel;  //this is an optional value
   Float_t x;
   Float_t y;
};

struct photon_part{
   Float_t e;
   Float_t tx;
   Float_t ty;
};


//these structs are basically arrays of data types defined above, with size
struct pairs{
   pair_part parts[NMAXPART];
   Int_t npart;
};

struct hadrons{
   hadron_part parts[NMAXPART];
   Int_t npart;
};

struct lumis{
   lumi_part parts[NMAXPART];
   Int_t npart;
};

struct beams1{
   beam1_part parts[NMAXPART];
   Int_t npart;
};

struct beams2{
   beam2_part parts[NMAXPART];
   Int_t npart;
};

struct photons{
   photon_part parts[NMAXPART];
   Int_t npart;

};


class gpData {

 public:

   gpData();
   gpData(const Char_t *fileName, const Char_t *fileType);
   ~gpData();

   void initPointers();
   bool loadFile(const Char_t *fileName, const Char_t *fileType);


   Int_t numOfPcles(Char_t *type);

   bool getPcle(Int_t i, pair_part& myPart);
   bool getPcle(Int_t i, hadron_part& myPart);
   bool getPcle(Int_t i, lumi_part& myPart);
   bool getPcle(Int_t i, beam1_part& myPart);
   bool getPcle(Int_t i, beam2_part& myPart);
   bool getPcle(Int_t i, photon_part& myPart);

 private:
   //using pointers to avoid making large arrays in memory
   pairs* pairsptr;
   hadrons* hadronsptr;
   photons* photonsptr;
   beams1* beams1ptr;
   beams2* beams2ptr;
   lumis* lumisptr;

};