ROOT logo
#ifndef ALIPHOSTrigger_H
#define ALIPHOSTrigger_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

//____________________________________________________________
//  Class for trigger analysis.
//
//  -- Author: Gustavo Conesa & Yves Schutz (IFIC, SUBATECH, CERN)
//  Digits are grouped in TRU's (Trigger Units). A TRU consist of 16x28 
//  crystals ordered fNTRUPhi x fNTRUZ matrix. The algorithm searches all possible 
//  2x2 and nxn (n multiple of 4) crystal combinations per each TRU, adding the 
//  digits amplitude and  finding the maximum. Iti is found is maximum is isolated.
//  Maxima are transformed in ADC time samples. Each time bin is compared to the trigger 
//  threshold until it is larger and then, triggers are set. Thresholds need to be fixed. 
//  Usage:
//
//  //Inside the event loop
//  AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
//  tr->SetL0Threshold(100);
//  tr->SetL1JetLowPtThreshold(1000);
//  tr->SetL1JetMediumPtThreshold(10000);
//  tr->SetL1JetHighPtThreshold(20000);
//  ....
//  tr->Trigger(); //Execute Trigger
//  tr->Print(""); //Print data members after calculation.
//     
// --- ROOT system ---

class TClonesArray ;
#include "TMatrixD.h"

// --- AliRoot header files ---
#include "AliTriggerDetector.h"

class AliPHOSGeometry ;

class AliPHOSTrigger : public AliTriggerDetector {
  
 public: 
  
  AliPHOSTrigger() ; //  ctor
  AliPHOSTrigger(const AliPHOSTrigger & trig) ; // cpy ctor
  virtual ~AliPHOSTrigger();

  virtual void    CreateInputs(); //Define trigger inputs for Central Trigger Processor
  void            Print(const Option_t * opt ="") const ;  
  virtual void    Trigger() {}                   //Make PHOS trigger
  void            Trigger(TClonesArray *digits); //Make PHOS trigger

  //Getters
  Float_t  Get2x2MaxAmplitude()  const {return f2x2MaxAmp ; }
  Float_t  GetnxnMaxAmplitude()  const {return fnxnMaxAmp ; }
  Int_t    Get2x2CrystalPhi()    const {return f2x2CrystalPhi ; }
  Int_t    GetnxnCrystalPhi()    const {return fnxnCrystalPhi ; }
  Int_t    Get2x2CrystalEta()    const {return f2x2CrystalEta ; }
  Int_t    GetnxnCrystalEta()    const {return fnxnCrystalEta ; }
  Int_t    Get2x2SuperModule()   const {return f2x2SM ; }
  Int_t    GetnxnSuperModule()   const {return fnxnSM ; }

  Int_t *  GetADCValuesLowGainMax2x2Sum()  {return fADCValuesLow2x2; }
  Int_t *  GetADCValuesHighGainMax2x2Sum() {return fADCValuesHigh2x2; }
  Int_t *  GetADCValuesLowGainMaxnxnSum()  {return fADCValuesLownxn; }
  Int_t *  GetADCValuesHighGainMaxnxnSum() {return fADCValuesHighnxn; }

  void     GetCrystalPhiEtaIndexInModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru,Int_t &ietaMod,Int_t &iphiMod) const ;

  Float_t  GetL0Threshold()            const {return fL0Threshold ; } 
  Float_t  GetL1JetLowPtThreshold()    const {return fL1JetLowPtThreshold ; }
  Float_t  GetL1JetMediumPtThreshold() const {return fL1JetMediumPtThreshold ; }
  Float_t  GetL1JetHighPtThreshold()   const {return fL1JetHighPtThreshold ; }

  Int_t    GetNTRU()                   const {return fNTRU ; }
  Int_t    GetNTRUZ()                  const {return fNTRUZ ; }
  Int_t    GetNTRUPhi()                const {return fNTRUPhi ; }
  
  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   IsIsolatedInModule()        const {return fIsolateInModule ; }

  //Setters
  void     SetDigitsList(TClonesArray * digits)          
   {fDigitsList  = digits ; }

  void     SetNTRU(Int_t ntru)             {fNTRU     = ntru ; }
  void     SetNTRUZ(Int_t ntru)            {fNTRUZ    = ntru ; }
  void     SetNTRUPhi(Int_t ntru)          {fNTRUPhi  = ntru ; } 

  void     SetL0Threshold(Int_t amp)         
    {fL0Threshold          = amp ; }
  void     SetL1JetLowPtThreshold(Int_t amp) 
    {fL1JetLowPtThreshold  = amp ; } 
  void     SetL1JetMediumPtThreshold(Int_t amp) 
    {fL1JetMediumPtThreshold = amp; } 
  void     SetL1JetHighPtThreshold(Int_t amp)
    {fL1JetHighPtThreshold = 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 SetIsolateInModule(Bool_t isol )     { fIsolateInModule = isol ; }

 private:

  AliPHOSTrigger & operator = (const AliPHOSTrigger & trig) ;//cpy assignment

  void FillTRU(const TClonesArray * digits, const AliPHOSGeometry * geom) const ;

  Bool_t IsPatchIsolated(Int_t iPatchType, const Int_t imod, const Int_t mtru, const Float_t maxamp, const Int_t maxphi, const Int_t maxeta) ;

  void MakeSlidingCell(Int_t mod, TMatrixD &ampmax2, TMatrixD &ampmaxn) ;

  void SetTriggers(Int_t iMod, const TMatrixD &ampmax2,const TMatrixD &ampmaxn) ;

  void DoIt() ; 
 
 private: 

  Float_t f2x2MaxAmp ;     //! Maximum 2x2 added amplitude (not overlapped) 
  Int_t   f2x2CrystalPhi ; //! upper right cell, row(phi)   
  Int_t   f2x2CrystalEta ; //! and column(eta) 
  Int_t   f2x2SM ;         //! Module where maximum is found
  Float_t fnxnMaxAmp ;     //! Maximum nxn added amplitude (overlapped)
  Int_t   fnxnCrystalPhi ; //! upper right cell, row(phi)   
  Int_t   fnxnCrystalEta ; //! and column(eta)
  Int_t   fnxnSM ;         //! Module where maximum is found

  Int_t*   fADCValuesHighnxn ; //! Sampled ADC high gain values for the nxn crystals amplitude sum
  Int_t*   fADCValuesLownxn  ; //! " low gain  " 
  Int_t*   fADCValuesHigh2x2 ; //! " high gain " 2x2 "
  Int_t*   fADCValuesLow2x2  ; //! " low gaing " "

  TClonesArray* fDigitsList ;  //  Array of digits 
  TClonesArray* fAmptrus    ;  //! Array of matrices with amplitudes per TRU
  TClonesArray* fAmpmods    ;  //! Array of matrices with amplitudes per module
  TClonesArray* fTimeRtrus  ;  //! Array of matrices with time
  
 
  Float_t fL0Threshold ;             //! L0 trigger energy threshold
  Float_t fL1JetLowPtThreshold ;     //! L1 Low  pT trigger threshold
  Float_t fL1JetMediumPtThreshold ;  //! L1 Medium  pT trigger threshold
  Float_t fL1JetHighPtThreshold ;    //! L1 High pT trigger threshold

  Int_t   fNTRU ;                //! Number of TRUs per module
  Int_t   fNTRUZ ;               //! Number of crystal rows per Z in one TRU
  Int_t   fNTRUPhi ;             //! Number of crystal rows per Phi in one TRU
  Int_t   fNCrystalsPhi;         //! Number of rows in a TRU
  Int_t   fNCrystalsZ;           //! Number of columns in a TRU
  
  Int_t fPatchSize;              //! Trigger patch factor, to be multiplied to 2x2 cells
                                 //  0 means 2x2, 1 means 4x4, 2 means 6x6 ...
  Int_t fIsolPatchSize ;         //  Isolation patch size, number of rows or columns to add to 
                                 //  the 2x2 or nxn maximum amplitude patch. 
                                 //  1 means a patch around max amplitude of 2x2 of 4x4 and around         
                                 //  max ampl patch of 4x4 of 8x8 
    
  Float_t f2x2AmpOutOfPatch;      // Amplitude in isolation cone minus maximum amplitude of the reference patch
  Float_t fnxnAmpOutOfPatch; 
  Float_t f2x2AmpOutOfPatchThres; // Threshold to select a trigger as isolated on f2x2AmpOutOfPatch value
  Float_t fnxnAmpOutOfPatchThres; 
  Float_t fIs2x2Isol;             //Patch is isolated if f2x2AmpOutOfPatchThres threshold is passed
  Float_t fIsnxnIsol ; 
  
  Bool_t  fSimulation ;           //! Flag to do the trigger during simulation or reconstruction
  Bool_t  fIsolateInModule;       //! Flag to isolate trigger patch in Module or in TRU acceptance

  ClassDef(AliPHOSTrigger,5)
} ;


