Added a new component (AliHLTTPCHWCFDataReverterComponent) which reads the data,...
authorkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 17 Nov 2008 13:35:11 +0000 (13:35 +0000)
committerkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 17 Nov 2008 13:35:11 +0000 (13:35 +0000)
Moved around the functions of the AliHLTTPCClusterFinder so the ones belonging to the ClusterFinderDecoder is at the top of the files, and the ClusterFinderPacked functions on the bottom.
Also changed from fMaxQ to fQMax in the AliHLTSpacePointData.h so that we only have one name convention for max charge of a cluster. This led to changes in KryptonClusterfinder, *Cluster*, Noise map, TrackHistoComponent.
In AliHLTAltroEncoder; added the functionality to revert 40 bit words.

18 files changed:
HLT/AliHLTTPCLinkDef.h
HLT/RCU/AliHLTAltroEncoder.cxx
HLT/RCU/AliHLTAltroEncoder.h
HLT/TPCLib/AliHLTTPCAgent.cxx
HLT/TPCLib/AliHLTTPCClusterDumpComponent.cxx
HLT/TPCLib/AliHLTTPCClusterFinder.cxx
HLT/TPCLib/AliHLTTPCClusterFinder.h
HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
HLT/TPCLib/AliHLTTPCClusterHistoComponent.cxx
HLT/TPCLib/AliHLTTPCHWCFDataReverterComponent.cxx [new file with mode: 0755]
HLT/TPCLib/AliHLTTPCHWCFDataReverterComponent.h [new file with mode: 0755]
HLT/TPCLib/AliHLTTPCKryptonClusterFinder.cxx
HLT/TPCLib/AliHLTTPCKryptonClusterFinderComponent.cxx
HLT/TPCLib/AliHLTTPCNoiseMapComponent.cxx
HLT/TPCLib/AliHLTTPCSpacePointData.h
HLT/TPCLib/AliHLTTPCTrackHistoComponent.cxx
HLT/TPCLib/offline/AliHLTTPCOfflineCluster.cxx
HLT/libAliHLTTPC.pkg

index 9fce0d2..a1b8425 100644 (file)
@@ -70,4 +70,6 @@
 #pragma link C++ class  AliHLTTPCEventStatisticsProducerComponent+;
 #pragma link C++ class  AliHLTTPCRunStatistics+;
 #pragma link C++ class  AliHLTTPCRunStatisticsProducerComponent+;
+#pragma link C++ class  AliHLTTPCHWCFDataReverterComponent+;
+
 #endif
index 58d2c1f..8e50876 100644 (file)
@@ -310,3 +310,29 @@ int AliHLTAltroEncoder::SetLength()
   }
   return fOffset;
 }
+
+void AliHLTAltroEncoder::Revert40BitWords(Int_t CDHSize, Int_t trailerSize)
+{
+  // see headerfile for class documentation
+  
+  //initialize to last 40 bit word in the payload
+  AliHLTUInt8_t * pointerToHighEnd40BitWord = fpBuffer + fOffset - trailerSize -5;
+  
+  //initialize to first 40 bit word in the payload
+  AliHLTUInt8_t * pointerToLowEnd40BitWord = fpBuffer+CDHSize;
+
+  assert(((pointerToHighEnd40BitWord - pointerToLowEnd40BitWord)+5)%5 == 0 );//check that it is a whole number of 40 bit words
+
+  Int_t total40BitWords = ((pointerToHighEnd40BitWord - pointerToLowEnd40BitWord) + 5)/(5);
+
+  AliHLTUInt8_t tmp8BitWords[5] = {0,0,0,0,0};
+
+  for(Int_t numberOf40BitWordMoves = 0 ; numberOf40BitWordMoves < total40BitWords/2 ; numberOf40BitWordMoves++){
+    memcpy(&tmp8BitWords, pointerToLowEnd40BitWord, 5);              // copy 40 bit word in to temporary from low side
+    memcpy(pointerToLowEnd40BitWord, pointerToHighEnd40BitWord, 5); // copy the high side 40 bit word to the low side
+    memcpy(pointerToHighEnd40BitWord, &tmp8BitWords, 5);             // copy from the temporary to the high side 40 bits 
+    pointerToLowEnd40BitWord += 5;
+    pointerToHighEnd40BitWord -= 5;
+  }
+
+}
index 01bae80..c07f1cc 100644 (file)
@@ -138,6 +138,11 @@ class AliHLTAltroEncoder : AliHLTLogging {
 
   int GetOffset(){return fOffset;}
 
+  /**
+   * Revert the 40 bit altro data
+   */
+  void Revert40BitWords(Int_t CDHSize, Int_t trailerSize);
+
   enum {
     kUnknownOrder = 0,
     kAscending,
index 1c8725a..c25bf70 100644 (file)
@@ -64,7 +64,7 @@ AliHLTTPCAgent gAliHLTTPCAgent;
 #include "AliHLTTPCCalibTracksComponent.h"
 #include "AliHLTTPCTrackHistoComponent.h"
 #include "AliHLTTPCTrackDumpComponent.h"
-
+#include "AliHLTTPCHWCFDataReverterComponent.h"
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTTPCAgent)
@@ -240,7 +240,8 @@ int AliHLTTPCAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
   pHandler->AddComponent(new AliHLTTPCCalibTracksComponent);
   pHandler->AddComponent(new AliHLTTPCTrackHistoComponent);
   pHandler->AddComponent(new AliHLTTPCTrackDumpComponent);
-  
+  pHandler->AddComponent(new AliHLTTPCHWCFDataReverterComponent);
+
   return 0;
 }
 
