]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RAW/AliRawEvent.cxx
macros for reading RecPoints
[u/mrichter/AliRoot.git] / RAW / AliRawEvent.cxx
CommitLineData
5ea08be4 1// @(#)alimdc:$Name$:$Id$
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). //
33// The AliRunDB class provides the interface to the run and file //
34// catalogues (AliEn or plain MySQL). //
35// The AliStats class provides statics information that is added as //
36// a single keyed object to each raw file. //
37// The AliTagDB provides an interface to a TAG database. //
38// The AliMDC class is usid by the "alimdc" stand-alone program //
39// that reads data directly from DATE. //
40// //
41//////////////////////////////////////////////////////////////////////////
42
a197a4ce 43#include <TObjArray.h>
5ea08be4 44
f2dc6b20 45#include "AliLog.h"
46
47#include "AliRawEventHeaderBase.h"
94d918a7 48#include "AliRawEquipment.h"
5ea08be4 49
50#include "AliRawEvent.h"
51
5ea08be4 52
53ClassImp(AliRawEvent)
5ea08be4 54
5ea08be4 55
56//______________________________________________________________________________
f3c1e83c 57AliRawEvent::AliRawEvent():
58fNEquipments(0),
59fNSubEvents(0),
60fEvtHdr(NULL),
61fEquipments(NULL),
62fSubEvents(NULL)
5ea08be4 63{
a197a4ce 64 // Create ALICE event object. If ownData is kFALSE we will use a static
65 // raw data object, otherwise a private copy will be made.
5ea08be4 66
5ea08be4 67}
68
c51de60d 69//______________________________________________________________________________
f2dc6b20 70AliRawEventHeaderBase *AliRawEvent::GetHeader(char*& data)
c51de60d 71{
f2dc6b20 72 // Get event header part of AliRawEvent.
73 // First the DATE version is identified and then the
74 // corresponding event header version object is created
75
76 if (!fEvtHdr) {
77 fEvtHdr = AliRawEventHeaderBase::Create(data);
78 }
79
80 return fEvtHdr;
81}
c51de60d 82
f2dc6b20 83//______________________________________________________________________________
84AliRawEventHeaderBase *AliRawEvent::GetHeader()
85{
86 if (!fEvtHdr) {
87 AliFatal("Header version not yet initialized!");
88 return 0x0;
89 }
c51de60d 90
f2dc6b20 91 return fEvtHdr;
c51de60d 92}
93
5ea08be4 94//______________________________________________________________________________
94d918a7 95AliRawEquipment *AliRawEvent::NextEquipment()
5ea08be4 96{
94d918a7 97 // Returns next equipment object.
98
99 if (!fEquipments)
100 fEquipments = new TObjArray(100); // arbitrary, probably enough to prevent resizing
101
102 if (fEquipments->GetSize() <= fNEquipments) {
103 fEquipments->Expand(fNEquipments+10);
104 Warning("NextEquipment", "expanded fEquipments by 10 to %d",
105 fEquipments->GetSize());
106 }
5ea08be4 107
94d918a7 108 AliRawEquipment *eq;
109 if (!(eq = (AliRawEquipment *)fEquipments->At(fNEquipments))) {
110 eq = new AliRawEquipment;
111 fEquipments->AddAt(eq, fNEquipments);
112 }
113
114 fNEquipments++;
5ea08be4 115
94d918a7 116 return eq;
5ea08be4 117}
118
119//______________________________________________________________________________
94d918a7 120AliRawEquipment *AliRawEvent::GetEquipment(Int_t index) const
5ea08be4 121{
94d918a7 122 // Get specified equipment. Returns 0 if equipment does not exist.
5ea08be4 123
94d918a7 124 if (!fEquipments)
125 return 0;
5ea08be4 126
94d918a7 127 return (AliRawEquipment *) fEquipments->At(index);
5ea08be4 128}
129
130//______________________________________________________________________________
131AliRawEvent *AliRawEvent::NextSubEvent()
132{
133 // Returns next sub-event object.
134
135 if (!fSubEvents)
136 fSubEvents = new TObjArray(100); // arbitrary, probably enough to prevent resizing
137
138 if (fSubEvents->GetSize() <= fNSubEvents) {
139 fSubEvents->Expand(fNSubEvents+10);
140 Warning("NextSubEvent", "expanded fSubEvents by 10 to %d",
141 fSubEvents->GetSize());
142 }
143
144 AliRawEvent *ev;
145 if (!(ev = (AliRawEvent *)fSubEvents->At(fNSubEvents))) {
146 ev = new AliRawEvent;
147 fSubEvents->AddAt(ev, fNSubEvents);
148 }
149
150 fNSubEvents++;
151
152 return ev;
153}
154
04fa961a 155//______________________________________________________________________________
5459c838 156AliRawEvent *AliRawEvent::GetSubEvent(Int_t index) const
04fa961a 157{
5459c838 158 // Get specified sub event. Returns 0 if sub event does not exist.
159
160 if (!fSubEvents)
161 return 0;
162
163 return (AliRawEvent *) fSubEvents->At(index);
04fa961a 164}
165
5ea08be4 166//______________________________________________________________________________
167void AliRawEvent::Reset()
168{
169 // Reset the event in case it needs to be re-used (avoiding costly
170 // new/delete cycle). We reset the size marker for the AliRawData
171 // objects and the sub event counter.
172
94d918a7 173 for (int i = 0; i < fNEquipments; i++) {
174 AliRawEquipment *eq = (AliRawEquipment *)fEquipments->At(i);
175 eq->Reset();
176 }
177 fNEquipments = 0;
5ea08be4 178 for (int i = 0; i < fNSubEvents; i++) {
179 AliRawEvent *ev = (AliRawEvent *)fSubEvents->At(i);
94d918a7 180 ev->Reset();
5ea08be4 181 }
182 fNSubEvents = 0;
183}
184
185//______________________________________________________________________________
186AliRawEvent::~AliRawEvent()
187{
188 // Clean up event object. Delete also, possible, private raw data.
189
190 delete fEvtHdr;
94d918a7 191 if (fEquipments)
192 fEquipments->Delete();
193 delete fEquipments;
5ea08be4 194 if (fSubEvents)
195 fSubEvents->Delete();
196 delete fSubEvents;
197}