#ifndef WireTrackingManager_h
#define WireTrackingManager_h 1

#include "G4ThreeVector.hh"

#include <unordered_map>

class G4Step;
class G4Track;
class G4StepPoint;

struct WireCrossingInfo
{
  int anodeId = -1;
  int cathodeId = -1;
  double anodeEnergy = 0.0;
  double cathodeEnergy = 0.0;
  double deltaE = 0.0;
  bool sawAnode = false;
  bool sawCathode = false;
};

class WireTrackingManager
{
  public:
    static WireTrackingManager& Instance();

    void UpdateForStep(const G4Step* step);
    bool GetInfo(int eventId, int trackId, WireCrossingInfo& info);
    WireCrossingInfo InferFromTrackGeometry(const G4Track* track, const G4StepPoint* hitPoint);

  private:
    WireTrackingManager();
    ~WireTrackingManager();

    WireTrackingManager(const WireTrackingManager&) = delete;
    WireTrackingManager& operator=(const WireTrackingManager&) = delete;

    void EnsureEvent(int eventId);

    int fCurrentEventId;
    std::unordered_map<int, WireCrossingInfo> fTrackInfo;
};

#endif
