1 // Author: Cvetan Cheshkov 11/05/2009
3 /**************************************************************************
4 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //////////////////////////////////////////////////////////////////////////
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. //
38 //////////////////////////////////////////////////////////////////////////
40 #include <TObjArray.h>
45 #include "AliRawEventHeaderBase.h"
46 #include "AliRawEquipmentV2.h"
48 #include "AliRawEventV2.h"
51 ClassImp(AliRawEventV2)
54 //______________________________________________________________________________
55 AliRawEventV2::AliRawEventV2():
57 fEquipments("AliRawEquipmentV2",1000),
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.
68 //______________________________________________________________________________
69 AliRawEventHeaderBase *AliRawEventV2::GetHeader(char*& data)
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
75 AliRawEventHeaderBase *hdr = NULL;
78 hdr = AliRawEventHeaderBase::Create(data);
79 hdr->IsA()->IgnoreTObjectStreamer();
80 fEvtHdrs = new TClonesArray(hdr->IsA()->GetName(),100);
84 if (fIndex < fNAllocHdrs) {
85 TClonesArray &arr = *fEvtHdrs;
86 return (AliRawEventHeaderBase *)arr[fIndex];
89 fNAllocHdrs = fIndex + 1;
90 return (AliRawEventHeaderBase *)fEvtHdrs->New(fIndex);
94 //______________________________________________________________________________
95 AliRawEventHeaderBase *AliRawEventV2::GetHeader()
97 AliRawEventHeaderBase *hdr = NULL;
98 if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
99 AliFatal("Event header does not exist!");
106 //______________________________________________________________________________
107 AliRawEquipmentV2 *AliRawEventV2::NextEquipment()
109 // Returns next equipment object.
111 AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex);
112 Int_t nEquipments = fEquipments.GetEntriesFast();
113 hdr->AddEqIndex(nEquipments);
115 if (nEquipments < fNAllocEqs) {
116 return (AliRawEquipmentV2 *)fEquipments[nEquipments];
119 fNAllocEqs = nEquipments + 1;
120 return new (fEquipments[nEquipments]) AliRawEquipmentV2();
124 //______________________________________________________________________________
125 AliRawVEquipment *AliRawEventV2::GetEquipment(Int_t index) const
127 // Get specified equipment. Returns 0 if equipment does not exist.
132 AliRawEventHeaderBase *hdr = NULL;
133 if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
134 AliFatal("Header is not yet initialized!");
138 if ((index + hdr->GetFirstEqIndex()) > hdr->GetLastEqIndex()) {
139 AliFatal("Equipment index out of scope!");
143 return (AliRawVEquipment *) fEquipments.UncheckedAt(index+hdr->GetFirstEqIndex());
147 //______________________________________________________________________________
148 Int_t AliRawEventV2::GetNEquipments() const
153 AliRawEventHeaderBase *hdr = NULL;
154 if (!fEvtHdrs || !(hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(fIndex))) {
155 AliFatal("Header is not yet initialized!");
159 return (hdr->GetFirstEqIndex() < 0) ? 0 : (hdr->GetLastEqIndex() - hdr->GetFirstEqIndex() + 1);
162 //______________________________________________________________________________
163 AliRawEventV2 *AliRawEventV2::NextSubEvent()
165 // Returns next sub-event object.
172 //______________________________________________________________________________
173 AliRawVEvent *AliRawEventV2::GetSubEvent(Int_t index)
175 // Get specified sub event. Returns 0 if sub event does not exist.
178 AliFatal("Headers are not yet initialized!");
187 //______________________________________________________________________________
188 void AliRawEventV2::Reset()
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.
197 for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) {
198 AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i);
206 //______________________________________________________________________________
207 AliRawEventV2::~AliRawEventV2()
209 // Clean up event object. Delete also, possible, private raw data.
212 fEquipments.Delete();
213 // delete fEquipments;
219 //______________________________________________________________________________
220 void AliRawEventV2::Clear(Option_t*)
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.
225 fEquipments.Clear("C");
228 for (int i = 0; i < fEvtHdrs->GetEntriesFast(); i++) {
229 AliRawEventHeaderBase *hdr = (AliRawEventHeaderBase *)fEvtHdrs->UncheckedAt(i);