Line data Source code
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 :
51 128 : ClassImp(AliRawEventV2)
52 :
53 :
54 : //______________________________________________________________________________
55 : AliRawEventV2::AliRawEventV2():
56 10 : AliRawVEvent(),
57 10 : fEquipments("AliRawEquipmentV2",1000),
58 10 : fEvtHdrs(NULL),
59 10 : fIndex(0),
60 10 : fNAllocHdrs(0),
61 10 : fNAllocEqs(0)
62 50 : {
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 20 : }
67 :
68 : //______________________________________________________________________________
69 : AliRawEventHeaderBase *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 956 : if (!fEvtHdrs) {
78 1 : hdr = AliRawEventHeaderBase::Create(data);
79 1 : hdr->IsA()->IgnoreTObjectStreamer();
80 4 : fEvtHdrs = new TClonesArray(hdr->IsA()->GetName(),100);
81 2 : delete hdr;
82 : }
83 :
84 478 : if (fIndex < fNAllocHdrs) {
85 357 : TClonesArray &arr = *fEvtHdrs;
86 357 : return (AliRawEventHeaderBase *)arr[fIndex];
87 : }
88 : else {
89 121 : fNAllocHdrs = fIndex + 1;
90 121 : return (AliRawEventHeaderBase *)fEvtHdrs->New(fIndex);
91 : }
92 478 : }
93 :
94 : //______________________________________________________________________________
95 : AliRawEventHeaderBase *AliRawEventV2::GetHeader()
96 : {
97 : AliRawEventHeaderBase *hdr = NULL;
98 289923 : if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
99 0 : AliFatal("Event header does not exist!");
100 0 : return NULL;
101 : }
102 :
103 96641 : return hdr;
104 96641 : }
105 :
106 : //______________________________________________________________________________
107 : AliRawEquipmentV2 *AliRawEventV2::NextEquipment()
108 : {
109 : // Returns next equipment object.
110 :
111 3242 : AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex);
112 1621 : Int_t nEquipments = fEquipments.GetEntriesFast();
113 1621 : hdr->AddEqIndex(nEquipments);
114 :
115 1621 : if (nEquipments < fNAllocEqs) {
116 1211 : return (AliRawEquipmentV2 *)fEquipments[nEquipments];
117 : }
118 : else {
119 410 : fNAllocEqs = nEquipments + 1;
120 820 : return new (fEquipments[nEquipments]) AliRawEquipmentV2();
121 : }
122 1621 : }
123 :
124 : //______________________________________________________________________________
125 : AliRawVEquipment *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 1078911 : if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
134 0 : AliFatal("Header is not yet initialized!");
135 0 : return NULL;
136 : }
137 :
138 359637 : if ((index + hdr->GetFirstEqIndex()) > hdr->GetLastEqIndex()) {
139 0 : AliFatal("Equipment index out of scope!");
140 0 : return NULL;
141 : }
142 :
143 359637 : return (AliRawVEquipment *) fEquipments.UncheckedAt(index+hdr->GetFirstEqIndex());
144 359637 : }
145 :
146 :
147 : //______________________________________________________________________________
148 : Int_t AliRawEventV2::GetNEquipments() const
149 : {
150 : // if (!fEquipments)
151 : // return 0;
152 :
153 : AliRawEventHeaderBase *hdr = NULL;
154 2148888 : if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
155 0 : AliFatal("Header is not yet initialized!");
156 0 : return 0;
157 : }
158 :
159 2148888 : return (hdr->GetFirstEqIndex() < 0) ? 0 : (hdr->GetLastEqIndex() - hdr->GetFirstEqIndex() + 1);
160 716296 : }
161 :
162 : //______________________________________________________________________________
163 : AliRawEventV2 *AliRawEventV2::NextSubEvent()
164 : {
165 : // Returns next sub-event object.
166 :
167 948 : fIndex++;
168 :
169 474 : return this;
170 : }
171 :
172 : //______________________________________________________________________________
173 : AliRawVEvent *AliRawEventV2::GetSubEvent(Int_t index)
174 : {
175 : // Get specified sub event. Returns 0 if sub event does not exist.
176 :
177 195056 : if (!fEvtHdrs) {
178 0 : AliFatal("Headers are not yet initialized!");
179 0 : return NULL;
180 : }
181 :
182 97528 : fIndex = index + 1;
183 :
184 97528 : return this;
185 97528 : }
186 :
187 : //______________________________________________________________________________
188 : void 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 8 : fEquipments.Clear();
195 :
196 4 : if (fEvtHdrs) {
197 964 : for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) {
198 478 : AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i);
199 478 : hdr->Reset();
200 : }
201 4 : fEvtHdrs->Clear();
202 4 : }
203 4 : fIndex = 0;
204 4 : }
205 :
206 : //______________________________________________________________________________
207 : AliRawEventV2::~AliRawEventV2()
208 60 : {
209 : // Clean up event object. Delete also, possible, private raw data.
210 :
211 : // if (fEquipments)
212 10 : fEquipments.Delete();
213 : // delete fEquipments;
214 10 : if (fEvtHdrs)
215 9 : fEvtHdrs->Delete();
216 19 : delete fEvtHdrs;
217 30 : }
218 :
219 : //______________________________________________________________________________
220 : void AliRawEventV2::Clear(Option_t*)
221 : {
222 : // Clear the event in case it needs to be re-used (avoiding costly
223 : // new/delete cycle). Can be used inside the event loop.
224 :
225 0 : fEquipments.Clear("C");
226 :
227 0 : if (fEvtHdrs) {
228 0 : for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) {
229 0 : AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i);
230 0 : hdr->Reset();
231 : }
232 0 : fEvtHdrs->Clear();
233 0 : }
234 0 : fIndex = 0;
235 0 : }
236 :
|