]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTHOMERBlockDesc.cxx
little changes
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERBlockDesc.cxx
CommitLineData
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
155ff173 29#include "AliHLTHOMERBlockDesc.h"
06272c83 30
155ff173 31#include "AliHLTMessage.h"
32
33#include "TMath.h"
34#include "TClass.h"
35
155ff173 36ClassImp(AliHLTHOMERBlockDesc)
37
06272c83 38/*
39 * ---------------------------------------------------------------------------------
40 * Constructor / Destructor
41 * ---------------------------------------------------------------------------------
42 */
43
155ff173 44//##################################################################################
45AliHLTHOMERBlockDesc::AliHLTHOMERBlockDesc() :
46 fData(NULL),
47 fSize(0),
06272c83 48 fBlockName(),
155ff173 49 fIsTObject(kFALSE),
50 fIsRawData(kFALSE),
51 fMessage(NULL),
2ff24e4c 52 fTObject(NULL),
155ff173 53 fClassName(),
06272c83 54 fDataType(),
155ff173 55 fDetector(),
155ff173 56 fSpecification(0),
06272c83 57 fSubDetector(0),
58 fSubSubDetector(0),
155ff173 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
155ff173 68//##################################################################################
69AliHLTHOMERBlockDesc::~AliHLTHOMERBlockDesc() {
70 // see header file for class documentation
71
72 if ( fMessage != NULL )
73 delete fMessage;
74 fMessage = NULL;
2ff24e4c 75
ea9a0e13 76 if ( fData )
77 delete [] fData;
78 fData = NULL;
6c1e30ef 79
80 if ( fTObject )
81 delete fTObject;
82 fTObject = NULL;
155ff173 83}
84
06272c83 85/*
86 * ---------------------------------------------------------------------------------
87 * Data Handling - Setter - public
88 * ---------------------------------------------------------------------------------
89 */
90
155ff173 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
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
6fe8cb30 104 fBlockName.Form("%s_%s_0x%08lX", 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//##################################################################################
119void AliHLTHOMERBlockDesc::SetBlockParameters() {
120 // see header file for class documentation
121
6e290578 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";
6e290578 178 //else
179 // iResult = -1;
06272c83 180 }
6e290578 181 /*
06272c83 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 }
6e290578 201 */
06272c83 202
203 // -- Check if classname has been defined
e728e5ba 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 // }
155ff173 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
64984943 229 if ( fMessage->What() == kMESS_OBJECT and fMessage->GetClass() != NULL and fMessage->GetClass() != (TClass*)-1)
230 {
155ff173 231 fClassName = fMessage->GetClass()->GetName();
232 fIsTObject = kTRUE;
2ff24e4c 233
234 fTObject = fMessage->ReadObject( fMessage->GetClass() );
155ff173 235 }
2ff24e4c 236
237 fMessage->Reset();
155ff173 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}
2ff24e4c 251