#endif //ALIPHOSTrigger_H
 AliPHOSTrigger.h:1
 AliPHOSTrigger.h:2
 AliPHOSTrigger.h:3
 AliPHOSTrigger.h:4
 AliPHOSTrigger.h:5
 AliPHOSTrigger.h:6
 AliPHOSTrigger.h:7
 AliPHOSTrigger.h:8
 AliPHOSTrigger.h:9
 AliPHOSTrigger.h:10
 AliPHOSTrigger.h:11
 AliPHOSTrigger.h:12
 AliPHOSTrigger.h:13
 AliPHOSTrigger.h:14
 AliPHOSTrigger.h:15
 AliPHOSTrigger.h:16
 AliPHOSTrigger.h:17
 AliPHOSTrigger.h:18
 AliPHOSTrigger.h:19
 AliPHOSTrigger.h:20
 AliPHOSTrigger.h:21
 AliPHOSTrigger.h:22
 AliPHOSTrigger.h:23
 AliPHOSTrigger.h:24
 AliPHOSTrigger.h:25
 AliPHOSTrigger.h:26
 AliPHOSTrigger.h:27
 AliPHOSTrigger.h:28
 AliPHOSTrigger.h:29
 AliPHOSTrigger.h:30
 AliPHOSTrigger.h:31
 AliPHOSTrigger.h:32
 AliPHOSTrigger.h:33
 AliPHOSTrigger.h:34
 AliPHOSTrigger.h:35
 AliPHOSTrigger.h:36
 AliPHOSTrigger.h:37
 AliPHOSTrigger.h:38
 AliPHOSTrigger.h:39
 AliPHOSTrigger.h:40
 AliPHOSTrigger.h:41
 AliPHOSTrigger.h:42
 AliPHOSTrigger.h:43
 AliPHOSTrigger.h:44
 AliPHOSTrigger.h:45
 AliPHOSTrigger.h:46
 AliPHOSTrigger.h:47
 AliPHOSTrigger.h:48
 AliPHOSTrigger.h:49
 AliPHOSTrigger.h:50
 AliPHOSTrigger.h:51
 AliPHOSTrigger.h:52
 AliPHOSTrigger.h:53
 AliPHOSTrigger.h:54
 AliPHOSTrigger.h:55
 AliPHOSTrigger.h:56
 AliPHOSTrigger.h:57
 AliPHOSTrigger.h:58
 AliPHOSTrigger.h:59
 AliPHOSTrigger.h:60
 AliPHOSTrigger.h:61
 AliPHOSTrigger.h:62
 AliPHOSTrigger.h:63
 AliPHOSTrigger.h:64
 AliPHOSTrigger.h:65
 AliPHOSTrigger.h:66
 AliPHOSTrigger.h:67
 AliPHOSTrigger.h:68
 AliPHOSTrigger.h:69
 AliPHOSTrigger.h:70
 AliPHOSTrigger.h:71
 AliPHOSTrigger.h:72
 AliPHOSTrigger.h:73
 AliPHOSTrigger.h:74
 AliPHOSTrigger.h:75
 AliPHOSTrigger.h:76
 AliPHOSTrigger.h:77
 AliPHOSTrigger.h:78
 AliPHOSTrigger.h:79
 AliPHOSTrigger.h:80
 AliPHOSTrigger.h:81
 AliPHOSTrigger.h:82
 AliPHOSTrigger.h:83
 AliPHOSTrigger.h:84
 AliPHOSTrigger.h:85
 AliPHOSTrigger.h:86
 AliPHOSTrigger.h:87
 AliPHOSTrigger.h:88
 AliPHOSTrigger.h:89
 AliPHOSTrigger.h:90
 AliPHOSTrigger.h:91
 AliPHOSTrigger.h:92
 AliPHOSTrigger.h:93
 AliPHOSTrigger.h:94
 AliPHOSTrigger.h:95
 AliPHOSTrigger.h:96
 AliPHOSTrigger.h:97
 AliPHOSTrigger.h:98
 AliPHOSTrigger.h:99
 AliPHOSTrigger.h:100
 AliPHOSTrigger.h:101
 AliPHOSTrigger.h:102
 AliPHOSTrigger.h:103
 AliPHOSTrigger.h:104
 AliPHOSTrigger.h:105
 AliPHOSTrigger.h:106
 AliPHOSTrigger.h:107
 AliPHOSTrigger.h:108
 AliPHOSTrigger.h:109
 AliPHOSTrigger.h:110
 AliPHOSTrigger.h:111
 AliPHOSTrigger.h:112
 AliPHOSTrigger.h:113
 AliPHOSTrigger.h:114
 AliPHOSTrigger.h:115
 AliPHOSTrigger.h:116
 AliPHOSTrigger.h:117
 AliPHOSTrigger.h:118
 AliPHOSTrigger.h:119
 AliPHOSTrigger.h:120
 AliPHOSTrigger.h:121
 AliPHOSTrigger.h:122
 AliPHOSTrigger.h:123
 AliPHOSTrigger.h:124
 AliPHOSTrigger.h:125
 AliPHOSTrigger.h:126
 AliPHOSTrigger.h:127
 AliPHOSTrigger.h:128
 AliPHOSTrigger.h:129
 AliPHOSTrigger.h:130
 AliPHOSTrigger.h:131
 AliPHOSTrigger.h:132
 AliPHOSTrigger.h:133
 AliPHOSTrigger.h:134
 AliPHOSTrigger.h:135
 AliPHOSTrigger.h:136
 AliPHOSTrigger.h:137
 AliPHOSTrigger.h:138
 AliPHOSTrigger.h:139
 AliPHOSTrigger.h:140
 AliPHOSTrigger.h:141
 AliPHOSTrigger.h:142
 AliPHOSTrigger.h:143
 AliPHOSTrigger.h:144
 AliPHOSTrigger.h:145
 AliPHOSTrigger.h:146
 AliPHOSTrigger.h:147
 AliPHOSTrigger.h:148
 AliPHOSTrigger.h:149
 AliPHOSTrigger.h:150
 AliPHOSTrigger.h:151
 AliPHOSTrigger.h:152
 AliPHOSTrigger.h:153
 AliPHOSTrigger.h:154
 AliPHOSTrigger.h:155
 AliPHOSTrigger.h:156
 AliPHOSTrigger.h:157
 AliPHOSTrigger.h:158
 AliPHOSTrigger.h:159
 AliPHOSTrigger.h:160
 AliPHOSTrigger.h:161
 AliPHOSTrigger.h:162
 AliPHOSTrigger.h:163
 AliPHOSTrigger.h:164
 AliPHOSTrigger.h:165
 AliPHOSTrigger.h:166
 AliPHOSTrigger.h:167
 AliPHOSTrigger.h:168
 AliPHOSTrigger.h:169
 AliPHOSTrigger.h:170
 AliPHOSTrigger.h:171
 AliPHOSTrigger.h:172
 AliPHOSTrigger.h:173
 AliPHOSTrigger.h:174
 AliPHOSTrigger.h:175
 AliPHOSTrigger.h:176
 AliPHOSTrigger.h:177
 AliPHOSTrigger.h:178
 AliPHOSTrigger.h:179
 AliPHOSTrigger.h:180
 AliPHOSTrigger.h:181
 AliPHOSTrigger.h:182
 AliPHOSTrigger.h:183
 AliPHOSTrigger.h:184
 AliPHOSTrigger.h:185