* Added new Handler Classes for HOMER Proxy
[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"
06272c83 33
155ff173 34#include "AliHLTMessage.h"
35
36#include "TMath.h"
37#include "TClass.h"
38
39
40ClassImp(AliHLTHOMERBlockDesc)
41
06272c83 42/*
43 * ---------------------------------------------------------------------------------
44 * Constructor / Destructor
45 * ---------------------------------------------------------------------------------
46 */
47
155ff173 48//##################################################################################
49AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
50 fData(NULL),
51 fSize(0),
06272c83 52 fBlockName(),
155ff173 53 fIsTObject(kFALSE),
54 fIsRawData(kFALSE),
55 fMessage(NULL),
2ff24e4c 56 fTObject(NULL),
155ff173 57 fClassName(),
06272c83 58 fDataType(),
155ff173 59 fDetector(),
155ff173 60 fSpecification(0),
06272c83 61 fSubDetector(0),
62 fSubSubDetector(0),
155ff173 63 fHasSubDetectorRange(kFALSE),
64 fHasSubSubDetectorRange(kFALSE) {
65 // see header file for class documentation
66 // or
67 // refer to README to build package
68 // or
69 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
70}
71
155ff173 72//##################################################################################
73AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
74 // see header file for class documentation
75
76 if ( fMessage != NULL )
77 delete fMessage;
78 fMessage = NULL;
2ff24e4c 79
155ff173 80}
81
06272c83 82/*
83 * ---------------------------------------------------------------------------------
84 * Data Handling - Setter - public
85 * ---------------------------------------------------------------------------------
86 */
87
155ff173 88//##################################################################################
89void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin,
90 TString dataType, ULong_t specification ) {
91 // see header file for class documentation
92
93 fData = data;
94 fSize = size;
95 fDetector = origin;
96 fDataType = dataType;
97 fSpecification = specification;
98
06272c83 99 fBlockName.Form("%s_%s%_%ul", fDetector.Data(), fDataType.Data(), fSpecification );
100
155ff173 101 // -- Set block parameters
102 SetBlockParameters();
103
104 return;
105}
106
06272c83 107/*
108 * ---------------------------------------------------------------------------------
109 * Data Handling - private
110 * ---------------------------------------------------------------------------------
111 */
112
155ff173 113//##################################################################################
114void AliHLTHOMERBlockDesc::SetBlockParameters() {
115 // see header file for class documentation
116
06272c83 117 Int_t iResult = 0;
155ff173 118
155ff173 119 // ---- SET SPECIFICATIONS ----
06272c83 120 // ----------------------------
155ff173 121
122 // **** TPC **** ( has special treatment )
155ff173 123 if ( ! fDetector.CompareTo("TPC") ) {
06272c83 124
155ff173 125 Int_t minPatch = (fSpecification & 0x000000FF);
126 Int_t maxPatch = (fSpecification & 0x0000FF00) >> 8;
127 Int_t minSector = (fSpecification & 0x00FF0000) >> 16 ;
128 Int_t maxSector = (fSpecification & 0xFF000000) >> 24;
129
06272c83 130 fSubDetector = minSector;
131 fSubSubDetector = minPatch;
132
155ff173 133 // -- check for ranges
134 if ( minSector != maxSector )
135 fHasSubDetectorRange = kTRUE;
136
137 if ( minPatch != maxPatch )
138 fHasSubSubDetectorRange = kTRUE;
06272c83 139
155ff173 140 }
155ff173 141 // **** OTHER DETECTORS ****
155ff173 142 else {
06272c83 143
155ff173 144 if ( fSpecification ) {
06272c83 145 // find the max bin which is set to 1
146 fSubDetector = TMath::FloorNint( TMath::Log2(fSpecification) );
147
155ff173 148 // -- check for ranges
06272c83 149 if ( TMath::Log2(fSpecification) !=
150 static_cast<Double_t>(TMath::FloorNint(TMath::Log2(fSpecification))) )
155ff173 151 fHasSubDetectorRange = kTRUE;
155ff173 152 }
153 }
154
06272c83 155 // ---- SET CLASS NAME, DATA CONTENTS ----
156 // ---------------------------------------
157
158 // -- Check if block contains raw data
159 if ( CheckIfRawData() )
160 return;
161
162 // -- Check if block contains TObject
163 if ( CheckIfTObject() )
164 return;
165
166 // -- Contains arbitrary data type
167
168 // **** TPC ****
169 if ( ! fDetector.CompareTo("TPC") ) {
170
171 if ( ! fDataType.CompareTo("CLUSTERS") )
172 fClassName = "AliHLTTPCSpacePoints";
173 else
174 iResult = -1;
175 }
176
177 // **** TRD ****
178 else if ( ! fDetector.CompareTo("TRD") ) {
179 iResult = -1;
180 }
181
182 // **** PHOS ****
183 else if ( ! fDetector.CompareTo("PHOS") ) {
184 iResult = -1;
185 }
186
187 // **** MUON ****
188 else if ( ! fDetector.CompareTo("MUON") ) {
189 iResult = -1;
190 }
191
192 // **** OTHER ****
193 else {
194 iResult = -1;
195 }
196
197 // -- Check if classname has been defined
198 /*
199 if ( iResult < 0 ) {
200 HLTWarning( "The classname for data type %s for the detector %s has not been defined yet.",
201 fDataType.Data(), fDetector.Data());
202 }
203 */
155ff173 204 return;
205}
206
207//##################################################################################
208Bool_t AliHLTHOMERBlockDesc::CheckIfTObject() {
209 // see header file for class documentation
210
211 // -- Check Length - First 32 bit word of payload contains the length
212 UInt_t len = *( (UInt_t*) fData );
213
214 if ( len != ( fSize - sizeof(UInt_t) ) )
215 return fIsTObject;
216
217 // -- set AliHLTMessage
218 if ( fMessage )
219 delete fMessage;
220 fMessage = NULL;
221
222 fMessage = new AliHLTMessage( fData, fSize );
223
224 // -- Check if TMessage payload is TObject
225 if ( fMessage->What() == kMESS_OBJECT ) {
226 fClassName = fMessage->GetClass()->GetName();
227 fIsTObject = kTRUE;
2ff24e4c 228
229 fTObject = fMessage->ReadObject( fMessage->GetClass() );
155ff173 230 }
2ff24e4c 231
232 fMessage->Reset();
155ff173 233
234 return fIsTObject;
235}
236
237//##################################################################################
238Bool_t AliHLTHOMERBlockDesc::CheckIfRawData() {
239 // see header file for class documentation
240
241 if ( ! fDataType.CompareTo("DDL_RAW") )
242 fIsRawData = kTRUE;
243
244 return fIsRawData;
245}
2ff24e4c 246