2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
7 //* for The ALICE HLT Project. *
9 //* Permission to use, copy, modify and distribute this software and its *
10 //* documentation strictly for non-commercial purposes is hereby granted *
11 //* without fee, provided that the above copyright notice appears in all *
12 //* copies and that both the copyright notice and this permission notice *
13 //* appear in the supporting documentation. The authors make no claims *
14 //* about the suitability of this software for any purpose. It is *
15 //* provided "as is" without express or implied warranty. *
16 //**************************************************************************
18 /** @file AliHLTTPCHWClusterTransformComponent.cxx
19 @author Kalliopi Kanaki
27 #include "AliHLTTPCHWClusterTransformComponent.h"
28 #include "AliHLTTPCDefinitions.h"
29 #include "AliHLTTPCTransform.h"
30 #include "AliHLTTPCSpacePointData.h"
31 #include "AliHLTTPCClusterDataFormat.h"
37 ClassImp(AliHLTTPCHWClusterTransformComponent) //ROOT macro for the implementation of ROOT specific class methods
39 AliHLTTPCHWClusterTransformComponent::AliHLTTPCHWClusterTransformComponent()
41 // see header file for class documentation
43 // refer to README to build package
45 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48 AliHLTTPCHWClusterTransformComponent::~AliHLTTPCHWClusterTransformComponent() {
49 // see header file for class documentation
52 const char* AliHLTTPCHWClusterTransformComponent::GetComponentID() {
53 // see header file for class documentation
55 return "TPCHWClusterTransform";
58 void AliHLTTPCHWClusterTransformComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
59 // see header file for class documentation
62 list.push_back( AliHLTTPCDefinitions::fgkHWClustersDataType );
65 AliHLTComponentDataType AliHLTTPCHWClusterTransformComponent::GetOutputDataType() {
66 // see header file for class documentation
68 return AliHLTTPCDefinitions::fgkClustersDataType;
71 int AliHLTTPCHWClusterTransformComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
72 // see header file for class documentation
75 tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
76 return tgtList.size();
79 void AliHLTTPCHWClusterTransformComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
80 // see header file for class documentation
83 inputMultiplier = 2.0;
86 AliHLTComponent* AliHLTTPCHWClusterTransformComponent::Spawn() {
87 // see header file for class documentation
89 return new AliHLTTPCHWClusterTransformComponent();
92 int AliHLTTPCHWClusterTransformComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
93 // see header file for class documentation
100 // TString configuration="";
101 // TString argument="";
102 // for (int j=0; j<argc && iResult>=0; j++) {
105 // if (!configuration.IsNull()) configuration+=" ";
106 // configuration+=argument;
109 // if (!configuration.IsNull()) {
110 // iResult=Configure(configuration.Data());
112 // iResult=Reconfigure(NULL, NULL);
118 int AliHLTTPCHWClusterTransformComponent::DoDeinit() {
119 // see header file for class documentation
124 int AliHLTTPCHWClusterTransformComponent::DoEvent(const AliHLTComponentEventData& evtData,
125 const AliHLTComponentBlockData* blocks,
126 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
127 AliHLTUInt32_t& size,
128 vector<AliHLTComponentBlockData>& outputBlocks ){
129 // see header file for class documentation
131 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
136 const AliHLTComponentBlockData *iter = NULL;
139 AliHLTTPCClusterData* outPtr;
141 AliHLTUInt8_t* outBPtr;
142 UInt_t offset, mysize, nSize, tSize = 0;
145 outPtr = (AliHLTTPCClusterData*)outBPtr;
147 AliHLTTPCSpacePointData *spacePoints = outPtr->fSpacePoints;
149 unsigned long maxPoints = 0;
151 for(ndx=0; ndx<evtData.fBlockCnt; ndx++){
157 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
158 evtData.fEventID, evtData.fEventID,
159 DataType2Text( iter->fDataType).c_str(),
160 DataType2Text(AliHLTTPCDefinitions::fgkHWClustersDataType).c_str());
162 if(iter->fDataType != AliHLTTPCDefinitions::fgkHWClustersDataType) continue;
164 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
165 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
166 //UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(*iter);
167 //UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(*iter);
169 outPtr = (AliHLTTPCClusterData*)outBPtr;
170 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
172 AliHLTUInt32_t *buffer;
173 buffer = (AliHLTUInt32_t*)iter->fPtr;
176 //cluster fabrication
177 buffer = new AliHLTUInt32_t[14];
179 buffer[0]=0xffffffff;
180 buffer[1]=0xffffffff;
181 buffer[2]=0xffffffff;
182 buffer[3]=0xffffffff;
183 buffer[4]=0xffffffff;
184 buffer[5]=0xffffffff;
185 buffer[6]=0xffffffff;
186 buffer[7]=0xffffffff;
188 buffer[8]=0xC60002EF;
194 buffer[13]=0x80000000;
197 Int_t sector=-99, thisrow=-99;
199 // PrintDebug(buffer, 14);
201 // skip the first 8 32-bit CDH words
204 //PrintDebug(buffer, (Int_t)iter->fSize/sizeof(AliHLTUInt32_t));
206 unsigned long nAddedClusters = 0;
208 for(UInt_t nWords=0; nWords<(iter->fSize/sizeof(AliHLTUInt32_t)); nWords+=5){
209 // for(UInt_t nWords=0; nWords<5; nWords+=5){
211 // check if bit 31 and 30 of the 32-bit word is 11 -> cluster (10 is RCU trailer)
212 AliHLTUInt32_t bit3130 = (buffer[nWords]>>30); // shift 30 to the right
214 if(bit3130 == 0x3){ //beginning of a cluster
216 //PrintDebug(&buffer[nWords], 5);
218 if(nAddedClusters>=maxPoints){
219 HLTWarning("No more space to add clusters, exiting!");
223 AliHLTTPCSpacePointData cluster = { 0.,0.,0.,0,0,0.,0.,0,0,kFALSE,0 };
226 AliHLTUInt32_t rowCharge = buffer[nWords];
227 AliHLTUInt8_t *rowPtr = reinterpret_cast<AliHLTUInt8_t*>(&rowCharge);
228 rowPtr+=3; // this is to run for little endian architecture, the word is read from right to left
230 cluster.fPadRow = (UChar_t)((*rowPtr)&0x3f);
231 cluster.fCharge = (UInt_t)rowCharge&0xFFFFFF; //24-bit mask to get out the charge
232 cluster.fSigmaY2 = (Float_t)buffer[nWords+3];
233 cluster.fSigmaZ2 = (Float_t)buffer[nWords+4];
235 Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = -99.;
237 cluster.fPadRow += AliHLTTPCTransform::GetFirstRow(minPartition);
238 AliHLTTPCTransform::Slice2Sector(minSlice, cluster.fPadRow, sector, thisrow);
239 AliHLTTPCTransform::Raw2Local(xyz, sector, thisrow, (Float_t)buffer[nWords+1], (Float_t)buffer[nWords+2]);
245 HLTDebug("X: %f, Y: %f, Z: %f, Charge: %d", cluster.fX,cluster.fY,cluster.fZ, cluster.fCharge);
247 spacePoints[nAddedClusters] = cluster;
250 } // end of clusters starting with 11=0x3
251 else if(bit3130 == 0x2){ // we have reached the beginning of the RCU trailer - 10=0x2
254 } // end of loop over clusters
256 HLTDebug("Number of found clusters: %d", nAddedClusters);
258 outPtr->fSpacePointCnt = nAddedClusters;
259 nSize = sizeof(AliHLTTPCSpacePointData)*outPtr->fSpacePointCnt;
260 mysize += nSize+sizeof(AliHLTTPCClusterData);
262 AliHLTComponentBlockData bd;
266 bd.fSpecification = iter->fSpecification;
267 bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
268 outputBlocks.push_back( bd );
272 outPtr = (AliHLTTPCClusterData*)outBPtr;
274 } // end of loop over data blocks
279 // int AliHLTTPCHWClusterTransformComponent::Configure(const char* arguments) {
280 // // see header file for class documentation
283 // if (!arguments) return iResult;
284 // HLTInfo("parsing configuration string \'%s\'", arguments);
286 // TString allArgs=arguments;
288 // int bMissingParam=0;
290 // TObjArray* pTokens=allArgs.Tokenize(" ");
292 // for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
293 // argument=((TObjString*)pTokens->At(i))->GetString();
294 // if (argument.IsNull()) continue;
296 // if (argument.CompareTo("-sum-noise-histograms")==0) {
297 // fNoiseHistograms = kTRUE;
298 // HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
300 // } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
301 // fKryptonHistograms = kTRUE;
302 // HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
304 // } else if (argument.CompareTo("-use-general")==0) {
305 // fUseGeneral = kTRUE;
306 // HLTInfo("got \'-use-general\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
308 // } else if (argument.CompareTo("-ignore-specification")==0) {
309 // fIgnoreSpecification = kTRUE;
310 // HLTInfo("got \'-ignore-specification\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
313 // HLTError("unknown argument %s", argument.Data());
322 // } // end if pTokens
324 // if (bMissingParam) {
325 // HLTError("missing parameter for argument %s", argument.Data());
331 // int AliHLTTPCHWClusterTransformComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) {
332 // // see header file for class documentation
335 // const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
336 // const char* defaultNotify="";
339 // defaultNotify=" (default)";
343 // HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
344 // AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
346 // TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
348 // HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
349 // iResult=Configure(pString->GetString().Data());
351 // HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
354 // HLTError("cannot fetch object \"%s\" from CDB", path);
361 void AliHLTTPCHWClusterTransformComponent::PrintDebug(AliHLTUInt32_t *buffer, Int_t size){
362 // see header file for class documentation
364 HLTInfo("The size is: %d", size);
365 for(Int_t n32bit=0; n32bit<size; n32bit++){
367 AliHLTUInt8_t *wordPtr = reinterpret_cast<AliHLTUInt8_t*>(&buffer[n32bit]);
368 // cout << "word ptr initialized"<<endl;
369 for(Int_t w=3;w>=0;w--){
370 // cout <<"accessing word"<<endl;
371 AliHLTUInt8_t word = wordPtr[w];
372 // cout<< "word was accessed"<<endl;
373 for(int n=7; n>=0; n--){
374 //print the byte values
375 if((((word>>n)<<7)&0x80) != 0){
386 } // end of PrintDebug