1 //****************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: Sergey Gorbunov, Torsten Alt *
6 //* Developers: Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de> *
7 //* Torsten Alt <talt@cern.ch> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //****************************************************************************
19 // @file AliHLTTPCHWCFDivisionUnit.cxx
20 // @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
21 // @author Torsten Alt <talt@cern.ch>
23 // @brief Division unit of FPGA ClusterFinder Emulator for TPC
24 // @brief ( see AliHLTTPCHWCFEmulator class )
27 #include "AliHLTTPCHWCFDivisionUnit.h"
32 AliHLTTPCHWCFDivisionUnit::AliHLTTPCHWCFDivisionUnit()
34 fSinglePadSuppression(1), fClusterLowerLimit(0), fkInput(0),fOutput()
40 AliHLTTPCHWCFDivisionUnit::~AliHLTTPCHWCFDivisionUnit()
45 AliHLTTPCHWCFDivisionUnit::AliHLTTPCHWCFDivisionUnit(const AliHLTTPCHWCFDivisionUnit&)
47 fSinglePadSuppression(1),fClusterLowerLimit(0),fkInput(0),fOutput()
52 AliHLTTPCHWCFDivisionUnit& AliHLTTPCHWCFDivisionUnit::operator=(const AliHLTTPCHWCFDivisionUnit&)
58 int AliHLTTPCHWCFDivisionUnit::Init()
66 int AliHLTTPCHWCFDivisionUnit::InputStream( const AliHLTTPCHWCFClusterFragment *fragment )
68 // input stream of data
71 //if( fInput->fFlag==1 && fInput->fQ>0 ){
72 //std::cout<<"Division: input F "<<fInput->fFlag<<" R "<<fInput->fRow
73 // <<" C "<<(fInput->fQ>>12)
74 // <<" P "<<fInput->fPad
75 // <<" T "<<fInput->fTMean
76 // <<" CoGPad "<<((float)fInput->fP)/fInput->fQ
77 // <<" CoGTime "<<((float)fInput->fT)/fInput->fQ
79 //} else std::cout<<"Division: input F "<<fInput->fFlag<<" R "<<fInput->fRow<<" P "<<fInput->fPad
80 // <<" Q "<<(fInput->fQ>>12)<<std::endl;
85 const AliHLTTPCHWCFCluster *AliHLTTPCHWCFDivisionUnit::OutputStream()
87 // output stream of data
89 if( !fkInput ) return 0;
91 if( fkInput->fFlag==2 ){ // RCU trailer word
93 fOutput.fRowQ = fkInput->fRow; // rcu word
98 if( fkInput->fFlag!=1 ) return 0;
100 if( fkInput->fQ==0 ) return 0;
101 if( fSinglePadSuppression && fkInput->fQ==fkInput->fLastQ && !fkInput->fBorder ) return 0;
102 if( fkInput->fQ < fClusterLowerLimit ) return 0;
104 AliHLTFloat32_t q = fkInput->fQ;
107 fOutput.fRowQ = (((AliHLTUInt32_t) 0x3)<<30) + ((fkInput->fRow &0x3f)<<24) + ((fkInput->fQ>>(AliHLTTPCHWCFDefinitions::kFixedPoint-6))&0xFFFFFF);
108 *((AliHLTFloat32_t*)&fOutput.fP) = (float)fkInput->fP/q;
109 *((AliHLTFloat32_t*)&fOutput.fT) = (float)fkInput->fT/q;
110 *((AliHLTFloat32_t*)&fOutput.fP2) = (float)fkInput->fP2/q;
111 *((AliHLTFloat32_t*)&fOutput.fT2) = (float)fkInput->fT2/q;
115 AliHLTTPCClusterMCWeight emptyWeight = {-1,0};
117 fOutput.fMC.fClusterID[0] = emptyWeight;
118 fOutput.fMC.fClusterID[1] = emptyWeight;
119 fOutput.fMC.fClusterID[2] = emptyWeight;
121 vector<AliHLTTPCClusterMCWeight> labels = fkInput->fMC;
122 sort(labels.begin(), labels.end(), CompareMCLabels);
123 for( unsigned int i=1; i<labels.size(); i++ ){
124 if(labels[i-1].fMCID==labels[i].fMCID ){
125 labels[i-1].fWeight+=labels[i].fWeight;
126 labels[i].fWeight = 0;
130 sort(labels.begin(), labels.end(), CompareMCWeights );
132 for( unsigned int i=0; i<3 && i<labels.size(); i++ ){
133 if( labels[i].fMCID <0 ) continue;
134 fOutput.fMC.fClusterID[i] = labels[i];