Line data Source code
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 :
36 126 : ClassImp(AliHLTHOMERBlockDesc)
37 :
38 : /*
39 : * ---------------------------------------------------------------------------------
40 : * Constructor / Destructor
41 : * ---------------------------------------------------------------------------------
42 : */
43 :
44 : //##################################################################################
45 0 : AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
46 0 : fData(NULL),
47 0 : fSize(0),
48 0 : fBlockName(),
49 0 : fIsTObject(kFALSE),
50 0 : fIsRawData(kFALSE),
51 0 : fMessage(NULL),
52 0 : fTObject(NULL),
53 0 : fClassName(),
54 0 : fDataType(),
55 0 : fDetector(),
56 0 : fSpecification(0),
57 0 : fSubDetector(0),
58 0 : fSubSubDetector(0),
59 0 : fHasSubDetectorRange(kFALSE),
60 0 : 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 0 : }
67 :
68 : //##################################################################################
69 0 : AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
70 : // see header file for class documentation
71 :
72 0 : if ( fMessage != NULL )
73 0 : delete fMessage;
74 0 : fMessage = NULL;
75 :
76 0 : if ( fData )
77 0 : delete [] fData;
78 0 : fData = NULL;
79 :
80 0 : if ( fTObject )
81 0 : delete fTObject;
82 0 : fTObject = NULL;
83 0 : }
84 :
85 : /*
86 : * ---------------------------------------------------------------------------------
87 : * Data Handling - Setter - public
88 : * ---------------------------------------------------------------------------------
89 : */
90 :
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 :
96 0 : fData = new Char_t[size];
97 0 : memcpy( fData, data, size);
98 :
99 0 : fSize = size;
100 0 : fDetector = origin;
101 0 : fDataType = dataType;
102 0 : fSpecification = specification;
103 :
104 0 : fBlockName.Form("%s_%s_0x%08lX", fDetector.Data(), fDataType.Data(), fSpecification );
105 :
106 : // -- Set block parameters
107 0 : SetBlockParameters();
108 :
109 0 : return;
110 : }
111 :
112 : /*
113 : * ---------------------------------------------------------------------------------
114 : * Data Handling - private
115 : * ---------------------------------------------------------------------------------
116 : */
117 :
118 : //##################################################################################
119 : void 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 0 : if ( ! fDetector.CompareTo("TPC") ) {
129 :
130 0 : Int_t minPatch = (fSpecification & 0x000000FF);
131 0 : Int_t maxPatch = (fSpecification & 0x0000FF00) >> 8;
132 0 : Int_t minSector = (fSpecification & 0x00FF0000) >> 16 ;
133 0 : Int_t maxSector = (fSpecification & 0xFF000000) >> 24;
134 :
135 0 : fSubDetector = minSector;
136 0 : fSubSubDetector = minPatch;
137 :
138 : // -- check for ranges
139 0 : if ( minSector != maxSector )
140 0 : fHasSubDetectorRange = kTRUE;
141 :
142 0 : if ( minPatch != maxPatch )
143 0 : fHasSubSubDetectorRange = kTRUE;
144 :
145 0 : }
146 : // **** OTHER DETECTORS ****
147 : else {
148 :
149 0 : if ( fSpecification ) {
150 : // find the max bin which is set to 1
151 0 : fSubDetector = TMath::FloorNint( TMath::Log2(fSpecification) );
152 :
153 : // -- check for ranges
154 0 : if ( TMath::Log2(fSpecification) !=
155 0 : static_cast<Double_t>(TMath::FloorNint(TMath::Log2(fSpecification))) )
156 0 : fHasSubDetectorRange = kTRUE;
157 : }
158 : }
159 :
160 : // ---- SET CLASS NAME, DATA CONTENTS ----
161 : // ---------------------------------------
162 :
163 : // -- Check if block contains raw data
164 0 : if ( CheckIfRawData() )
165 : return;
166 :
167 : // -- Check if block contains TObject
168 0 : if ( CheckIfTObject() )
169 : return;
170 :
171 : // -- Contains arbitrary data type
172 :
173 : // **** TPC ****
174 0 : if ( ! fDetector.CompareTo("TPC") ) {
175 :
176 0 : if ( ! fDataType.CompareTo("CLUSTERS") )
177 0 : 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 0 : }
210 :
211 : //##################################################################################
212 : Bool_t AliHLTHOMERBlockDesc::CheckIfTObject() {
213 : // see header file for class documentation
214 :
215 : // -- Check Length - First 32 bit word of payload contains the length
216 0 : UInt_t len = *( (UInt_t*) fData );
217 :
218 0 : if ( len != ( fSize - sizeof(UInt_t) ) )
219 0 : return fIsTObject;
220 :
221 : // -- set AliHLTMessage
222 0 : if ( fMessage )
223 0 : delete fMessage;
224 0 : fMessage = NULL;
225 :
226 0 : fMessage = new AliHLTMessage( fData, fSize );
227 :
228 : // -- Check if TMessage payload is TObject
229 0 : if ( fMessage->What() == kMESS_OBJECT and fMessage->GetClass() != NULL and fMessage->GetClass() != (TClass*)-1)
230 : {
231 0 : fClassName = fMessage->GetClass()->GetName();
232 0 : fIsTObject = kTRUE;
233 :
234 0 : fTObject = fMessage->ReadObject( fMessage->GetClass() );
235 0 : }
236 :
237 0 : fMessage->Reset();
238 :
239 0 : return fIsTObject;
240 0 : }
241 :
242 : //##################################################################################
243 : Bool_t AliHLTHOMERBlockDesc::CheckIfRawData() {
244 : // see header file for class documentation
245 :
246 0 : if ( ! fDataType.CompareTo("DDL_RAW") )
247 0 : fIsRawData = kTRUE;
248 :
249 0 : return fIsRawData;
250 : }
251 :
252 : //##################################################################################
253 : void AliHLTHOMERBlockDesc::ComponentDataType(AliHLTComponentDataType& dataType)
254 : {
255 0 : dataType.fStructSize = sizeof(AliHLTComponentDataType);
256 0 : memcpy(dataType.fID, fDataType.Data(), kAliHLTComponentDataTypefIDsize);
257 0 : memcpy(dataType.fOrigin, fDetector.Data(), kAliHLTComponentDataTypefOriginSize);
258 0 : }
259 :
260 : //##################################################################################
261 : void AliHLTHOMERBlockDesc::Topic(char* topic, int topicSize)
262 : {
263 0 : memcpy(topic, fDataType.Data(), kAliHLTComponentDataTypefIDsize);
264 0 : memcpy(topic+kAliHLTComponentDataTypefIDsize, fDetector.Data(), kAliHLTComponentDataTypefOriginSize);
265 0 : }
|