index 249632f..64e18fa 100644 (file)
@@ -160,7 +160,7 @@ int AliHLTTPCClusterDumpComponent::DumpEvent( const AliHLTComponentEventData& /*
         AliHLTTPCTransform::LocHLT2Raw(xyz,(Int_t)(clusters[i].fID/10),(Int_t)(clusters[i].fID%10));
         dump << "[R,P,T]:       [" << xyz[0]<<" , "<<xyz[1]<<" , "<<xyz[2] <<"]"<< endl;
         dump << "Total Charge:  " << clusters[i].fCharge         << endl;
-        dump << "Q Max:         " << clusters[i].fMaxQ           << endl;
+        dump << "Q Max:         " << clusters[i].fQMax           << endl;
         spacePointCounter++;
        }
        
index cf01733..12f27e8 100644 (file)
@@ -81,8 +81,9 @@ AliHLTTPCClusterFinder::AliHLTTPCClusterFinder()
   //constructor  
 }
 
-AliHLTTPCClusterFinder::~AliHLTTPCClusterFinder()
-{
+AliHLTTPCClusterFinder::~AliHLTTPCClusterFinder(){
+  // see header file for class documentation
+  
   //destructor
   if(fVectorInitialized){
     DeInitializePadArray();
@@ -92,16 +93,17 @@ AliHLTTPCClusterFinder::~AliHLTTPCClusterFinder()
     fNumberOfPadsInRow=NULL;
   }
 }
-void AliHLTTPCClusterFinder::InitSlice(Int_t slice,Int_t patch,Int_t firstrow, Int_t lastrow,Int_t nmaxpoints)
-{
+
+void AliHLTTPCClusterFinder::InitSlice(Int_t slice,Int_t patch,Int_t nmaxpoints){
+  // see header file for class documentation
+
   //init slice
   fNClusters = 0;
   fMaxNClusters = nmaxpoints;
   fCurrentSlice = slice;
   fCurrentPatch = patch;
-  fFirstRow = firstrow;
-  fLastRow = lastrow;
+  fFirstRow=AliHLTTPCTransform::GetFirstRow(patch);
+  fLastRow=AliHLTTPCTransform::GetLastRow(patch);
 }
 
 void AliHLTTPCClusterFinder::InitializePadArray(){
@@ -135,9 +137,9 @@ void AliHLTTPCClusterFinder::InitializePadArray(){
   fVectorInitialized=kTRUE;
 }
 
-Int_t AliHLTTPCClusterFinder::DeInitializePadArray()
-{
+Int_t AliHLTTPCClusterFinder::DeInitializePadArray(){
   // see header file for class documentation
+
   for(UInt_t i=0;i<fNumberOfRows;i++){
     for(UInt_t j=0;j<=fNumberOfPadsInRow[i];j++){
       delete fRowPadVector[i][j];
@@ -150,31 +152,310 @@ Int_t AliHLTTPCClusterFinder::DeInitializePadArray()
 } 
 
 
-void AliHLTTPCClusterFinder::InitSlice(Int_t slice,Int_t patch,Int_t nmaxpoints)
-{
-  //init slice
-  fNClusters = 0;
-  fMaxNClusters = nmaxpoints;
-  fCurrentSlice = slice;
-  fCurrentPatch = patch;
-  fFirstRow=AliHLTTPCTransform::GetFirstRow(patch);
-  fLastRow=AliHLTTPCTransform::GetLastRow(patch);
-}
 
-void AliHLTTPCClusterFinder::SetOutputArray(AliHLTTPCSpacePointData *pt)
-{
+void AliHLTTPCClusterFinder::SetOutputArray(AliHLTTPCSpacePointData *pt){
+  // see header file for class documentation
   //set pointer to output
   fSpacePointData = pt;
 }
 
+
+void AliHLTTPCClusterFinder::ReadDataUnsorted(void* ptr,unsigned long size){
+  // see header file for class documentation
+  //set input pointer
+  fPtr = (UChar_t*)ptr;
+  fSize = size;
+
+  if(!fVectorInitialized){
+    InitializePadArray();
+  }
+
+  if (fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice)<0) {
+    HLTError("failed setting up digit reader (InitBlock)");
+    return;
+  }
+  
+  while(fDigitReader->NextChannel()){
+    UInt_t row=fDigitReader->GetRow();
+    UInt_t pad=fDigitReader->GetPad();
+
+    if(row>=fRowPadVector.size()){
+      HLTError("Row number is to large: %d, max is %d",row,fRowPadVector.size()-1);
+      continue;
+    }
+    if(pad>=fRowPadVector[row].size()){
+      HLTError("Pad number is to large: %d, max is %d",pad,fRowPadVector[row].size());
+      continue;
+    }
+
+    while(fDigitReader->NextBunch()){
+      if(fDigitReader->GetBunchSize()>1){//to remove single timebin values, this will have to change at some point
+       UInt_t time = fDigitReader->GetTime();
+       if((Int_t)time>=fFirstTimeBin && (Int_t)time+fDigitReader->GetBunchSize()<=fLastTimeBin){
+         const UInt_t *bunchData= fDigitReader->GetSignals();
+         AliHLTTPCClusters candidate;
+         for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+           candidate.fTotalCharge+=bunchData[i];       
+           candidate.fTime += time*bunchData[i];
+           candidate.fTime2 += time*time*bunchData[i];
+           if(bunchData[i]>candidate.fQMax){
+             candidate.fQMax=bunchData[i];
+           }
+           time++;
+         }
+         if(candidate.fTotalCharge>0){
+           candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+           candidate.fPad=candidate.fTotalCharge*pad;
+           candidate.fPad2=candidate.fPad*pad;
+           candidate.fLastMergedPad=pad;
+           candidate.fRowNumber=row+fDigitReader->GetRowOffset();
+         }
+         if(fRowPadVector[row][pad] != NULL){
+           fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+         }
+       }
+      }
+    }
+  }
+}
+
+void AliHLTTPCClusterFinder::ReadDataUnsortedDeconvoluteTime(void* ptr,unsigned long size){
+  // see header file for class documentation
+
+  //set input pointer
+  fPtr = (UChar_t*)ptr;
+  fSize = size;
+
+  if(!fVectorInitialized){
+    InitializePadArray();
+  }
+
+  if (fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice)<0) {
+    HLTError("failed setting up digit reader (InitBlock)");
+    return;
+  }
+  
+  while(fDigitReader->NextChannel()){
+    UInt_t row=fDigitReader->GetRow();
+    UInt_t pad=fDigitReader->GetPad();
+
+    while(fDigitReader->NextBunch()){
+      if(fDigitReader->GetBunchSize()>1){//to remove single timebin values, this will have to change at some point
+       UInt_t time = fDigitReader->GetTime();
+       if((Int_t)time>=fFirstTimeBin && (Int_t)time+fDigitReader->GetBunchSize()<=fLastTimeBin){
+         Int_t indexInBunchData=0;
+         Bool_t moreDataInBunch=kFALSE;
+         UInt_t prevSignal=0;
+         Bool_t signalFalling=kFALSE;
+         const UInt_t *bunchData= fDigitReader->GetSignals();
+         do{
+           AliHLTTPCClusters candidate;
+           for(Int_t i=indexInBunchData;i<fDigitReader->GetBunchSize();i++){
+             // Checks if one need to deconvolute the signals
+             if(bunchData[i]>prevSignal && signalFalling==kTRUE){
+               if(i<fDigitReader->GetBunchSize()-1){ // means there are more than one signal left in the bunch
+                 moreDataInBunch=kTRUE;
+                 prevSignal=0;
+               }
+               break;
+             }
+             
+             // Checks if the signal is 0, then quit processing the data.
+             if(bunchData[i]==0 && i<fDigitReader->GetBunchSize()-1){//means we have 0 data fom the rcu, might happen depending on the configuration settings
+               moreDataInBunch=kTRUE;
+               prevSignal=0;
+               break;
+             }
+
+             if(prevSignal>bunchData[i]){//means the peak of the signal has been reached and deconvolution will happen if the signal rise again.
+               signalFalling=kTRUE;
+             }
+             candidate.fTotalCharge+=bunchData[i];     
+             candidate.fTime += time*bunchData[i];
+             candidate.fTime2 += time*time*bunchData[i];
+             if(bunchData[i]>candidate.fQMax){
+               candidate.fQMax=bunchData[i];
+             }
+
+             prevSignal=bunchData[i];
+             time++;
+             indexInBunchData++;
+           }
+           if(candidate.fTotalCharge>0){
+             candidate.fMean=candidate.fTime/candidate.fTotalCharge;
+             candidate.fPad=candidate.fTotalCharge*pad;
+             candidate.fPad2=candidate.fPad*pad;
+             candidate.fLastMergedPad=pad;
+             candidate.fRowNumber=row+fDigitReader->GetRowOffset();
+           }
+           fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+           if(indexInBunchData<fDigitReader->GetBunchSize()-1){
+             moreDataInBunch=kFALSE;
+           }
+         }while(moreDataInBunch);
+       }
+      }
+    }
+  }
+}
+
+Bool_t AliHLTTPCClusterFinder::ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* cluster,Int_t nextPadToRead){
+  // see header file for class documentation
+
+  //Checking if we have a match on the next pad
+  for(UInt_t candidateNumber=0;candidateNumber<nextPad->fClusterCandidates.size();candidateNumber++){
+    AliHLTTPCClusters *candidate =&nextPad->fClusterCandidates[candidateNumber]; 
+    if(cluster->fMean-candidate->fMean==1 || candidate->fMean-cluster->fMean==1 || cluster->fMean-candidate->fMean==0){
+      if(fDeconvPad){
+       if(candidate->fTotalCharge<fTotalChargeOfPreviousClusterCandidate){//peak is reached
+         fChargeOfCandidatesFalling=kTRUE;
+       }
+       if(candidate->fTotalCharge>fTotalChargeOfPreviousClusterCandidate && fChargeOfCandidatesFalling==kTRUE){//we have deconvolution
+         return kFALSE;
+       }
+      }
+      cluster->fMean=candidate->fMean;
+      cluster->fTotalCharge+=candidate->fTotalCharge;
+      cluster->fTime += candidate->fTime;
+      cluster->fTime2 += candidate->fTime2;
+      cluster->fPad+=candidate->fPad;
+      cluster->fPad2+=candidate->fPad2;
+      cluster->fLastMergedPad=candidate->fPad;
+      if(candidate->fQMax>cluster->fQMax){
+       cluster->fQMax=candidate->fQMax;
+      }
+      
+      if(fDoPadSelection){
+       UInt_t rowNo = nextPad->GetRowNumber();
+       UInt_t padNo = nextPad->GetPadNumber();
+       if(padNo-1>0){
+         fRowPadVector[rowNo][padNo-2]->fSelectedPad=kTRUE;
+         fRowPadVector[rowNo][padNo-2]->fHWAddress=(AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr(rowNo,padNo-2);
+       }
+       fRowPadVector[rowNo][padNo-1]->fSelectedPad=kTRUE;// quick solution to set the first pad to selected
+       fRowPadVector[rowNo][padNo-1]->fHWAddress=(AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr(rowNo,padNo-1);
+       fRowPadVector[rowNo][padNo]->fSelectedPad=kTRUE;
+       fRowPadVector[rowNo][padNo]->fHWAddress=(AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr(rowNo,padNo);
+      }
+
+      //setting the matched pad to used
+      nextPad->fUsedClusterCandidates[candidateNumber]=1;
+      nextPadToRead++;
+      if(nextPadToRead<(Int_t)fNumberOfPadsInRow[fRowOfFirstCandidate]){
+       nextPad=fRowPadVector[fRowOfFirstCandidate][nextPadToRead];
+       ComparePads(nextPad,cluster,nextPadToRead);
+      }
+      else{
+       return kFALSE;
+      }
+    }
+    else{
+      return kFALSE;
+    }
+  }
+  return kFALSE;
+}
+
+Int_t AliHLTTPCClusterFinder::FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWadd){
+  // see header file for class documentation
+
+  Int_t counter=0;
+  for(UInt_t row=0;row<fNumberOfRows;row++){
+    for(UInt_t pad=0;pad<fNumberOfPadsInRow[row]-1;pad++){
+      if(fRowPadVector[row][pad]->fSelectedPad){
+       if(counter<maxHWadd){
+        hwaddlist[counter]=(AliHLTUInt16_t)fRowPadVector[row][pad]->fHWAddress;
+        counter++;
+       }
+       else{
+        HLTWarning("To many hardwareaddresses, skip adding");
+       }
+       
+      }
+    }
+  }  
+  return counter;
+}
+
+void AliHLTTPCClusterFinder::FindClusters(){
+  // see header file for function documentation
+
+  AliHLTTPCClusters* tmpCandidate=NULL;
+  for(UInt_t row=0;row<fNumberOfRows;row++){
+    fRowOfFirstCandidate=row;
+    for(UInt_t pad=0;pad<fNumberOfPadsInRow[row];pad++){
+      AliHLTTPCPad *tmpPad=fRowPadVector[row][pad];
+      for(size_t candidate=0;candidate<tmpPad->fClusterCandidates.size();candidate++){
+       if(tmpPad->fUsedClusterCandidates[candidate]){
+         continue;
+       }
+       tmpCandidate=&tmpPad->fClusterCandidates[candidate];
+       UInt_t tmpTotalCharge=tmpCandidate->fTotalCharge;
+
+       ComparePads(fRowPadVector[row][pad+1],tmpCandidate,pad+1);
+       if(tmpCandidate->fTotalCharge>tmpTotalCharge){
+         //we have a cluster
+         fClusters.push_back(*tmpCandidate);
+       }
+      }
+      tmpPad->ClearCandidates();
+    }
+    fRowPadVector[row][fNumberOfPadsInRow[row]]->ClearCandidates();
+  }
+
+  HLTInfo("Found %d clusters.",fClusters.size());
+
+  //TODO:  Change so it stores AliHLTTPCSpacePointData directly, instead of this copying
+  
+  AliClusterData * clusterlist = new AliClusterData[fClusters.size()]; //Clusterlist
+  for(unsigned int i=0;i<fClusters.size();i++){
+    clusterlist[i].fTotalCharge = fClusters[i].fTotalCharge;
+    clusterlist[i].fPad = fClusters[i].fPad;
+    clusterlist[i].fPad2 = fClusters[i].fPad2;
+    clusterlist[i].fTime = fClusters[i].fTime;
+    clusterlist[i].fTime2 = fClusters[i].fTime2;
+    clusterlist[i].fMean = fClusters[i].fMean;
+    clusterlist[i].fFlags = fClusters[i].fFlags;
+    clusterlist[i].fChargeFalling = fClusters[i].fChargeFalling;
+    clusterlist[i].fLastCharge = fClusters[i].fLastCharge;
+    clusterlist[i].fLastMergedPad = fClusters[i].fLastMergedPad;
+    clusterlist[i].fRow = fClusters[i].fRowNumber;
+    clusterlist[i].fQMax = fClusters[i].fQMax;
+  }
+
+  WriteClusters(fClusters.size(),clusterlist);
+  delete [] clusterlist;
+  fClusters.clear();
+}
+
+
+//---------------------------------- Under this line the old sorted clusterfinder functions can be found --------------------------------
+
+
+void AliHLTTPCClusterFinder::PrintClusters(){
+  // see header file for class documentation
+
+  for(size_t i=0;i<fClusters.size();i++){
+    HLTInfo("Cluster number: %d",i);
+    HLTInfo("Row: %d \t Pad: %d",fClusters[i].fRowNumber,fClusters[i].fPad/fClusters[i].fTotalCharge);
+    HLTInfo("Total Charge:   %d",fClusters[i].fTotalCharge);
+    HLTInfo("fPad:           %d",fClusters[i].fPad);
+    HLTInfo("PadError:       %d",fClusters[i].fPad2);
+    HLTInfo("TimeMean:       %d",fClusters[i].fTime/fClusters[i].fTotalCharge);
+    HLTInfo("TimeError:      %d",fClusters[i].fTime2);
+    HLTInfo("EndOfCluster:");
+  }
+}
+
 void AliHLTTPCClusterFinder::Read(void* ptr,unsigned long size){
   //set input pointer
   fPtr = (UChar_t*)ptr;
   fSize = size;
 }
 
-void AliHLTTPCClusterFinder::ProcessDigits()
-{
+void AliHLTTPCClusterFinder::ProcessDigits(){
+  // see header file for class documentation
+
   int iResult=0;
   bool readValue = true;
   Int_t newRow = 0;    
@@ -524,8 +805,9 @@ void AliHLTTPCClusterFinder::ProcessDigits()
 
 } // ENDEND
 
-void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliClusterData *list)
-{
+void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliClusterData *list){
+  // see header file for class documentation
+
   //write cluster to output pointer
   Int_t thisrow=-1,thissector=-1;
   UInt_t counter = fNClusters;
@@ -626,7 +908,7 @@ void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliClusterData *list)
       fSpacePointData[counter].fSigmaY2 = fpad2;
       fSpacePointData[counter].fSigmaZ2  = ftime2;
 
-      fSpacePointData[counter].fMaxQ = list[j].fQMax;
+      fSpacePointData[counter].fQMax = list[j].fQMax;
 
       fSpacePointData[counter].fUsed = kFALSE;         // only used / set in AliHLTTPCDisplay
       fSpacePointData[counter].fTrackN = -1;           // only used / set in AliHLTTPCDisplay
@@ -654,8 +936,9 @@ void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliClusterData *list)
 // STILL TO FIX  ----------------------------------------------------------------------------
 
 #ifdef do_mc
-void AliHLTTPCClusterFinder::GetTrackID(Int_t pad,Int_t time,Int_t *trackID)
-{
+void AliHLTTPCClusterFinder::GetTrackID(Int_t pad,Int_t time,Int_t *trackID){
+  // see header file for class documentation
+
   //get mc id
   AliHLTTPCDigitRowData *rowPt = (AliHLTTPCDigitRowData*)fDigitRowData;
   
@@ -683,290 +966,11 @@ void AliHLTTPCClusterFinder::GetTrackID(Int_t pad,Int_t time,Int_t *trackID)
 }
 #endif
 
-//----------------------------------Methods for the new unsorted way of reading the data --------------------------------
-
-void AliHLTTPCClusterFinder::ReadDataUnsorted(void* ptr,unsigned long size)
-{
-  //set input pointer
-  fPtr = (UChar_t*)ptr;
-  fSize = size;
-
-  if(!fVectorInitialized){
-    InitializePadArray();
-  }
-
-  if (fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice)<0) {
-    HLTError("failed setting up digit reader (InitBlock)");
-    return;
-  }
-  
-  while(fDigitReader->NextChannel()){
-    UInt_t row=fDigitReader->GetRow();
-    UInt_t pad=fDigitReader->GetPad();
 
-    if(row>=fRowPadVector.size()){
-      HLTError("Row number is to large: %d, max is %d",row,fRowPadVector.size()-1);
-      continue;
-    }
-    if(pad>=fRowPadVector[row].size()){
-      HLTError("Pad number is to large: %d, max is %d",pad,fRowPadVector[row].size());
-      continue;
-    }
 
-    while(fDigitReader->NextBunch()){
-      if(fDigitReader->GetBunchSize()>1){//to remove single timebin values, this will have to change at some point
-       UInt_t time = fDigitReader->GetTime();
-       if((Int_t)time>=fFirstTimeBin && (Int_t)time+fDigitReader->GetBunchSize()<=fLastTimeBin){
-         const UInt_t *bunchData= fDigitReader->GetSignals();
-         AliHLTTPCClusters candidate;
-         for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
-           candidate.fTotalCharge+=bunchData[i];       
-           candidate.fTime += time*bunchData[i];
-           candidate.fTime2 += time*time*bunchData[i];
-           if(bunchData[i]>candidate.fQMax){
-             candidate.fQMax=bunchData[i];
-           }
-           time++;
-         }
-         if(candidate.fTotalCharge>0){
-           candidate.fMean=candidate.fTime/candidate.fTotalCharge;
-           candidate.fPad=candidate.fTotalCharge*pad;
-           candidate.fPad2=candidate.fPad*pad;
-           candidate.fLastMergedPad=pad;
-           candidate.fRowNumber=row+fDigitReader->GetRowOffset();
-         }
-         if(fRowPadVector[row][pad] != NULL){
-           fRowPadVector[row][pad]->AddClusterCandidate(candidate);
-         }
-       }
-      }
-    }
-  }
-}
-
-void AliHLTTPCClusterFinder::ReadDataUnsortedDeconvoluteTime(void* ptr,unsigned long size)
-{
-  //set input pointer
-  fPtr = (UChar_t*)ptr;
-  fSize = size;
-
-  if(!fVectorInitialized){
-    InitializePadArray();
-  }
-
-  if (fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice)<0) {
-    HLTError("failed setting up digit reader (InitBlock)");
-    return;
-  }
-  
-  while(fDigitReader->NextChannel()){
-    UInt_t row=fDigitReader->GetRow();
-    UInt_t pad=fDigitReader->GetPad();
-
-    while(fDigitReader->NextBunch()){
-      if(fDigitReader->GetBunchSize()>1){//to remove single timebin values, this will have to change at some point
-       UInt_t time = fDigitReader->GetTime();
-       if((Int_t)time>=fFirstTimeBin && (Int_t)time+fDigitReader->GetBunchSize()<=fLastTimeBin){
-         Int_t indexInBunchData=0;
-         Bool_t moreDataInBunch=kFALSE;
-         UInt_t prevSignal=0;
-         Bool_t signalFalling=kFALSE;
-         const UInt_t *bunchData= fDigitReader->GetSignals();
-         do{
-           AliHLTTPCClusters candidate;
-           for(Int_t i=indexInBunchData;i<fDigitReader->GetBunchSize();i++){
-             // Checks if one need to deconvolute the signals
-             if(bunchData[i]>prevSignal && signalFalling==kTRUE){
-               if(i<fDigitReader->GetBunchSize()-1){ // means there are more than one signal left in the bunch
-                 moreDataInBunch=kTRUE;
-                 prevSignal=0;
-               }
-               break;
-             }
-             
-             // Checks if the signal is 0, then quit processing the data.
-             if(bunchData[i]==0 && i<fDigitReader->GetBunchSize()-1){//means we have 0 data fom the rcu, might happen depending on the configuration settings
-               moreDataInBunch=kTRUE;
-               prevSignal=0;
-               break;
-             }
-
-             if(prevSignal>bunchData[i]){//means the peak of the signal has been reached and deconvolution will happen if the signal rise again.
-               signalFalling=kTRUE;
-             }
-             candidate.fTotalCharge+=bunchData[i];     
-             candidate.fTime += time*bunchData[i];
-             candidate.fTime2 += time*time*bunchData[i];
-             if(bunchData[i]>candidate.fQMax){
-               candidate.fQMax=bunchData[i];
-             }
-
-             prevSignal=bunchData[i];
-             time++;
-             indexInBunchData++;
-           }
-           if(candidate.fTotalCharge>0){
-             candidate.fMean=candidate.fTime/candidate.fTotalCharge;
-             candidate.fPad=candidate.fTotalCharge*pad;
-             candidate.fPad2=candidate.fPad*pad;
-             candidate.fLastMergedPad=pad;
-             candidate.fRowNumber=row+fDigitReader->GetRowOffset();
-           }
-           fRowPadVector[row][pad]->AddClusterCandidate(candidate);
-           if(indexInBunchData<fDigitReader->GetBunchSize()-1){
-             moreDataInBunch=kFALSE;
-           }
-         }while(moreDataInBunch);
-       }
-      }
-    }
-  }
-}
-
-Bool_t AliHLTTPCClusterFinder::ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* cluster,Int_t nextPadToRead){
-  //Checking if we have a match on the next pad
-  for(UInt_t candidateNumber=0;candidateNumber<nextPad->fClusterCandidates.size();candidateNumber++){
-    AliHLTTPCClusters *candidate =&nextPad->fClusterCandidates[candidateNumber]; 
-    if(cluster->fMean-candidate->fMean==1 || candidate->fMean-cluster->fMean==1 || cluster->fMean-candidate->fMean==0){
-      if(fDeconvPad){
-       if(candidate->fTotalCharge<fTotalChargeOfPreviousClusterCandidate){//peak is reached
-         fChargeOfCandidatesFalling=kTRUE;
-       }
-       if(candidate->fTotalCharge>fTotalChargeOfPreviousClusterCandidate && fChargeOfCandidatesFalling==kTRUE){//we have deconvolution
-         return kFALSE;
-       }
-      }
-      cluster->fMean=candidate->fMean;
-      cluster->fTotalCharge+=candidate->fTotalCharge;
-      cluster->fTime += candidate->fTime;
-      cluster->fTime2 += candidate->fTime2;
-      cluster->fPad+=candidate->fPad;
-      cluster->fPad2+=candidate->fPad2;
-      cluster->fLastMergedPad=candidate->fPad;
-      if(candidate->fQMax>cluster->fQMax){
-       cluster->fQMax=candidate->fQMax;
-      }
-      
-      if(fDoPadSelection){
-       UInt_t rowNo = nextPad->GetRowNumber();
-       UInt_t padNo = nextPad->GetPadNumber();
-       if(padNo-1>0){
-         fRowPadVector[rowNo][padNo-2]->fSelectedPad=kTRUE;
-         fRowPadVector[rowNo][padNo-2]->fHWAddress=(AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr(rowNo,padNo-2);
-       }
-       fRowPadVector[rowNo][padNo-1]->fSelectedPad=kTRUE;// quick solution to set the first pad to selected
-       fRowPadVector[rowNo][padNo-1]->fHWAddress=(AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr(rowNo,padNo-1);
-       fRowPadVector[rowNo][padNo]->fSelectedPad=kTRUE;
-       fRowPadVector[rowNo][padNo]->fHWAddress=(AliHLTUInt16_t)fDigitReader->GetAltroBlockHWaddr(rowNo,padNo);
-      }
-
-      //setting the matched pad to used
-      nextPad->fUsedClusterCandidates[candidateNumber]=1;
-      nextPadToRead++;
-      if(nextPadToRead<(Int_t)fNumberOfPadsInRow[fRowOfFirstCandidate]){
-       nextPad=fRowPadVector[fRowOfFirstCandidate][nextPadToRead];
-       ComparePads(nextPad,cluster,nextPadToRead);
-      }
-      else{
-       return kFALSE;
-      }
-    }
-    else{
-      return kFALSE;
-    }
-  }
-  return kFALSE;
-}
-
-Int_t AliHLTTPCClusterFinder::FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWadd){
-  Int_t counter=0;
-  for(UInt_t row=0;row<fNumberOfRows;row++){
-    for(UInt_t pad=0;pad<fNumberOfPadsInRow[row]-1;pad++){
-      if(fRowPadVector[row][pad]->fSelectedPad){
-       if(counter<maxHWadd){
-        hwaddlist[counter]=(AliHLTUInt16_t)fRowPadVector[row][pad]->fHWAddress;
-        counter++;
-       }
-       else{
-        HLTWarning("To many hardwareaddresses, skip adding");
-       }
-       
-      }
-    }
-  }  
-  return counter;
-}
-
-void AliHLTTPCClusterFinder::FindClusters()
-{
-  // see header file for function documentation
-
-  AliHLTTPCClusters* tmpCandidate=NULL;
-  for(UInt_t row=0;row<fNumberOfRows;row++){
-    fRowOfFirstCandidate=row;
-    for(UInt_t pad=0;pad<fNumberOfPadsInRow[row];pad++){
-      AliHLTTPCPad *tmpPad=fRowPadVector[row][pad];
-      for(size_t candidate=0;candidate<tmpPad->fClusterCandidates.size();candidate++){
-       if(tmpPad->fUsedClusterCandidates[candidate]){
-         continue;
-       }
-       tmpCandidate=&tmpPad->fClusterCandidates[candidate];
-       UInt_t tmpTotalCharge=tmpCandidate->fTotalCharge;
-
-       ComparePads(fRowPadVector[row][pad+1],tmpCandidate,pad+1);
-       if(tmpCandidate->fTotalCharge>tmpTotalCharge){
-         //we have a cluster
-         fClusters.push_back(*tmpCandidate);
-       }
-      }
-      tmpPad->ClearCandidates();
-    }
-    fRowPadVector[row][fNumberOfPadsInRow[row]]->ClearCandidates();
-  }
-
-  HLTInfo("Found %d clusters.",fClusters.size());
-
-  //TODO:  Change so it stores AliHLTTPCSpacePointData directly, instead of this copying
-  
-  AliClusterData * clusterlist = new AliClusterData[fClusters.size()]; //Clusterlist
-  for(unsigned int i=0;i<fClusters.size();i++){
-    clusterlist[i].fTotalCharge = fClusters[i].fTotalCharge;
-    clusterlist[i].fPad = fClusters[i].fPad;
-    clusterlist[i].fPad2 = fClusters[i].fPad2;
-    clusterlist[i].fTime = fClusters[i].fTime;
-    clusterlist[i].fTime2 = fClusters[i].fTime2;
-    clusterlist[i].fMean = fClusters[i].fMean;
-    clusterlist[i].fFlags = fClusters[i].fFlags;
-    clusterlist[i].fChargeFalling = fClusters[i].fChargeFalling;
-    clusterlist[i].fLastCharge = fClusters[i].fLastCharge;
-    clusterlist[i].fLastMergedPad = fClusters[i].fLastMergedPad;
-    clusterlist[i].fRow = fClusters[i].fRowNumber;
-    clusterlist[i].fQMax = fClusters[i].fQMax;
-
-  }
-  //  PrintClusters();
-  WriteClusters(fClusters.size(),clusterlist);
-  delete [] clusterlist;
-  fClusters.clear();
-}
-
-void AliHLTTPCClusterFinder::PrintClusters()
-{
+void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliHLTTPCClusters *list){//This is used when using the AliHLTTPCClusters class for cluster data
   // see header file for class documentation
-  for(size_t i=0;i<fClusters.size();i++){
-    HLTInfo("Cluster number: %d",i);
-    HLTInfo("Row: %d \t Pad: %d",fClusters[i].fRowNumber,fClusters[i].fPad/fClusters[i].fTotalCharge);
-    HLTInfo("Total Charge:   %d",fClusters[i].fTotalCharge);
-    HLTInfo("fPad:           %d",fClusters[i].fPad);
-    HLTInfo("PadError:       %d",fClusters[i].fPad2);
-    HLTInfo("TimeMean:       %d",fClusters[i].fTime/fClusters[i].fTotalCharge);
-    HLTInfo("TimeError:      %d",fClusters[i].fTime2);
-    HLTInfo("EndOfCluster:");
-  }
-}
 
-void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliHLTTPCClusters *list)//This is used when using the AliHLTTPCClusters class for cluster data
-{
   //write cluster to output pointer
   Int_t thisrow,thissector;
   UInt_t counter = fNClusters;
@@ -1056,7 +1060,7 @@ void AliHLTTPCClusterFinder::WriteClusters(Int_t nclusters,AliHLTTPCClusters *li
       fSpacePointData[counter].fSigmaY2 = fpad2;
       fSpacePointData[counter].fSigmaZ2  = ftime2;
 
-      fSpacePointData[counter].fMaxQ = list[j].fQMax;
+      fSpacePointData[counter].fQMax = list[j].fQMax;
 
       fSpacePointData[counter].fUsed = kFALSE;         // only used / set in AliHLTTPCDisplay
       fSpacePointData[counter].fTrackN = -1;           // only used / set in AliHLTTPCDisplay
index 2796afe..b5fb2c3 100644 (file)
@@ -122,23 +122,59 @@ class AliHLTTPCClusterFinder : public AliHLTLogging {
 
   /** standard constructor */
   AliHLTTPCClusterFinder();
+
   /** destructor */
   virtual ~AliHLTTPCClusterFinder();
 
-  void Read(void* ptr,unsigned long size);
-
-  void InitSlice(Int_t slice,Int_t patch,Int_t firstrow, Int_t lastrow,Int_t maxpoints);
+  /** Initialize the slice */
   void InitSlice(Int_t slice,Int_t patch,Int_t maxpoints);
-  void ProcessDigits();
 
+  /** Initializes the pad array (vector)*/
+  void InitializePadArray();
+
+  /** Deinitialize the pad array (vector)*/
+  Int_t DeInitializePadArray();
+
+  /** Read the data in unsorted format, storing the clustercandidates */
+  void ReadDataUnsorted(void* ptr,unsigned long size);
+
+  /** Read the data in unsorted format, and deconvolute the signals for each pad in time direction */
+  void ReadDataUnsortedDeconvoluteTime(void* ptr,unsigned long size);
+
+  /** Loops over all rows finding the clusters */
+  void FindClusters();
+
+  /** Compare two neighbouring pads for matching clustercandidates */
+  Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
+  
+  /**  Fills the hw address list */
+  Int_t FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWAddress);
+
+  /** Set the pointer to the outputbuffer */
   void SetOutputArray(AliHLTTPCSpacePointData *pt);
