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 AliHLTTPCHWCFProcessorUnit.cxx
20 // @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
21 // @author Torsten Alt <talt@cern.ch>
23 // @brief Channel Processor unit of FPGA ClusterFinder Emulator for TPC
24 // @brief ( see AliHLTTPCHWCFEmulator class )
27 #include "AliHLTTPCHWCFProcessorUnit.h"
31 AliHLTTPCHWCFProcessorUnit::AliHLTTPCHWCFProcessorUnit()
45 AliHLTTPCHWCFProcessorUnit::~AliHLTTPCHWCFProcessorUnit()
50 AliHLTTPCHWCFProcessorUnit::AliHLTTPCHWCFProcessorUnit(const AliHLTTPCHWCFProcessorUnit&)
63 AliHLTTPCHWCFProcessorUnit& AliHLTTPCHWCFProcessorUnit::operator=(const AliHLTTPCHWCFProcessorUnit&)
69 int AliHLTTPCHWCFProcessorUnit::Init()
77 int AliHLTTPCHWCFProcessorUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
79 // input stream of data
81 if( bunch && fDebug ){
82 printf("\nHWCF Processor: input bunch F %1d R %3d P %3d T %3d NS %2ld:\n",
83 bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fTime, bunch->fData.size());
84 for( unsigned int i=0; i<bunch->fData.size(); i++ ){
85 printf(" %2d ", bunch->fData[i]);
86 if( i*3+2<bunch->fMC.size() ){
88 for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",bunch->fMC[i*3+j].fMCID, bunch->fMC[i*3+j].fWeight );
99 const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
101 // output stream of data
103 if( !fkBunch ) return 0;
105 fOutput.fFlag = fkBunch->fFlag;
106 fOutput.fRow = fkBunch->fRow;
107 fOutput.fPad = fkBunch->fPad;
108 fOutput.fBranch = fkBunch->fBranch;
109 fOutput.fBorder = fkBunch->fBorder;
115 fOutput.fTMean = fkBunch->fTime;
119 if( fkBunch->fFlag==2 && fkBunch->fData.size()==1 ){ // rcu trailer word, forward it
120 fOutput.fRow = fkBunch->fData[0];
123 if( fkBunch->fFlag >1 ){
129 if( fkBunch->fFlag < 1 ) return 0;
132 if( fBunchIndex >= fkBunch->fData.size() || fkBunch->fTime < fBunchIndex ) return 0;
134 AliHLTInt32_t bunchTime0 = fkBunch->fTime - fBunchIndex;
135 AliHLTInt32_t bunchTime = bunchTime0;
137 AliHLTUInt64_t qLast = 0;
139 AliHLTUInt32_t length = 0;
140 for( ; fBunchIndex<fkBunch->fData.size() && bunchTime>=0; fBunchIndex++, bunchTime--, length++ ){
141 AliHLTUInt64_t q = fkBunch->fData[fBunchIndex]*fkBunch->fGain;
142 if( fDeconvolute && slope && q>qLast ){
143 //cout<<"deconvolution time!!!"<<endl;
144 if( length==1 && fOutput.fQ<fSingleSeqLimit ){
150 bunchTime0 = fkBunch->fTime - fBunchIndex;
158 if( q<qLast ) slope = 1;
161 fOutput.fT += q*bunchTime;
162 fOutput.fT2+= q*bunchTime*bunchTime;
163 fOutput.fP += q*fkBunch->fPad;
164 fOutput.fP2+= q*fkBunch->fPad*fkBunch->fPad;
165 fOutput.fMC.insert(fOutput.fMC.end(),fkBunch->fMC.begin(), fkBunch->fMC.end() );
168 fOutput.fTMean = (AliHLTUInt64_t)( (bunchTime0 + bunchTime + 1)/2 );
170 if( length==1 && fOutput.fQ < fSingleSeqLimit ) return 0;