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