Bug correction
[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
a197a4ce 45#include "AliRawEventHeader.h"
46#include "AliRawEquipmentHeader.h"
47#include "AliRawData.h"
5ea08be4 48
49#include "AliRawEvent.h"
50
5ea08be4 51
52ClassImp(AliRawEvent)
5ea08be4 53
54
55//______________________________________________________________________________
a197a4ce 56AliRawEvent::AliRawEvent()
5ea08be4 57{
a197a4ce 58 // Create ALICE event object. If ownData is kFALSE we will use a static
59 // raw data object, otherwise a private copy will be made.
5ea08be4 60
a197a4ce 61 fNSubEvents = 0;
62 fEvtHdr = 0;
63 fEqpHdr = 0;
64 fRawData = 0;
65 fSubEvents = 0;
5ea08be4 66}
67
68//______________________________________________________________________________
a197a4ce 69AliRawEvent::AliRawEvent(const AliRawEvent& rawEvent): TObject(rawEvent)
5ea08be4 70{
a197a4ce 71// copy constructor
5ea08be4 72
a197a4ce 73 Fatal("AliRawEvent", "copy constructor not implemented");
5ea08be4 74}
75
5ea08be4 76//______________________________________________________________________________
a197a4ce 77AliRawEvent& AliRawEvent::operator = (const AliRawEvent& /*rawEvent*/)
5ea08be4 78{
a197a4ce 79// assignment operator
5459c838 80
a197a4ce 81 Fatal("operator =", "assignment operator not implemented");
82 return *this;
5ea08be4 83}
84
85//______________________________________________________________________________
c51de60d 86AliRawEventHeader *AliRawEvent::GetHeader()
87{
88 // Get event header part of AliRawEvent.
89
90 if (!fEvtHdr)
91 fEvtHdr = new AliRawEventHeader;
92
93 return fEvtHdr;
94}
95
96//______________________________________________________________________________
5ea08be4 97AliRawEquipmentHeader *AliRawEvent::GetEquipmentHeader()
98{
99 // Get equipment header part of AliRawEvent.
100
101 if (!fEqpHdr)
102 fEqpHdr = new AliRawEquipmentHeader;
103
104 return fEqpHdr;
105}
106
107//______________________________________________________________________________
108AliRawData *AliRawEvent::GetRawData()
109{
110 // Get raw data part of AliRawEvent.
111
112 if (!fRawData)
113 fRawData = new AliRawData;
114
115 return fRawData;
116}
117
118//______________________________________________________________________________
119AliRawEvent *AliRawEvent::NextSubEvent()
120{
121 // Returns next sub-event object.
122
123 if (!fSubEvents)
124 fSubEvents = new TObjArray(100); // arbitrary, probably enough to prevent resizing
125
126 if (fSubEvents->GetSize() <= fNSubEvents) {
127 fSubEvents->Expand(fNSubEvents+10);
128 Warning("NextSubEvent", "expanded fSubEvents by 10 to %d",
129 fSubEvents->GetSize());
130 }
131
132 AliRawEvent *ev;
133 if (!(ev = (AliRawEvent *)fSubEvents->At(fNSubEvents))) {
134 ev = new AliRawEvent;
135 fSubEvents->AddAt(ev, fNSubEvents);
136 }
137
138 fNSubEvents++;
139
140 return ev;
141}
142
143//______________________________________________________________________________
5459c838 144AliRawEvent *AliRawEvent::GetSubEvent(Int_t index) const
04fa961a 145{
5459c838 146 // Get specified sub event. Returns 0 if sub event does not exist.
147
148 if (!fSubEvents)
149 return 0;
150
151 return (AliRawEvent *) fSubEvents->At(index);
04fa961a 152}
153
154//______________________________________________________________________________
5ea08be4 155void AliRawEvent::Reset()
156{
157 // Reset the event in case it needs to be re-used (avoiding costly
158 // new/delete cycle). We reset the size marker for the AliRawData
159 // objects and the sub event counter.
160
161 for (int i = 0; i < fNSubEvents; i++) {
162 AliRawEvent *ev = (AliRawEvent *)fSubEvents->At(i);
163 ev->GetRawData()->SetSize(0);
164 }
165 fNSubEvents = 0;
166}
167
168//______________________________________________________________________________
169AliRawEvent::~AliRawEvent()
170{
171 // Clean up event object. Delete also, possible, private raw data.
172
173 delete fEvtHdr;
174 delete fEqpHdr;
175 delete fRawData;
176 if (fSubEvents)
177 fSubEvents->Delete();
178 delete fSubEvents;
179}