// 
// Adapted from similar file in  Gismo 2

// define the HEPEVT commom
#ifndef LCDREADSTDFILE_H
#define LCDREADSTDFILE_H

#include <assert.h>
#include "TObjArray.h"
#include "TMap.h"
#include "LCDEvent.h"
#include "LCDMcPart.h"
#include "LCDEventSource.h"

extern "C"{
#include "stdhep.h"

Double_t partchg( Int_t );
  
Int_t StdHepXdrReadInit(char*, Int_t, Int_t);
Int_t StdHepXdrReadOpen(char*, Int_t, Int_t);
Int_t StdHepXdrRead(Int_t*, Int_t);
Int_t StdHepXdrReadMulti(Int_t*, Int_t);
Int_t StdHepXdrWriteInit(char*, char*, Int_t, Int_t);
Int_t StdHepXdrWriteOpen(char*, char*, Int_t, Int_t);
Int_t StdHepXdrWrite(Int_t, Int_t);
Int_t StdHepXdrWriteCM(Int_t, Int_t);
Int_t StdHepXdrWriteEvent(Int_t, Int_t);
void  StdHepXdrEnd(Int_t);
void  StdHepZero(void);
  
#include "stdlun.h"
#include "stdcnt.h"
}



class LCDreadStdFile : public LCDEventSource
{
public:

  LCDreadStdFile():istr(0){};
  LCDreadStdFile(Char_t*);
  // constructor that reads from an open stream

  ~LCDreadStdFile();

  Int_t GetEvent(LCDEvent* event);
  // creates structure with next event

  Int_t MakeMcPart(LCDEvent* event);
  // creates structure with current event

private:

  Int_t readEvent();
  // fill the common from input file. failed if n()==0

  ClassDef(LCDreadStdFile,0) // Make McPart objects from info in stdHEP file

private:

  LCDEvent* m_event;    // current event
  Char_t* inputfile; // stdHEP file from which we read
  Int_t ierr;        // last IO status
  Int_t istr;
};

#endif

