1 // $Id: AliHLTTPCHWCFPeakFinderUnit.cxx 51236 2011-08-22 16:01:48Z sgorbuno $
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 AliHLTTPCHWCFPeakFinderUnit.cxx
21 // @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de>
22 // @author Torsten Alt <talt@cern.ch>
24 // @brief Channel Processor unit of FPGA ClusterFinder Emulator for TPC
25 // @brief ( see AliHLTTPCHWCFEmulator class )
28 #include "AliHLTTPCHWCFPeakFinderUnit.h"
33 AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit()
37 fChargeFluctuation(0),
45 AliHLTTPCHWCFPeakFinderUnit::~AliHLTTPCHWCFPeakFinderUnit()
50 AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit(const AliHLTTPCHWCFPeakFinderUnit&)
54 fChargeFluctuation(0),
61 AliHLTTPCHWCFPeakFinderUnit& AliHLTTPCHWCFPeakFinderUnit::operator=(const AliHLTTPCHWCFPeakFinderUnit&)
67 int AliHLTTPCHWCFPeakFinderUnit::Init()
75 int AliHLTTPCHWCFPeakFinderUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
77 // input stream of data
79 if( bunch && fDebug ){
80 printf("\nHWCF Processor: input bunch F %1d R %3d P %3d NS %2ld:\n",
81 bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fData.size());
82 for( unsigned int i=0; i<bunch->fData.size(); i++ ){
83 const AliHLTTPCHWCFDigit &d = bunch->fData[i];
84 printf(" q %2d t %3d ", d.fQ, d.fTime);
86 for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",d.fMC.fClusterID[j].fMCID, d.fMC.fClusterID[j].fWeight );
95 const AliHLTTPCHWCFBunch *AliHLTTPCHWCFPeakFinderUnit::OutputStream()
97 // output stream of data
99 if( !fkBunch ) return 0;
101 fOutput.fFlag = fkBunch->fFlag;
102 fOutput.fRow = fkBunch->fRow;
103 fOutput.fPad = fkBunch->fPad;
104 fOutput.fBranch = fkBunch->fBranch;
105 fOutput.fBorder = fkBunch->fBorder;
106 fOutput.fGain = fkBunch->fGain;
107 fOutput.fData.clear();
108 fOutput.fData.insert(fOutput.fData.end(),fkBunch->fData.begin(), fkBunch->fData.end());
111 if( fOutput.fFlag !=1 ){ // rcu trailer word, forward it
116 AliHLTUInt32_t qLast = 0;
117 AliHLTUInt32_t n = fOutput.fData.size();
119 for( AliHLTUInt32_t i=0; i<n; i++ ){
120 AliHLTUInt32_t q = fOutput.fData[i].fQ;
121 if( !slope && q + fChargeFluctuation < qLast ){ // peak
123 if( i>0 ) fOutput.fData[i-1].fPeak = 1;
125 if( slope && q > qLast + fChargeFluctuation ){ // minimum
127 if( i>0 ) fOutput.fData[i-1].fPeak = 2;
133 if( !slope ) fOutput.fData[n-1].fPeak = 1;
134 else fOutput.fData[n-1].fPeak = 2;