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