2 //****************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Sergey Gorbunov, Torsten Alt *
7 //* Developers: Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de> *
8 //* Torsten Alt <talt@cern.ch> *
9 //* for The ALICE HLT Project. *
11 //* Permission to use, copy, modify and distribute this software and its *
12 //* documentation strictly for non-commercial purposes is hereby granted *
13 //* without fee, provided that the above copyright notice appears in all *
14 //* copies and that both the copyright notice and this permission notice *
15 //* appear in the supporting documentation. The authors make no claims *
16 //* about the suitability of this software for any purpose. It is *
17 //* provided "as is" without express or implied warranty. *
18 //****************************************************************************
20 // @file AliHLTTPCHWCFDivisionUnit.cxx
21 // @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
22 // @author Torsten Alt <talt@cern.ch>
24 // @brief Division unit of FPGA ClusterFinder Emulator for TPC
25 // @brief ( see AliHLTTPCHWCFEmulator class )
28 #include "AliHLTTPCHWCFDivisionUnit.h"
33 AliHLTTPCHWCFDivisionUnit::AliHLTTPCHWCFDivisionUnit()
35 fSinglePadSuppression(1), fClusterLowerLimit(0), fkInput(0),fOutput(), fDebug(0)
41 AliHLTTPCHWCFDivisionUnit::~AliHLTTPCHWCFDivisionUnit()
46 AliHLTTPCHWCFDivisionUnit::AliHLTTPCHWCFDivisionUnit(const AliHLTTPCHWCFDivisionUnit&)
48 fSinglePadSuppression(1),fClusterLowerLimit(0),fkInput(0),fOutput(), fDebug(0)
53 AliHLTTPCHWCFDivisionUnit& AliHLTTPCHWCFDivisionUnit::operator=(const AliHLTTPCHWCFDivisionUnit&)
59 int AliHLTTPCHWCFDivisionUnit::Init()
67 int AliHLTTPCHWCFDivisionUnit::InputStream( const AliHLTTPCHWCFClusterFragment *fragment )
69 // input stream of data
71 if( fkInput && fDebug ){
72 std::cout<<"HWCF Division: input Br: "<<fragment->fBranch<<" F: "<<fragment->fFlag<<" R: "<<fragment->fRow
73 <<" Q: "<<(fragment->fQ>>AliHLTTPCHWCFDefinitions::kFixedPoint)
74 <<" P: "<<fragment->fPad<<" Tmean: "<<fragment->fTMean;
75 if( fragment->fFlag==1 && fragment->fQ > 0 ){
76 std::cout<<" Pw: "<<((float)fragment->fP)/fragment->fQ
77 <<" Tw: "<<((float)fragment->fT)/fragment->fQ;
79 for( unsigned int j=0; j<fragment->fMC.size(); j++ ){
80 for( int k=0; k<3; k++ ){
81 std::cout<<"("<<fragment->fMC[j].fClusterID[k].fMCID<<" "<<fragment->fMC[j].fClusterID[k].fWeight<<") ";
86 else std::cout<<std::endl;
92 const AliHLTTPCHWCFCluster *AliHLTTPCHWCFDivisionUnit::OutputStream()
94 // output stream of data
96 if( !fkInput ) return 0;
98 if( fkInput->fFlag==2 ){ // RCU trailer word
100 fOutput.fRowQ = fkInput->fRow; // rcu word
105 if( fkInput->fFlag!=1 ) return 0;
107 if( fkInput->fQ==0 ) return 0;
108 if( fSinglePadSuppression && fkInput->fQ==fkInput->fLastQ && !fkInput->fBorder ) return 0;
109 if( fkInput->fQ < fClusterLowerLimit ) return 0;
111 AliHLTFloat32_t q = fkInput->fQ;
114 fOutput.fRowQ = (((AliHLTUInt32_t) 0x3)<<30) + ((fkInput->fRow &0x3f)<<24) + ((fkInput->fQmax)&0xFFFFFF);
115 fOutput.fQ = fkInput->fQ;
116 *((AliHLTFloat32_t*)&fOutput.fP) = (float)fkInput->fP/q;
117 *((AliHLTFloat32_t*)&fOutput.fT) = (float)fkInput->fT/q;
118 *((AliHLTFloat32_t*)&fOutput.fP2) = (float)fkInput->fP2/q;
119 *((AliHLTFloat32_t*)&fOutput.fT2) = (float)fkInput->fT2/q;
123 AliHLTTPCClusterMCWeight emptyWeight;
125 fOutput.fMC.fClusterID[0] = emptyWeight;
126 fOutput.fMC.fClusterID[1] = emptyWeight;
127 fOutput.fMC.fClusterID[2] = emptyWeight;
129 vector<AliHLTTPCClusterMCWeight> labels;
130 for( unsigned i=0; i<fkInput->fMC.size(); i++){
131 labels.push_back(fkInput->fMC[i].fClusterID[0]);
132 labels.push_back(fkInput->fMC[i].fClusterID[1]);
133 labels.push_back(fkInput->fMC[i].fClusterID[2]);
135 sort(labels.begin(), labels.end(), CompareMCLabels);
136 for( unsigned int i=1; i<labels.size(); i++ ){
137 if(labels[i-1].fMCID==labels[i].fMCID ){
138 labels[i].fWeight+=labels[i-1].fWeight;
139 labels[i-1].fWeight = 0;
143 sort(labels.begin(), labels.end(), CompareMCWeights );
145 for( unsigned int i=0; i<3 && i<labels.size(); i++ ){
146 if( labels[i].fMCID <0 ) continue;
147 fOutput.fMC.fClusterID[i] = labels[i];