--- /dev/null
+// $Id$
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Primary Authors: Anders Vestbo, Constantin Loizides, Jochen Thaeder *
+ * 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 AliHLTTPCKryptonClusterFinder.cxx
+ @author Kenneth Aamodt kenneth.aamodt@student.uib.no
+ @date
+ @brief Krypton Cluster Finder for the TPC
+*/
+
+#include "AliHLTTPCDigitReader.h"
+#include "AliHLTTPCRootTypes.h"
+#include "AliHLTTPCLogging.h"
+#include "AliHLTTPCKryptonClusterFinder.h"
+#include "AliHLTTPCDigitData.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCSpacePointData.h"
+#include "AliHLTTPCMemHandler.h"
+#include "AliHLTTPCPad.h"
+#include <sys/time.h>
+
+#if __GNUC__ >= 3
+using namespace std;
+#endif
+
+ClassImp(AliHLTTPCKryptonClusterFinder)
+
+AliHLTTPCKryptonClusterFinder::AliHLTTPCKryptonClusterFinder()
+ :
+ fSpacePointData(NULL),
+ fDigitReader(NULL),
+ fPtr(NULL),
+ fSize(0),
+ fFirstRow(0),
+ fLastRow(0),
+ fCurrentRow(0),
+ fCurrentSlice(0),
+ fCurrentPatch(0),
+ fMatch(1),
+ fThreshold(10),
+ fNClusters(0),
+ fMaxNClusters(0),
+ fXYErr(0.2),
+ fZErr(0.3),
+ fVectorInitialized(kFALSE),
+ fRowPadVector(),
+ fClusters(),
+ fTimebinsInBunch(),
+ fIndexOfBunchStart(),
+ fNumberOfPadsInRow(NULL),
+ fNumberOfRows(0),
+ fRowOfFirstCandidate(0)
+{
+ //constructor
+}
+
+AliHLTTPCKryptonClusterFinder::~AliHLTTPCKryptonClusterFinder()
+{
+ //destructor
+ if(fVectorInitialized){
+ DeInitializePadArray();
+ }
+ if(fNumberOfPadsInRow){
+ delete [] fNumberOfPadsInRow;
+ fNumberOfPadsInRow=NULL;
+ }
+}
+
+void AliHLTTPCKryptonClusterFinder::InitializePadArray(){
+ // see header file for class documentation
+
+ if(fCurrentPatch>5||fCurrentPatch<0){
+ HLTFatal("Patch is not set");
+ return;
+ }
+
+ HLTDebug("Patch number=%d",fCurrentPatch);
+
+ fFirstRow = AliHLTTPCTransform::GetFirstRow(fCurrentPatch);
+ fLastRow = AliHLTTPCTransform::GetLastRow(fCurrentPatch);
+
+ fNumberOfRows=fLastRow-fFirstRow+1;
+ fNumberOfPadsInRow= new UInt_t[fNumberOfRows];
+
+ memset( fNumberOfPadsInRow, 0, sizeof(Int_t)*(fNumberOfRows));
+
+ for(UInt_t i=0;i<fNumberOfRows;i++){
+ fNumberOfPadsInRow[i]=AliHLTTPCTransform::GetNPads(i+fFirstRow);
+ AliHLTTPCPadVector tmpRow;
+ for(UInt_t j=0;j<fNumberOfPadsInRow[i];j++){
+ AliHLTTPCPad *tmpPad = new AliHLTTPCPad(2);
+ tmpPad->SetID(i,j);
+ tmpRow.push_back(tmpPad);
+ }
+ fRowPadVector.push_back(tmpRow);
+ }
+ fVectorInitialized=kTRUE;
+}
+
+Int_t AliHLTTPCKryptonClusterFinder::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];
+ fRowPadVector[i][j]=NULL;
+ }
+ fRowPadVector[i].clear();
+ }
+ fRowPadVector.clear();
+ return 1;
+}
+
+void AliHLTTPCKryptonClusterFinder::InitSlice(Int_t slice,Int_t patch,Int_t firstrow, Int_t lastrow,Int_t nmaxpoints)
+{
+ //init slice
+ fNClusters = 0;
+ fMaxNClusters = nmaxpoints;
+ fCurrentSlice = slice;
+ fCurrentPatch = patch;
+ fFirstRow = firstrow;
+ fLastRow = lastrow;
+}
+
+void AliHLTTPCKryptonClusterFinder::ReBunch(const UInt_t *bunchData , Int_t bunchSize){
+ fTimebinsInBunch.clear();
+ fIndexOfBunchStart.clear();
+ Bool_t newBunch=kTRUE;
+ Int_t currentBunchNumber=-1;
+ for(Int_t i=0;i<bunchSize;i++){
+ if(newBunch){
+ if(bunchData[i]>5){
+ fIndexOfBunchStart.push_back(i);
+ fTimebinsInBunch.push_back(1);
+ currentBunchNumber++;
+ newBunch=kFALSE;
+ }
+ }
+ else{
+ if(bunchData[i]>0){
+ fTimebinsInBunch[currentBunchNumber]++;
+ }
+ else{
+ newBunch=kTRUE;
+ }
+ }
+ }
+}
+
+void AliHLTTPCKryptonClusterFinder::ReadDataUnsorted(void* ptr,unsigned long size)
+{
+ //set input pointer
+ fPtr = (UChar_t*)ptr;
+ fSize = size;
+
+ if(!fVectorInitialized){
+ InitializePadArray();
+ }
+
+ fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice);
+
+ while(fDigitReader->NextChannel()){
+ UInt_t row=fDigitReader->GetRow();
+ UInt_t pad=fDigitReader->GetPad();
+
+ fRowPadVector[row][pad]->ClearCandidates();
+
+ while(fDigitReader->NextBunch()){
+ if(fDigitReader->GetBunchSize()>1){
+ const UInt_t *bunchData= fDigitReader->GetSignals();
+
+ ReBunch(bunchData,fDigitReader->GetBunchSize());
+ Int_t rebunchCount=fIndexOfBunchStart.size();
+
+ for(Int_t r=0;r<rebunchCount;r++){
+ UInt_t time = fDigitReader->GetTime()+fIndexOfBunchStart[r];
+ AliHLTTPCClusters candidate;
+ candidate.fTotalCharge=0;
+ if(fTimebinsInBunch[r]>2){
+ for(Int_t i=0;i<fTimebinsInBunch[r];i++){
+ candidate.fTotalCharge+=bunchData[i + fIndexOfBunchStart[r]];
+ candidate.fTime += time*bunchData[i + fIndexOfBunchStart[r]];
+ candidate.fTime2 += time*time*bunchData[i + fIndexOfBunchStart[r]];
+ 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(candidate.fTotalCharge>10 && candidate.fMean<924){
+ fRowPadVector[row][pad]->AddClusterCandidate(candidate);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+Bool_t AliHLTTPCKryptonClusterFinder::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){
+ 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;
+
+ //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;
+}
+
+void AliHLTTPCKryptonClusterFinder::FindNormalClusters()
+{
+ // see header file for function documentation
+
+ AliHLTTPCClusters* tmpCandidate=NULL;
+ for(UInt_t row=5;row<fNumberOfRows-5;row++){
+ fRowOfFirstCandidate=row;
+ for(UInt_t pad=5;pad<fNumberOfPadsInRow[row]-1-5;pad++){
+ AliHLTTPCPad *tmpPad=fRowPadVector[row][pad];
+ for(size_t candidate=0;candidate<tmpPad->fClusterCandidates.size();candidate++){
+ if(tmpPad->fUsedClusterCandidates[candidate]){
+ continue;
+ }
+ if((Int_t)tmpPad->fClusterCandidates[candidate].fMean<100 || (Int_t)tmpPad->fClusterCandidates[candidate].fMean>AliHLTTPCTransform::GetNTimeBins()-100){
+ 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
+ tmpCandidate->fPad=tmpCandidate->fPad/tmpCandidate->fTotalCharge;
+ fClusters.push_back(*tmpCandidate);
+ }
+ }
+ }
+ }
+
+ HLTDebug("Found %d normal clusters.",fClusters.size());
+}
+
+void AliHLTTPCKryptonClusterFinder::FindKryptonClusters()
+{
+ if(fClusters.size()<2){
+ return;
+ }
+
+ for(UInt_t i=0; i<fClusters.size();i++){
+ AliHLTTPCClusters * tmpCluster=&fClusters[i];
+ if(tmpCluster->fFlags==99){//quickfix to check if a cluster is used already
+ continue;
+ }
+
+ //adds "normal" clusters belonging to the krypton cluster
+ for(UInt_t j=i+1;j<fClusters.size();j++){
+ AliHLTTPCClusters * nextCluster=&fClusters[j];
+
+ if(nextCluster->fFlags==99){//quickfix to check if a cluster is used already
+ continue;
+ }
+
+ if(tmpCluster->fRowNumber==nextCluster->fRowNumber-1){//Checks if the row numbers are ok (next to eachother)
+ // if(abs((Int_t)(tmpCluster->fPad/tmpCluster->fTotalCharge) - (Int_t)(nextCluster->fPad/nextCluster->fTotalCharge))<3){ // checks if the pad numbers are ok
+ if(abs((Int_t)(tmpCluster->fPad) - (Int_t)(nextCluster->fPad))<3){ // checks if the pad numbers are ok
+ if(abs((Int_t)tmpCluster->fMean-(Int_t)nextCluster->fMean)<2){
+ tmpCluster->fMean=nextCluster->fMean;
+ tmpCluster->fTotalCharge+=nextCluster->fTotalCharge;
+ tmpCluster->fPad=nextCluster->fPad;
+ if(tmpCluster->fFlags!=99){//means that this is the first time normal clusters match
+ CheckForCandidateOnPreviousPad(tmpCluster);
+ }
+ tmpCluster->fRowNumber=nextCluster->fRowNumber;
+ nextCluster->fFlags=99;
+ tmpCluster->fFlags=99;
+ if(j!=fClusters.size()-1){
+ continue;
+ }
+
+ }
+ }
+ }
+
+ if(tmpCluster->fFlags==99){
+ //adds a clustercandidate on next row if present TODO
+ /* if(tmpCluster->fFlags==99){
+ for(Int_t p=-1;p<2;p++){
+ AliHLTTPCPad *padAfter=fRowPadVector[tmpCluster->fRowNumber+1][tmpCluster->fPad+p];
+ for(UInt_t c=0;c<padAfter->fClusterCandidates.size();c++)
+ if(abs((Int_t)tmpCluster->fMean - (Int_t)padAfter->fClusterCandidates[c].fMean)<2){
+ tmpCluster->fTotalCharge+=padAfter->fClusterCandidates[c].fTotalCharge;
+ }
+ }//end add clustercandidate if present
+ }*/
+ HLTInfo("Krypton cluster found, charge: %d in patch number: %d",tmpCluster->fTotalCharge,fCurrentPatch);
+ break;
+ }
+
+
+ }
+ }//end add "normal" clusters belonging to the krypton cluster
+
+}
+
+void AliHLTTPCKryptonClusterFinder::CheckForCandidateOnPreviousPad(AliHLTTPCClusters *tmpCluster){
+ if(tmpCluster->fRowNumber>1){
+ for(Int_t p=-1;p<2;p++){
+ if(tmpCluster->fPad+p>0 && tmpCluster->fPad+p<fNumberOfPadsInRow[tmpCluster->fRowNumber-1]){
+ AliHLTTPCPad *prevPad=fRowPadVector[tmpCluster->fRowNumber-1-AliHLTTPCTransform::GetFirstRow(fCurrentPatch)][tmpCluster->fPad+p];
+ for(UInt_t i=0;i<prevPad->fClusterCandidates.size();i++){
+ if(abs((Int_t)prevPad->fClusterCandidates[i].fMean - (Int_t)tmpCluster->fMean)<2 && prevPad->fUsedClusterCandidates[i]==0){
+ tmpCluster->fTotalCharge += prevPad->fClusterCandidates[i].fTotalCharge;
+ }
+ }
+ }
+ }
+ }
+}
+
+void AliHLTTPCKryptonClusterFinder::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].fFirstPad);
+ 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);
+ HLTInfo("TimeError: %d",fClusters[i].fTime2);
+ HLTInfo("EndOfCluster:");
+ }
+}
--- /dev/null
+// $Id$
+
+#ifndef AliHLTTPC_KRYPTONCLUSTERFINDER
+#define AliHLTTPC_KRYPTONCLUSTERFINDER
+/* 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 AliHLTTPCKryptonClusterFinder.h
+ @author Anders Vestbo, Constantin Loizides, Jochen Thaeder
+ Kenneth Aamodt kenneth.aamodt@student.uib.no
+ @date
+ @brief Cluster Finder for the TPC
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+
+#include "AliHLTLogging.h"
+#include "AliHLTTPCPad.h"
+class AliHLTTPCSpacePointData;
+class AliHLTTPCDigitReader;
+
+class AliHLTTPCKryptonClusterFinder : public AliHLTLogging {
+
+ public:
+ struct AliClusterData
+ {
+ UInt_t fTotalCharge; //tot charge of cluster
+ UInt_t fPad; //pad value
+ UInt_t fTime; //time value
+ ULong64_t fPad2; //for error in XY direction
+ ULong64_t fTime2; //for error in Z direction
+ UInt_t fMean; //mean in time
+ UInt_t fFlags; //different flags
+ UInt_t fChargeFalling; //for deconvolution
+ UInt_t fLastCharge; //for deconvolution
+ UInt_t fLastMergedPad; //dont merge twice per pad
+ Int_t fRow; //row value
+ };
+ typedef struct AliClusterData AliClusterData; //!
+
+ /** standard constructor */
+ AliHLTTPCKryptonClusterFinder();
+ /** destructor */
+ virtual ~AliHLTTPCKryptonClusterFinder();
+
+ void InitSlice(Int_t slice,Int_t patch,Int_t firstrow, Int_t lastrow,Int_t maxpoints);
+
+ void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
+
+ void PrintClusters();
+
+ Int_t GetNumberOfClusters() const {return fNClusters;}
+
+ void ReBunch(const UInt_t * bunchData,Int_t bunchSize);
+ void ReadDataUnsorted(void* ptr,unsigned long size);
+ void FindNormalClusters();
+ void FindKryptonClusters();
+ void CheckForCandidateOnPreviousPad(AliHLTTPCClusters* tmpCluster);
+ void SetPatch(Int_t patch){fCurrentPatch=patch;}
+ void InitializePadArray();
+ Int_t DeInitializePadArray();
+ Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
+ private:
+ /** copy constructor prohibited */
+ AliHLTTPCKryptonClusterFinder(const AliHLTTPCKryptonClusterFinder&);
+ /** assignment operator prohibited */
+ AliHLTTPCKryptonClusterFinder& operator=(const AliHLTTPCKryptonClusterFinder&);
+
+ AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
+ AliHLTTPCDigitReader *fDigitReader; //! reader instance
+
+ UChar_t* fPtr; //! pointer to packed block
+ unsigned long fSize; //packed block size
+
+ 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 on total charge for krypton cluster
+
+ 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
+
+ Bool_t fVectorInitialized;
+
+ typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
+
+ vector<AliHLTTPCPadVector> fRowPadVector; //! transient
+
+ vector<AliHLTTPCClusters> fClusters; //! transient
+
+ vector<Int_t> fTimebinsInBunch; //! transient
+
+ vector<Int_t> fIndexOfBunchStart; //! transient
+
+ UInt_t* fNumberOfPadsInRow; //! transient
+
+ UInt_t fNumberOfRows; //! transient
+
+ UInt_t fRowOfFirstCandidate;
+
+ ClassDef(AliHLTTPCKryptonClusterFinder,0) //Fast cluster finder
+};
+#endif
--- /dev/null
+// $Id$
+
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project *
+ * ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Primary Authors: Kenneth Aamodt *
+ * Kalliopi Kanaki *
+ * 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 AliHLTTPCKryptonClusterFinderComponent.cxx
+ @author Kenneth Aamodt, Kalliopi Kanaki
+ @date
+ @brief The TPC krypton cluster finder processing component
+*/
+
+// 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 "AliHLTTPCKryptonClusterFinderComponent.h"
+#include "AliHLTTPCDigitReaderDecoder.h"
+#include "AliHLTTPCKryptonClusterFinder.h"
+#include "AliHLTTPCSpacePointData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCClusters.h"
+#include "AliHLTTPCDefinitions.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+
+#include <cstdlib>
+#include <cerrno>
+#include "TString.h"
+#include "TObjString.h"
+#include <sys/time.h>
+
+AliHLTTPCKryptonClusterFinderComponent gAliHLTTPCKryptonClusterFinderComponent;
+
+/** ROOT macro for the implementation of ROOT specific class methods */
+ClassImp(AliHLTTPCKryptonClusterFinderComponent)
+
+AliHLTTPCKryptonClusterFinderComponent::AliHLTTPCKryptonClusterFinderComponent()
+ :
+ fClusterFinder(NULL),
+ fReader(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
+}
+
+AliHLTTPCKryptonClusterFinderComponent::~AliHLTTPCKryptonClusterFinderComponent()
+{
+ // see header file for class documentation
+}
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCKryptonClusterFinderComponent::GetComponentID()
+{
+ // see header file for class documentation
+ return "TPCKryptonClusterFinder";
+}
+
+void AliHLTTPCKryptonClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+{
+ // see header file for class documentation
+ list.clear();
+ list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
+}
+
+AliHLTComponentDataType AliHLTTPCKryptonClusterFinderComponent::GetOutputDataType()
+{
+ // see header file for class documentation
+ return kAliHLTDataTypeHistogram;
+}
+
+int AliHLTTPCKryptonClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+
+{
+ // see header file for class documentation
+ tgtList.clear();
+ tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
+ return tgtList.size();
+}
+
+void AliHLTTPCKryptonClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+{
+ // see header file for class documentation
+ // XXX TODO: Find more realistic values.
+ constBase = 0;
+ inputMultiplier = (6 * 0.4);
+}
+
+AliHLTComponent* AliHLTTPCKryptonClusterFinderComponent::Spawn()
+{
+ // see header file for class documentation
+ return new AliHLTTPCKryptonClusterFinderComponent();
+}
+
+int AliHLTTPCKryptonClusterFinderComponent::DoInit( int argc, const char** argv )
+{
+ // see header file for class documentation
+ if ( fClusterFinder )
+ return EINPROGRESS;
+
+ fClusterFinder = new AliHLTTPCKryptonClusterFinder();
+
+ Int_t i = 0;
+
+ while ( i < argc ) {
+
+ //No arguments so far
+
+ Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+ return EINVAL;
+
+ }
+
+ fReader = new AliHLTTPCDigitReaderDecoder();
+ fClusterFinder->SetReader(fReader);
+
+ return 0;
+}
+
+int AliHLTTPCKryptonClusterFinderComponent::DoDeinit()
+{
+ // see header file for class documentation
+
+ if ( fClusterFinder )
+ delete fClusterFinder;
+ fClusterFinder = NULL;
+
+ if ( fReader )
+ delete fReader;
+ fReader = NULL;
+
+ return 0;
+}
+
+int AliHLTTPCKryptonClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData,
+ const AliHLTComponentBlockData* blocks,
+ AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size,
+ vector<AliHLTComponentBlockData>& outputBlocks )
+{
+ // see header file for class documentation
+
+ // == init iter (pointer to datablock)
+ const AliHLTComponentBlockData* iter = NULL;
+ unsigned long ndx;
+
+ // == OUTdatatype pointer
+ AliHLTTPCClusterData* outPtr;
+
+ AliHLTUInt8_t* outBPtr;
+ UInt_t offset, mysize, nSize, tSize = 0;
+
+ outBPtr = outputPtr;
+ outPtr = (AliHLTTPCClusterData*)outBPtr;
+
+ Int_t slice, patch, row[2];
+ unsigned long maxPoints, realPoints = 0;
+
+ for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+ {
+ iter = blocks+ndx;
+ mysize = 0;
+ offset = tSize;
+
+
+ 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 == 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) &&
+ iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue;
+
+
+ slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+ patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+ row[0] = AliHLTTPCTransform::GetFirstRow( patch );
+ row[1] = AliHLTTPCTransform::GetLastRow( patch );
+
+
+ fClusterFinder->SetPatch(patch);
+
+ outPtr = (AliHLTTPCClusterData*)outBPtr;
+
+ maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
+
+ fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
+
+ fClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize);
+
+ fClusterFinder->FindNormalClusters();
+
+ fClusterFinder->FindKryptonClusters();
+
+ realPoints = fClusterFinder->GetNumberOfClusters();
+
+
+ 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;
+ outBPtr += mysize;
+ outPtr = (AliHLTTPCClusterData*)outBPtr;
+
+
+ if ( tSize > size )
+ {
+ Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
+ "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
+ tSize, size );
+ return EMSGSIZE;
+ }
+
+ size = tSize;
+ }
+ return 0;
+}
+
+int AliHLTTPCKryptonClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+ // see header file for class documentation
+ const char* path="HLT/ConfigTPC";
+ if (cdbEntry) path=cdbEntry;
+ if (path) {
+ HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+ AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+ if (pEntry) {
+ TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+ if (pString) {
+ HLTInfo("received configuration object: %s", pString->GetString().Data());
+ } else {
+ HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+ }
+ } else {
+ HLTError("can not fetch object \"%s\" from CDB", path);
+ }
+ }
+ return 0;
+}
--- /dev/null
+// $Id$
+
+#ifndef ALIHLTTPCKRYPTONCLUSTERFINDERCOMPONENT_H
+#define ALIHLTTPCKRYPTONCLUSTERFINDERCOMPONENT_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 AliHLTTPCKryptonClusterFinderComponent.h
+ @author Timm Steinbeck, Matthias Richter, Jochen Thaeder
+ @date
+ @brief The TPC cluster finder component.
+*/
+
+// see below for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
+#include "AliHLTProcessor.h"
+
+class AliHLTTPCKryptonClusterFinder;
+class AliHLTTPCDigitReader;
+
+/**
+ * @class AliHLTTPCKryptonClusterFinderComponent
+ * Component for the krypton ClusterFinder
+ * @ingroup alihlt_tpc_components
+ */
+class AliHLTTPCKryptonClusterFinderComponent : public AliHLTProcessor
+ {
+ public:
+
+ /**
+ * constructor
+ * @param mode input type see e.g. @ref kClusterFinderUnpacked
+ */
+ AliHLTTPCKryptonClusterFinderComponent();
+ /** destructor */
+ virtual ~AliHLTTPCKryptonClusterFinderComponent();
+
+ // Public functions to implement AliHLTComponent's interface.
+ // These functions are required for the registration process
+
+ /** interface function, see @ref AliHLTComponent for description */
+ const char* GetComponentID();
+ /** interface function, see @ref AliHLTComponent for description */
+ void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+ /** interface function, see @ref AliHLTComponent for description */
+ AliHLTComponentDataType GetOutputDataType();
+ /** interface function, see @ref AliHLTComponent for description */
+ int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
+ /** interface function, see @ref AliHLTComponent for description */
+ virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+ /** interface function, see @ref AliHLTComponent for description */
+ AliHLTComponent* Spawn();
+
+ 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 );
+ int Reconfigure(const char* cdbEntry, const char* chainId);
+
+ using AliHLTProcessor::DoEvent;
+
+ private:
+ /** copy constructor prohibited */
+ AliHLTTPCKryptonClusterFinderComponent(const AliHLTTPCKryptonClusterFinderComponent&);
+ /** assignment operator prohibited */
+ AliHLTTPCKryptonClusterFinderComponent& operator=(const AliHLTTPCKryptonClusterFinderComponent&);
+ /** the cluster finder object */
+ AliHLTTPCKryptonClusterFinder* fClusterFinder; //!transient
+ /** the reader object for data decoding */
+ AliHLTTPCDigitReader* fReader; //!transient
+
+ ClassDef(AliHLTTPCKryptonClusterFinderComponent, 0)
+
+};
+#endif