+
+  /** Returns the number of clusters */
+  Int_t GetNumberOfClusters() const {return fNClusters;}
+
+  // setters
+  void SetDeconv(Bool_t f) {fDeconvPad=f; fDeconvTime=f;}
+  void SetDeconvPad(Bool_t f) {fDeconvPad=f;}
+  void SetDeconvTime(Bool_t f) {fDeconvTime=f;}
+  void SetUnsorted(Int_t unsorted){fUnsorted=unsorted;}
+  void SetPatch(Int_t patch){fCurrentPatch=patch;}
+  void SetDoPadSelection(Bool_t input){fDoPadSelection=input;}
+  void SetLastTimeBin(Int_t ltb){fLastTimeBin=ltb;}
+  void SetFirstTimeBin(Int_t ftb){fFirstTimeBin=ftb;}
+  void UpdateLastTimeBin(){fLastTimeBin=AliHLTTPCTransform::GetNTimeBins();}
+
+//---------------------------------- Under this line the old sorted clusterfinder functions can be found --------------------------------
+  void Read(void* ptr,unsigned long size);
+  void ProcessDigits();
   void WriteClusters(Int_t n_clusters,AliClusterData *list);
+  void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
   void PrintClusters();
   void SetXYError(Float_t f) {fXYErr=f;}
   void SetZError(Float_t f) {fZErr=f;}
