#ifndef Fireworks_Core_Context_h
#define Fireworks_Core_Context_h
// -*- C++ -*-
//
// Package:     Core
// Class  :     Context
//
/**\class Context Context.h Fireworks/Core/interface/Context.h

   Description: Central collection of all framework managers

   Usage:
    <usage>

 */
//
// Original Author:  Chris Jones
//         Created:  Tue Sep 30 14:21:45 EDT 2008
//

// system include files

// user include files

// forward declarations
class TEveTrackPropagator;
class TEveCaloDataHist;
class TEveCaloDataVec;

class FWModelChangeManager;
class FWSelectionManager;
class FWEventItemsManager;
class FWColorManager;
class FWJobMetadataManager;
class FWMagField;
class FWGeometry;
class FWBeamSpot;
class CmsShowCommon;

namespace fireworks {
  class Context {
  public:
    Context(FWModelChangeManager* iCM,
            FWSelectionManager* iSM,
            FWEventItemsManager* iEM,
            FWColorManager* iColorM,
            FWJobMetadataManager* iJMDM);
    virtual ~Context();

    void setGeom(FWGeometry* x) { m_geom = x; }

    // ---------- const member functions ---------------------
    FWModelChangeManager* modelChangeManager() const { return m_changeManager; }
    FWSelectionManager* selectionManager() const { return m_selectionManager; }

    const FWEventItemsManager* eventItemsManager() const { return m_eventItemsManager; }

    FWColorManager* colorManager() const { return m_colorManager; }

    FWJobMetadataManager* metadataManager() const { return m_metadataManager; }

    TEveTrackPropagator* getTrackPropagator() const { return m_propagator; }
    TEveTrackPropagator* getTrackerTrackPropagator() const { return m_trackerPropagator; }
    TEveTrackPropagator* getMuonTrackPropagator() const { return m_muonPropagator; }

    FWMagField* getField() const { return m_magField; }
    FWBeamSpot* getBeamSpot() const { return m_beamSpot; }

    TEveCaloDataHist* getCaloData() const { return m_caloData; }
    TEveCaloDataVec* getCaloDataHF() const { return m_caloDataHF; }

    FWGeometry* getGeom() const { return m_geom; }

    CmsShowCommon* commonPrefs() const;

    float getMaxEnergyInEvent(bool isEt) const;
    void voteMaxEtAndEnergy(float Et, float energy) const;
    void resetMaxEtAndEnergy() const;

    bool getHidePFBuilders() const { return m_hidePFBuilders; }
    void setHidePFBuilders(bool x) { m_hidePFBuilders = x; }

    // ---------- member functions ---------------------------

    void initEveElements();
    void deleteEveElements();

    // ---------- static member  ---------------------------

    static Context* getInstance();

    static float caloR1(bool offset = true);
    static float caloR2(bool offset = true);
    static float caloZ1(bool offset = true);
    static float caloZ2(bool offset = true);

    static float caloTransEta();
    static float caloTransAngle();
    static double caloMaxEta();

    static float mtdEtlR1();
    static float mtdEtlR2();
    static float mtdEtlZ1(const unsigned int& disk_number = 1);
    static float mtdEtlZ2(const unsigned int& disk_number = 1);

    Context(const Context&) = delete;                   // stop default
    const Context& operator=(const Context&) = delete;  // stop default
  private:
    // ---------- member data --------------------------------
    FWModelChangeManager* m_changeManager;
    FWSelectionManager* m_selectionManager;
    FWEventItemsManager* m_eventItemsManager;
    FWColorManager* m_colorManager;
    FWJobMetadataManager* m_metadataManager;

    FWGeometry* m_geom;

    TEveTrackPropagator* m_propagator;
    TEveTrackPropagator* m_trackerPropagator;
    TEveTrackPropagator* m_muonPropagator;

    FWMagField* m_magField;
    FWBeamSpot* m_beamSpot;

    CmsShowCommon* m_commonPrefs;

    mutable float m_maxEt;
    mutable float m_maxEnergy;

    mutable bool m_hidePFBuilders;

    TEveCaloDataHist* m_caloData;
    TEveCaloDataVec* m_caloDataHF;

    static Context* s_fwContext;

    // calo data
    static const float s_caloTransEta;
    static const float s_caloTransAngle;
    // simplified
    static const float s_caloR;
    static const float s_caloZ;

    // proxy-builder offsets
    static const float s_caloOffR;
    static const float s_caloOffZ;

    // mtd data
    static const float s_mtdEtlR1;
    static const float s_mtdEtlR2;
    static const float s_mtdEtlZ1;
    static const float s_mtdEtlZ2;
    static const float s_mtdEtlOffZ;
  };
}  // namespace fireworks

#endif
