]>
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" | |
f670cd93 | 33 | #include "AliRawDataHeader.h" |
6af4f584 | 34 | |
491d6af5 | 35 | #include "AliCDBManager.h" |
36 | #include "AliCDBEntry.h" | |
dccee396 | 37 | #include "AliTPCcalibDB.h" |
491d6af5 | 38 | |
2b727eff | 39 | #include "TMath.h" |
7361746a | 40 | #include "TObjString.h" |
6af4f584 | 41 | #include <cstdlib> |
42 | #include <cerrno> | |
43 | #include <sys/time.h> | |
44 | ||
45 | ClassImp(AliHLTTPCHWClusterTransformComponent) //ROOT macro for the implementation of ROOT specific class methods | |
46 | ||
84e36c27 | 47 | const char* AliHLTTPCHWClusterTransformComponent::fgkOCDBEntryHWTransform="HLT/ConfigTPC/TPCHWClusterTransform"; |
48 | ||
6af4f584 | 49 | AliHLTTPCHWClusterTransformComponent::AliHLTTPCHWClusterTransformComponent() |
a9d14303 | 50 | : |
84e36c27 | 51 | fDataId(kFALSE), |
58df4cfa | 52 | fChargeThreshold(10), |
dccee396 | 53 | fTransform(), |
a5dc9013 | 54 | fBenchmark("HWClusterTransform") |
6af4f584 | 55 | { |
56 | // see header file for class documentation | |
57 | // or | |
58 | // refer to README to build package | |
59 | // or | |
a9d14303 | 60 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt |
a5dc9013 | 61 | |
62 | fBenchmark.Reset(); | |
63 | fBenchmark.SetTimer(0,"total"); | |
6af4f584 | 64 | } |
65 | ||
66 | AliHLTTPCHWClusterTransformComponent::~AliHLTTPCHWClusterTransformComponent() { | |
67 | // see header file for class documentation | |
68 | } | |
69 | ||
70 | const char* AliHLTTPCHWClusterTransformComponent::GetComponentID() { | |
71 | // see header file for class documentation | |
72 | ||
73 | return "TPCHWClusterTransform"; | |
74 | } | |
75 | ||
76 | void AliHLTTPCHWClusterTransformComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
77 | // see header file for class documentation | |
78 | ||
79 | list.clear(); | |
80 | list.push_back( AliHLTTPCDefinitions::fgkHWClustersDataType ); | |
81 | } | |
82 | ||
83 | AliHLTComponentDataType AliHLTTPCHWClusterTransformComponent::GetOutputDataType() { | |
84 | // see header file for class documentation | |
85 | ||
86 | return AliHLTTPCDefinitions::fgkClustersDataType; | |
87 | } | |
88 | ||
89 | int AliHLTTPCHWClusterTransformComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) { | |
90 | // see header file for class documentation | |
91 | ||
92 | tgtList.clear(); | |
93 | tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType); | |
94 | return tgtList.size(); | |
95 | } | |
96 | ||
97 | void AliHLTTPCHWClusterTransformComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
98 | // see header file for class documentation | |
6af4f584 | 99 | constBase = 0; |
641530bb | 100 | inputMultiplier = 3.0; |
6af4f584 | 101 | } |
102 | ||
103 | AliHLTComponent* AliHLTTPCHWClusterTransformComponent::Spawn() { | |
104 | // see header file for class documentation | |
105 | ||
106 | return new AliHLTTPCHWClusterTransformComponent(); | |
107 | } | |
108 | ||
491d6af5 | 109 | int AliHLTTPCHWClusterTransformComponent::DoInit( int argc, const char** argv ) { |
6af4f584 | 110 | // see header file for class documentation |
dccee396 | 111 | |
aa0d6ff8 | 112 | AliTPCcalibDB *calib=AliTPCcalibDB::Instance(); |
113 | if(!calib){ | |
114 | HLTError("AliTPCcalibDB does not exist"); | |
115 | return -ENOENT; | |
116 | } | |
117 | calib->SetRun(GetRunNo()); | |
118 | calib->UpdateRunInformations(GetRunNo()); | |
119 | ||
dccee396 | 120 | int err = fTransform.Init( GetBz(), GetTimeStamp() ); |
6af4f584 | 121 | |
dccee396 | 122 | if( err!=0 ){ |
123 | HLTError("Cannot retrieve offline transform from AliTPCcalibDB"); | |
b4c689c4 | 124 | return -ENOENT; |
125 | } | |
491d6af5 | 126 | |
127 | int iResult=0; | |
84e36c27 | 128 | iResult = ConfigureFromCDBTObjString(fgkOCDBEntryHWTransform); |
129 | ||
130 | if (iResult>=0 && argc>0) | |
131 | iResult=ConfigureFromArgumentString(argc, argv); | |
132 | ||
133 | return iResult; | |
6af4f584 | 134 | } // end DoInit() |
135 | ||
136 | int AliHLTTPCHWClusterTransformComponent::DoDeinit() { | |
bd1ecd64 | 137 | // see header file for class documentation |
6af4f584 | 138 | return 0; |
139 | } | |
140 | ||
141 | int AliHLTTPCHWClusterTransformComponent::DoEvent(const AliHLTComponentEventData& evtData, | |
491d6af5 | 142 | const AliHLTComponentBlockData* blocks, |
143 | AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, | |
144 | AliHLTUInt32_t& size, | |
145 | vector<AliHLTComponentBlockData>& outputBlocks ){ | |
6af4f584 | 146 | // see header file for class documentation |
bd1ecd64 | 147 | |
6af4f584 | 148 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){ |
149 | size = 0; | |
150 | return 0; | |
151 | } | |
a5dc9013 | 152 | |
153 | fBenchmark.StartNewEvent(); | |
154 | fBenchmark.Start(0); | |
155 | ||
dccee396 | 156 | fTransform.SetCurrentTimeStamp( GetTimeStamp() ); |
157 | ||
6af4f584 | 158 | const AliHLTComponentBlockData *iter = NULL; |
61c1f30c | 159 | unsigned long ndx; |
6af4f584 | 160 | |
161 | AliHLTUInt8_t* outBPtr; | |
162 | UInt_t offset, mysize, nSize, tSize = 0; | |
163 | ||
164 | outBPtr = outputPtr; | |
61c1f30c | 165 | |
6af4f584 | 166 | for(ndx=0; ndx<evtData.fBlockCnt; ndx++){ |
167 | ||
168 | iter = blocks+ndx; | |
169 | mysize = 0; | |
170 | offset = tSize; | |
a5dc9013 | 171 | |
172 | fBenchmark.AddInput(iter->fSize); | |
173 | ||
6af4f584 | 174 | HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", |
491d6af5 | 175 | evtData.fEventID, evtData.fEventID, |
176 | DataType2Text( iter->fDataType).c_str(), | |
177 | DataType2Text(AliHLTTPCDefinitions::fgkHWClustersDataType).c_str()); | |
6af4f584 | 178 | |
179 | if(iter->fDataType != AliHLTTPCDefinitions::fgkHWClustersDataType) continue; | |
180 | ||
181 | UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); | |
182 | UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter); | |
183 | //UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(*iter); | |
184 | //UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(*iter); | |
a5dc9013 | 185 | |
186 | fBenchmark.SetName(Form("HWClusterTransform slice %d patch %d",minSlice,minPartition)); | |
187 | ||
491d6af5 | 188 | HLTDebug("minSlice: %d, minPartition: %d", minSlice, minPartition); |
6af4f584 | 189 | |
61c1f30c | 190 | AliHLTTPCClusterData* outPtr = (AliHLTTPCClusterData*)outBPtr; |
191 | ||
192 | unsigned long maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData); | |
6af4f584 | 193 | |
194 | AliHLTUInt32_t *buffer; | |
195 | buffer = (AliHLTUInt32_t*)iter->fPtr; | |
196 | ||
197 | /* | |
198 | //cluster fabrication | |
199 | buffer = new AliHLTUInt32_t[14]; | |
200 | //header | |
201 | buffer[0]=0xffffffff; | |
202 | buffer[1]=0xffffffff; | |
203 | buffer[2]=0xffffffff; | |
204 | buffer[3]=0xffffffff; | |
205 | buffer[4]=0xffffffff; | |
206 | buffer[5]=0xffffffff; | |
207 | buffer[6]=0xffffffff; | |
208 | buffer[7]=0xffffffff; | |
209 | //cluster 1 | |
210 | buffer[8]=0xC60002EF; | |
211 | buffer[9]=0x0; | |
212 | buffer[10]=0x0; | |
213 | buffer[11]=0x0; | |
214 | buffer[12]=0x0; | |
215 | //RCU trailer | |
216 | buffer[13]=0x80000000; | |
217 | */ | |
218 | ||
6af4f584 | 219 | // PrintDebug(buffer, 14); |
220 | ||
221 | // skip the first 8 32-bit CDH words | |
222 | buffer += 8; | |
f670cd93 | 223 | UInt_t bufferSize32 = ((Int_t)iter->fSize - sizeof(AliRawDataHeader) )/sizeof(AliHLTUInt32_t); |
6af4f584 | 224 | |
225 | //PrintDebug(buffer, (Int_t)iter->fSize/sizeof(AliHLTUInt32_t)); | |
226 | ||
227 | unsigned long nAddedClusters = 0; | |
228 | ||
f670cd93 | 229 | for(UInt_t nWords=0; nWords<bufferSize32; nWords+=5){ |
6af4f584 | 230 | // for(UInt_t nWords=0; nWords<5; nWords+=5){ |
bd1ecd64 | 231 | |
6af4f584 | 232 | // check if bit 31 and 30 of the 32-bit word is 11 -> cluster (10 is RCU trailer) |
233 | AliHLTUInt32_t bit3130 = (buffer[nWords]>>30); // shift 30 to the right | |
234 | ||
84e36c27 | 235 | |
6af4f584 | 236 | if(bit3130 == 0x3){ //beginning of a cluster |
237 | ||
238 | //PrintDebug(&buffer[nWords], 5); | |
239 | ||
240 | if(nAddedClusters>=maxPoints){ | |
241 | HLTWarning("No more space to add clusters, exiting!"); | |
242 | break; | |
243 | } | |
bd1ecd64 | 244 | |
6af4f584 | 245 | |
246 | AliHLTTPCSpacePointData cluster = { 0.,0.,0.,0,0,0.,0.,0,0,kFALSE,0 }; | |
247 | ||
248 | //get the first word | |
249 | AliHLTUInt32_t rowCharge = buffer[nWords]; | |
250 | AliHLTUInt8_t *rowPtr = reinterpret_cast<AliHLTUInt8_t*>(&rowCharge); | |
251 | rowPtr+=3; // this is to run for little endian architecture, the word is read from right to left | |
252 | ||
253 | cluster.fPadRow = (UChar_t)((*rowPtr)&0x3f); | |
641530bb | 254 | cluster.fCharge = ((UInt_t)rowCharge&0xFFFFFF)>>6; //24-bit mask to get out the charge and division with 64(>>6) for the gain correction |
255 | ||
256 | Float_t tmpPad = *((Float_t*)&buffer[nWords+1]); | |
257 | Float_t tmpTime = *((Float_t*)&buffer[nWords+2]); | |
bd1ecd64 | 258 | cluster.fSigmaY2 = *((Float_t*)&buffer[nWords+3]); |
259 | cluster.fSigmaZ2 = *((Float_t*)&buffer[nWords+4]); | |
2b727eff | 260 | |
116fb816 | 261 | |
58df4cfa | 262 | if(cluster.fCharge<fChargeThreshold) continue; |
116fb816 | 263 | |
2b727eff | 264 | // correct expressions for the error calculation |
84e36c27 | 265 | // Kenneth: 12.11.2009 I'm not sure if this is a correct calculation. Leave it out for now since it is anyway not used later since it caused segfaults. |
266 | // cluster.fSigmaY2 = TMath::Sqrt( *((Float_t*)&buffer[nWords+3]) - *((Float_t*)&buffer[nWords+1])* (*((Float_t*)&buffer[nWords+1])) ); | |
267 | // cluster.fSigmaZ2 = TMath::Sqrt( *((Float_t*)&buffer[nWords+3]) - *((Float_t*)&buffer[nWords+1])* (*((Float_t*)&buffer[nWords+1])) ); | |
491d6af5 | 268 | |
caa1158d | 269 | HLTDebug("padrow: %d, charge: %d, pad: %f, time: %f, errY: %f, errZ: %f \n", cluster.fPadRow, (UInt_t)cluster.fCharge, tmpPad, tmpTime, cluster.fSigmaY2, cluster.fSigmaZ2); |
dccee396 | 270 | |
271 | cluster.fPadRow += AliHLTTPCTransform::GetFirstRow(minPartition); | |
116fb816 | 272 | |
dccee396 | 273 | Float_t xyz[3]; |
274 | fTransform.Transform( minSlice, cluster.fPadRow, tmpPad, tmpTime, xyz ); | |
275 | cluster.fX = xyz[0]; | |
276 | cluster.fY = xyz[1]; | |
277 | cluster.fZ = xyz[2]; | |
84e36c27 | 278 | |
b3fe7b2c | 279 | // set the cluster ID so that the cluster dump printout is the same for FCF and SCF |
a371a266 | 280 | cluster.SetID( minSlice, minPartition, nAddedClusters ); |
b3fe7b2c | 281 | |
282 | HLTDebug("Cluster number %d: %f, Y: %f, Z: %f, charge: %d \n", nAddedClusters, cluster.fX, cluster.fY, cluster.fZ, (UInt_t)cluster.fCharge); | |
61c1f30c | 283 | outPtr->fSpacePoints[nAddedClusters] = cluster; |
6af4f584 | 284 | |
285 | nAddedClusters++; | |
286 | } // end of clusters starting with 11=0x3 | |
287 | else if(bit3130 == 0x2){ // we have reached the beginning of the RCU trailer - 10=0x2 | |
288 | break; | |
289 | } | |
290 | } // end of loop over clusters | |
291 | ||
292 | HLTDebug("Number of found clusters: %d", nAddedClusters); | |
293 | ||
294 | outPtr->fSpacePointCnt = nAddedClusters; | |
295 | nSize = sizeof(AliHLTTPCSpacePointData)*outPtr->fSpacePointCnt; | |
296 | mysize += nSize+sizeof(AliHLTTPCClusterData); | |
297 | ||
298 | AliHLTComponentBlockData bd; | |
299 | FillBlockData( bd ); | |
300 | bd.fOffset = offset; | |
301 | bd.fSize = mysize; | |
302 | bd.fSpecification = iter->fSpecification; | |
491d6af5 | 303 | |
304 | if(fDataId==kFALSE) bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType; | |
305 | else bd.fDataType = AliHLTTPCDefinitions::fgkAlterClustersDataType; | |
306 | ||
307 | //HLTDebug("datatype: %s", DataType2Text(bd.fDataType).c_str()); | |
308 | ||
6af4f584 | 309 | outputBlocks.push_back( bd ); |
310 | ||
a5dc9013 | 311 | fBenchmark.AddOutput(bd.fSize); |
312 | ||
6af4f584 | 313 | tSize += mysize; |
314 | outBPtr += mysize; | |
6af4f584 | 315 | |
316 | } // end of loop over data blocks | |
a5dc9013 | 317 | |
318 | size = tSize; | |
319 | ||
320 | fBenchmark.Stop(0); | |
321 | HLTInfo(fBenchmark.GetStatistics()); | |
322 | ||
323 | return 0; | |
6af4f584 | 324 | } // end DoEvent() |
84e36c27 | 325 | |
326 | int AliHLTTPCHWClusterTransformComponent::ScanConfigurationArgument(int argc, const char** argv){ | |
327 | ||
328 | // see header file for class documentation | |
329 | ||
330 | if (argc<=0) return 0; | |
331 | int i=0; | |
332 | TString argument=argv[i]; | |
333 | ||
334 | if (argument.CompareTo("-solenoidBz")==0){ | |
335 | if (++i>=argc) return -EPROTO; | |
336 | argument=argv[i]; | |
337 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); | |
338 | if(!calib){ | |
66a3e955 | 339 | HLTError("CalibDB instance cannot be created."); |
340 | return 0; | |
84e36c27 | 341 | } |
342 | Float_t magneticField = argument.Atof(); | |
343 | calib->SetExBField(magneticField); | |
344 | HLTInfo("SolenoidBz is set to %f in the calibDB",magneticField); | |
345 | return 2; | |
346 | } | |
347 | ||
348 | if (argument.CompareTo("-change-dataId")==0){ | |
349 | HLTDebug("Change data ID received."); | |
350 | fDataId = kTRUE; | |
351 | return 1; | |
352 | } | |
58df4cfa | 353 | |
354 | if (argument.CompareTo("-charge-threshold")==0) { | |
355 | if (++i>=argc) return -EPROTO; | |
356 | argument=argv[i]; | |
5c2dca91 | 357 | fChargeThreshold=(UInt_t)argument.Atoi(); |
58df4cfa | 358 | HLTInfo("The charge threshold has been set to %d.", fChargeThreshold); |
359 | return 2; | |
360 | } | |
84e36c27 | 361 | |
362 | // unknown argument | |
363 | return -EINVAL; | |
364 | } | |
365 | ||
84e36c27 | 366 | int AliHLTTPCHWClusterTransformComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) { |
491d6af5 | 367 | // see header file for class documentation |
84e36c27 | 368 | return ConfigureFromCDBTObjString(fgkOCDBEntryHWTransform); |
491d6af5 | 369 | } |
6af4f584 | 370 | |
371 | void AliHLTTPCHWClusterTransformComponent::PrintDebug(AliHLTUInt32_t *buffer, Int_t size){ | |
372 | // see header file for class documentation | |
373 | ||
374 | HLTInfo("The size is: %d", size); | |
375 | for(Int_t n32bit=0; n32bit<size; n32bit++){ | |
376 | ||
377 | AliHLTUInt8_t *wordPtr = reinterpret_cast<AliHLTUInt8_t*>(&buffer[n32bit]); | |
378 | // cout << "word ptr initialized"<<endl; | |
379 | for(Int_t w=3;w>=0;w--){ | |
380 | // cout <<"accessing word"<<endl; | |
381 | AliHLTUInt8_t word = wordPtr[w]; | |
382 | // cout<< "word was accessed"<<endl; | |
383 | for(int n=7; n>=0; n--){ | |
384 | //print the byte values | |
385 | if((((word>>n)<<7)&0x80) != 0){ | |
386 | printf("1"); | |
387 | } | |
388 | else{ | |
389 | printf("0"); | |
390 | } | |
391 | } | |
392 | printf(" "); | |
393 | } | |
394 | printf("\n"); | |
395 | } | |
396 | } // end of PrintDebug | |
1c29fee7 | 397 | |
398 | void AliHLTTPCHWClusterTransformComponent::GetOCDBObjectDescription( TMap* const targetMap){ | |
399 | // Get a list of OCDB object description needed for the particular component | |
400 | if (!targetMap) return; | |
401 | targetMap->Add(new TObjString("HLT/ConfigTPC/TPCHWClusterTransform"), new TObjString("component argument for the charge threshold")); | |
402 | } |