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