]>
Commit | Line | Data |
---|---|---|
25080052 | 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. * | |
5 | //* * | |
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. * | |
10 | //* * | |
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 | //**************************************************************************** | |
19 | ||
20 | // @file AliHLTTPCHWCFPeakFinderUnit.cxx | |
21 | // @author Sergey Gorbunov <sergey.gorbunov@fias.uni-frankfurt.de> | |
22 | // @author Torsten Alt <talt@cern.ch> | |
23 | // @date | |
24 | // @brief Channel Processor unit of FPGA ClusterFinder Emulator for TPC | |
25 | // @brief ( see AliHLTTPCHWCFEmulator class ) | |
26 | // @note | |
27 | ||
28 | #include "AliHLTTPCHWCFPeakFinderUnit.h" | |
29 | #include <iostream> | |
30 | #include <cstdio> | |
31 | ||
32 | ||
33 | AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit() | |
34 | : | |
35 | fOutput(), | |
36 | fkBunch(0), | |
37 | fChargeFluctuation(0), | |
38 | fDebug(0) | |
39 | { | |
40 | //constructor | |
41 | Init(); | |
42 | } | |
43 | ||
44 | ||
45 | AliHLTTPCHWCFPeakFinderUnit::~AliHLTTPCHWCFPeakFinderUnit() | |
46 | { | |
47 | //destructor | |
48 | } | |
49 | ||
50 | AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit(const AliHLTTPCHWCFPeakFinderUnit&) | |
51 | : | |
52 | fOutput(), | |
53 | fkBunch(0), | |
54 | fChargeFluctuation(0), | |
55 | fDebug(0) | |
56 | { | |
57 | // dummy | |
58 | Init(); | |
59 | } | |
60 | ||
61 | AliHLTTPCHWCFPeakFinderUnit& AliHLTTPCHWCFPeakFinderUnit::operator=(const AliHLTTPCHWCFPeakFinderUnit&) | |
62 | { | |
63 | // dummy | |
64 | return *this; | |
65 | } | |
66 | ||
67 | int AliHLTTPCHWCFPeakFinderUnit::Init() | |
68 | { | |
69 | // initialise | |
70 | ||
71 | fkBunch = 0; | |
72 | return 0; | |
73 | } | |
74 | ||
75 | int AliHLTTPCHWCFPeakFinderUnit::InputStream( const AliHLTTPCHWCFBunch *bunch ) | |
76 | { | |
77 | // input stream of data | |
4d67c3e3 | 78 | |
25080052 | 79 | if( bunch && fDebug ){ |
4d67c3e3 | 80 | printf("\nHWCF Peak Finder: input bunch F %1d R %3d P %3d NS %2ld:\n", |
25080052 | 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); | |
85 | printf("("); | |
86 | for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",d.fMC.fClusterID[j].fMCID, d.fMC.fClusterID[j].fWeight ); | |
87 | printf(" )\n"); | |
88 | } | |
89 | } | |
90 | ||
91 | fkBunch = bunch; | |
92 | return 0; | |
93 | } | |
94 | ||
95 | const AliHLTTPCHWCFBunch *AliHLTTPCHWCFPeakFinderUnit::OutputStream() | |
96 | { | |
97 | // output stream of data | |
98 | ||
99 | if( !fkBunch ) return 0; | |
100 | ||
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()); | |
109 | fkBunch = 0; | |
110 | ||
111 | if( fOutput.fFlag !=1 ){ // rcu trailer word, forward it | |
112 | return &fOutput; | |
113 | } | |
114 | ||
115 | bool slope = 0; | |
116 | AliHLTUInt32_t qLast = 0; | |
117 | AliHLTUInt32_t n = fOutput.fData.size(); | |
118 | ||
119 | for( AliHLTUInt32_t i=0; i<n; i++ ){ | |
4d67c3e3 | 120 | AliHLTUInt32_t q = fOutput.fData[i].fQ; |
121 | if( !slope ){ | |
122 | if(q + fChargeFluctuation < qLast ){ // peak | |
123 | slope = 1; | |
124 | if( i>0 ) fOutput.fData[i-1].fPeak = 1; | |
125 | } | |
126 | }else if( q > qLast + fChargeFluctuation ){ // minimum | |
25080052 | 127 | slope = 0; |
128 | if( i>0 ) fOutput.fData[i-1].fPeak = 2; | |
129 | } | |
130 | qLast = q; | |
131 | } | |
132 | ||
133 | if( n>0 ){ | |
134 | if( !slope ) fOutput.fData[n-1].fPeak = 1; | |
135 | else fOutput.fData[n-1].fPeak = 2; | |
136 | } | |
137 | ||
138 | return &fOutput; | |
139 | } |