// -*- C++ -*-

//
// Pibero Djawotho <pibero@indiana.edu>
// Indiana University
// 5 October 2006
//

#ifndef Event_h
#define Event_h

// ROOT
class TClonesArray;

// STAR
class StMuEvent;

// C++ STL
#include <set>
#include <iostream>

using namespace std;

// ROOT
#include "TDatime.h"
#include "TVector3.h"
#include "L2Result.h"

class Event : public TObject {
public:
  Event();
  Event(const Event& event);
  ~Event();

  void Clear(Option_t* option = "");
  int runId() const;
  int eventId() const;
  int refMult() const;
  float energy() const;
  TDatime& timeStamp();
  TVector3& vertex();
  float magneticField() const;
  set<int>& triggerIds();
  bool isTrigger(int id) const;
  unsigned int* L2Result();
  TClonesArray& tracks();
  TClonesArray& emcHits();
  TClonesArray& emcClusters();
  TClonesArray& ctbHits();
  TClonesArray& particles();
  TClonesArray& smdEtaHits();
  TClonesArray& smdPhiHits();
  TClonesArray& smdEtaClusters();
  TClonesArray& smdPhiClusters();

  void setEventInfo(StMuEvent* event);

  bool operator==(const Event& event) const;
  bool operator!=(const Event& event) const;
  friend ostream& operator<<(ostream& out, const Event& event);

private:
  int mRunId;
  int mEventId;
  int mRefMult;
  TDatime mTimeStamp;
  TVector3 mVertex;
  float mMagneticField;
  set<int> mTriggerIds;
  unsigned int mL2Result[64];
  TClonesArray* mTracks;	 //->
  TClonesArray* mEmcHits;	 //->
  TClonesArray* mEmcClusters;	 //->
  TClonesArray* mCtbHits;	 //->
  TClonesArray* mParticles;	 //->
  TClonesArray* mSmdEtaHits;     //->
  TClonesArray* mSmdPhiHits;     //->
  TClonesArray* mSmdEtaClusters; //->
  TClonesArray* mSmdPhiClusters; //->

  ClassDef(Event, 1);
};

inline int Event::runId() const { return mRunId; }
inline int Event::eventId() const { return mEventId; }
inline int Event::refMult() const { return mRefMult; }
inline TDatime& Event::timeStamp() { return mTimeStamp; }
inline TVector3& Event::vertex() { return mVertex; }
inline float Event::magneticField() const { return mMagneticField; }
inline set<int>& Event::triggerIds() { return mTriggerIds; }
inline bool Event::isTrigger(int id) const { return mTriggerIds.find(id) != mTriggerIds.end(); }
inline unsigned int* Event::L2Result() { return mL2Result; }
inline TClonesArray& Event::tracks() { return *mTracks; }
inline TClonesArray& Event::emcHits() { return *mEmcHits; }
inline TClonesArray& Event::emcClusters() { return *mEmcClusters; }
inline TClonesArray& Event::ctbHits() { return *mCtbHits; }
inline TClonesArray& Event::particles() { return *mParticles; }
inline TClonesArray& Event::smdEtaHits() { return *mSmdEtaHits; }
inline TClonesArray& Event::smdPhiHits() { return *mSmdPhiHits; }
inline TClonesArray& Event::smdEtaClusters() { return *mSmdEtaClusters; }
inline TClonesArray& Event::smdPhiClusters() { return *mSmdPhiClusters; }

inline bool Event::operator==(const Event& event) const { return mRunId == event.mRunId && mEventId == event.mEventId; }
inline bool Event::operator!=(const Event& event) const { return !(*this == event); }

#endif
