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