MUON trigger classes to collaborate with CTP (E. Lopez Torres)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrigger.cxx
CommitLineData
25354ff4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15/* $Id$ */
16
17
18//_________________________________________________________________________
19//
20// Class for trigger analysis.
21// Digits are grouped in TRU's (16x28 crystals). The algorithm searches all
22// possible 4x4 crystal combinations and per each TRU, adding the digits
23// amplitude and finding the maximum. Maximums are compared to triggers threshold
24// and they are set.
25// FIRST ATTEMPT TO MAKE A TRIGGER CLASS. IT WILL CHANGE WHEN CENTRAL TRIGGER CLASS FIXES
26// THINGS
27//
28//*-- Author: Gustavo Conesa & Yves Schutz (IFIC, CERN)
29//////////////////////////////////////////////////////////////////////////////
30
31
32// --- ROOT system ---
33
34
35// --- ALIROOT system ---
36#include "AliPHOSTrigger.h"
37#include "AliPHOSGeometry.h"
38#include "AliPHOSGetter.h"
39
40
41ClassImp(AliPHOSTrigger)
42
43//____________________________________________________________________________
44 AliPHOSTrigger::AliPHOSTrigger() : TObject(),
45 fL0(kFALSE), fL1Low(kFALSE), fL1Medium(kFALSE),
46 fL1High(kFALSE), fL0Threshold(50), fL1LowThreshold(1200),
47 fL1MediumThreshold(12000), fL1HighThreshold(30000)
48{
49 // default ctor
50 Print("") ;
51}
52
53//____________________________________________________________________________
54AliPHOSTrigger::AliPHOSTrigger(const AliPHOSTrigger & trig) : TObject(trig)
55{
56
57 // cpy ctor
58
59 fL0 = trig.fL0 ;
60 fL1Low = trig.fL1Low ;
61 fL1Medium = trig.fL1Medium ;
62 fL1High = trig.fL1High ;
63 fL0Threshold = trig.fL0Threshold ;
64 fL1LowThreshold = trig.fL1LowThreshold ;
65 fL1MediumThreshold = trig.fL1MediumThreshold ;
66 fL1HighThreshold = trig.fL1HighThreshold ;
67
68}
69
70//____________________________________________________________________________
71TClonesArray * AliPHOSTrigger::FillTRU(const TClonesArray * digits){
72
73 //Orders digits ampitudes list in 8 TRUs (16x28 crystals) per module.
74 //Each TRU is a TMatrixD, and they are kept in TClonesArrays.
75
76 //Initilize variables
77
78 const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
79
80 TClonesArray * matrix = new TClonesArray("TMatrixD",1000);
81 for(Int_t k = 0; k < 40 ; k++){
82 TMatrixD * trus = new TMatrixD(16,28) ;
83 for(Int_t i = 0; i < 16; i++)
84 for(Int_t j = 0; j < 28; j++)
85 (*trus)(i,j) = 0.0;
86 new((*matrix)[k]) TMatrixD(*trus) ;
87 }
88
89 AliPHOSDigit * dig ;
90
91 //Declare different variables
92 Int_t relid[4] ;
93 Float_t amp = 0;
94
95 for(Int_t idig = 0 ; idig < digits->GetEntriesFast() ; idig++){
96
97 dig = static_cast<AliPHOSDigit *>(digits->At(idig)) ;
98 amp = dig->GetAmp() ; //Energy of the digit (arbitrary units)
99 geom->AbsToRelNumbering(dig->GetId(), relid) ;//Transform digit number into 4 numbers
100 //relid[0] = module
101 //relid[1] = EMC (0) or CPV (-1)
102 //relid[2] = row <= 64 (fNPhi)
103 //relid[3] = column <= 56 (fNZ)
104
105 if(relid[1] == 0){
106
107 Int_t ntru = 1;
108 Int_t row = 1;
109 Int_t col = 1;
110 //Check which TRU in the module. It is divided in a (4,2) matrix.
111 //Fill the TRU matrix (16,28)
112 if(relid[3] > 28)
113 col = 2;
114
115 if(relid[2] > 16 && relid[2] <= 32)
116 row = 2;
117
118 if(relid[2] > 32 && relid[2] <= 48)
119 row = 3;
120
121 if(relid[2] > 48)
122 row = 4;
123
124 ntru = col*row + (relid[0]-1)*8 - 1;
125 TMatrixD * trus = dynamic_cast<TMatrixD *>(matrix->At(ntru)) ;
126
127 Int_t nrow = (relid[2]-1) - (row-1) * 16 ;
128 Int_t ncol = (relid[3]-1) - (col-1) * 28 ;
129
130 (*trus)(nrow,ncol) = amp ;
131 }
132 }
133 return matrix;
134}
135
136//____________________________________________________________________________
137void AliPHOSTrigger::InitTriggers()
138{
139 //Initialize Boolean variables per each event
140
141 fL0 = kFALSE ;
142 fL1Low = kFALSE ;
143 fL1Medium = kFALSE ;
144 fL1High = kFALSE ;
145
146}
147//____________________________________________________________________________
148void AliPHOSTrigger::MakeSlidingCell(const TClonesArray * trus, const Int_t mod,
149 Float_t *ampmax){
150
151 //Sums energy of all possible 4x4 crystals per each TRU. Fast signal
152 //in the experiment is given by 2x2 crystals, for this reason we loop
153 //inside the TRU crystals by 2.
154
155 Float_t amp = 0 ;
156
157 for(Int_t i = 0 ; i < 8 ; i++)
158 ampmax[i] = 0 ;
159
160 //Loop over all TRUS in a module
161 for(Int_t itru = 0 + (mod - 1) * 8 ; itru < mod*8 ; itru++){
162 TMatrixD * tru = dynamic_cast<TMatrixD *>(trus->At(itru)) ;
163 //Sliding 2x2 cell
164 //ampmax[itru-(mod-1)*8]=0.0;
165 for(Int_t irow = 0 ; irow < 16 ; irow += 2){
166 for(Int_t icol = 0 ; icol < 28 ; icol += 2){
167 amp = 0;
168 if( (irow+4) < 16 && (icol+4) < 28){//Avoid exit the TRU
169 for(Int_t i = irow; i < irow + 4 ; i++){
170 for(Int_t j = icol; j < icol + 4 ; j++){
171 amp += (*tru)(i,j) ;
172 }
173 }
174 }
175 if(amp > ampmax[itru-(mod-1)*8])
176 ampmax[itru-(mod-1)*8] = amp ;
177 }
178 }
179 }
180}
181
182//____________________________________________________________________________
183void AliPHOSTrigger::MakeTrigger()
184{
185
186 //Main Method to select triggers.
187
188 InitTriggers() ; //Initialize triggers to kFALSE
189
190 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
191
192 //Take the digits list and declare digits pointers
193 TClonesArray * digits = gime->Digits() ;
194 //Fill TRU Matrix
195 TClonesArray * trus = FillTRU(digits);
196
197 //Do Cell Sliding and select Trigger
198 Float_t max [8] ;
199 for(Int_t imod = 1 ; imod <= 5 ; imod++) {
200 MakeSlidingCell(trus, imod, max);
201 SetTriggers(max) ;
202 }
203
204}
205
206//____________________________________________________________________________
207void AliPHOSTrigger::Print(const Option_t * opt) const
208{
209
210 //Prints main parameters
211
212 if(! opt)
213 return;
214
215 AliInfo("PHOS trigger information:") ;
216 printf( " Threshold for LO %d\n", fL0Threshold) ;
217 printf( " Low Threshold for L1 %d\n", fL1LowThreshold) ;
218 printf( " Medium Threshold for L1 %d\n", fL1MediumThreshold) ;
219 printf( " High Threshold for L1 %d\n", fL1HighThreshold) ;
220 if ( IsL0Set() )
221 printf(" LO is set\n") ;
222 else
223 printf(" LO is not set\n") ;
224 if ( IsL1LowSet() )
225 printf(" L1 Low is set\n") ;
226 else
227 printf(" L1 Low is not set\n") ;
228 if ( IsL1MediumSet() )
229 printf(" L1 Medium is set\n") ;
230 else
231 printf(" L1 Medium is not set\n") ;
232 if ( IsL1HighSet() )
233 printf(" L1 High is set\n") ;
234 else
235 printf(" L1 High is not set\n") ;
236
237}
238
239//____________________________________________________________________________
240void AliPHOSTrigger::SetTriggers(const Float_t * amp)
241{
242
243 //Checks the maximum amplitude per each TRU and compares with the
244 //different triggers thresholds
245
246 Float_t max = 0;
247 for(Int_t i = 0 ; i < 8 ; i++){
248 if(max < amp[i] )
249 max = amp[i] ;
250 }
251
252 if(max >= fL0Threshold){
253 SetL0();
254 if(max >= fL1LowThreshold){
255 SetL1Low();
256 if(max >= fL1MediumThreshold){
257 SetL1Medium();
258 if(max >= fL1HighThreshold){
259 SetL1High();
260 }
261 }
262 }
263 }
264}