]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliRawEventV2.cxx
warning fix
[u/mrichter/AliRoot.git] / RAW / AliRawEventV2.cxx
CommitLineData
33314186 1// Author: Cvetan Cheshkov 11/05/2009
2
3/**************************************************************************
4 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
18//////////////////////////////////////////////////////////////////////////
19// //
20// AliRawEventV2 //
21// //
22// Set of classes defining the ALICE RAW event format. The AliRawEventV2 //
23// class defines a RAW event. It consists of an AliEventHeader object //
24// an AliEquipmentHeader object, an AliRawData object and an array of //
25// sub-events, themselves also being AliRawEventV2s. The number of //
26// sub-events depends on the number of DATE LDC's. //
27// The AliRawEventV2 objects are written to a ROOT file using different //
28// technologies, i.e. to local disk via AliRawDB or via rfiod using //
29// AliRawRFIODB or via rootd using AliRawRootdDB or to CASTOR via //
30// rootd using AliRawCastorDB (and for performance testing there is //
31// also AliRawNullDB). //
32// The AliStats class provides statics information that is added as //
33// a single keyed object to each raw file. //
34// The AliTagDB provides an interface to a TAG database. //
35// The AliMDC class is usid by the "alimdc" stand-alone program //
36// that reads data directly from DATE. //
37// //
38//////////////////////////////////////////////////////////////////////////
39
40#include <TObjArray.h>
41#include <TClass.h>
42
43#include "AliLog.h"
44
45#include "AliRawEventHeaderBase.h"
46#include "AliRawEquipmentV2.h"
47
48#include "AliRawEventV2.h"
49
50
51ClassImp(AliRawEventV2)
52
53
54//______________________________________________________________________________
55AliRawEventV2::AliRawEventV2():
56AliRawVEvent(),
57fEquipments("AliRawEquipmentV2",1000),
58fEvtHdrs(NULL),
59fIndex(0),
60fNAllocHdrs(0),
61fNAllocEqs(0)
62{
63 // Create ALICE event object. If ownData is kFALSE we will use a static
64 // raw data object, otherwise a private copy will be made.
65
66}
67
68//______________________________________________________________________________
69AliRawEventHeaderBase *AliRawEventV2::GetHeader(char*& data)
70{
71 // Get event header part of AliRawEventV2.
72 // First the DATE version is identified and then the
73 // corresponding event header version object is created
74
75 AliRawEventHeaderBase *hdr = NULL;
76
77 if (!fEvtHdrs) {
78 hdr = AliRawEventHeaderBase::Create(data);
79 hdr->IsA()->IgnoreTObjectStreamer();
80 fEvtHdrs = new TClonesArray(hdr->IsA()->GetName(),100);
81 delete hdr;
82 }
83
84 if (fIndex < fNAllocHdrs) {
85 TClonesArray &arr = *fEvtHdrs;
86 return (AliRawEventHeaderBase *)arr[fIndex];
87 }
88 else {
89 fNAllocHdrs = fIndex + 1;
90 return (AliRawEventHeaderBase *)fEvtHdrs->New(fIndex);
91 }
92}
93
94//______________________________________________________________________________
95AliRawEventHeaderBase *AliRawEventV2::GetHeader()
96{
97 AliRawEventHeaderBase *hdr = NULL;
98 if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
99 AliFatal("Event header does not exist!");
100 return NULL;
101 }
102
103 return hdr;
104}
105
106//______________________________________________________________________________
107AliRawEquipmentV2 *AliRawEventV2::NextEquipment()
108{
109 // Returns next equipment object.
110
111 AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex);
112 Int_t nEquipments = fEquipments.GetEntriesFast();
113 hdr->AddEqIndex(nEquipments);
114
115 if (nEquipments < fNAllocEqs) {
116 return (AliRawEquipmentV2 *)fEquipments[nEquipments];
117 }
118 else {
119 fNAllocEqs = nEquipments + 1;
120 return new (fEquipments[nEquipments]) AliRawEquipmentV2();
121 }
122}
123
124//______________________________________________________________________________
125AliRawVEquipment *AliRawEventV2::GetEquipment(Int_t index) const
126{
127 // Get specified equipment. Returns 0 if equipment does not exist.
128
129 // if (!fEquipments)
130 // return NULL;
131
132 AliRawEventHeaderBase *hdr = NULL;
133 if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
134 AliFatal("Header is not yet initialized!");
135 return NULL;
136 }
137
138 if ((index + hdr->GetFirstEqIndex()) > hdr->GetLastEqIndex()) {
139 AliFatal("Equipment index out of scope!");
140 return NULL;
141 }
142
143 return (AliRawVEquipment *) fEquipments.UncheckedAt(index+hdr->GetFirstEqIndex());
144}
145
146
147//______________________________________________________________________________
148Int_t AliRawEventV2::GetNEquipments() const
149{
150 // if (!fEquipments)
151 // return 0;
152
153 AliRawEventHeaderBase *hdr = NULL;
154 if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
155 AliFatal("Header is not yet initialized!");
156 return 0;
157 }
158
159 return (hdr->GetFirstEqIndex() < 0) ? 0 : (hdr->GetLastEqIndex() - hdr->GetFirstEqIndex() + 1);
160}
161
162//______________________________________________________________________________
163AliRawEventV2 *AliRawEventV2::NextSubEvent()
164{
165 // Returns next sub-event object.
166
167 fIndex++;
168
169 return this;
170}
171
172//______________________________________________________________________________
173AliRawVEvent *AliRawEventV2::GetSubEvent(Int_t index)
174{
175 // Get specified sub event. Returns 0 if sub event does not exist.
176
177 if (!fEvtHdrs) {
178 AliFatal("Headers are not yet initialized!");
179 return NULL;
180 }
181
182 fIndex = index + 1;
183
184 return this;
185}
186
187//______________________________________________________________________________
188void AliRawEventV2::Reset()
189{
190 // Reset the event in case it needs to be re-used (avoiding costly
191 // new/delete cycle). We reset the size marker for the AliRawData
192 // objects and the sub event counter.
193
194 fEquipments.Clear();
195
196 if (fEvtHdrs) {
197 for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) {
198 AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i);
199 hdr->Reset();
200 }
201 fEvtHdrs->Clear();
202 }
203 fIndex = 0;
204}
205
206//______________________________________________________________________________
207AliRawEventV2::~AliRawEventV2()
208{
209 // Clean up event object. Delete also, possible, private raw data.
210
211 // if (fEquipments)
212 fEquipments.Delete();
213 // delete fEquipments;
214 if (fEvtHdrs)
215 fEvtHdrs->Delete();
216 delete fEvtHdrs;
217}