#ifndef DTtTrigDBValidation_H
#define DTtTrigDBValidation_H

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"

#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "CondFormats/DTObjects/interface/DTTtrig.h"
#include "CondFormats/DataRecord/interface/DTTtrigRcd.h"
#include <fstream>
#include <string>
#include <vector>

// class DTTtrig;
class TFile;

class DTtTrigDBValidation : public DQMEDAnalyzer {
public:
  /// Constructor
  DTtTrigDBValidation(const edm::ParameterSet &pset);

  /// Destructor
  ~DTtTrigDBValidation() override;

  /// Operations
  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
  void analyze(const edm::Event &, const edm::EventSetup &) override;

private:
  // Switch for verbosity
  std::string metname_;
  // The DB label
  edm::ESGetToken<DTTtrig, DTTtrigRcd> labelDBRef_;
  edm::ESGetToken<DTTtrig, DTTtrigRcd> labelDB_;
  const DTTtrig *DTTtrigRefMap;
  const DTTtrig *DTTtrigMap;

  int lowerLimit_;
  int higherLimit_;

  // The DTGeometry
  edm::ESGetToken<DTGeometry, MuonGeometryRecord> muonGeomToken_;
  const DTGeometry *dtGeom;

  // Map of the tTrig and sigma by super-layer
  std::map<DTSuperLayerId, std::pair<float, float>> tTrigRefMap_;
  std::map<DTSuperLayerId, std::pair<float, float>> tTrigMap_;

  // Map of the tTrig difference histos by (wheel,sector)
  std::map<std::pair<int, int>, MonitorElement *> tTrigDiffHistos_;
  std::map<int, MonitorElement *> tTrigDiffWheel_;

  void bookHistos(DQMStore::IBooker &, int, int);
  void bookHistos(DQMStore::IBooker &, int wheel);
  // Compute the station from the bin number of mean and sigma histos
  int stationFromBin(int bin) const;
  // Compute the sl from the bin number of mean and sigma histos
  int slFromBin(int bin) const;
};
#endif
