]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALTriggerData.cxx
1a0e03a2f0de1dfe0c6be131acf17f60db7d109d
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerData.cxx
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 purpeateose. It is      *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17  
18  
19 EMCal trigger data container
20 for data (both raw & rec) persistency
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
22 */
23
24 #include "AliEMCALTriggerData.h"
25 #include "AliEMCALTriggerPatch.h"
26 #include "AliLog.h"
27 #include "Riostream.h"
28
29 ClassImp(AliEMCALTriggerData)
30
31 //_____________
32 AliEMCALTriggerData::AliEMCALTriggerData() : TObject(),
33 fMode(0),
34 fL0Patches(),
35 fL0Region(),
36 fL1GammaPatches(),
37 fL1JetPatches(),
38 fL1Region(),
39 fL1GammaThreshold(0),
40 fL1JetThreshold(0)
41 {  
42         //
43         for (Int_t i = 0; i < 2; i++)
44         {
45                        fL0Patches[i] = new TClonesArray("AliEMCALTriggerPatch");
46                   fL1GammaPatches[i] = new TClonesArray("AliEMCALTriggerPatch");
47                     fL1JetPatches[i] = new TClonesArray("AliEMCALTriggerPatch");
48         }
49         
50         for (Int_t i = 0; i < 32; i++) for (Int_t j = 0; j < 24; j++) for (Int_t k = 0; k <  4; k++) fL0Region[i][j][k] = 0;
51         for (Int_t i = 0; i <  2; i++) for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = 0;
52 }
53
54 //_____________
55 AliEMCALTriggerData::~AliEMCALTriggerData()
56 {
57         //
58         for (Int_t i = 0; i < 2; i++)
59         {
60                 if (     fL0Patches[i])      fL0Patches[i]->Delete();
61                 if (fL1GammaPatches[i]) fL1GammaPatches[i]->Delete();
62                 if (  fL1JetPatches[i])   fL1JetPatches[i]->Delete();
63         }
64 }
65
66 //_____________
67 void AliEMCALTriggerData::SetL0Region(Int_t i, const Int_t**& region)
68 {
69         //
70         if (i < 0 || i > 31) 
71         {
72                 AliError("Bad index!");
73                 return;
74         }
75         
76         for (Int_t j=0;j<24;j++)
77                 for (Int_t k=0;k<4;k++) fL0Region[i][j][k] = region[j][k];
78 }
79
80 //_____________
81 void AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i, TClonesArray& patches) const
82 {
83         //
84         if (i < 0 || i > 1) 
85         {
86                 AliError("Bad index!");
87                 return;
88         }
89         
90         switch (type)
91         {
92                 case kL0:
93                         patches =  *fL0Patches[i];
94                         break;
95                 case kL1Gamma:
96                         patches =  *fL1GammaPatches[i];
97                         break;
98                 case kL1Jet:
99                         patches =  *fL1JetPatches[i];
100                         break;
101                 default:
102                         AliError("Unknown trigger type!");
103                         break;
104         }
105 }
106
107 //_____________
108 TClonesArray* AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i) const
109 {
110         //
111         if (i < 0 || i > 1) 
112         {
113                 AliError("Bad index!");
114                 return 0x0;
115         }
116         
117         switch (type)
118         {
119                 case kL0:
120                         return fL0Patches[i];
121                         break;
122                 case kL1Gamma:
123                         return fL1GammaPatches[i];
124                         break;
125                 case kL1Jet:
126                         return fL1JetPatches[i];
127                         break;
128                 default:
129                         AliError("Unknown trigger type!");
130                         break;
131         }
132
133         return 0x0;
134 }
135
136 //_____________
137 void AliEMCALTriggerData::SetPatches(TriggerType_t type, Int_t i, const TClonesArray& patches)
138 {
139         //
140         if (i < 0 || i > 1) 
141         {
142                 AliError("Bad index!");
143                 return;
144         }
145         
146         if (patches.GetEntriesFast())
147         {
148                 TClonesArray* arr = 0x0;
149                 
150                 switch (type)
151                 {
152                         case kL0:
153                                 arr = fL0Patches[i];
154                                 break;
155                         case kL1Gamma:
156                                 arr = fL1GammaPatches[i];
157                                 break;
158                         case kL1Jet:
159                                 arr = fL1JetPatches[i];
160                                 break;
161                         default:
162                                 AliError("Unknown trigger type!");
163                                 return;
164                 }
165                 
166                 if (arr)
167                 {
168                         Int_t size = arr->GetSize() + patches.GetSize();
169                 
170                         arr->Expand(size);
171                 
172                         for (Int_t k = 0; k < patches.GetEntriesFast(); k++)
173                         {
174                                 AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>(patches.At(k));
175                                 new((*arr)[arr->GetEntriesFast()]) AliEMCALTriggerPatch(*p);
176                         }
177                 }
178                 else
179                 {
180                         AliError("TClonesArray is NULL!");
181                 }
182         }
183 }
184
185 //_____________
186 void AliEMCALTriggerData::SetL1Region(Int_t i, Int_t**& region)
187 {
188         //
189         if (i < 0 || i > 1) 
190         {
191                 AliError("Bad index!");
192                 return;
193         }
194                 
195         for (Int_t j = 0; j < 48; j++)
196                 for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = region[j][k];
197 }
198
199 //_____________
200 void AliEMCALTriggerData::GetL1Region(Int_t i, Int_t arr[][64]) const 
201
202         //
203         if (i < 0 || i > 1) 
204         {
205                 AliError("Bad index!");
206                 return;
207         }
208         
209         for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) { arr[j][k] = fL1Region[i][j][k]; } 
210 }
211
212
213 //_____________
214 void AliEMCALTriggerData::Scan() const
215 {
216         //
217         printf("L0:\n");
218         printf("\tFound (%2d , %2d) patches\n", fL0Patches[0]->GetEntriesFast(), fL0Patches[1]->GetEntriesFast());
219         printf("L1:\n");
220         printf("\tFound (%4d,%4d) gamma patches\n",fL1GammaPatches[0]->GetEntriesFast(), fL1GammaPatches[1]->GetEntriesFast());
221         printf("\tFound (%4d,%4d) jet patches\n",fL1JetPatches[0]->GetEntriesFast(), fL1JetPatches[1]->GetEntriesFast());
222 }
223
224 //_____________
225 void AliEMCALTriggerData::Reset()
226 {
227         //
228         for (Int_t i = 0; i < 2; i++)
229         {
230                 if (     fL0Patches[i])      fL0Patches[i]->Delete();
231                 if (fL1GammaPatches[i]) fL1GammaPatches[i]->Delete();
232                 if (  fL1JetPatches[i])   fL1JetPatches[i]->Delete();   
233         }
234                 
235         for (Int_t i = 0; i < 2; i++) for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = 0;
236 }
237
238
239