-  void SetDeconv(Bool_t f) {fDeconvPad=f; fDeconvTime=f;}
-  void SetDeconvPad(Bool_t f) {fDeconvPad=f;}
-  void SetDeconvTime(Bool_t f) {fDeconvTime=f;}
   void SetThreshold(UInt_t i) {fThreshold=i;}
   void SetOccupancyLimit(Float_t f) {fOccupancyLimit=f;}
   void SetMatchWidth(UInt_t i) {fMatch=i;}
@@ -146,28 +182,6 @@ class AliHLTTPCClusterFinder : public AliHLTLogging {
   void SetCalcErr(Bool_t f=kTRUE) {fCalcerr=f;}
   void SetRawSP(Bool_t f=kFALSE) {fRawSP=f;}
   void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
-  Int_t GetNumberOfClusters() const {return fNClusters;}
-
-  //----------------------------------Methods for the new unsorted way of reading data ----------
-  void ReadDataUnsorted(void* ptr,unsigned long size);
-  void ReadDataUnsortedDeconvoluteTime(void* ptr,unsigned long size);
-  void FindClusters();
-  void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
-  void SetUnsorted(Int_t unsorted){fUnsorted=unsorted;}
-  void SetPatch(Int_t patch){fCurrentPatch=patch;}
-  void InitializePadArray();
-  Int_t DeInitializePadArray();
-  Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
-
-  void SetDoPadSelection(Bool_t input){fDoPadSelection=input;}
-  
-  Int_t FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWAddress);
-
-  void UpdateLastTimeBin(){fLastTimeBin=AliHLTTPCTransform::GetNTimeBins();}
-
-  void SetLastTimeBin(Int_t ltb){fLastTimeBin=ltb;}
-
-  void SetFirstTimeBin(Int_t ftb){fFirstTimeBin=ftb;}
   
   vector<AliHLTUInt16_t> fClustersHWAddressVector;  //! transient
   
