]>
Commit | Line | Data |
---|---|---|
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 | ||
40 | ClassImp(AliHLTHOMERBlockDesc) | |
41 | ||
06272c83 | 42 | /* |
43 | * --------------------------------------------------------------------------------- | |
44 | * Constructor / Destructor | |
45 | * --------------------------------------------------------------------------------- | |
46 | */ | |
47 | ||
155ff173 | 48 | //################################################################################## |
49 | AliHLTHOMERBlockDesc::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 | //################################################################################## |
73 | AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() { | |
74 | // see header file for class documentation | |
75 | ||
76 | if ( fMessage != NULL ) | |
77 | delete fMessage; | |
78 | fMessage = NULL; | |
2ff24e4c | 79 | |
ea9a0e13 | 80 | if ( fData ) |
81 | delete [] fData; | |
82 | fData = NULL; | |
155ff173 | 83 | } |
84 | ||
06272c83 | 85 | /* |
86 | * --------------------------------------------------------------------------------- | |
87 | * Data Handling - Setter - public | |
88 | * --------------------------------------------------------------------------------- | |
89 | */ | |
90 | ||
155ff173 | 91 | //################################################################################## |
92 | void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin, | |
93 | TString dataType, ULong_t specification ) { | |
94 | // see header file for class documentation | |
95 | ||
ea9a0e13 | 96 | fData = new Char_t[size]; |
97 | memcpy( fData, data, size); | |
98 | ||
155ff173 | 99 | fSize = size; |
100 | fDetector = origin; | |
101 | fDataType = dataType; | |
102 | fSpecification = specification; | |
103 | ||
9e78371d | 104 | fBlockName.Form("%s_%s_0x%08X", fDetector.Data(), fDataType.Data(), fSpecification ); |
06272c83 | 105 | |
155ff173 | 106 | // -- Set block parameters |
107 | SetBlockParameters(); | |
108 | ||
109 | return; | |
110 | } | |
111 | ||
06272c83 | 112 | /* |
113 | * --------------------------------------------------------------------------------- | |
114 | * Data Handling - private | |
115 | * --------------------------------------------------------------------------------- | |
116 | */ | |
117 | ||
155ff173 | 118 | //################################################################################## |
119 | void AliHLTHOMERBlockDesc::SetBlockParameters() { | |
120 | // see header file for class documentation | |
121 | ||
06272c83 | 122 | Int_t iResult = 0; |
155ff173 | 123 | |
155ff173 | 124 | // ---- SET SPECIFICATIONS ---- |
06272c83 | 125 | // ---------------------------- |
155ff173 | 126 | |
127 | // **** TPC **** ( has special treatment ) | |
155ff173 | 128 | if ( ! fDetector.CompareTo("TPC") ) { |
06272c83 | 129 | |
155ff173 | 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 | ||
06272c83 | 135 | fSubDetector = minSector; |
136 | fSubSubDetector = minPatch; | |
137 | ||
155ff173 | 138 | // -- check for ranges |
139 | if ( minSector != maxSector ) | |
140 | fHasSubDetectorRange = kTRUE; | |
141 | ||
142 | if ( minPatch != maxPatch ) | |
143 | fHasSubSubDetectorRange = kTRUE; | |
06272c83 | 144 | |
155ff173 | 145 | } |
155ff173 | 146 | // **** OTHER DETECTORS **** |
155ff173 | 147 | else { |
06272c83 | 148 | |
155ff173 | 149 | if ( fSpecification ) { |
06272c83 | 150 | // find the max bin which is set to 1 |
151 | fSubDetector = TMath::FloorNint( TMath::Log2(fSpecification) ); | |
152 | ||
155ff173 | 153 | // -- check for ranges |
06272c83 | 154 | if ( TMath::Log2(fSpecification) != |
155 | static_cast<Double_t>(TMath::FloorNint(TMath::Log2(fSpecification))) ) | |
155ff173 | 156 | fHasSubDetectorRange = kTRUE; |
155ff173 | 157 | } |
158 | } | |
159 | ||
06272c83 | 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 | // -- Check if classname has been defined | |
e728e5ba | 203 | // if ( iResult < 0 ) { |
204 | // AliWarning( Form("The classname for data type %s for the detector %s has not been defined yet.", | |
205 | // fDataType.Data(), fDetector.Data()) ); | |
206 | // } | |
155ff173 | 207 | return; |
208 | } | |
209 | ||
210 | //################################################################################## | |
211 | Bool_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; | |
2ff24e4c | 231 | |
232 | fTObject = fMessage->ReadObject( fMessage->GetClass() ); | |
155ff173 | 233 | } |
2ff24e4c | 234 | |
235 | fMessage->Reset(); | |
155ff173 | 236 | |
237 | return fIsTObject; | |
238 | } | |
239 | ||
240 | //################################################################################## | |
241 | Bool_t AliHLTHOMERBlockDesc::CheckIfRawData() { | |
242 | // see header file for class documentation | |
243 | ||
244 | if ( ! fDataType.CompareTo("DDL_RAW") ) | |
245 | fIsRawData = kTRUE; | |
246 | ||
247 | return fIsRawData; | |
248 | } | |
2ff24e4c | 249 |