]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTHOMERBlockDesc.cxx
added HOMER block and source descriptor classes
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERBlockDesc.cxx
CommitLineData
155ff173 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
5 * for The ALICE HLT Project. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/** @file AliHLTHOMERBlockDesc.cxx
17 @author Jochen Thaeder
18 @date
19 @brief Container for HOMER Blocks
20*/
21
22// see header file for class documentation
23// or
24// refer to README to build package
25// or
26// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
27
28#if __GNUC__>= 3
29 using namespace std;
30#endif
31
32#include "AliHLTHOMERBlockDesc.h"
33#include "AliHLTMessage.h"
34
35#include "TMath.h"
36#include "TClass.h"
37
38
39ClassImp(AliHLTHOMERBlockDesc)
40
41//##################################################################################
42AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
43 fData(NULL),
44 fSize(0),
45 fIsTObject(kFALSE),
46 fIsRawData(kFALSE),
47 fMessage(NULL),
48 fClassName(),
49 fDetector(),
50 fSubDetector(),
51 fSubSubDetector(),
52 fSpecification(0),
53 fDataType(),
54 fHasSubDetectorRange(kFALSE),
55 fHasSubSubDetectorRange(kFALSE) {
56 // see header file for class documentation
57 // or
58 // refer to README to build package
59 // or
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61}
62
63//##################################################################################
64AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc( void * data, ULong_t size, TString origin,
65 TString dataType, ULong_t specification ) :
66 fData(data),
67 fSize(size),
68 fIsTObject(kFALSE),
69 fIsRawData(kFALSE),
70 fMessage(NULL),
71 fClassName(),
72 fDetector(origin),
73 fSubDetector(),
74 fSubSubDetector(),
75 fSpecification(specification),
76 fDataType(dataType),
77 fHasSubDetectorRange(kFALSE),
78 fHasSubSubDetectorRange(kFALSE) {
79 // see header file for class documentation
80
81 // -- Set block parameters
82 SetBlockParameters();
83
84}
85
86//##################################################################################
87AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
88 // see header file for class documentation
89
90 if ( fMessage != NULL )
91 delete fMessage;
92 fMessage = NULL;
93}
94
95//##################################################################################
96void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin,
97 TString dataType, ULong_t specification ) {
98 // see header file for class documentation
99
100 fData = data;
101 fSize = size;
102 fDetector = origin;
103 fDataType = dataType;
104 fSpecification = specification;
105
106 // -- Set block parameters
107 SetBlockParameters();
108
109 return;
110}
111
112//##################################################################################
113void AliHLTHOMERBlockDesc::SetBlockParameters() {
114 // see header file for class documentation
115
116 Int_t iError = 0;
117
118 // ---- SET CLASS NAME, DATA CONTENTS ----
119
120 // -- Check if block contains raw data
121 if ( ! CheckIfRawData() ) {
122
123 // -- Check if block contains TObject
124 if ( ! CheckIfTObject() ) {
125
126 // -- Contains arbitrary data type
127
128 // **** TPC ****
129 if ( ! fDetector.CompareTo("TPC") ) {
130
131 if ( ! fDataType.CompareTo("CLUSTERS") )
132 fClassName = "AliHLTTPCSpacePoints";
133 else
134 iError = 1;
135 }
136
137 // **** TRD ****
138
139 else if ( ! fDetector.CompareTo("TRD") ) {
140 iError = 1;
141 }
142
143 // **** PHOS ****
144
145 else if ( ! fDetector.CompareTo("PHOS") ) {
146 iError = 1;
147 }
148
149 // **** MUON ****
150
151 else if ( ! fDetector.CompareTo("MUON") ) {
152 iError = 1;
153 }
154
155 // **** OTHER ****
156
157 else {
158 iError = 1;
159 }
160 }
161 } // if ( ! CheckIfRawData() ) {
162
163 // -- Check if Data Type has been defined
164 if ( iError ) {
165 //AliError( Form("The data type %s for the detector %s has not been defined yet.",
166 // fDataType.Data(), fDetector.Data()) );
167 }
168
169 // ---- SET SPECIFICATIONS ----
170 // -- Convert Specification to "SubDetector/SubSubDetector"
171
172 // **** TPC **** ( has special treatment )
173
174 if ( ! fDetector.CompareTo("TPC") ) {
175
176 Int_t minPatch = (fSpecification & 0x000000FF);
177 Int_t maxPatch = (fSpecification & 0x0000FF00) >> 8;
178 Int_t minSector = (fSpecification & 0x00FF0000) >> 16 ;
179 Int_t maxSector = (fSpecification & 0xFF000000) >> 24;
180
181 fSubDetector += minSector;
182 fSubSubDetector += minPatch;
183
184 // -- check for ranges
185 if ( minSector != maxSector )
186 fHasSubDetectorRange = kTRUE;
187
188 if ( minPatch != maxPatch )
189 fHasSubSubDetectorRange = kTRUE;
190 }
191
192 // **** OTHER DETECTORS ****
193
194 else {
195
196 if ( fSpecification ) {
197 // find the max bin which is set to 1
198 fSubDetector += TMath::FloorNint( TMath::Log2(fSpecification) );
199
200 // -- check for ranges
201 if ( TMath::Log2(fSpecification) != ( (Double_t) TMath::FloorNint( TMath::Log2(fSpecification) ) ) )
202 fHasSubDetectorRange = kTRUE;
203
204 }
205 }
206
207 return;
208}
209
210//##################################################################################
211Bool_t AliHLTHOMERBlockDesc::CheckIfTObject() {
212 // see header file for class documentation
213
214 // -- Check Length - First 32 bit word of payload contains the length
215 UInt_t len = *( (UInt_t*) fData );
216
217 if ( len != ( fSize - sizeof(UInt_t) ) )
218 return fIsTObject;
219
220 // -- set AliHLTMessage
221 if ( fMessage )
222 delete fMessage;
223 fMessage = NULL;
224
225 fMessage = new AliHLTMessage( fData, fSize );
226
227 // -- Check if TMessage payload is TObject
228 if ( fMessage->What() == kMESS_OBJECT ) {
229 fClassName = fMessage->GetClass()->GetName();
230 fIsTObject = kTRUE;
231 }
232
233 return fIsTObject;
234}
235
236//##################################################################################
237Bool_t AliHLTHOMERBlockDesc::CheckIfRawData() {
238 // see header file for class documentation
239
240 if ( ! fDataType.CompareTo("DDL_RAW") )
241 fIsRawData = kTRUE;
242
243 return fIsRawData;
244}
245
246//##################################################################################
247TObject* AliHLTHOMERBlockDesc::GetTObject() {
248 // see header file for class documentation
249
250 if ( fMessage )
251 return (TObject*) fMessage->ReadObject( fMessage->GetClass() );
252 else
253 return NULL;
254}