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 AliHLTTPCHWCFMergerUnit.cxx
21 // @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
22 // @author Torsten Alt <talt@cern.ch>
24 // @brief Channel Merger unit of FPGA ClusterFinder Emulator for TPC
25 // @brief ( see AliHLTTPCHWCFEmulator class )
28 #include "AliHLTTPCHWCFMergerUnit.h"
31 AliHLTTPCHWCFMergerUnit::AliHLTTPCHWCFMergerUnit()
45 AliHLTTPCHWCFMergerUnit::~AliHLTTPCHWCFMergerUnit()
50 AliHLTTPCHWCFMergerUnit::AliHLTTPCHWCFMergerUnit(const AliHLTTPCHWCFMergerUnit&)
63 AliHLTTPCHWCFMergerUnit& AliHLTTPCHWCFMergerUnit::operator=(const AliHLTTPCHWCFMergerUnit&)
69 int AliHLTTPCHWCFMergerUnit::Init()
74 for( int i=0; i<2; i++ ){
75 fSearchRange[i] = fMemory[i];
76 fInsertRange[i] = (fMemory[i]+AliHLTTPCHWCFDefinitions::kMaxNTimeBins);
86 int AliHLTTPCHWCFMergerUnit::InputStream( const AliHLTTPCHWCFClusterFragment *fragment )
88 // input stream of data
95 fInput.fLastQ = fInput.fQ;
97 std::cout<<"Merger: input Br: "<<fragment->fBranch<<" F: "<<fragment->fFlag<<" R: "<<fragment->fRow
98 <<" Q: "<<(fragment->fQ>>AliHLTTPCHWCFDefinitions::kFixedPoint)
99 <<" P: "<<fragment->fPad<<" Tmean: "<<fragment->fTMean;
100 if( fragment->fFlag==1 && fragment->fQ > 0 ){
101 std::cout<<" Pw: "<<((float)fragment->fP)/fragment->fQ
102 <<" Tw: "<<((float)fragment->fT)/fragment->fQ;
104 for( unsigned int j=0; j<fragment->fMC.size(); j++ ){
105 for( int k=0; k<3; k++ ){
106 std::cout<<"("<<fragment->fMC[j].fClusterID[k].fMCID<<" "<<fragment->fMC[j].fClusterID[k].fWeight<<") ";
109 std::cout<<std::endl;
111 else std::cout<<std::endl;
117 const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFMergerUnit::OutputStream()
119 // output stream of data
121 if( fInput.fFlag==0 ) return 0;
124 fInsertRange[0][0] = fInput;
126 return &fInsertRange[0][0];
129 if( fInput.fFlag!=1 ){
131 for( int ib=0; ib<2; ib++){
133 // move insert range to search range
135 if( fSearchStart[ib]>=fSearchEnd[ib] && fInsertEnd[ib]>0 ){
136 AliHLTTPCHWCFClusterFragment *tmp = fSearchRange[ib];
137 fSearchRange[ib] = fInsertRange[ib];
138 fSearchStart[ib] = 0;
139 fSearchEnd[ib] = fInsertEnd[ib];
140 fInsertRange[ib] = tmp;
145 // flush the search range
147 if( fSearchStart[ib]<fSearchEnd[ib] ){
149 return &(fSearchRange[ib][fSearchStart[ib]-1]);
156 fInsertRange[0][0] = fInput; // forward the input
158 return &fInsertRange[0][0];
161 if( fInput.fFlag!=1 ) return 0; // should not happen
163 int ib = fInput.fBranch;
165 // move insert range to search range
167 if( (int)fInput.fRow!=fInsertRow[ib] || (int)fInput.fPad!=fInsertPad[ib] ){
169 if( fSearchStart[ib]>=fSearchEnd[ib] && fInsertEnd[ib]>0 ){
170 // cout<<"move insert range pad "<<fInsertPad[ib]<<endl;
171 AliHLTTPCHWCFClusterFragment *tmp = fSearchRange[ib];
172 fSearchRange[ib] = fInsertRange[ib];
173 fSearchStart[ib] = 0;
174 fSearchEnd[ib] = fInsertEnd[ib];
175 fInsertRange[ib] = tmp;
181 // flush the search range
183 if( (int)fInput.fRow!=fInsertRow[ib] || (int)fInput.fPad!=fInsertPad[ib] ){
184 if( fSearchStart[ib]<fSearchEnd[ib] ){
185 //cout<<"push from search range at "<<fSearchStart[ib]<<" of "<<fSearchEnd[ib]<<endl;
187 return &(fSearchRange[ib][fSearchStart[ib]-1]);
191 fInsertRow[ib] = fInput.fRow;
192 fInsertPad[ib] = fInput.fPad;
194 // flush the search range
196 if( fSearchStart[ib]<fSearchEnd[ib] && fSearchRange[ib][fSearchStart[ib]].fTMean>=fInput.fTMean+fMatchDistance
198 //cout<<"push from search range at "<<fSearchStart[ib]<<" of "<<fSearchEnd[ib]<<endl;
200 return &(fSearchRange[ib][fSearchStart[ib]-1]);
205 AliHLTTPCHWCFClusterFragment *ret = 0;
207 if( fSearchStart[ib]<fSearchEnd[ib] && fSearchRange[ib][fSearchStart[ib]].fTMean+fMatchDistance>fInput.fTMean ){
208 AliHLTTPCHWCFClusterFragment &s = fSearchRange[ib][fSearchStart[ib]++];
209 if( fDeconvolute && s.fSlope && s.fLastQ<fInput.fLastQ ){
210 //cout<<"push from search range at "<<fSearchStart[ib]-1<<" of "<<fSearchEnd[ib]<<endl;
213 // cout<<"merge search range at "<<fSearchStart-1<<" of "<<fSearchEnd<<endl;
214 fInput.fSlope = s.fSlope;
215 if( !fInput.fSlope && s.fLastQ > fInput.fQ ) fInput.fSlope = 1;
216 if (fInput.fQmax < s.fQmax) fInput.fQmax = s.fQmax;
222 fInput.fMC.insert(fInput.fMC.end(), s.fMC.begin(), s.fMC.end());
223 if( !fMatchTimeFollow ) fInput.fTMean = s.fTMean;
230 fInsertRange[ib][fInsertEnd[ib]++] = fInput;