#ifndef ALIEMCALTRIGGER_H
#define ALIEMCALTRIGGER_H
class TClonesArray ;
class TTree;
#include <TMatrixD.h>
#include <TArrayF.h>
#include "AliTriggerDetector.h"
class TBrowser;
class AliEMCALGeometry ;
class TH2F;
class AliEMCALTrigger : public AliTriggerDetector {
public:
AliEMCALTrigger() ;
virtual ~AliEMCALTrigger();
virtual void CreateInputs();
void Print(const Option_t * opt ="") const ;
virtual void Trigger();
Float_t Get2x2MaxAmplitude() const { return f2x2MaxAmp ; }
Float_t GetnxnMaxAmplitude() const { return fnxnMaxAmp ; }
Int_t Get2x2ModulePhi() const { return f2x2ModulePhi ; }
Int_t GetnxnModulePhi() const { return fnxnModulePhi ; }
Int_t Get2x2ModuleEta() const { return f2x2ModuleEta ; }
Int_t GetnxnModuleEta() const { return fnxnModuleEta ; }
Int_t Get2x2SuperModule() const { return f2x2SM ; }
Int_t GetnxnSuperModule() const { return fnxnSM ; }
Int_t * GetADCValuesLowGainMax2x2Sum() const { return fADCValuesLow2x2; }
Int_t * GetADCValuesHighGainMax2x2Sum() const { return fADCValuesHigh2x2; }
Int_t * GetADCValuesLowGainMaxnxnSum() const { return fADCValuesLownxn; }
Int_t * GetADCValuesHighGainMaxnxnSum() const { return fADCValuesHighnxn; }
Float_t GetL0Threshold() const { return fL0Threshold ; }
Float_t GetL1GammaLowPtThreshold() const { return fL1GammaLowPtThreshold ; }
Float_t GetL1GammaMediumPtThreshold() const { return fL1GammaMediumPtThreshold ; }
Float_t GetL1GammaHighPtThreshold() const { return fL1GammaHighPtThreshold ; }
Int_t GetPatchSize() const { return fPatchSize ; }
Int_t GetIsolPatchSize() const { return fIsolPatchSize ; }
Float_t Get2x2AmpOutOfPatch() const { return f2x2AmpOutOfPatch ; }
Float_t GetnxnAmpOutOfPatch() const { return fnxnAmpOutOfPatch ; }
Float_t Get2x2AmpOutOfPatchThres() const { return f2x2AmpOutOfPatchThres ; }
Float_t GetnxnAmpOutOfPatchThres() const { return fnxnAmpOutOfPatchThres ; }
Bool_t Is2x2Isol() const { return fIs2x2Isol ; }
Bool_t IsnxnIsol() const { return fIsnxnIsol ; }
Bool_t IsSimulation() const { return fSimulation ; }
Bool_t IsIsolatedInSuperModule() const { return fIsolateInSuperModule ; }
Bool_t GetTimeKey() const { return fTimeKey;}
TH2F* GetJetMatrixE() const { return fJetMatrixE;}
Double_t GetEmcalSumAmp() const;
Int_t GetNJetThreshold() const {return fNJetThreshold;}
Double_t* GetL1JetThresholds() const {return fL1JetThreshold;}
TMatrixD GetAmpJetMax() const {return fAmpJetMax;}
void PrintJetMatrix() const;
void PrintAmpTruMatrix(Int_t ind) const;
void PrintAmpSmMatrix(Int_t ind) const;
void PrintMatrix(const TMatrixD &mat) const;
Bool_t CheckConsistentOfMatrixes(const Int_t pri=0);
void SetDigitsList(TClonesArray * digits)
{fDigitsList = digits ; }
void SetL0Threshold(Int_t amp)
{fL0Threshold = amp; }
void SetL1GammaLowPtThreshold(Int_t amp)
{fL1GammaLowPtThreshold = amp; }
void SetL1GammaMediumPtThreshold(Int_t amp)
{fL1GammaMediumPtThreshold = amp; }
void SetL1GammaHighPtThreshold(Int_t amp)
{fL1GammaHighPtThreshold = amp; }
void SetPatchSize(Int_t ps) {fPatchSize = ps ; }
void SetIsolPatchSize(Int_t ps) {fIsolPatchSize = ps ; }
void Set2x2AmpOutOfPatchThres(Float_t th) { f2x2AmpOutOfPatchThres = th; }
void SetnxnAmpOutOfPatchThres(Float_t th) { fnxnAmpOutOfPatchThres = th; }
void SetSimulation(Bool_t sim ) {fSimulation = sim ; }
void SetIsolateInSuperModule(Bool_t isol ) {fIsolateInSuperModule = isol ; }
void SetTimeKey(Bool_t timeKey) {fTimeKey = timeKey;}
void SetJetPatchSize(const Int_t patchSize) {fNJetPatchPhi = fNJetPatchEta = patchSize;}
void SetJetParameters(const Int_t patchSize, Double_t* jetThreshold)
{
fNJetPatchPhi = fNJetPatchEta = patchSize;
fL1JetThreshold = jetThreshold;
}
void SetVZER0Multiplicity(Double_t mult) {fVZER0Mult = mult;}
virtual void Browse(TBrowser* b);
virtual Bool_t IsFolder() const {return kTRUE;}
Char_t* GetNameOfJetTrigger(const Int_t i) {return Form("%s_Th_%2.2i",fgNameOfJetTriggers.Data(),i);}
static TString GetNameOfJetTriggers() {return fgNameOfJetTriggers;}
static TString fgNameOfJetTriggers;
static Double_t GetMeanEmcalEnergy(const Int_t mult) {return 2.52248e-02*Double_t(mult);}
static Double_t GetMeanEmcalPatchEnergy(const Int_t mult, Int_t patchSize)
{return GetMeanEmcalEnergy(mult)*Double_t(patchSize)*Double_t(patchSize)/208.;}
private:
void FillTRU(const TClonesArray * digits, TClonesArray * ampmatrix, TClonesArray * ampmatrixsmod, TClonesArray * timeRmatrix);
Bool_t IsPatchIsolated(Int_t iPatchType, const TClonesArray * ampmods, const Int_t imod, const Int_t mtru, const Float_t maxamp, const Int_t maxphi, const Int_t maxeta) ;
void MakeSlidingTowers(const TClonesArray * amptrus, const TClonesArray * timeRtrus,
const Int_t supermod, TMatrixD &max2, TMatrixD &maxn) ;
void SetTriggers(const TClonesArray * amptrus,const Int_t iSM, const TMatrixD &max2, const TMatrixD &maxn) ;
void GetTriggerInfo(TArrayF &triggerPosition, TArrayF &triggerAmplitudes) const;
void FillJetMatrixFromSMs(TClonesArray *ampmatrixsmod, TMatrixD * const jetMat, AliEMCALGeometry * const g);
void MakeSlidingPatch(const TMatrixD &jm, const Int_t nPatchSize, TMatrixD &JetMax);
private:
AliEMCALGeometry *fGeom;
Float_t f2x2MaxAmp ;
Int_t f2x2ModulePhi ;
Int_t f2x2ModuleEta ;
Int_t f2x2SM ;
Float_t fnxnMaxAmp ;
Int_t fnxnModulePhi ;
Int_t fnxnModuleEta ;
Int_t fnxnSM ;
Int_t* fADCValuesHighnxn ;
Int_t* fADCValuesLownxn ;
Int_t* fADCValuesHigh2x2 ;
Int_t* fADCValuesLow2x2 ;
TClonesArray* fDigitsList;
Float_t fL0Threshold ;
Float_t fL1GammaLowPtThreshold ;
Float_t fL1GammaMediumPtThreshold ;
Float_t fL1GammaHighPtThreshold ;
Int_t fPatchSize;
Int_t fIsolPatchSize ;
Float_t f2x2AmpOutOfPatch;
Float_t fnxnAmpOutOfPatch;
Float_t f2x2AmpOutOfPatchThres;
Float_t fnxnAmpOutOfPatchThres;
Float_t fIs2x2Isol;
Float_t fIsnxnIsol ;
Bool_t fSimulation ;
Bool_t fIsolateInSuperModule;
Bool_t fTimeKey;
TClonesArray *fAmpTrus;
TClonesArray *fTimeRtrus;
TClonesArray *fAmpSMods;
TArrayF fTriggerPosition;
TArrayF fTriggerAmplitudes;
Int_t fNJetPatchPhi;
Int_t fNJetPatchEta;
Int_t fNJetThreshold;
Double_t *fL1JetThreshold;
Double_t fJetMaxAmp;
TMatrixD* fAmpJetMatrix;
TH2F* fJetMatrixE;
TMatrixD fAmpJetMax;
Double_t fVZER0Mult;
const AliEMCALTrigger & operator = (const AliEMCALTrigger & ) ;
AliEMCALTrigger(const AliEMCALTrigger & trig) ;
ClassDef(AliEMCALTrigger, 2)
} ;
#endif //ALIEMCALTRIGGER_H