Changes for report #76227: ZDC TDC info in ESD and physics selection (for release...
[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"
27#include "Riostream.h"
916f1e76 28
29ClassImp(AliEMCALTriggerData)
30
31//_____________
32AliEMCALTriggerData::AliEMCALTriggerData() : TObject(),
de39a0ff 33fMode(0),
34fL0Patches(),
35fL0Region(),
36fL1GammaPatches(),
37fL1JetPatches(),
38fL1Region(),
39fL1GammaThreshold(0),
40fL1JetThreshold(0)
916f1e76 41{
de39a0ff 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 }
916f1e76 49
de39a0ff 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;
916f1e76 52}
53
54//_____________
55AliEMCALTriggerData::~AliEMCALTriggerData()
56{
de39a0ff 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 }
916f1e76 64}
65
66//_____________
de39a0ff 67void AliEMCALTriggerData::SetL0Region(Int_t i, const Int_t**& region)
916f1e76 68{
de39a0ff 69 //
70 if (i < 0 || i > 31)
916f1e76 71 {
de39a0ff 72 AliError("Bad index!");
73 return;
916f1e76 74 }
de39a0ff 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];
916f1e76 78}
79
80//_____________
de39a0ff 81void AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i, TClonesArray& patches) const
916f1e76 82{
de39a0ff 83 //
84 if (i < 0 || i > 1)
916f1e76 85 {
de39a0ff 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;
916f1e76 104 }
105}
106
107//_____________
de39a0ff 108TClonesArray* AliEMCALTriggerData::GetPatches(TriggerType_t type, Int_t i) const
916f1e76 109{
de39a0ff 110 //
111 if (i < 0 || i > 1)
112 {
113 AliError("Bad index!");
114 return 0x0;
115 }
916f1e76 116
de39a0ff 117 switch (type)
916f1e76 118 {
de39a0ff 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;
916f1e76 131 }
de39a0ff 132
133 return 0x0;
916f1e76 134}
135
136//_____________
de39a0ff 137void AliEMCALTriggerData::SetPatches(TriggerType_t type, Int_t i, const TClonesArray& patches)
916f1e76 138{
139 //
de39a0ff 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)
916f1e76 151 {
de39a0ff 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;
916f1e76 164 }
de39a0ff 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 }
916f1e76 183}
184
185//_____________
de39a0ff 186void AliEMCALTriggerData::SetL1Region(Int_t i, Int_t**& region)
916f1e76 187{
de39a0ff 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];
916f1e76 197}
198
199//_____________
de39a0ff 200void 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//_____________
916f1e76 214void AliEMCALTriggerData::Scan() const
215{
216 //
217 printf("L0:\n");
de39a0ff 218 printf("\tFound (%2d , %2d) patches\n", fL0Patches[0]->GetEntriesFast(), fL0Patches[1]->GetEntriesFast());
916f1e76 219 printf("L1:\n");
de39a0ff 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());
916f1e76 222}
223
224//_____________
225void AliEMCALTriggerData::Reset()
226{
227 //
de39a0ff 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;
916f1e76 236}
237
238
239