// 
// Adapted from similar file in  Gismo 2
//  31 Mar 1999   J. Bogart  moved to Util (in libRootAppsUtil.so)

// define the HEPEVT commom
#ifndef LCDREADSTDFILE_H
#define LCDREADSTDFILE_H

//#include <assert.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* stdfilename, LCDEvent* event=0);
  // constructor that reads from an open stream
  ~LCDreadStdFile();

  Int_t GetEvent(LCDEvent* event=0);
  // creates structure with next event

  Int_t MakeMcPart(LCDEvent* event);
  // creates structure with current event

private:
  Char_t*   inputfile;  // stdHEP file from which we read
  Int_t     ierr;       // last IO status
  Int_t     istr;
  Bool_t     m_ownevent;

  Int_t readEvent();
  // fill the common from input file. failed if n()==0

public:
  ClassDef(LCDreadStdFile,0) // Make McPart objects from info in stdHEP file

};

#endif

