#ifndef ALICALOCALIBSIGNAL_H
#define ALICALOCALIBSIGNAL_H
#include "TString.h"
#include "TTree.h"
#include "AliEMCALGeoParams.h"
class AliCaloRawStreamV3;
class AliCaloAltroMapping;
class AliRawReader;
class AliCaloRawAnalyzer;
class AliCaloCalibSignal : public TObject {
public:
enum kDetType {kPhos, kEmCal, kNone};
AliCaloCalibSignal(kDetType detectorType = kPhos);
virtual ~AliCaloCalibSignal();
private:
AliCaloCalibSignal(const AliCaloCalibSignal & );
AliCaloCalibSignal& operator = (const AliCaloCalibSignal &);
public:
Bool_t ProcessEvent(AliRawReader *rawReader);
Bool_t ProcessEvent(AliCaloRawStreamV3 *in, UInt_t Timestamp);
Bool_t CheckFractionAboveAmp(const int *AmpVal, int resultArray[]) const;
Bool_t CheckLEDRefAboveAmp(const int *AmpVal, int resultArray[]) const;
AliCaloAltroMapping **GetAltroMapping() const { return fMapping; };
void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
Int_t GetFittingAlgorithm() const {return fFittingAlgorithm; }
void SetFittingAlgorithm(Int_t val) ;
AliCaloRawAnalyzer *GetRawAnalyzer() const { return fRawAnalyzer;}
void SetParametersFromFile(const char *parameterFile);
void WriteParametersToFile(const char *parameterFile);
TTree * GetTreeAmpVsTime() const { return fTreeAmpVsTime; }
TTree * GetTreeAvgAmpVsTime() const {return fTreeAvgAmpVsTime; }
TTree * GetTreeLEDAmpVsTime() const {return fTreeLEDAmpVsTime; }
TTree * GetTreeLEDAvgAmpVsTime() const {return fTreeLEDAvgAmpVsTime; }
int GetNHighGain(int imod, int icol, int irow) const
{ int towId = GetTowerNum(imod, icol, irow); return fNHighGain[towId];};
int GetNLowGain(int imod, int icol, int irow) const
{ int towId = GetTowerNum(imod, icol, irow); return fNLowGain[towId];};
int GetNHighGain(int towId) const { return fNHighGain[towId];};
int GetNLowGain(int towId) const { return fNLowGain[towId];};
int GetNRef(const int imod, const int istripMod, const int igain) const
{ int refId = GetRefNum(imod, istripMod, igain); return fNRef[refId];};
int GetNRef(int refId) const { return fNRef[refId];};
kDetType GetDetectorType() const {return fDetType;};
TString GetCaloString() const {return fCaloString;};
int GetColumns() const {return fColumns;};
int GetRows() const {return fRows;};
int GetLEDRefs() const {return fLEDRefs;};
int GetModules() const {return fModules;};
int GetTowerNum(const int imod, const int icol, const int irow) const { return (imod*fColumns*fRows + icol*fRows + irow);};
int GetChannelNum(const int imod, const int icol, const int irow, const int igain) const { return (igain*fModules*fColumns*fRows + imod*fColumns*fRows + icol*fRows + irow);};
Bool_t DecodeChannelNum(const int chanId,
int *imod, int *icol, int *irow, int *igain) const;
int GetRefNum(const int imod, const int istripMod, const int igain) const { return (igain*fModules*fLEDRefs + imod*fLEDRefs + istripMod);};
Bool_t DecodeRefNum(const int refId,
int *imod, int *istripMod, int *igain) const;
int GetNEvents() const {return fNEvents;};
int GetNAcceptedEvents() const {return fNAcceptedEvents;};
void SetAmpCut(double d) { fAmpCut = d; }
double GetAmpCut() const { return fAmpCut; };
void SetReqFractionAboveAmpCutVal(double d) { fReqFractionAboveAmpCutVal = d; }
double GetReqFractionAboveAmpCutVal() const { return fReqFractionAboveAmpCutVal; };
void SetReqFractionAboveAmp(bool b) { fReqFractionAboveAmp = b; }
bool GetReqFractionAboveAmp() const { return fReqFractionAboveAmp; };
void SetAmpCutLEDRef(double d) { fAmpCutLEDRef = d; }
double GetAmpCutLEDRef() const { return fAmpCutLEDRef; };
void SetReqLEDRefAboveAmpCutVal(bool b) { fReqLEDRefAboveAmpCutVal = b; }
bool GetReqLEDRefAboveAmpCutVal() const { return fReqLEDRefAboveAmpCutVal; };
void SetUseAverage(bool b) { fUseAverage = b; }
bool GetUseAverage() const { return fUseAverage; };
void SetSecInAverage(int secInAverage) {fSecInAverage = secInAverage;};
int GetSecInAverage() const {return fSecInAverage;};
void SetDownscale(int i) {fDownscale = i;};
int GetDownscale() const {return fDownscale;};
double GetHour() const { return fHour; };
double GetCurrentHour() const { return fHour; };
double GetLatestHour() const { return fLatestHour; };
void SetLatestHour(double d) { fLatestHour = d; };
void SetRunNumber(int runNo) {fRunNumber = runNo;};
int GetRunNumber() const {return fRunNumber;};
void SetStartTime(int startTime) {fStartTime = startTime;};
int GetStartTime() const {return fStartTime;};
void ResetInfo();
Bool_t AddInfo(const AliCaloCalibSignal *sig);
Bool_t Save(TString fileName);
Bool_t Analyze();
private:
void DeleteTrees();
void Zero();
void CreateTrees();
private:
kDetType fDetType;
int fColumns;
int fRows;
int fLEDRefs;
int fModules;
TString fCaloString;
AliCaloAltroMapping **fMapping;
Int_t fFittingAlgorithm;
AliCaloRawAnalyzer *fRawAnalyzer;
int fRunNumber;
int fStartTime;
double fAmpCut;
double fReqFractionAboveAmpCutVal;
bool fReqFractionAboveAmp;
double fAmpCutLEDRef;
bool fReqLEDRefAboveAmpCutVal;
double fHour;
double fLatestHour;
bool fUseAverage;
int fSecInAverage;
int fDownscale;
int fNEvents;
int fNAcceptedEvents;
static const int fgkPhosRows = 64;
static const int fgkPhosCols = 56;
static const int fgkPhosLEDRefs = 0;
static const int fgkPhosModules = 5;
static const int fgkMaxTowers = 17920;
static const int fgkMaxRefs = 288;
static const int fgkNumSecInHr = 3600;
TTree *fTreeAmpVsTime;
TTree *fTreeAvgAmpVsTime;
TTree *fTreeLEDAmpVsTime;
TTree *fTreeLEDAvgAmpVsTime;
int fNHighGain[fgkMaxTowers];
int fNLowGain[fgkMaxTowers];
int fNRef[fgkMaxRefs * 2];
ClassDef(AliCaloCalibSignal, 8)
};
#endif