3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTTPCHWClusterTransformComponent.cxx
20 @author Kalliopi Kanaki
28 #include "AliHLTTPCHWClusterTransformComponent.h"
29 #include "AliHLTTPCDefinitions.h"
30 #include "AliHLTTPCTransform.h"
31 #include "AliHLTTPCSpacePointData.h"
32 #include "AliHLTTPCClusterDataFormat.h"
34 #include "AliTPCcalibDB.h"
35 #include "AliTPCTransform.h"
41 ClassImp(AliHLTTPCHWClusterTransformComponent) //ROOT macro for the implementation of ROOT specific class methods
43 AliHLTTPCHWClusterTransformComponent::AliHLTTPCHWClusterTransformComponent()
45 fOfflineTransform(NULL)
47 // see header file for class documentation
49 // refer to README to build package
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 fOfflineTransform = AliTPCcalibDB::Instance()->GetTransform();
54 if(!fOfflineTransform){
55 HLTError("AliHLTTPCHWClusterTransformComponent(): Offline transform not in AliTPCcalibDB.");
59 AliHLTTPCHWClusterTransformComponent::~AliHLTTPCHWClusterTransformComponent() {
60 // see header file for class documentation
63 const char* AliHLTTPCHWClusterTransformComponent::GetComponentID() {
64 // see header file for class documentation
66 return "TPCHWClusterTransform";
69 void AliHLTTPCHWClusterTransformComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
70 // see header file for class documentation
73 list.push_back( AliHLTTPCDefinitions::fgkHWClustersDataType );
76 AliHLTComponentDataType AliHLTTPCHWClusterTransformComponent::GetOutputDataType() {
77 // see header file for class documentation
79 return AliHLTTPCDefinitions::fgkClustersDataType;
82 int AliHLTTPCHWClusterTransformComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
83 // see header file for class documentation
86 tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
87 return tgtList.size();
90 void AliHLTTPCHWClusterTransformComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
91 // see header file for class documentation
94 inputMultiplier = 2.0;
97 AliHLTComponent* AliHLTTPCHWClusterTransformComponent::Spawn() {
98 // see header file for class documentation
100 return new AliHLTTPCHWClusterTransformComponent();
103 int AliHLTTPCHWClusterTransformComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
104 // see header file for class documentation
111 // TString configuration="";
112 // TString argument="";
113 // for (int j=0; j<argc && iResult>=0; j++) {
116 // if (!configuration.IsNull()) configuration+=" ";
117 // configuration+=argument;
120 // if (!configuration.IsNull()) {
121 // iResult=Configure(configuration.Data());
123 // iResult=Reconfigure(NULL, NULL);
129 int AliHLTTPCHWClusterTransformComponent::DoDeinit() {
130 // see header file for class documentation
135 int AliHLTTPCHWClusterTransformComponent::DoEvent(const AliHLTComponentEventData& evtData,
136 const AliHLTComponentBlockData* blocks,
137 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
138 AliHLTUInt32_t& size,
139 vector<AliHLTComponentBlockData>& outputBlocks ){
140 // see header file for class documentation
142 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
147 const AliHLTComponentBlockData *iter = NULL;
150 AliHLTTPCClusterData* outPtr;
152 AliHLTUInt8_t* outBPtr;
153 UInt_t offset, mysize, nSize, tSize = 0;
156 outPtr = (AliHLTTPCClusterData*)outBPtr;
158 AliHLTTPCSpacePointData *spacePoints = outPtr->fSpacePoints;
160 unsigned long maxPoints = 0;
162 for(ndx=0; ndx<evtData.fBlockCnt; ndx++){
168 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
169 evtData.fEventID, evtData.fEventID,
170 DataType2Text( iter->fDataType).c_str(),
171 DataType2Text(AliHLTTPCDefinitions::fgkHWClustersDataType).c_str());
173 if(iter->fDataType != AliHLTTPCDefinitions::fgkHWClustersDataType) continue;
175 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
176 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
177 //UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(*iter);
178 //UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(*iter);
180 outPtr = (AliHLTTPCClusterData*)outBPtr;
181 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
183 AliHLTUInt32_t *buffer;
184 buffer = (AliHLTUInt32_t*)iter->fPtr;
187 //cluster fabrication
188 buffer = new AliHLTUInt32_t[14];
190 buffer[0]=0xffffffff;
191 buffer[1]=0xffffffff;
192 buffer[2]=0xffffffff;
193 buffer[3]=0xffffffff;
194 buffer[4]=0xffffffff;
195 buffer[5]=0xffffffff;
196 buffer[6]=0xffffffff;
197 buffer[7]=0xffffffff;
199 buffer[8]=0xC60002EF;
205 buffer[13]=0x80000000;
208 Int_t sector=-99, thisrow=-99;
210 // PrintDebug(buffer, 14);
212 // skip the first 8 32-bit CDH words
215 //PrintDebug(buffer, (Int_t)iter->fSize/sizeof(AliHLTUInt32_t));
217 unsigned long nAddedClusters = 0;
219 for(UInt_t nWords=0; nWords<(iter->fSize/sizeof(AliHLTUInt32_t)); nWords+=5){
220 // for(UInt_t nWords=0; nWords<5; nWords+=5){
222 // check if bit 31 and 30 of the 32-bit word is 11 -> cluster (10 is RCU trailer)
223 AliHLTUInt32_t bit3130 = (buffer[nWords]>>30); // shift 30 to the right
225 if(bit3130 == 0x3){ //beginning of a cluster
227 //PrintDebug(&buffer[nWords], 5);
229 if(nAddedClusters>=maxPoints){
230 HLTWarning("No more space to add clusters, exiting!");
234 AliHLTTPCSpacePointData cluster = { 0.,0.,0.,0,0,0.,0.,0,0,kFALSE,0 };
237 AliHLTUInt32_t rowCharge = buffer[nWords];
238 AliHLTUInt8_t *rowPtr = reinterpret_cast<AliHLTUInt8_t*>(&rowCharge);
239 rowPtr+=3; // this is to run for little endian architecture, the word is read from right to left
241 cluster.fPadRow = (UChar_t)((*rowPtr)&0x3f);
242 cluster.fCharge = (UInt_t)rowCharge&0xFFFFFF; //24-bit mask to get out the charge
243 cluster.fSigmaY2 = (Float_t)buffer[nWords+3];
244 cluster.fSigmaZ2 = (Float_t)buffer[nWords+4];
246 Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = -99.;
248 if(fOfflineTransform == NULL){
249 cluster.fPadRow += AliHLTTPCTransform::GetFirstRow(minPartition);
250 AliHLTTPCTransform::Slice2Sector(minSlice, cluster.fPadRow, sector, thisrow);
251 AliHLTTPCTransform::Raw2Local(xyz, sector, thisrow, (Float_t)buffer[nWords+1], (Float_t)buffer[nWords+2]);
252 if(minSlice>17) xyz[1]=(-1)*xyz[1];
258 Double_t x[3] = {thisrow, (Float_t)buffer[nWords+1]+.5, (Float_t)buffer[nWords+2]};
259 Int_t iSector[1]= {sector};
260 fOfflineTransform->Transform(x,iSector,0,1);
266 // cluster.fX = xyz[0];
267 // cluster.fY = xyz[1];
268 // cluster.fZ = xyz[2];
270 HLTDebug("X: %f, Y: %f, Z: %f, Charge: %d", cluster.fX,cluster.fY,cluster.fZ, cluster.fCharge);
272 spacePoints[nAddedClusters] = cluster;
275 } // end of clusters starting with 11=0x3
276 else if(bit3130 == 0x2){ // we have reached the beginning of the RCU trailer - 10=0x2
279 } // end of loop over clusters
281 HLTDebug("Number of found clusters: %d", nAddedClusters);
283 outPtr->fSpacePointCnt = nAddedClusters;
284 nSize = sizeof(AliHLTTPCSpacePointData)*outPtr->fSpacePointCnt;
285 mysize += nSize+sizeof(AliHLTTPCClusterData);
287 AliHLTComponentBlockData bd;
291 bd.fSpecification = iter->fSpecification;
292 bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
293 outputBlocks.push_back( bd );
297 outPtr = (AliHLTTPCClusterData*)outBPtr;
299 } // end of loop over data blocks
304 // int AliHLTTPCHWClusterTransformComponent::Configure(const char* arguments) {
305 // // see header file for class documentation
308 // if (!arguments) return iResult;
309 // HLTInfo("parsing configuration string \'%s\'", arguments);
311 // TString allArgs=arguments;
313 // int bMissingParam=0;
315 // TObjArray* pTokens=allArgs.Tokenize(" ");
317 // for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
318 // argument=((TObjString*)pTokens->At(i))->GetString();
319 // if (argument.IsNull()) continue;
321 // if (argument.CompareTo("-sum-noise-histograms")==0) {
322 // fNoiseHistograms = kTRUE;
323 // HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
325 // } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
326 // fKryptonHistograms = kTRUE;
327 // HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
329 // } else if (argument.CompareTo("-use-general")==0) {
330 // fUseGeneral = kTRUE;
331 // HLTInfo("got \'-use-general\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
333 // } else if (argument.CompareTo("-ignore-specification")==0) {
334 // fIgnoreSpecification = kTRUE;
335 // HLTInfo("got \'-ignore-specification\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
338 // HLTError("unknown argument %s", argument.Data());
347 // } // end if pTokens
349 // if (bMissingParam) {
350 // HLTError("missing parameter for argument %s", argument.Data());
356 // int AliHLTTPCHWClusterTransformComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/) {
357 // // see header file for class documentation
360 // const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
361 // const char* defaultNotify="";
364 // defaultNotify=" (default)";
368 // HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
369 // AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
371 // TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
373 // HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
374 // iResult=Configure(pString->GetString().Data());
376 // HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
379 // HLTError("cannot fetch object \"%s\" from CDB", path);
386 void AliHLTTPCHWClusterTransformComponent::PrintDebug(AliHLTUInt32_t *buffer, Int_t size){
387 // see header file for class documentation
389 HLTInfo("The size is: %d", size);
390 for(Int_t n32bit=0; n32bit<size; n32bit++){
392 AliHLTUInt8_t *wordPtr = reinterpret_cast<AliHLTUInt8_t*>(&buffer[n32bit]);
393 // cout << "word ptr initialized"<<endl;
394 for(Int_t w=3;w>=0;w--){
395 // cout <<"accessing word"<<endl;
396 AliHLTUInt8_t word = wordPtr[w];
397 // cout<< "word was accessed"<<endl;
398 for(int n=7; n>=0; n--){
399 //print the byte values
400 if((((word>>n)<<7)&0x80) != 0){
411 } // end of PrintDebug