]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALTriggerData.cxx
coverity
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerData.cxx
CommitLineData
916f1e76 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
19EMCal trigger data container
de39a0ff 20for data (both raw & rec) persistency
916f1e76 21Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
22*/
23
24#include "AliEMCALTriggerData.h"
25#include "AliEMCALTriggerPatch.h"
de39a0ff 26#include "AliLog.h"
a61738e1 27#include "TIterator.h"
de39a0ff 28#include "Riostream.h"
916f1e76 29
30ClassImp(AliEMCALTriggerData)
31
32//_____________
33AliEMCALTriggerData::AliEMCALTriggerData() : TObject(),
de39a0ff 34fMode(0),
35fL0Patches(),
36fL0Region(),
37fL1GammaPatches(),
38fL1JetPatches(),
39fL1Region(),
40fL1GammaThreshold(0),
da6062af 41fL1JetThreshold(0),
42fL1V0(),
43fL1FrameMask(0),
521ea43e 44fL1TriggerType(),
804b828a 45fL1DataDecoded(0),
46fL1RawData(0)
916f1e76 47{
79b05051 48 // Ctor
49
de39a0ff 50 for (Int_t i = 0; i < 2; i++)
51 {
52 fL0Patches[i] = new TClonesArray("AliEMCALTriggerPatch");
53 fL1GammaPatches[i] = new TClonesArray("AliEMCALTriggerPatch");
54 fL1JetPatches[i] = new TClonesArray("AliEMCALTriggerPatch");
55 }
916f1e76 56
de39a0ff 57 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;
58 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;
da6062af 59
60 fL1V0[0] = fL1V0[1] = 0;
61 for (Int_t i = 0; i < 8; i++) fL1TriggerType[i] = 0;
916f1e76 62}
63
64//_____________
65AliEMCALTriggerData::~AliEMCALTriggerData()
66{
79b05051 67 // Dtor
68
de39a0ff 69 for (Int_t i = 0; i < 2; i++)
70 {
71 if ( fL0Patches[i]) fL0Patches[i]->Delete();
72 if (fL1GammaPatches[i]) fL1GammaPatches[i]->Delete();
73 if ( fL1JetPatches[i]) fL1JetPatches[i]->Delete();
74 }
916f1e76 75}
76
77//_____________
de39a0ff 78void AliEMCALTriggerData::SetL0Region(Int_t i, const Int_t**& region)
916f1e76 79{
79b05051 80 // L0 region
81
de39a0ff 82 if (i < 0 || i > 31)
916f1e76 83 {
de39a0ff 84 AliError("Bad index!");
85 return;
916f1e76 86 }
de39a0ff 87
88 for (Int_t j=0;j<24;j++)
89 for (Int_t k=0;k<4;k++) fL0Region[i][j][k] = region[j][k];
916f1e76 90}
91
92//_____________
de39a0ff 93void AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i, TClonesArray& patches) const
916f1e76 94{
79b05051 95 // List of patches
96
de39a0ff 97 if (i < 0 || i > 1)
916f1e76 98 {
de39a0ff 99 AliError("Bad index!");
100 return;
101 }
102
103 switch (type)
104 {
105 case kL0:
106 patches = *fL0Patches[i];
107 break;
108 case kL1Gamma:
109 patches = *fL1GammaPatches[i];
110 break;
111 case kL1Jet:
112 patches = *fL1JetPatches[i];
113 break;
114 default:
115 AliError("Unknown trigger type!");
116 break;
916f1e76 117 }
118}
119
120//_____________
de39a0ff 121TClonesArray* AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i) const
916f1e76 122{
79b05051 123 // List of patches
124
de39a0ff 125 if (i < 0 || i > 1)
126 {
127 AliError("Bad index!");
128 return 0x0;
129 }
916f1e76 130
de39a0ff 131 switch (type)
916f1e76 132 {
de39a0ff 133 case kL0:
134 return fL0Patches[i];
135 break;
136 case kL1Gamma:
137 return fL1GammaPatches[i];
138 break;
139 case kL1Jet:
140 return fL1JetPatches[i];
141 break;
142 default:
143 AliError("Unknown trigger type!");
144 break;
916f1e76 145 }
de39a0ff 146
147 return 0x0;
916f1e76 148}
149
150//_____________
de39a0ff 151void AliEMCALTriggerData::SetPatches(TriggerType_t type, Int_t i, const TClonesArray& patches)
916f1e76 152{
79b05051 153 // Set list of patches
154
de39a0ff 155 if (i < 0 || i > 1)
156 {
157 AliError("Bad index!");
158 return;
159 }
160
161 if (patches.GetEntriesFast())
162 {
163 TClonesArray* arr = 0x0;
164
165 switch (type)
916f1e76 166 {
de39a0ff 167 case kL0:
168 arr = fL0Patches[i];
169 break;
170 case kL1Gamma:
171 arr = fL1GammaPatches[i];
172 break;
173 case kL1Jet:
174 arr = fL1JetPatches[i];
175 break;
176 default:
177 AliError("Unknown trigger type!");
178 return;
916f1e76 179 }
de39a0ff 180
181 if (arr)
182 {
183 Int_t size = arr->GetSize() + patches.GetSize();
184
185 arr->Expand(size);
186
187 for (Int_t k = 0; k < patches.GetEntriesFast(); k++)
188 {
189 AliEMCALTriggerPatch* p = static_cast<AliEMCALTriggerPatch*>(patches.At(k));
190 new((*arr)[arr->GetEntriesFast()]) AliEMCALTriggerPatch(*p);
191 }
192 }
193 else
194 {
195 AliError("TClonesArray is NULL!");
196 }
197 }
916f1e76 198}
199
200//_____________
de39a0ff 201void AliEMCALTriggerData::SetL1Region(Int_t i, Int_t**& region)
916f1e76 202{
79b05051 203 // Set L1 region
204
de39a0ff 205 if (i < 0 || i > 1)
206 {
207 AliError("Bad index!");
208 return;
209 }
210
211 for (Int_t j = 0; j < 48; j++)
212 for (Int_t k = 0; k < 64; k++) fL1Region[i][j][k] = region[j][k];
916f1e76 213}
214
de39a0ff 215//_____________
216void AliEMCALTriggerData::GetL1Region(Int_t i, Int_t arr[][64]) const
217{
79b05051 218 // Get L1 region
219
de39a0ff 220 if (i < 0 || i > 1)
221 {
222 AliError("Bad index!");
223 return;
224 }
225
226 for (Int_t j = 0; j < 48; j++) for (Int_t k = 0; k < 64; k++) { arr[j][k] = fL1Region[i][j][k]; }
227}
228
229
916f1e76 230//_____________
231void AliEMCALTriggerData::Scan() const
232{
79b05051 233 // Dump
234
a61738e1 235 TIterator* nP;
236
916f1e76 237 printf("L0:\n");
a61738e1 238 printf("\tFound (%2d,%2d) patches\n", fL0Patches[1]->GetEntriesFast(), fL0Patches[0]->GetEntriesFast());
239 printf("\tRAW:\n");
240 nP = fL0Patches[1]->MakeIterator();
241 while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)nP->Next()) {printf("\t"); p->Print("");}
242 printf("\tREC:\n");
243 nP = fL0Patches[0]->MakeIterator();
244 while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)nP->Next()) {printf("\t"); p->Print("");}
916f1e76 245 printf("L1:\n");
a61738e1 246 printf("\tFound (%4d,%4d) gamma patches\n",fL1GammaPatches[1]->GetEntriesFast(), fL1GammaPatches[0]->GetEntriesFast());
247 printf("\tRAW:\n");
248 nP = fL1GammaPatches[1]->MakeIterator();
249 while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)nP->Next()) {printf("\t"); p->Print("");}
250 printf("\tREC:\n");
251 nP = fL1GammaPatches[0]->MakeIterator();
252 while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)nP->Next()) {printf("\t"); p->Print("");}
253 printf("\tFound (%4d,%4d) jet patches\n",fL1JetPatches[1]->GetEntriesFast(), fL1JetPatches[0]->GetEntriesFast());
254 printf("\tRAW:\n");
255 nP = fL1JetPatches[1]->MakeIterator();
256 while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)nP->Next()) {printf("\t"); p->Print("");}
257 printf("\tREC:\n");
258 nP = fL1JetPatches[0]->MakeIterator();
259 while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)nP->Next()) {printf("\t"); p->Print("");}
916f1e76 260}
261
262//_____________
263void AliEMCALTriggerData::Reset()
264{
79b05051 265 // Reset
266
de39a0ff 267 for (Int_t i = 0; i < 2; i++)
268 {
269 if ( fL0Patches[i]) fL0Patches[i]->Delete();
270 if (fL1GammaPatches[i]) fL1GammaPatches[i]->Delete();
271 if ( fL1JetPatches[i]) fL1JetPatches[i]->Delete();
272 }
273
274 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;
521ea43e 275
276 fL1DataDecoded = 0;
916f1e76 277}
278
279
280