@@ -184,32 +198,32 @@ class AliHLTTPCClusterFinder : public AliHLTLogging {
   AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
   AliHLTTPCDigitReader *fDigitReader;       //! reader instance
 
-  UChar_t* fPtr;   //! pointer to packed block
-  unsigned long fSize; //packed block size
-  Bool_t fDeconvTime;  //deconv in time direction
-  Bool_t fDeconvPad;  //deconv in pad direction
-  Bool_t fStdout;     //have print out in write clusters
-  Bool_t fCalcerr;    //calculate centroid sigmas
-  Bool_t fRawSP;      //store centroids in raw system
-
-
-  Int_t fFirstRow;       //first row
-  Int_t fLastRow;        //last row
-  Int_t fCurrentRow;     //current active row
-  Int_t fCurrentSlice;   //current slice
-  Int_t fCurrentPatch;   //current patch
-  Int_t fMatch;          //size of match
-  UInt_t fThreshold;     //threshold for clusters
-  Int_t fNClusters;      //number of found clusters
-  Int_t fMaxNClusters;   //max. number of clusters
-  Float_t fXYErr;        //fixed error in XY
-  Float_t fZErr;         //fixed error in Z
+  UChar_t* fPtr;           //! pointer to packed block
+  unsigned long fSize;     //! packed block size
+  Bool_t fDeconvTime;      //! deconv in time direction
+  Bool_t fDeconvPad;       //! deconv in pad direction
+  Bool_t fStdout;          //! have print out in write clusters
+  Bool_t fCalcerr;         //! calculate centroid sigmas
+  Bool_t fRawSP;           //! store centroids in raw system
+
+
+  Int_t fFirstRow;       //! first row
+  Int_t fLastRow;        //! last row
+  Int_t fCurrentRow;     //! current active row
+  Int_t fCurrentSlice;   //! current slice
+  Int_t fCurrentPatch;   //! current patch
+  Int_t fMatch;          //! size of match
+  UInt_t fThreshold;     //! threshold for clusters
+  Int_t fNClusters;      //! number of found clusters
+  Int_t fMaxNClusters;   //! max. number of clusters
+  Float_t fXYErr;        //! fixed error in XY
+  Float_t fZErr;         //! fixed error in Z
   
-  Float_t fOccupancyLimit; // Occupancy Limit
-
-  Int_t fUnsorted;       // enable for processing of unsorted digit data
-  Bool_t fVectorInitialized;
+  Float_t fOccupancyLimit;    //! Occupancy Limit
 
+  Int_t fUnsorted;            //! enable for processing of unsorted digit data
+  Bool_t fVectorInitialized;  //! flag to check if pad vector is initialized
   vector<AliHLTTPCClusters> fClusters;                             //! transient
   
   UInt_t* fNumberOfPadsInRow;                                      //! transient
index 8ee19d4..e194254 100644 (file)
@@ -86,9 +86,6 @@ const char* AliHLTTPCClusterFinderComponent::GetComponentID()
   case kClusterFinderPacked:
     return "TPCClusterFinderPacked";
     break;
-  case kClusterFinderUnpacked:
-    return "TPCClusterFinderUnpacked";
-    break;
   case kClusterFinderDecoder:
     return "TPCClusterFinderDecoder";
     break;
@@ -105,9 +102,6 @@ void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentD
   case kClusterFinderPacked:
     list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
     break;
-  case kClusterFinderUnpacked:
-    list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
-    break;
   case kClusterFinderDecoder:
     list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
     break;
@@ -162,24 +156,13 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
 
   fClusterFinder = new AliHLTTPCClusterFinder();
 
-  //  Int_t sigthresh = -1;
-  //  Double_t sigmathresh= -1;
   Float_t occulimit = 1.0;
-  //  Int_t oldRCUFormat=0;
-  // Data Format version numbers:
-  // 0: RCU Data format as delivered during TPC commissioning, pads/padrows are sorted, RCU trailer is one 32 bit word.
-  // 1: As 0, but pads/padrows are delivered "as is", without sorting
-  // 2: As 0, but RCU trailer is 3 32 bit words.
-  // 3: As 1, but RCU trailer is 3 32 bit words.
-  // -1: use offline raw reader
 
   Int_t i = 0;
   Char_t* cpErr;
 
   while ( i < argc ) {      
 
-
-
     // -- deconvolute-time option
     if ( !strcmp( argv[i], "-deconvolute-time" ) ) {
       fDeconvTime = kTRUE;
@@ -284,7 +267,6 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
       continue;
     }
 
-
     // -- raw reader mode option
     if ( !strcmp( argv[i], "rawreadermode" ) ) {
       if ( argc <= i+1 ) {
@@ -298,7 +280,6 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
       continue;
     }
 
-
     // -- pp-run option
     if ( !strcmp( argv[i], "pp-run") ) {
       HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
@@ -319,7 +300,6 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
       continue;
     }
 
-
     // -- checking for rcu format
     if ( !strcmp( argv[i], "oldrcuformat" ) ) {
       strtoul( argv[i+1], &cpErr ,0);
@@ -379,24 +359,9 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
   if (fModeSwitch==kClusterFinderPacked) {
       HLTDebug("using AliHLTTPCDigitReaderPacked");
       fReader = new AliHLTTPCDigitReaderPacked();
-      /*
-       if(oldRCUFormat==1){
-       fReader->SetOldRCUFormat(kTRUE);
-       }
-       else if(oldRCUFormat!=0){
-       HLTWarning("Wrong oldrcuformat specifier %d; oldrcuformat set to default(kFALSE)",oldRCUFormat);
-       }
-      */
-      if(fUnsorted==1){
-       fReader->SetUnsorted(kTRUE);
-      }
+      if(fUnsorted==1){        fReader->SetUnsorted(kTRUE); }
       fClusterFinder->SetReader(fReader);
   }
-  else if(fModeSwitch==kClusterFinderUnpacked){
-    HLTDebug("using AliHLTTPCDigitReaderUnpacked");
-    fReader = new AliHLTTPCDigitReaderUnpacked();
-    fClusterFinder->SetReader(fReader);
-  }
   else if(fModeSwitch==kClusterFinderDecoder){
     HLTDebug("using AliHLTTPCDigitReaderDecoder");
     fReader = new AliHLTTPCDigitReaderDecoder();
@@ -420,8 +385,6 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
   if ( (fXYClusterError>0) && (fZClusterError>0) ){
     fClusterFinder->SetCalcErr( false );
   }
-  //  fClusterFinder->SetSignalThreshold(sigthresh);
-  //  fClusterFinder->SetNSigmaThreshold(sigmathresh);
 
   if(fFirstTimeBin>0){
     fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
@@ -456,6 +419,12 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
 {
   // see header file for class documentation
 
+  if(fReader == NULL){
+    HLTFatal("Digit reader not initialized, aborting event.");
+    size=0;
+    return 0;    
+  }
+
   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
     size=0;
     return 0;
@@ -474,7 +443,7 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
   outBPtr = outputPtr;
   outPtr = (AliHLTTPCClusterData*)outBPtr;
 
-  Int_t slice, patch, row[2];
+  Int_t slice, patch;
   unsigned long maxPoints, realPoints = 0;
 
   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
@@ -502,20 +471,16 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
 
       }
       else if(fModeSwitch==1){
+       HLTWarning("Unpacked data type depreciated, block aborted");
        HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
                 evtData.fEventID, evtData.fEventID, 
                 DataType2Text( iter->fDataType).c_str(), 
                 DataType2Text(AliHLTTPCDefinitions::fgkUnpackedRawDataType).c_str());
-
-       if ( iter->fDataType != AliHLTTPCDefinitions::fgkUnpackedRawDataType ) continue;
-
+       continue;
       }
 
       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
       patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
-      row[0] = AliHLTTPCTransform::GetFirstRow( patch );
-      row[1] = AliHLTTPCTransform::GetLastRow( patch );
-
 
       if(fUnsorted){
        fClusterFinder->SetUnsorted(fUnsorted);
@@ -526,14 +491,13 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
 
       maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
 
-      fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
+      fClusterFinder->InitSlice( slice, patch, maxPoints );
       fClusterFinder->SetOutputArray( (AliHLTTPCSpacePointData*)outPtr->fSpacePoints );
        
       if(fUnsorted){
        if(fGetActivePads){
          fClusterFinder->SetDoPadSelection(kTRUE);
-       }
-       
+       }       
        if(fDeconvTime){
          fClusterFinder->ReadDataUnsortedDeconvoluteTime(iter->fPtr, iter->fSize);
        }
@@ -547,6 +511,7 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
        fClusterFinder->Read(iter->fPtr, iter->fSize );
        fClusterFinder->ProcessDigits();
       }
+
       realPoints = fClusterFinder->GetNumberOfClusters();
        
       outPtr->fSpacePointCnt = realPoints;
@@ -555,14 +520,13 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
 
       Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints", 
               "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
-              realPoints, slice, patch, row[0], row[1] );
+              realPoints, slice, patch,AliHLTTPCTransform::GetFirstRow( patch ) , AliHLTTPCTransform::GetLastRow( patch ) );
       AliHLTComponentBlockData bd;
       FillBlockData( bd );
       bd.fOffset = offset;
       bd.fSize = mysize;
       bd.fSpecification = iter->fSpecification;
       bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
-      //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
       outputBlocks.push_back( bd );
        
       tSize += mysize;
index f946041..3d72260 100644 (file)
@@ -209,15 +209,15 @@ int AliHLTTPCClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*ev
        
       }
       if(fPlotQmaxPartAll){
-       if(clusters[i].fMaxQ>tmpQPart){
-         fQMaxPartitionAll->SetBinContent(patch+6*slice,clusters[i].fMaxQ);
-         tmpQPart=clusters[i].fMaxQ;
+       if(clusters[i].fQMax>tmpQPart){
+         fQMaxPartitionAll->SetBinContent(patch+6*slice,clusters[i].fQMax);
+         tmpQPart=clusters[i].fQMax;
        }
       }
       if(fPlotQmaxROCAll){
-       if(clusters[i].fMaxQ>fQMaxROCAll->GetBinContent(thissector)){
-         fQMaxROCAll->SetBinContent(thissector,clusters[i].fMaxQ);
-         //      tmpQROC=clusters[i].fMaxQ;
+       if(clusters[i].fQMax>fQMaxROCAll->GetBinContent(thissector)){
+         fQMaxROCAll->SetBinContent(thissector,clusters[i].fQMax);
+         //      tmpQROC=clusters[i].fQMax;
        }
       }
     }
diff --git a/HLT/TPCLib/AliHLTTPCHWCFDataReverterComponent.cxx b/HLT/TPCLib/AliHLTTPCHWCFDataReverterComponent.cxx
new file mode 100755 (executable)
index 0000000..f8f807f
--- /dev/null
@@ -0,0 +1,411 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
+ *                                                                        *
+ * Primary Authors: Kenneth Aamodt <Kenneth.Aamodt@student.uib.no>        *
+ *                  for The ALICE HLT Project.                            *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/** @file   AliHLTTPCHWCFDataReverterComponent.cxx
+    @author Kenneth Aamodt
+    @date   
+    @brief  Component for reverting data for the HW clusterfinder
+*/
+
+// see header file for class documentation                                   //
+// or                                                                        //
+// refer to README to build package                                          //
+// or                                                                        //
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt                          //
+
+#if __GNUC__>= 3
+using namespace std;
+#endif
+#include "AliHLTTPCHWCFDataReverterComponent.h"
+#include "AliHLTTPCDigitReaderDecoder.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliHLTTPCDigitData.h"
+#include "AliHLTTPCMapping.h"
+#include <cstdlib>
+#include <cerrno>
+#include <cassert>
+#include "TString.h"
+#include <sys/time.h>
+#include "AliHLTAltroEncoder.h"
+#include "AliRawDataHeader.h"
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTTPCHWCFDataReverterComponent)
+
+  AliHLTTPCHWCFDataReverterComponent::AliHLTTPCHWCFDataReverterComponent()
+    :
+    fDigitReader(NULL),
+    fRowPadVector(),
+    fNumberOfPadsInRow(NULL),
+    fFirstPadHigh(NULL),
+    fNumberOfRows(0),
+    fCurrentPatch(0),
+    fFirstRow(0),
+    fLastRow(0),
+    fNTimeBins(0),
+    fVectorInitialized(kFALSE),
+    fMapping(NULL)
+{
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+}
+
+AliHLTTPCHWCFDataReverterComponent::~AliHLTTPCHWCFDataReverterComponent()
+{
+  // see header file for class documentation
+  if(fVectorInitialized){
+    DeInitializePadArray();
+  }
+  if(fNumberOfPadsInRow){
+    delete [] fNumberOfPadsInRow;
+    fNumberOfPadsInRow=NULL;
+  }
+  if(fFirstPadHigh){
+    delete [] fFirstPadHigh;
+    fFirstPadHigh=NULL;
+  }
+  if(fDigitReader){
+    delete fDigitReader;
+    fDigitReader=NULL;
+  }
+  if(fMapping){
+    delete fMapping;
+    fMapping = NULL;
+  }
+}
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCHWCFDataReverterComponent::GetComponentID()
+{
+  // see header file for class documentation
+  return "TPCHWCFDataReverter";
+}
+
+void AliHLTTPCHWCFDataReverterComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+{
+  // see header file for class documentation
+  list.clear(); 
+  list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
+}
+
+AliHLTComponentDataType AliHLTTPCHWCFDataReverterComponent::GetOutputDataType()
+{
+  // see header file for class documentation
+  return kAliHLTDataTypeDDLRaw;
+}
+
+int AliHLTTPCHWCFDataReverterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+  // see header file for class documentation
+  tgtList.clear();
+  tgtList.push_back(kAliHLTDataTypeDDLRaw);
+  return tgtList.size();
+}
+
+void AliHLTTPCHWCFDataReverterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+  // see header file for class documentation
+  constBase=0;
+  inputMultiplier=1.0;
+}
+
+AliHLTComponent* AliHLTTPCHWCFDataReverterComponent::Spawn()
+{
+  // see header file for class documentation
+  return new AliHLTTPCHWCFDataReverterComponent();
+}
+       
+int AliHLTTPCHWCFDataReverterComponent::DoInit( int argc, const char** argv )
+{
+  // see header file for class documentation
+
+  Int_t i = 0;
+  Char_t* cpErr;
+
+  while ( i < argc ) {      
+
+    // -- number of timebins
+    if ( !strcmp( argv[i], "-timebins" )) {
+      fNTimeBins = strtoul( argv[i+1], &cpErr ,0);
+      AliHLTTPCTransform::SetNTimeBins(fNTimeBins);
+      if ( *cpErr ) {
+       HLTError("Cannot convert ntimebins specifier '%s'.", argv[i+1]);
+       return EINVAL;
+      }
+      i+=2;
+      continue;
+    }
+     
+    HLTError("HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+
+    return EINVAL;
+  }
+
+  HLTDebug("using AliHLTTPCDigitReaderDecoder");
+  fDigitReader = new AliHLTTPCDigitReaderDecoder();
+
+  return 0;
+}
+
+int AliHLTTPCHWCFDataReverterComponent::DoDeinit()
+{
+  // see header file for class documentation
+  return 0;
+}
+
+Int_t AliHLTTPCHWCFDataReverterComponent::DeInitializePadArray()
+{
+  // see header file for class documentation
+  if(fVectorInitialized){
+    for(Int_t i=0;i<fNumberOfRows;i++){
+      for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){
+       delete fRowPadVector[i][j];
+       fRowPadVector[i][j]=NULL;
+      }
+      fRowPadVector[i].clear();
+    }
+    fRowPadVector.clear();
+  }
+  return 1;
+} 
+
+void AliHLTTPCHWCFDataReverterComponent::InitializePadArray(){
+  // see header file for class documentation
+  if(fCurrentPatch>5){
+    HLTFatal("Patch is not set");
+    return;
+  }
+
+  fFirstRow = AliHLTTPCTransform::GetFirstRow(fCurrentPatch);
+  fLastRow = AliHLTTPCTransform::GetLastRow(fCurrentPatch);
+
+  fNumberOfRows=fLastRow-fFirstRow+1;
+  fNumberOfPadsInRow= new Int_t[fNumberOfRows];
+  fFirstPadHigh= new Int_t[fNumberOfRows];
+
+  memset( fNumberOfPadsInRow, 0, sizeof(Int_t)*(fNumberOfRows));
+  memset( fFirstPadHigh, 0, sizeof(Int_t)*(fNumberOfRows));
+
+  for(Int_t i=0;i<fNumberOfRows;i++){
+    fNumberOfPadsInRow[i]=AliHLTTPCTransform::GetNPads(i+fFirstRow);
+    AliHLTTPCPadVector tmpRow;
+    for(Int_t j=0;j<fNumberOfPadsInRow[i];j++){
+      AliHLTTPCPad *tmpPad = new AliHLTTPCPad();
+      if(fFirstPadHigh[i] != 0){
+       if(fMapping->GetHwAddress(i,j) > 2047){
+         fFirstPadHigh[i]=j;
+       }
+      }
+      tmpPad->SetID(i,j);
+      tmpRow.push_back(tmpPad);
+    }
+    fRowPadVector.push_back(tmpRow);
+  }
+  fVectorInitialized=kTRUE;
+}
+
+
+int AliHLTTPCHWCFDataReverterComponent::DoEvent( const AliHLTComponentEventData& evtData, 
+                                                const AliHLTComponentBlockData* blocks, 
+                                                AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
+                                                AliHLTUInt32_t& size, 
+                                                vector<AliHLTComponentBlockData>& outputBlocks )
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (!fDigitReader) return -ENODEV;
+
+  AliHLTUInt32_t capacity=size;
+  size=0;
+  if (!IsDataEvent()) return 0;
+
+  //  == init iter (pointer to datablock)
+  const AliHLTComponentBlockData* iter = NULL;
+  unsigned long ndx;
+
+  //reading the data
+  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ){
+
+    iter = blocks+ndx;
+      
+    HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
+            evtData.fEventID, evtData.fEventID, 
+            DataType2Text( iter->fDataType).c_str(), 
+            DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
+
+    if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)){
+      continue;
+    }
+
+    if (iter->fSize<=sizeof(AliRawDataHeader)) {
+      // forward empty DDLs
+      outputBlocks.push_back(*iter);
+      continue;
+    }
+
+    UInt_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+    UInt_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+
+    if(fDigitReader->InitBlock(iter->fPtr,iter->fSize,patch,slice)<0){
+      HLTWarning("Decoder failed to initialize, event aborted.");
+      continue;
+    }
+      
+    fMapping = new AliHLTTPCMapping(patch);
+
+    if(!fVectorInitialized){
+      fCurrentPatch=patch;
+      InitializePadArray();
+    }
+
+    //Here the reading of the data and the zerosuppression takes place
+    while(fDigitReader->NextChannel()){//Pad
+
+      Int_t row=fDigitReader->GetRow();
+      Int_t pad=fDigitReader->GetPad();
+
+      if(row >= fNumberOfRows || row < 0){
+       continue;
+      }
+      else if(pad >= fNumberOfPadsInRow[row] || pad < 0){
+       continue;
+      }  
+       
+      AliHLTTPCPad *tmpPad = fRowPadVector[row][pad];
+      if (tmpPad){
+       tmpPad->SetDataToDefault();
+      }
+       
+      //reading data to pad
+      while(fDigitReader->NextBunch()){
+       const UInt_t *bunchData= fDigitReader->GetSignals();
+       Int_t time=fDigitReader->GetTime();
+       for(Int_t i=0;i<fDigitReader->GetBunchSize();i++){
+         if(bunchData[i]>0){// disregarding 0 data.
+           if(time+i >= 0 && time+i < AliHLTTPCTransform::GetNTimeBins()){
+             if (tmpPad){
+               tmpPad->SetDataSignal(time+i,bunchData[i]);
+             }
+           }
+         }
+       }
+      }
+    }
+
+    if( iter->fSize > sizeof(AliRawDataHeader )){
+  
+      AliHLTAltroEncoder *altroEncoder = new AliHLTAltroEncoder;
+      altroEncoder->SetBuffer(outputPtr,capacity); //tests if one overwrite the buffer is done in the encoder
+
+      // set CDH from the beginning of buffer
+      altroEncoder->SetCDH((AliHLTUInt8_t*)iter->fPtr,sizeof(AliRawDataHeader));
+
+      UChar_t *RCUTrailer=NULL;
+      Int_t RCUTrailerSize=fDigitReader->GetRCUTrailerSize();
+      if (RCUTrailerSize<=0 || !fDigitReader->GetRCUTrailerData( RCUTrailer )) {
+       if(RCUTrailer==NULL){
+         HLTWarning("can not find RCU trailer for data block %s 0x%08x: skipping data block",
+                    DataType2Text(iter->fDataType).c_str(), iter->fSpecification);
+         continue;
+       }
+      }
+      altroEncoder->SetRCUTrailer(RCUTrailer, RCUTrailerSize);
+
+      for(Int_t row = 0; row< fNumberOfRows;row++){
+       Int_t padHigh=fFirstPadHigh[row];
+
+       Int_t padLowIndex=0;
+       Int_t padHighIndex= padHigh;
+         
+       while(padLowIndex < padHigh || padHighIndex < fNumberOfPadsInRow[row]){
+         Int_t currentTime = 0;
+         Int_t bunchSize = 0;
+         //add the data from low side
+         if(padLowIndex < padHigh){
+           AliHLTTPCPad * lowPad= fRowPadVector[row][padLowIndex];
+           while(lowPad->GetNextGoodSignal(currentTime, bunchSize)){
+             for(Int_t i=0;i<bunchSize;i++){
+               if (altroEncoder->AddSignal((AliHLTUInt16_t)(lowPad->GetDataSignal(currentTime+i)),(AliHLTUInt16_t)(currentTime+i))<0) {
+                 HLTWarning("can not add channel: slice %d, partition %d, hw address %d, row %d, pad %d, time %d, bunch size %d",
+                            slice, patch, fMapping->GetHwAddress(row,padLowIndex), row, padLowIndex, currentTime+i, bunchSize);
+                 break;
+               }
+             }
+           }
+           altroEncoder->SetChannel(fMapping->GetHwAddress(row,padLowIndex));
+         }
+         currentTime = 0;
+         bunchSize = 0;
+         //add the data from the high side
+         if(padHighIndex < fNumberOfPadsInRow[row]){
+           AliHLTTPCPad * highPad= fRowPadVector[row][padHighIndex];
+           while(highPad->GetNextGoodSignal(currentTime, bunchSize)){
+             for(Int_t i=0;i<bunchSize;i++){
+               if (altroEncoder->AddSignal((AliHLTUInt16_t)(highPad->GetDataSignal(currentTime+i)),(AliHLTUInt16_t)(currentTime+i))<0) {
+                 HLTWarning("can not add channel: slice %d, partition %d, hw address %d, row %d, pad %d, time %d, bunch size %d",
+                            slice, patch, fMapping->GetHwAddress(row,padHighIndex), row, padHighIndex, currentTime+i, bunchSize);
+                 break;
+               }
+             }
+           }
+           altroEncoder->SetChannel(fMapping->GetHwAddress(row,padHighIndex));
+         }
+         padLowIndex++;
+         padHighIndex++;
+       }
+      }
+       
+      altroEncoder->Revert40BitWords(sizeof(AliRawDataHeader),RCUTrailerSize);
+
+      int sizeOfData=altroEncoder->SetLength();
+
+      if (sizeOfData<0) {
+       HLTError("data encoding failed");
+       iResult=sizeOfData;
+       break;
+      }
+      if(sizeOfData>(int)capacity){
+       HLTWarning("Buffer too small too add the altrodata: %d of %d byte(s) already used", sizeOfData, capacity);
+       iResult=-ENOSPC;
+       break;
+      }
+
+      AliHLTComponentBlockData bd;
+      FillBlockData( bd );
+      bd.fOffset = 0;
+      bd.fSize = sizeOfData;
+      bd.fDataType = kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC;
+      bd.fSpecification = iter->fSpecification;
+      outputBlocks.push_back( bd );
+
+      size+=sizeOfData;
+    }
+    fDigitReader->Reset();
+  }
+  
+  if(iResult < 0) {
+    fDigitReader->Reset();
+    size=0;
+  }
+  HLTDebug("Total size of output is: %d ",size);
+  return iResult;
+}
diff --git a/HLT/TPCLib/AliHLTTPCHWCFDataReverterComponent.h b/HLT/TPCLib/AliHLTTPCHWCFDataReverterComponent.h
new file mode 100755 (executable)
index 0000000..f8fde33
--- /dev/null
@@ -0,0 +1,121 @@
+// XEmacs -*-C++-*-
+
+#ifndef ALIHLTTPCHWCFDATAREVERTERCOMPONENT_H
+#define ALIHLTTPCHWCFDATAREVERTERCOMPONENT_H
+
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               *
+
+/** @file   AliHLTTPCHWCFDataReverterComponent.h
+    @author Kenneth Aamodt
+    @date   
+    @brief  Component for reverting data for the HW clusterfinder
+*/
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCPad.h"
+#include "AliHLTDataTypes.h"
+
+class AliHLTTPCDigitReader;
+class AliHLTTPCMapping;
+
+/**
+ * @class AliHLTTPCHWCFDataReverterComponent
+ * Implementation of the zero suppression component.
+ * The component implements the interface methods of the @ref AliHLTProcessor.
+ *
+ * The component orders the data in the format the Hardware ClusterFinder 
+ * expects, and revert the 40 bit altro words.
+ * 
+ * The component has the following component arguments:
+ *
+ * @ingroup alihlt_tpc_components
+ */
+class AliHLTTPCHWCFDataReverterComponent : public AliHLTProcessor
+    {
+    public:
+        /** constructor */
+       AliHLTTPCHWCFDataReverterComponent();
+       /** destructor */
+       virtual ~AliHLTTPCHWCFDataReverterComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+  /** interface function, see AliHLTComponent for description */
+  const char* GetComponentID();
+  /** interface function, see AliHLTComponent for description */
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+  /** interface function, see AliHLTComponent for description */
+  AliHLTComponentDataType GetOutputDataType();
+  /** interface function, see AliHLTComponent for description */
+  int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+  /** interface function, see AliHLTComponent for description */
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+  /** interface function, see AliHLTComponent for description */
+  AliHLTComponent* Spawn();
+
+      Int_t DeInitializePadArray();
+      void InitializePadArray();
+      
+    protected:
+       
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+        int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
+                    AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
+       using AliHLTProcessor::DoEvent;
+
+    private:
+
+      /** copy constructor prohibited */
+      AliHLTTPCHWCFDataReverterComponent(const AliHLTTPCHWCFDataReverterComponent&);
+       
+      /** assignment operator prohibited */
+      AliHLTTPCHWCFDataReverterComponent& operator=(const AliHLTTPCHWCFDataReverterComponent&);
+       
+      /** the reader object for data decoding */
+      AliHLTTPCDigitReader* fDigitReader;                              //!transient
+
+      /** Vector of pointers to pad objects */
+      typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
+      
+      /** 2D vector of pointers to pad objects (vector of vectors)*/
+      vector<AliHLTTPCPadVector> fRowPadVector;                        //! transient
+      
+      /** Array containing number of pads in the different rows */
+      Int_t* fNumberOfPadsInRow;                                      //! transient
+      
+      /** Array containing the index f forst pad on row with hwaddress > 2048 */
+      Int_t* fFirstPadHigh;                                      //! transient
+
+      /** Number of rows the patch has */
+      Int_t fNumberOfRows;                                            //! transient
+
+      /** Current patch number */
+      UInt_t fCurrentPatch;                                            //! transient
+
+      /** First row in patch */
+      UInt_t fFirstRow;                                                //! transient
+
+      /** Last row in patch */
+      UInt_t fLastRow;                                                 //! transient
+      
+      /** Number of timebins */
+      Int_t fNTimeBins;                                                //! transient
+
+      /** Flag to check if the 2d vector is initialized */
+      Bool_t fVectorInitialized;                                       //! transient
+
+      /** pointer to mapping object */
+      AliHLTTPCMapping *fMapping;
+
+      ClassDef(AliHLTTPCHWCFDataReverterComponent, 0)  
+    };
+#endif
index 1eb8523..0496ff3 100644 (file)
@@ -313,11 +313,11 @@ void AliHLTTPCKryptonClusterFinder::FindKryptonClusters()
          fSpacePointData[fNKryptonClusters].fY = xyz[1];
          fSpacePointData[fNKryptonClusters].fZ = xyz[2];
          fSpacePointData[fNKryptonClusters].fCharge = tmpCluster->fTotalCharge;
