]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/HWCFemulator/AliHLTTPCHWCFProcessorUnit.cxx
extended HWCF emulation to include Qmax in the output
[u/mrichter/AliRoot.git] / HLT / TPCLib / HWCFemulator / AliHLTTPCHWCFProcessorUnit.cxx
CommitLineData
33861fe0 1// $Id$
c012881c 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 AliHLTTPCHWCFProcessorUnit.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 "AliHLTTPCHWCFProcessorUnit.h"
29#include <iostream>
a277d7d8 30#include <cstdio>
c012881c 31
32
33AliHLTTPCHWCFProcessorUnit::AliHLTTPCHWCFProcessorUnit()
34 :
35 fOutput(),
36 fkBunch(0),
37 fBunchIndex(0),
38 fDeconvolute(0),
31959cd6 39 fSingleSeqLimit(0),
40 fDebug(0)
c012881c 41{
42 //constructor
43 Init();
44}
45
46
47AliHLTTPCHWCFProcessorUnit::~AliHLTTPCHWCFProcessorUnit()
48{
49 //destructor
50}
51
52AliHLTTPCHWCFProcessorUnit::AliHLTTPCHWCFProcessorUnit(const AliHLTTPCHWCFProcessorUnit&)
53 :
54 fOutput(),
55 fkBunch(0),
56 fBunchIndex(0),
57 fDeconvolute(0),
31959cd6 58 fSingleSeqLimit(0),
59 fDebug(0)
c012881c 60{
61 // dummy
62 Init();
63}
64
65AliHLTTPCHWCFProcessorUnit& AliHLTTPCHWCFProcessorUnit::operator=(const AliHLTTPCHWCFProcessorUnit&)
66{
67 // dummy
68 return *this;
69}
70
71int AliHLTTPCHWCFProcessorUnit::Init()
72{
73 // initialise
74
75 fkBunch = 0;
76 return 0;
77}
78
79int AliHLTTPCHWCFProcessorUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
80{
81 // input stream of data
82
31959cd6 83 if( bunch && fDebug ){
84 printf("\nHWCF Processor: input bunch F %1d R %3d P %3d T %3d NS %2ld:\n",
85 bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fTime, bunch->fData.size());
86 for( unsigned int i=0; i<bunch->fData.size(); i++ ){
87 printf(" %2d ", bunch->fData[i]);
b7ea7fe9 88 if( i < bunch->fMC.size() ){
31959cd6 89 printf("(");
b7ea7fe9 90 for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",bunch->fMC[i].fClusterID[j].fMCID, bunch->fMC[i].fClusterID[j].fWeight );
31959cd6 91 printf(" )\n");
92 }
93 }
94 }
95
c012881c 96 fkBunch = bunch;
97 fBunchIndex = 0;
98 return 0;
99}
100
101const AliHLTTPCHWCFClusterFragment *AliHLTTPCHWCFProcessorUnit::OutputStream()
102{
103 // output stream of data
104
105 if( !fkBunch ) return 0;
106
107 fOutput.fFlag = fkBunch->fFlag;
108 fOutput.fRow = fkBunch->fRow;
109 fOutput.fPad = fkBunch->fPad;
110 fOutput.fBranch = fkBunch->fBranch;
111 fOutput.fBorder = fkBunch->fBorder;
33861fe0 112 fOutput.fQmax = 0;
c012881c 113 fOutput.fQ = 0;
114 fOutput.fT = 0;
115 fOutput.fT2 = 0;
116 fOutput.fP = 0;
117 fOutput.fP2 = 0;
b7ea7fe9 118 fOutput.fTMean = fkBunch->fTime;
c012881c 119 fOutput.fMC.clear();
120
121 if( fkBunch->fFlag==2 && fkBunch->fData.size()==1 ){ // rcu trailer word, forward it
122 fOutput.fRow = fkBunch->fData[0];
123 }
124
125 if( fkBunch->fFlag >1 ){
126 fkBunch = 0;
127 fBunchIndex = 0;
128 return &fOutput;
129 }
130
131 if( fkBunch->fFlag < 1 ) return 0;
132
133
134 if( fBunchIndex >= fkBunch->fData.size() || fkBunch->fTime < fBunchIndex ) return 0;
135
136 AliHLTInt32_t bunchTime0 = fkBunch->fTime - fBunchIndex;
137 AliHLTInt32_t bunchTime = bunchTime0;
138
139 AliHLTUInt64_t qLast = 0;
140 bool slope = 0;
141 AliHLTUInt32_t length = 0;
142 for( ; fBunchIndex<fkBunch->fData.size() && bunchTime>=0; fBunchIndex++, bunchTime--, length++ ){
143 AliHLTUInt64_t q = fkBunch->fData[fBunchIndex]*fkBunch->fGain;
144 if( fDeconvolute && slope && q>qLast ){
31959cd6 145 //cout<<"deconvolution time!!!"<<endl;
c012881c 146 if( length==1 && fOutput.fQ<fSingleSeqLimit ){
33861fe0 147 fOutput.fQmax = 0;
c012881c 148 fOutput.fQ = 0;
149 fOutput.fT = 0;
150 fOutput.fT2 = 0;
151 fOutput.fP = 0;
152 fOutput.fP2 = 0;
b7ea7fe9 153 fOutput.fMC.clear();
c012881c 154 bunchTime0 = fkBunch->fTime - fBunchIndex;
155 qLast = 0;
156 slope = 0;
157 length = 0;
158 } else {
159 break;
160 }
161 }
162 if( q<qLast ) slope = 1;
163 qLast = q;
33861fe0 164 if (fOutput.fQmax < q) fOutput.fQmax = q;
c012881c 165 fOutput.fQ += q;
166 fOutput.fT += q*bunchTime;
167 fOutput.fT2+= q*bunchTime*bunchTime;
168 fOutput.fP += q*fkBunch->fPad;
169 fOutput.fP2+= q*fkBunch->fPad*fkBunch->fPad;
b7ea7fe9 170 if( fBunchIndex<fkBunch->fMC.size() ){
171 fOutput.fMC.push_back(fkBunch->fMC[fBunchIndex]);
172 }
c012881c 173 }
174
175 fOutput.fTMean = (AliHLTUInt64_t)( (bunchTime0 + bunchTime + 1)/2 );
176
177 if( length==1 && fOutput.fQ < fSingleSeqLimit ) return 0;
178
179 return &fOutput;
180}