LCOV - code coverage report
Current view: top level - HLT/TPCLib/HWCFemulator - AliHLTTPCHWCFPeakFinderUnit.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 57 21.1 %
Date: 2016-06-14 17:26:59 Functions: 5 10 50.0 %

          Line data    Source code
       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           6 :   fOutput(),
      36           3 :   fkBunch(0),
      37           3 :   fChargeFluctuation(0),
      38           3 :   fNoiseSuppression(0),
      39           3 :   fDebug(0)
      40           6 : {
      41             :   //constructor 
      42           3 :   Init();
      43           6 : }
      44             : 
      45             : 
      46             : AliHLTTPCHWCFPeakFinderUnit::~AliHLTTPCHWCFPeakFinderUnit()
      47           6 : {   
      48             :   //destructor 
      49           9 : }
      50             : 
      51             : AliHLTTPCHWCFPeakFinderUnit::AliHLTTPCHWCFPeakFinderUnit(const AliHLTTPCHWCFPeakFinderUnit&)
      52             :   :
      53           0 :   fOutput(),
      54           0 :   fkBunch(0),
      55           0 :   fChargeFluctuation(0),
      56           0 :   fDebug(0)
      57           0 : {
      58             :   // dummy
      59           0 :   Init();
      60           0 : }
      61             : 
      62             : AliHLTTPCHWCFPeakFinderUnit& AliHLTTPCHWCFPeakFinderUnit::operator=(const AliHLTTPCHWCFPeakFinderUnit&)
      63             : {
      64             :   // dummy  
      65           0 :   return *this;
      66             : }
      67             : 
      68             : int AliHLTTPCHWCFPeakFinderUnit::Init()
      69             : {
      70             :   // initialise  
      71             : 
      72           6 :   fkBunch = 0;
      73           3 :   return 0;
      74             : }
      75             : 
      76             : int AliHLTTPCHWCFPeakFinderUnit::InputStream( const AliHLTTPCHWCFBunch *bunch )
      77             : {
      78             :   // input stream of data 
      79             : 
      80           0 :   if( bunch && fDebug ){
      81           0 :     printf("\nHWCF Peak Finder: input bunch F %1d R %3d P %3d  NS %2ld:\n",
      82           0 :            bunch->fFlag, bunch->fRow, bunch->fPad, bunch->fData.size());
      83           0 :     for( unsigned int i=0; i<bunch->fData.size(); i++ ){
      84           0 :       const AliHLTTPCHWCFDigit &d = bunch->fData[i];
      85           0 :       printf("   q %2d t %3d ", d.fQ, d.fTime);
      86           0 :       printf("(");
      87           0 :       for( int j=0; j<3; j++ ) printf(" {%d,%2.0f}",d.fMC.fClusterID[j].fMCID, d.fMC.fClusterID[j].fWeight );
      88           0 :       printf(" )\n");      
      89             :     }
      90           0 :   }
      91             : 
      92           0 :   fkBunch = bunch;
      93           0 :   return 0;
      94             : }
      95             : 
      96             : const AliHLTTPCHWCFBunch *AliHLTTPCHWCFPeakFinderUnit::OutputStream()
      97             : { 
      98             :   // output stream of data 
      99             : 
     100           0 :   if( !fkBunch ) return 0;
     101             : 
     102           0 :   fOutput.fFlag = fkBunch->fFlag;
     103           0 :   fOutput.fRow = fkBunch->fRow;
     104           0 :   fOutput.fPad = fkBunch->fPad;
     105           0 :   fOutput.fBranch = fkBunch->fBranch;
     106           0 :   fOutput.fBorder = fkBunch->fBorder;
     107           0 :   fOutput.fGain = fkBunch->fGain;
     108           0 :   fOutput.fData.clear();
     109           0 :   fOutput.fData.insert(fOutput.fData.end(),fkBunch->fData.begin(), fkBunch->fData.end());
     110           0 :   fkBunch = 0;
     111             : 
     112           0 :   if( fOutput.fFlag !=1 ){ // rcu trailer word, forward it 
     113           0 :     return &fOutput;
     114             :   }
     115             : 
     116             :   bool slope = 0;
     117             :   AliHLTUInt32_t qLast = 0;
     118           0 :   AliHLTUInt32_t n = fOutput.fData.size();
     119             :   AliHLTUInt32_t qPeak = 0;
     120             :   
     121           0 :   for( AliHLTUInt32_t i=0; i<n; i++ ){
     122           0 :     AliHLTUInt32_t q = fOutput.fData[i].fQ;    
     123           0 :     if( !slope ){
     124           0 :       if(fNoiseSuppression ? (q + fNoiseSuppression < qPeak) : (q + fChargeFluctuation < qLast) ){ // peak
     125             :         slope = 1;
     126           0 :         if( i>0 ) fOutput.fData[i-1].fPeak = 1;
     127             :       }
     128           0 :       if (q > qPeak) qPeak = q;
     129           0 :     }else if( q > qLast + fChargeFluctuation ){ // minimum
     130             :       slope = 0;
     131             :       qPeak = 0;
     132           0 :       if( i>0 ) fOutput.fData[i-1].fPeak = 2;
     133             :     }
     134             :     qLast = q;
     135             :   }
     136             :   
     137           0 :   if( n>0 ){
     138           0 :     if( !slope ) fOutput.fData[n-1].fPeak = 1;
     139           0 :     else fOutput.fData[n-1].fPeak = 2;
     140             :   }
     141             :   
     142             :   return &fOutput;
     143           0 : }

Generated by: LCOV version 1.11