]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/BASE/AliHLTHOMERBlockDesc.cxx
Adding the new detector MFT (Antonio Uras)
[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#if __GNUC__>= 3
30 using namespace std;
31#endif
32
33#include "AliHLTHOMERBlockDesc.h"
34
35#include "AliHLTMessage.h"
36
37#include "TMath.h"
38#include "TClass.h"
39
40
41ClassImp(AliHLTHOMERBlockDesc)
42
43/*
44 * ---------------------------------------------------------------------------------
45 * Constructor / Destructor
46 * ---------------------------------------------------------------------------------
47 */
48
49//##################################################################################
50AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
51 fData(NULL),
52 fSize(0),
53 fBlockName(),
54 fIsTObject(kFALSE),
55 fIsRawData(kFALSE),
56 fMessage(NULL),
57 fTObject(NULL),
58 fClassName(),
59 fDataType(),
60 fDetector(),
61 fSpecification(0),
62 fSubDetector(0),
63 fSubSubDetector(0),
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
73//##################################################################################
74AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
75 // see header file for class documentation
76
77 if ( fMessage != NULL )
78 delete fMessage;
79 fMessage = NULL;
80
81 if ( fData )
82 delete [] fData;
83 fData = NULL;
84
85 if ( fTObject )
86 delete fTObject;
87 fTObject = NULL;
88}
89
90/*
91 * ---------------------------------------------------------------------------------
92 * Data Handling - Setter - public
93 * ---------------------------------------------------------------------------------
94 */
95
96//##################################################################################
97void AliHLTHOMERBlockDesc::SetBlock( void * data, ULong_t size, TString origin,
98 TString dataType, ULong_t specification ) {
99 // see header file for class documentation
100
101 fData = new Char_t[size];
102 memcpy( fData, data, size);
103
104 fSize = size;
105 fDetector = origin;
106 fDataType = dataType;
107 fSpecification = specification;
108
109 fBlockName.Form("%s_%s_0x%08lX", fDetector.Data(), fDataType.Data(), fSpecification );
110
111 // -- Set block parameters
112 SetBlockParameters();
113
114 return;
115}
116
117/*
118 * ---------------------------------------------------------------------------------
119 * Data Handling - private
120 * ---------------------------------------------------------------------------------
121 */
122
123//##################################################################################
124void AliHLTHOMERBlockDesc::SetBlockParameters() {
125 // see header file for class documentation
126
127 //Int_t iResult = 0;
128
129 // ---- SET SPECIFICATIONS ----
130 // ----------------------------
131
132 // **** TPC **** ( has special treatment )
133 if ( ! fDetector.CompareTo("TPC") ) {
134
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
140 fSubDetector = minSector;
141 fSubSubDetector = minPatch;
142
143 // -- check for ranges
144 if ( minSector != maxSector )
145 fHasSubDetectorRange = kTRUE;
146
147 if ( minPatch != maxPatch )
148 fHasSubSubDetectorRange = kTRUE;
149
150 }
151 // **** OTHER DETECTORS ****
152 else {
153
154 if ( fSpecification ) {
155 // find the max bin which is set to 1
156 fSubDetector = TMath::FloorNint( TMath::Log2(fSpecification) );
157
158 // -- check for ranges
159 if ( TMath::Log2(fSpecification) !=
160 static_cast<Double_t>(TMath::FloorNint(TMath::Log2(fSpecification))) )
161 fHasSubDetectorRange = kTRUE;
162 }
163 }
164
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";
183 //else
184 // iResult = -1;
185 }
186 /*
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 }
206 */
207
208 // -- Check if classname has been defined
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 // }
213 return;
214}
215
216//##################################################################################
217Bool_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
234 if ( fMessage->What() == kMESS_OBJECT and fMessage->GetClass() != NULL and fMessage->GetClass() != (TClass*)-1)
235 {
236 fClassName = fMessage->GetClass()->GetName();
237 fIsTObject = kTRUE;
238
239 fTObject = fMessage->ReadObject( fMessage->GetClass() );
240 }
241
242 fMessage->Reset();
243
244 return fIsTObject;
245}
246
247//##################################################################################
248Bool_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}
256