]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliRawEquipment.cxx
New version of dateStream which hadnles correctly the raw-data headers on Mac (which...
[u/mrichter/AliRoot.git] / RAW / AliRawEquipment.cxx
1 // @(#)alimdc:$Name$:$Id$
2 // Author: Fons Rademakers  26/11/99
3
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 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
41 #include <AliRawDataArray.h>
42
43 #include "AliRawEquipmentHeader.h"
44 #include "AliRawData.h"
45
46 #include "AliRawEquipment.h"
47
48
49 ClassImp(AliRawEquipment)
50
51
52 //______________________________________________________________________________
53 AliRawEquipment::AliRawEquipment():
54 fEqpHdr(NULL),
55 fRawData(NULL),
56 fRawDataRef(NULL)
57 {
58    // Create ALICE equipment object.
59
60 }
61
62 //______________________________________________________________________________
63 AliRawEquipmentHeader *AliRawEquipment::GetEquipmentHeader()
64 {
65    // Get equipment header part of AliRawEquipment.
66
67    if (!fEqpHdr)
68       fEqpHdr = new AliRawEquipmentHeader;
69
70    return fEqpHdr;
71 }
72
73 //______________________________________________________________________________
74 AliRawData *AliRawEquipment::GetRawData()
75 {
76    // Get raw data part of AliRawEquipment.
77
78   if (!fRawData) {
79     if (!fRawDataRef.IsValid())
80       fRawData = new AliRawData;
81     else {
82       fRawData = (AliRawData*)fRawDataRef.GetObject();
83     }
84   }
85   return fRawData;
86 }
87
88 //______________________________________________________________________________
89 void AliRawEquipment::Reset()
90 {
91    // Reset the equipment in case it needs to be re-used (avoiding costly
92    // new/delete cycle). We reset the size marker for the AliRawData
93    // object.
94
95    if (fEqpHdr) fEqpHdr->Reset();
96    GetRawData()->SetSize(0);
97    fRawDataRef = NULL;
98 }
99
100 //______________________________________________________________________________
101 AliRawEquipment::~AliRawEquipment()
102 {
103    // Clean up event object. Delete also, possible, private raw data.
104
105    delete fEqpHdr;
106    delete fRawData;
107 }
108
109 //______________________________________________________________________________
110 void AliRawEquipment::SetRawDataRef(AliRawDataArray *array)
111 {
112   // Set the TRef to the raw-data container
113   // before writing it to the branch
114   if (fRawData) {
115     fRawDataRef = fRawData;
116     array->Add(fRawData);
117     fRawData = NULL;
118     return;
119   }
120   else {
121     Error("SetRawDataRef", "Raw-data payload does not exist! Can not set a reference to it!");    
122     fRawDataRef = NULL;
123     return;
124   }
125 }