]>
Commit | Line | Data |
---|---|---|
a9d14303 | 1 | // $Id$ |
6af4f584 | 2 | |
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
18 | ||
19 | /** @file AliHLTTPCHWClusterTransformComponent.cxx | |
20 | @author Kalliopi Kanaki | |
21 | @date | |
22 | @brief | |
23 | */ | |
24 | ||
25 | #if __GNUC__>= 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | #include "AliHLTTPCHWClusterTransformComponent.h" | |
29 | #include "AliHLTTPCDefinitions.h" | |
30 | #include "AliHLTTPCTransform.h" | |
31 | #include "AliHLTTPCSpacePointData.h" | |
32 | #include "AliHLTTPCClusterDataFormat.h" | |
33 | ||
a9d14303 | 34 | #include "AliTPCcalibDB.h" |
35 | #include "AliTPCTransform.h" | |
36 | ||
6af4f584 | 37 | #include <cstdlib> |
38 | #include <cerrno> | |
39 | #include <sys/time.h> | |
40 | ||
41 | ClassImp(AliHLTTPCHWClusterTransformComponent) //ROOT macro for the implementation of ROOT specific class methods | |
42 | ||
43 | AliHLTTPCHWClusterTransformComponent::AliHLTTPCHWClusterTransformComponent() | |
a9d14303 | 44 | : |
45 | fOfflineTransform(NULL) | |
6af4f584 | 46 | { |
47 | // see header file for class documentation | |
48 | // or | |
49 | // refer to README to build package | |
50 | // or | |
a9d14303 | 51 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt |
52 | ||
6af4f584 | 53 | } |
54 | ||
55 | AliHLTTPCHWClusterTransformComponent::~AliHLTTPCHWClusterTransformComponent() { | |
56 | // see header file for class documentation | |
57 | } | |
58 | ||
59 | const char* AliHLTTPCHWClusterTransformComponent::GetComponentID() { | |
60 | // see header file for class documentation | |
61 | ||
62 | return "TPCHWClusterTransform"; | |
63 | } | |
64 | ||
65 | void AliHLTTPCHWClusterTransformComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
66 | // see header file for class documentation | |
67 | ||
68 | list.clear(); | |
69 | list.push_back( AliHLTTPCDefinitions::fgkHWClustersDataType ); | |
70 | } | |
71 | ||
72 | AliHLTComponentDataType AliHLTTPCHWClusterTransformComponent::GetOutputDataType() { | |
73 | // see header file for class documentation | |
74 | ||
75 | return AliHLTTPCDefinitions::fgkClustersDataType; | |
76 | } | |
77 | ||
78 | int AliHLTTPCHWClusterTransformComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) { | |
79 | // see header file for class documentation | |
80 | ||
81 | tgtList.clear(); | |
82 | tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType); | |
83 | return tgtList.size(); | |
84 | } | |
85 | ||
86 | void AliHLTTPCHWClusterTransformComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
87 | // see header file for class documentation | |
88 | ||
89 | constBase = 0; | |
90 | inputMultiplier = 2.0; | |
91 | } | |
92 | ||
93 | AliHLTComponent* AliHLTTPCHWClusterTransformComponent::Spawn() { | |
94 | // see header file for class documentation | |
95 | ||
96 | return new AliHLTTPCHWClusterTransformComponent(); | |
97 | } | |
98 | ||
99 | int AliHLTTPCHWClusterTransformComponent::DoInit( int /*argc*/, const char** /*argv*/ ) { | |
100 | // see header file for class documentation | |
101 | ||
b4c689c4 | 102 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); |
103 | if(!pCalib || | |
104 | !(fOfflineTransform = AliTPCcalibDB::Instance()->GetTransform())){ | |
105 | HLTError("Can not retrieve Offline transform from AliTPCcalibDB (%p)", pCalib); | |
106 | return -ENOENT; | |
107 | } | |
108 | ||
6af4f584 | 109 | // Int_t i = 0; |
110 | // Char_t* cpErr; | |
111 | // | |
112 | // int iResult=0; | |
113 | // | |
114 | // TString configuration=""; | |
115 | // TString argument=""; | |
116 | // for (int j=0; j<argc && iResult>=0; j++) { | |
117 | // | |
118 | // argument=argv[j]; | |
119 | // if (!configuration.IsNull()) configuration+=" "; | |
120 | // configuration+=argument; | |
121 | // } | |
122 | // | |
123 | // if (!configuration.IsNull()) { | |
124 | // iResult=Configure(configuration.Data()); | |
125 | // } else { | |
126 | // iResult=Reconfigure(NULL, NULL); | |
127 | // } | |
128 | ||
129 | return 0; | |
130 | } // end DoInit() | |
131 | ||
132 | int AliHLTTPCHWClusterTransformComponent::DoDeinit() { | |
133 | // see header file for class documentation | |
134 | ||
135 | return 0; | |
136 | } | |
137 | ||
138 | int AliHLTTPCHWClusterTransformComponent::DoEvent(const AliHLTComponentEventData& evtData, | |
139 | const AliHLTComponentBlockData* blocks, | |
140 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, | |
141 | AliHLTUInt32_t& size, | |
142 | vector<AliHLTComponentBlockData>& outputBlocks ){ | |
143 | // see header file for class documentation | |
144 | ||
145 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){ | |
146 | size = 0; | |
147 | return 0; | |
148 | } | |
149 | ||
150 | const AliHLTComponentBlockData *iter = NULL; | |
151 | unsigned long ndx; | |
152 | ||
153 | AliHLTTPCClusterData* outPtr; | |
154 | ||
155 | AliHLTUInt8_t* outBPtr; | |
156 | UInt_t offset, mysize, nSize, tSize = 0; | |
157 | ||
158 | outBPtr = outputPtr; | |
159 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
160 | ||
161 | AliHLTTPCSpacePointData *spacePoints = outPtr->fSpacePoints; | |
162 | ||
163 | unsigned long maxPoints = 0; | |
164 | ||
165 | for(ndx=0; ndx<evtData.fBlockCnt; ndx++){ | |
166 | ||
167 | iter = blocks+ndx; | |
168 | mysize = 0; | |
169 | offset = tSize; | |
170 | ||
171 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
172 | evtData.fEventID, evtData.fEventID, | |
173 | DataType2Text( iter->fDataType).c_str(), | |
174 | DataType2Text(AliHLTTPCDefinitions::fgkHWClustersDataType).c_str()); | |
175 | ||
176 | if(iter->fDataType != AliHLTTPCDefinitions::fgkHWClustersDataType) continue; | |
177 | ||
178 | UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); | |
179 | UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter); | |
180 | //UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(*iter); | |
181 | //UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(*iter); | |
182 | ||
183 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
184 | maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData); | |
185 | ||
186 | AliHLTUInt32_t *buffer; | |
187 | buffer = (AliHLTUInt32_t*)iter->fPtr; | |
188 | ||
189 | /* | |
190 | //cluster fabrication | |
191 | buffer = new AliHLTUInt32_t[14]; | |
192 | //header | |
193 | buffer[0]=0xffffffff; | |
194 | buffer[1]=0xffffffff; | |
195 | buffer[2]=0xffffffff; | |
196 | buffer[3]=0xffffffff; | |
197 | buffer[4]=0xffffffff; | |
198 | buffer[5]=0xffffffff; | |
199 | buffer[6]=0xffffffff; | |
200 | buffer[7]=0xffffffff; | |
201 | //cluster 1 | |
202 | buffer[8]=0xC60002EF; | |
203 | buffer[9]=0x0; | |
204 | buffer[10]=0x0; | |
205 | buffer[11]=0x0; | |
206 | buffer[12]=0x0; | |
207 | //RCU trailer | |
208 | buffer[13]=0x80000000; | |
209 | */ | |
210 | ||
211 | Int_t sector=-99, thisrow=-99; | |
212 | ||
213 | // PrintDebug(buffer, 14); | |
214 | ||
215 | // skip the first 8 32-bit CDH words | |
216 | buffer += 8; | |
217 | ||
218 | //PrintDebug(buffer, (Int_t)iter->fSize/sizeof(AliHLTUInt32_t)); | |
219 | ||
220 | unsigned long nAddedClusters = 0; | |
221 | ||
222 | for(UInt_t nWords=0; nWords<(iter->fSize/sizeof(AliHLTUInt32_t)); nWords+=5){ | |
223 | // for(UInt_t nWords=0; nWords<5; nWords+=5){ | |
224 | ||
225 | // check if bit 31 and 30 of the 32-bit word is 11 -> cluster (10 is RCU trailer) | |
226 | AliHLTUInt32_t bit3130 = (buffer[nWords]>>30); // shift 30 to the right | |
227 | ||
228 | if(bit3130 == 0x3){ //beginning of a cluster | |
229 | ||
230 | //PrintDebug(&buffer[nWords], 5); | |
231 | ||
232 | if(nAddedClusters>=maxPoints){ | |
233 | HLTWarning("No more space to add clusters, exiting!"); | |
234 | break; | |
235 | } | |
236 | ||
237 | AliHLTTPCSpacePointData cluster = { 0.,0.,0.,0,0,0.,0.,0,0,kFALSE,0 }; | |
238 | ||
239 | //get the first word | |
240 | AliHLTUInt32_t rowCharge = buffer[nWords]; | |
241 | AliHLTUInt8_t *rowPtr = reinterpret_cast<AliHLTUInt8_t*>(&rowCharge); | |
242 | rowPtr+=3; // this is to run for little endian architecture, the word is read from right to left | |
243 | ||
244 | cluster.fPadRow = (UChar_t)((*rowPtr)&0x3f); | |
245 | cluster.fCharge = (UInt_t)rowCharge&0xFFFFFF; //24-bit mask to get out the charge | |
246 | cluster.fSigmaY2 = (Float_t)buffer[nWords+3]; | |
247 | cluster.fSigmaZ2 = (Float_t)buffer[nWords+4]; | |
248 | ||
249 | Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = -99.; | |
a9d14303 | 250 | |
251 | if(fOfflineTransform == NULL){ | |
252 | cluster.fPadRow += AliHLTTPCTransform::GetFirstRow(minPartition); | |
253 | AliHLTTPCTransform::Slice2Sector(minSlice, cluster.fPadRow, sector, thisrow); | |
254 | AliHLTTPCTransform::Raw2Local(xyz, sector, thisrow, (Float_t)buffer[nWords+1], (Float_t)buffer[nWords+2]); | |
255 | if(minSlice>17) xyz[1]=(-1)*xyz[1]; | |
256 | cluster.fX = xyz[0]; | |
257 | cluster.fY = xyz[1]; | |
258 | cluster.fZ = xyz[2]; | |
259 | ||
260 | } else { | |
261 | Double_t x[3] = {thisrow, (Float_t)buffer[nWords+1]+.5, (Float_t)buffer[nWords+2]}; | |
262 | Int_t iSector[1]= {sector}; | |
263 | fOfflineTransform->Transform(x,iSector,0,1); | |
264 | cluster.fX = x[0]; | |
265 | cluster.fY = x[1]; | |
266 | cluster.fZ = x[2]; | |
267 | ||
268 | } | |
269 | // cluster.fX = xyz[0]; | |
270 | // cluster.fY = xyz[1]; | |
271 | // cluster.fZ = xyz[2]; | |
6af4f584 | 272 | |
273 | HLTDebug("X: %f, Y: %f, Z: %f, Charge: %d", cluster.fX,cluster.fY,cluster.fZ, cluster.fCharge); | |
274 | ||
275 | spacePoints[nAddedClusters] = cluster; | |
276 | ||
277 | nAddedClusters++; | |
278 | } // end of clusters starting with 11=0x3 | |
279 | else if(bit3130 == 0x2){ // we have reached the beginning of the RCU trailer - 10=0x2 | |
280 | break; | |
281 | } | |
282 | } // end of loop over clusters | |
283 | ||
284 | HLTDebug("Number of found clusters: %d", nAddedClusters); | |
285 | ||
286 | outPtr->fSpacePointCnt = nAddedClusters; | |
287 | nSize = sizeof(AliHLTTPCSpacePointData)*outPtr->fSpacePointCnt; | |
288 | mysize += nSize+sizeof(AliHLTTPCClusterData); | |
289 | ||
290 | AliHLTComponentBlockData bd; | |
291 | FillBlockData( bd ); | |
292 | bd.fOffset = offset; | |
293 | bd.fSize = mysize; | |
294 | bd.fSpecification = iter->fSpecification; | |
295 | bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType; | |
296 | outputBlocks.push_back( bd ); | |
297 | ||
298 | tSize += mysize; | |
299 | outBPtr += mysize; | |
300 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
301 | ||
302 | } // end of loop over data blocks | |
303 | size = tSize; | |
304 | return 0; | |
305 | } // end DoEvent() | |
306 | ||
307 | // int AliHLTTPCHWClusterTransformComponent::Configure(const char* arguments) { | |
308 | // // see header file for class documentation | |
309 | // | |
310 | // int iResult=0; | |
311 | // if (!arguments) return iResult; | |
312 | // HLTInfo("parsing configuration string \'%s\'", arguments); | |
313 | // | |
314 | // TString allArgs=arguments; | |
315 | // TString argument; | |
316 | // int bMissingParam=0; | |
317 | // | |
318 | // TObjArray* pTokens=allArgs.Tokenize(" "); | |
319 | // if (pTokens) { | |
320 | // for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
321 | // argument=((TObjString*)pTokens->At(i))->GetString(); | |
322 | // if (argument.IsNull()) continue; | |
323 | // | |
324 | // if (argument.CompareTo("-sum-noise-histograms")==0) { | |
325 | // fNoiseHistograms = kTRUE; | |
326 | // HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
327 | // | |
328 | // } else if (argument.CompareTo("-sum-krypton-histograms")==0) { | |
329 | // fKryptonHistograms = kTRUE; | |
330 | // HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
331 | // | |
332 | // } else if (argument.CompareTo("-use-general")==0) { | |
333 | // fUseGeneral = kTRUE; | |
334 | // HLTInfo("got \'-use-general\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
335 | // | |
336 | // } else if (argument.CompareTo("-ignore-specification")==0) { | |
337 | // fIgnoreSpecification = kTRUE; | |
338 | // HLTInfo("got \'-ignore-specification\': %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
339 | // } | |
340 | // else { | |
341 | // HLTError("unknown argument %s", argument.Data()); | |
342 | // iResult=-EINVAL; | |
343 | // break; | |
344 | // } | |
345 | // } // end for | |
346 | // | |
347 | // | |
348 | // delete pTokens; | |
349 | // | |
350 | // } // end if pTokens | |
351 | // | |
352 | // if (bMissingParam) { | |
353 | // HLTError("missing parameter for argument %s", argument.Data()); | |
354 | // iResult=-EINVAL; | |
355 | // } | |
356 | // return iResult; | |
357 | // } | |
358 | ||
359 | // int AliHLTTPCHWClusterTransformComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) { | |
360 | // // see header file for class documentation | |
361 | // | |
362 | // int iResult=0; | |
363 | // const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent"; | |
364 | // const char* defaultNotify=""; | |
365 | // if (cdbEntry) { | |
366 | // path=cdbEntry; | |
367 | // defaultNotify=" (default)"; | |
368 | // } | |
369 | // | |
370 | // if (path) { | |
371 | // HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
372 | // AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/); | |
373 | // if (pEntry) { | |
374 | // TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
375 | // if (pString) { | |
376 | // HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
377 | // iResult=Configure(pString->GetString().Data()); | |
378 | // } else { | |
379 | // HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
380 | // } | |
381 | // } else { | |
382 | // HLTError("cannot fetch object \"%s\" from CDB", path); | |
383 | // } | |
384 | // } | |
385 | // return iResult; | |
386 | // } | |
387 | ||
388 | ||
389 | void AliHLTTPCHWClusterTransformComponent::PrintDebug(AliHLTUInt32_t *buffer, Int_t size){ | |
390 | // see header file for class documentation | |
391 | ||
392 | HLTInfo("The size is: %d", size); | |
393 | for(Int_t n32bit=0; n32bit<size; n32bit++){ | |
394 | ||
395 | AliHLTUInt8_t *wordPtr = reinterpret_cast<AliHLTUInt8_t*>(&buffer[n32bit]); | |
396 | // cout << "word ptr initialized"<<endl; | |
397 | for(Int_t w=3;w>=0;w--){ | |
398 | // cout <<"accessing word"<<endl; | |
399 | AliHLTUInt8_t word = wordPtr[w]; | |
400 | // cout<< "word was accessed"<<endl; | |
401 | for(int n=7; n>=0; n--){ | |
402 | //print the byte values | |
403 | if((((word>>n)<<7)&0x80) != 0){ | |
404 | printf("1"); | |
405 | } | |
406 | else{ | |
407 | printf("0"); | |
408 | } | |
409 | } | |
410 | printf(" "); | |
411 | } | |
412 | printf("\n"); | |
413 | } | |
414 | } // end of PrintDebug |