]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSTrigger.h
Bug fix
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrigger.h
1 #ifndef ALIPHOSTrigger_H
2 #define ALIPHOSTrigger_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //____________________________________________________________
9 //  Class for trigger analysis.
10 //
11 //  -- Author: Gustavo Conesa & Yves Schutz (IFIC, SUBATECH, CERN)
12 //  Digits are grouped in TRU's (Trigger Units). A TRU consist of 16x28 
13 //  crystals ordered fNTRUPhi x fNTRUZ matrix. The algorithm searches all possible 
14 //  2x2 and nxn (n multiple of 4) crystal combinations per each TRU, adding the 
15 //  digits amplitude and  finding the maximum. Iti is found is maximum is isolated.
16 //  Maxima are transformed in ADC time samples. Each time bin is compared to the trigger 
17 //  threshold until it is larger and then, triggers are set. Thresholds need to be fixed. 
18 //  Usage:
19 //
20 //  //Inside the event loop
21 //  AliEMCALTrigger *tr = new AliEMCALTrigger();//Init Trigger
22 //  tr->SetL0Threshold(100);
23 //  tr->SetL1JetLowPtThreshold(1000);
24 //  tr->SetL1JetMediumPtThreshold(10000);
25 //  tr->SetL1JetHighPtThreshold(20000);
26 //  ....
27 //  tr->Trigger(); //Execute Trigger
28 //  tr->Print(""); //Print data members after calculation.
29 //     
30 // --- ROOT system ---
31
32 class TClonesArray ;
33 #include "TMatrixD.h"
34
35 // --- AliRoot header files ---
36 #include "AliTriggerDetector.h"
37
38 class AliPHOSGeometry ;
39
40 class AliPHOSTrigger : public AliTriggerDetector {
41   
42  public: 
43   
44   AliPHOSTrigger() ; //  ctor
45   AliPHOSTrigger(const AliPHOSTrigger & trig) ; // cpy ctor
46   virtual ~AliPHOSTrigger(){}; //virtual dtor
47
48
49   virtual void    CreateInputs(); //Define trigger inputs for Central Trigger Processor
50   void            Print(const Option_t * opt ="") const ;  
51   virtual void    Trigger();  //Make PHOS trigger
52   void    Trigger(const char * fileName);  //Make PHOS trigger
53
54   //Getters
55   Float_t  Get2x2MaxAmplitude()  const {return f2x2MaxAmp ; }
56   Float_t  GetnxnMaxAmplitude()  const {return fnxnMaxAmp ; }
57   Int_t    Get2x2CrystalPhi()    const {return f2x2CrystalPhi ; }
58   Int_t    GetnxnCrystalPhi()    const {return fnxnCrystalPhi ; }
59   Int_t    Get2x2CrystalEta()    const {return f2x2CrystalEta ; }
60   Int_t    GetnxnCrystalEta()    const {return fnxnCrystalEta ; }
61   Int_t    Get2x2SuperModule()   const {return f2x2SM ; }
62   Int_t    GetnxnSuperModule()   const {return fnxnSM ; }
63
64   Int_t *  GetADCValuesLowGainMax2x2Sum()  {return fADCValuesLow2x2; }
65   Int_t *  GetADCValuesHighGainMax2x2Sum() {return fADCValuesHigh2x2; }
66   Int_t *  GetADCValuesLowGainMaxnxnSum()  {return fADCValuesLownxn; }
67   Int_t *  GetADCValuesHighGainMaxnxnSum() {return fADCValuesHighnxn; }
68
69   void     GetCrystalPhiEtaIndexInModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru,Int_t &ietaMod,Int_t &iphiMod) const ;
70
71   Float_t  GetL0Threshold()            const {return fL0Threshold ; } 
72   Float_t  GetL1JetLowPtThreshold()    const {return fL1JetLowPtThreshold ; }
73   Float_t  GetL1JetMediumPtThreshold() const {return fL1JetMediumPtThreshold ; }
74   Float_t  GetL1JetHighPtThreshold()   const {return fL1JetHighPtThreshold ; }
75
76   Int_t    GetNTRU()                   const {return fNTRU ; }
77   Int_t    GetNTRUZ()                  const {return fNTRUZ ; }
78   Int_t    GetNTRUPhi()                const {return fNTRUPhi ; }
79   
80   Int_t    GetPatchSize()              const {return fPatchSize ; }
81   Int_t    GetIsolPatchSize()          const {return fIsolPatchSize ; }
82
83   Float_t  Get2x2AmpOutOfPatch()       const {return  f2x2AmpOutOfPatch; }
84   Float_t  GetnxnAmpOutOfPatch()       const {return  fnxnAmpOutOfPatch; }
85   Float_t  Get2x2AmpOutOfPatchThres()  const {return  f2x2AmpOutOfPatchThres; }
86   Float_t  GetnxnAmpOutOfPatchThres()  const {return  fnxnAmpOutOfPatchThres; }
87
88   Bool_t   Is2x2Isol()                 const {return  fIs2x2Isol; }
89   Bool_t   IsnxnIsol()                 const {return  fIsnxnIsol; }
90
91   Bool_t   IsSimulation()              const {return fSimulation ; }
92   Bool_t   IsIsolatedInModule()        const {return fIsolateInModule ; }
93
94   //Setters
95   void     SetDigitsList(TClonesArray * digits)          
96    {fDigitsList  = digits ; }
97
98   void     SetNTRU(Int_t ntru)             {fNTRU     = ntru ; }
99   void     SetNTRUZ(Int_t ntru)            {fNTRUZ    = ntru ; }
100   void     SetNTRUPhi(Int_t ntru)          {fNTRUPhi  = ntru ; } 
101
102   void     SetL0Threshold(Int_t amp)         
103     {fL0Threshold          = amp ; }
104   void     SetL1JetLowPtThreshold(Int_t amp) 
105     {fL1JetLowPtThreshold  = amp ; } 
106   void     SetL1JetMediumPtThreshold(Int_t amp) 
107     {fL1JetMediumPtThreshold = amp; } 
108   void     SetL1JetHighPtThreshold(Int_t amp)
109     {fL1JetHighPtThreshold = amp ; }
110
111   void SetPatchSize(Int_t ps)               { fPatchSize = ps ; }
112   void SetIsolPatchSize(Int_t ps)           { fIsolPatchSize = ps ; }
113   void Set2x2AmpOutOfPatchThres(Float_t th) { f2x2AmpOutOfPatchThres = th; }
114   void SetnxnAmpOutOfPatchThres(Float_t th) { fnxnAmpOutOfPatchThres = th; }
115   void SetSimulation(Bool_t sim )           { fSimulation = sim ; }
116   void SetIsolateInModule(Bool_t isol )     { fIsolateInModule = isol ; }
117
118  private:
119
120   AliPHOSTrigger & operator = (const AliPHOSTrigger & trig) ;//cpy assignment
121
122   void FillTRU(const TClonesArray * digits, const AliPHOSGeometry * geom, TClonesArray * amptru, TClonesArray * ampmod, TClonesArray * timeRtru) const ;
123
124   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) ;
125
126   void MakeSlidingCell(const TClonesArray * amptrus, const TClonesArray * timeRtrus, Int_t mod, TMatrixD &ampmax2, TMatrixD &ampmaxn) ;
127
128   void SetTriggers(const TClonesArray * amptrus, Int_t iMod, const TMatrixD &ampmax2,const TMatrixD &ampmaxn) ;
129
130   void DoIt(const char * fileName) ; 
131  
132  private: 
133
134   Float_t f2x2MaxAmp ;     //! Maximum 2x2 added amplitude (not overlapped) 
135   Int_t   f2x2CrystalPhi ; //! upper right cell, row(phi)   
136   Int_t   f2x2CrystalEta ; //! and column(eta) 
137   Int_t   f2x2SM ;         //! Module where maximum is found
138   Float_t fnxnMaxAmp ;     //! Maximum nxn added amplitude (overlapped)
139   Int_t   fnxnCrystalPhi ; //! upper right cell, row(phi)   
140   Int_t   fnxnCrystalEta ; //! and column(eta)
141   Int_t   fnxnSM ;         //! Module where maximum is found
142
143   Int_t*   fADCValuesHighnxn ; //! Sampled ADC high gain values for the nxn crystals amplitude sum
144   Int_t*   fADCValuesLownxn  ; //! " low gain  " 
145   Int_t*   fADCValuesHigh2x2 ; //! " high gain " 2x2 "
146   Int_t*   fADCValuesLow2x2  ; //! " low gaing " "
147
148   TClonesArray* fDigitsList ;  //Array of digits 
149  
150   Float_t fL0Threshold ;             //! L0 trigger energy threshold
151   Float_t fL1JetLowPtThreshold ;     //! L1 Low  pT trigger threshold
152   Float_t fL1JetMediumPtThreshold ;  //! L1 Medium  pT trigger threshold
153   Float_t fL1JetHighPtThreshold ;    //! L1 High pT trigger threshold
154
155   Int_t   fNTRU ;                //! Number of TRUs per module
156   Int_t   fNTRUZ ;               //! Number of crystal rows per Z in one TRU
157   Int_t   fNTRUPhi ;             //! Number of crystal rows per Phi in one TRU
158   Int_t   fNCrystalsPhi;         //! Number of rows in a TRU
159   Int_t   fNCrystalsZ;           //! Number of columns in a TRU
160   
161   Int_t fPatchSize;              //! Trigger patch factor, to be multiplied to 2x2 cells
162                                  //  0 means 2x2, 1 means 4x4, 2 means 6x6 ...
163   Int_t fIsolPatchSize ;         //  Isolation patch size, number of rows or columns to add to 
164                                  //  the 2x2 or nxn maximum amplitude patch. 
165                                  //  1 means a patch around max amplitude of 2x2 of 4x4 and around         
166                                  //  max ampl patch of 4x4 of 8x8 
167     
168   Float_t f2x2AmpOutOfPatch;      // Amplitude in isolation cone minus maximum amplitude of the reference patch
169   Float_t fnxnAmpOutOfPatch; 
170   Float_t f2x2AmpOutOfPatchThres; // Threshold to select a trigger as isolated on f2x2AmpOutOfPatch value
171   Float_t fnxnAmpOutOfPatchThres; 
172   Float_t fIs2x2Isol;             //Patch is isolated if f2x2AmpOutOfPatchThres threshold is passed
173   Float_t fIsnxnIsol ; 
174   
175   Bool_t  fSimulation ;           //! Flag to do the trigger during simulation or reconstruction
176   Bool_t  fIsolateInModule;       //! Flag to isolate trigger patch in Module or in TRU acceptance
177
178   ClassDef(AliPHOSTrigger,4)
179 } ;
180
181
182 #endif //ALIPHOSTrigger_H