// -*- mode: C++ -*-
//
// Pibero Djawotho <pibero@indiana.edu>
// Indiana University
// Nov 18 2007
//

#ifndef ST_HEAVY_TRIGGER_MAKER_H
#define ST_HEAVY_TRIGGER_MAKER_H

// ROOT
class TH1;
class TH2;

// STAR
class StBemcTables;
class StEmcDecoder;
struct TrgDataType2005;

// Local
class StHeavyTrigger;

// STAR
#include "StMaker.h"

class StHeavyTriggerMaker : public StMaker {
public:
  StHeavyTriggerMaker(const char* name = "StHeavyTriggerMaker") : StMaker(name) {}
  ~StHeavyTriggerMaker() {}

  void Clear(Option_t* option = "");
  int InitRun(int runNumber);
  int Init();
  int Make();
  int FinishRun(int runNumber);
  int Finish();

  void printBemcTable(ostream& out);
  void printLocalBemcTable(ostream& out);

private:
  enum { NTOWERS = 4800, NPATCHES = 300 };

  // From event
  unsigned short mAdc[NTOWERS];

  // From database
  float mPedestal[NTOWERS];
  int mTowerStatus[NTOWERS];
  int mHighTowerStatus[NPATCHES];
  int mTriggerPatchStatus[NPATCHES];
  int mBitConvMode[NPATCHES];
  int mFormula[NPATCHES];
  int mParameters[NPATCHES][6];
  int mPedestalShift;

  // Computed in Make()
  int mHT[NPATCHES];
  int mTP[NPATCHES];
  int mNumberOfMaskedTowers[NPATCHES];

  TrgDataType2005* mTriggerData;

  StBemcTables* mBemcTables;
  StEmcDecoder* mEmcDecoder;

  StHeavyTrigger* mTrigger;

  TH1* mHighTowerFreq;
  TH1* mTriggerPatchFreq;

  TH2* mHighTowerCorr;
  TH2* mTriggerPatchCorr;

  TH2* mHighTowerAdc;
  TH2* mTriggerPatchAdc;

  ClassDef(StHeavyTriggerMaker, 1);
};

#endif