-         fSpacePointData[fNKryptonClusters].fMaxQ = tmpCluster->fQMax;
+         fSpacePointData[fNKryptonClusters].fQMax = tmpCluster->fQMax;
          fSpacePointData[fNKryptonClusters].fPadRow = tmpCluster->fRowNumber/tmpCluster->fTotalCharge;
          HLTDebug("Krypton cluster found");
          HLTDebug("xyz=[%f,%f,%f]",fSpacePointData[fNKryptonClusters].fX,fSpacePointData[fNKryptonClusters].fY,fSpacePointData[fNKryptonClusters].fZ);
-         HLTDebug("TotalCharge = %d    and   QMax = %d",fSpacePointData[fNKryptonClusters].fCharge,fSpacePointData[fNKryptonClusters].fMaxQ);
+         HLTDebug("TotalCharge = %d    and   QMax = %d",fSpacePointData[fNKryptonClusters].fCharge,fSpacePointData[fNKryptonClusters].fQMax);
          fNKryptonClusters++;
          break;
        }
index 7216d8e..baa9dc2 100644 (file)
@@ -179,7 +179,7 @@ int AliHLTTPCKryptonClusterFinderComponent::DoEvent( const AliHLTComponentEventD
   //  == init iter (pointer to datablock)
   const AliHLTComponentBlockData* iter = NULL;
 
-  Int_t slice, patch, row[2];
+  Int_t slice, patch;
 
   unsigned long maxPoints = 0;
 
@@ -207,13 +207,11 @@ int AliHLTTPCKryptonClusterFinderComponent::DoEvent( const AliHLTComponentEventD
       
     slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
     patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
-    row[0] = AliHLTTPCTransform::GetFirstRow( patch );
-    row[1] = AliHLTTPCTransform::GetLastRow( patch );
 
 
     fKryptonClusterFinder->SetPatch(patch);
 
-    fKryptonClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
+    fKryptonClusterFinder->InitSlice( slice, patch, maxPoints );
 
     fKryptonClusterFinder->SetOutputArray((AliHLTTPCSpacePointData*)outPtr->fSpacePoints);
     
index e3c73fa..5c01e1f 100644 (file)
@@ -248,7 +248,7 @@ int AliHLTTPCNoiseMapComponent::DoInit( int argc, const char** argv ) {
 } // end DoInit()
 
 int AliHLTTPCNoiseMapComponent::DoDeinit() { 
-// see header file for class documentation  
+  // see header file for class documentation  
 
   if(fHistMaxSignal) delete fHistMaxSignal; fHistMaxSignal = NULL;
   if(fHistTotSignal) delete fHistTotSignal; fHistTotSignal = NULL;
@@ -260,7 +260,7 @@ int AliHLTTPCNoiseMapComponent::DoDeinit() {
 }
 
 int AliHLTTPCNoiseMapComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& /*trigData*/){
-// see header file for class documentation
+  // see header file for class documentation
  
   //HLTInfo("--- Entering DoEvent() in TPCNoiseMap ---");
  
@@ -273,34 +273,41 @@ int AliHLTTPCNoiseMapComponent::DoEvent(const AliHLTComponentEventData& evtData,
     
   for(iter = GetFirstInputBlock(kAliHLTDataTypeDDLRaw|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
       
-     HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", 
-              evtData.fEventID, evtData.fEventID,
-              DataType2Text(iter->fDataType).c_str(), 
-             DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
-
-     if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){
-         HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", 
-        DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
-         DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
-     }      
+    HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", 
+           evtData.fEventID, evtData.fEventID,
+           DataType2Text(iter->fDataType).c_str(), 
+           DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
+
+    if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType && GetEventCount()<2){
+      HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!", 
+                DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
+                DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
+    }      
      
-     if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue;
+    if (iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC)) continue;
       
-     UInt_t slice     = AliHLTTPCDefinitions::GetMinSliceNr(*iter); 
-     UInt_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
+    UInt_t slice     = AliHLTTPCDefinitions::GetMinSliceNr(*iter); 
+    UInt_t partition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
      
-     fSpecification = iter->fSpecification;
+    fSpecification = iter->fSpecification;
      
-     AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder;
+    AliHLTTPCDigitReader *pDigitReader = new AliHLTTPCDigitReaderDecoder;
 
-     pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice);
-     if(!pDigitReader) break;
+    pDigitReader->InitBlock(iter->fPtr,iter->fSize,partition,slice);
+    if(!pDigitReader) break;
        
-     //sprintf(name,"hMaxSignal_slice%d_partition%d", slice, partition);
-     //fHistMaxSignal = new TH2F(name,name,250,-250,250,250,-250,250);
+    //sprintf(name,"hMaxSignal_slice%d_partition%d", slice, partition);
+    //fHistMaxSignal = new TH2F(name,name,250,-250,250,250,-250,250);
             
-     while(pDigitReader->Next()){ 
-     //while( pDigitReader->NextChannel()) { // pad loop 
+    //  while(pDigitReader->Next()){ 
+
+
+    Float_t maxSignal     = 0.;
+    Float_t totalSignal   = 0.;
+    Float_t squaredSignal = 0.;
+    Float_t rms = 0.; 
+    
+    while( pDigitReader->NextChannel()) { // pad loop 
       
       fCurrentRow  = pDigitReader->GetRow();  
       fCurrentRow += pDigitReader->GetRowOffset();
@@ -319,49 +326,53 @@ int AliHLTTPCNoiseMapComponent::DoEvent(const AliHLTComponentEventData& evtData,
       // transformation from pad-row coordinates to global ones
       // time info is not taken into account
       
-//       AliTPCCalROC *calRoc = noisePad->GetCalROC(thissector);
-//       calRoc->GetValue(thisrow,pDigitReader->GetPad());
+      //       AliTPCCalROC *calRoc = noisePad->GetCalROC(thissector);
+      //       calRoc->GetValue(thisrow,pDigitReader->GetPad());
+      
       
-      //while( pDigitReader->NextBunch()) {
+      while( pDigitReader->NextBunch()) {
     
-      const UInt_t *bunchData = pDigitReader->GetSignals();
-      Float_t maxSignal     = 0.;
-      Float_t totalSignal   = 0.;
-      Float_t squaredSignal = 0.;
-      Float_t rms = 0.; 
+       const UInt_t *bunchData = pDigitReader->GetSignals();
       
-      //fHistSignal = new TH1F("fHistSignal", "signal distribution per pad",1024,0,1024);
+       //fHistSignal = new TH1F("fHistSignal", "signal distribution per pad",1024,0,1024);
       
-      //fHistSignal->Reset();
-      //Int_t time = pDigitReader->GetTime();
+       //fHistSignal->Reset();
+       //Int_t time = pDigitReader->GetTime();
      
-      for(Int_t i=0;i<pDigitReader->GetBunchSize();i++){
+       for(Int_t i=0;i<pDigitReader->GetBunchSize();i++){
           
          if((Float_t)(bunchData[i])>maxSignal){ maxSignal = (Float_t)(bunchData[i]); }
          totalSignal += (Float_t)bunchData[i];
          squaredSignal += (Float_t)bunchData[i]*(Float_t)bunchData[i];
          //fHistSignal->Fill(time+i, bunchData[i]);
-      } // end for loop over bunches
-      rms = TMath::Sqrt(squaredSignal/pDigitReader->GetBunchSize());
+       } // end for loop over bunches
+       rms = TMath::Sqrt(squaredSignal/pDigitReader->GetBunchSize());
             
-      //} // end of inner while loop
+      } // end of inner while loop
            
-      fHistMaxSignal->Fill(xyz[0],xyz[1],maxSignal);
-      fHistTotSignal->Fill(xyz[0],xyz[1],totalSignal);
-            
-      fHistPadRMS->Fill(xyz[0],xyz[1],rms);
+    } // end of while loop over pads
      
-      //fHistPadRMS->Fill(xyz[0],xyz[1],fHistSignal->GetRMS());
-      //delete fHistSignal; fHistSignal = NULL;
-            
-      if(fPlotSideA || fPlotSideC){
-         if(slice<18) fHistSideA->Fill(xyz[0],xyz[1],maxSignal);
-         else        fHistSideC->Fill(xyz[0],xyz[1],maxSignal);                             
-      } // end if plotting sides    
-     } // end of while loop over pads
-   
-     pDigitReader->Reset();
-     delete pDigitReader;
+    fHistMaxSignal->Fill(xyz[0],xyz[1],maxSignal);
+    fHistTotSignal->Fill(xyz[0],xyz[1],totalSignal);
+     
+    fHistPadRMS->Fill(xyz[0],xyz[1],rms);
+      
+    //fHistPadRMS->Fill(xyz[0],xyz[1],fHistSignal->GetRMS());
+    //delete fHistSignal; fHistSignal = NULL;
+      
+    if(fPlotSideA || fPlotSideC){
+      if(slice<18) fHistSideA->Fill(xyz[0],xyz[1],maxSignal);
+      else           fHistSideC->Fill(xyz[0],xyz[1],maxSignal);                             
+    } // end if plotting sides    
+      
+    
+    maxSignal     = 0.;
+    totalSignal   = 0.;
+    squaredSignal = 0.;
+    rms = 0.; 
+
+    pDigitReader->Reset();
+    delete pDigitReader;
   } // end of for loop over data blocks
  
   if(fResetHistograms) ResetHistograms();
index dc3966c..36b8f30 100644 (file)
@@ -28,7 +28,7 @@ struct AliHLTTPCSpacePointData{
   Float_t fSigmaY2; // error (former width) of the clusters
   Float_t fSigmaZ2; // error (former width) of the clusters
   UInt_t fCharge;   // total charge of cluster
-  UInt_t fMaxQ;     // QMax of cluster
+  UInt_t fQMax;     // QMax of cluster
   Bool_t fUsed;     // only used in AliHLTTPCDisplay 
   Int_t fTrackN;    // only used in AliHLTTPCDisplay 
 };
index 23dfd96..1078734 100644 (file)
@@ -236,13 +236,13 @@ int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtD
       Int_t patchCl = (idCluster>>22) & 0x7;
       UInt_t pos = idCluster&0x3fffff;
       if(fPlotChargeClusters || fPlotAll){fHistoChargeAllClusters->Fill(clusters[i].fCharge);}
-      if(fPlotQMaxClusters || fPlotAll){fHistoQMaxAllClusters->Fill(clusters[i].fMaxQ);}
+      if(fPlotQMaxClusters || fPlotAll){fHistoQMaxAllClusters->Fill(clusters[i].fQMax);}
       for(UInt_t id=0;id<fTrackClusterID[sliceCl][patchCl].size();id++){
        if(fTrackClusterID[sliceCl][patchCl][id]==pos){
          clusters[i].fUsed=kTRUE;
          nClustersUsed++;
          if(fPlotChargeUsedClusters || fPlotAll){fHistoChargeUsedClusters->Fill(clusters[i].fCharge);}
-         if(fPlotQMaxUsedClusters || fPlotAll){fHistoQMaxUsedClusters->Fill(clusters[i].fMaxQ);}
+         if(fPlotQMaxUsedClusters || fPlotAll){fHistoQMaxUsedClusters->Fill(clusters[i].fQMax);}
        }
       } 
       fClusters.push_back(clusters[i]);
index a77e388..e82f1d0 100644 (file)
@@ -64,7 +64,7 @@ AliTPCclusterMI* AliHLTTPCOfflineCluster::ConvertHLTToOffline(AliHLTTPCSpacePoin
    offCluster->SetRow((Int_t)spacePoint.fPadRow); // row 
    offCluster->SetTimeBin(spacePoint.fZ);         // time bin
    offCluster->SetQ(spacePoint.fCharge);         // charge
-   offCluster->SetMax(spacePoint.fMaxQ);         // max Q (amplitude)
+   offCluster->SetMax(spacePoint.fQMax);         // max Q (amplitude)
    //offCluster->SetDetector(0);                 // detector/slice
    //offCluster->SetType(0);                     // default from constructor
    //offCluster->IsUsed(0);                      // default from constructor
@@ -83,7 +83,7 @@ AliHLTTPCSpacePointData AliHLTTPCOfflineCluster::ConvertOfflineToHLT(AliTPCclust
    spacePoint.fPadRow = offCluster->GetRow();
    spacePoint.fZ      = offCluster->GetTimeBin();
    spacePoint.fCharge = (UInt_t)offCluster->GetQ();
-   spacePoint.fMaxQ   = (UInt_t)offCluster->GetMax();
+   spacePoint.fQMax   = (UInt_t)offCluster->GetMax();
 
    return spacePoint;
    
index ed6be7f..b5a4b30 100644 (file)
@@ -93,7 +93,8 @@ CLASS_HDRS:=          AliHLTTPCTransform.h \
                AliHLTTPCTrackHistoComponent.h \
                AliHLTTPCTrackDumpComponent.h \
                AliHLTTPCClusterDumpComponent.h \
-               AliHLTTPCCalibTracksComponent.h
+               AliHLTTPCCalibTracksComponent.h \
+               AliHLTTPCHWCFDataReverterComponent.h