LCOV - code coverage report
Current view: top level - HLT/BASE/util - AliHLTCaloClusterReader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 37 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 9 0.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * This file is property of and copyright by the ALICE HLT Project        * 
       3             :  * All rights reserved.                                                   *
       4             :  *                                                                        *
       5             :  * Primary Authors: Oystein Djuvsland                                     *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          * 
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : #include "AliHLTCaloClusterReader.h"
      17             : #include "AliHLTCaloClusterDataStruct.h"
      18             : #include "AliHLTCaloDigitDataStruct.h"
      19             : 
      20             : AliHLTCaloClusterReader::AliHLTCaloClusterReader(): 
      21           0 :   fCurrentClusterPtr(0),
      22           0 :   fIsSetMemory(false),
      23           0 :   fMaxCnt(0),
      24           0 :   fCurrentCnt(0),
      25           0 :   fDigitsPointer(0),
      26           0 :   fNDigits(0)
      27           0 : {
      28             :   //See header file for documentation
      29           0 : }
      30             : 
      31             : 
      32             : AliHLTCaloClusterReader::~AliHLTCaloClusterReader()
      33           0 : {
      34             :   //See header file for documentation
      35           0 : }
      36             : 
      37             : 
      38             : AliHLTCaloClusterDataStruct*   
      39             : AliHLTCaloClusterReader::NextCluster()
      40             : {
      41             :   // See header file for documentation
      42             :   AliHLTCaloClusterDataStruct* tmpChannelPtr = 0;
      43             : 
      44             :   // Check if we have set our memory buffer
      45           0 :   if(fIsSetMemory == false) 
      46             :     {
      47           0 :       return 0;
      48             :     }
      49             : 
      50             :   // Check if we don't read more clusters than we have
      51           0 :   if(fCurrentCnt < fMaxCnt)
      52             :     {
      53             :       // So, we get our cluster
      54           0 :       tmpChannelPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(fCurrentClusterPtr);
      55             :       
      56             : //      printf("CR: Energy: %f, cluster pointer: %x\n", tmpChannelPtr->fEnergy, tmpChannelPtr);
      57             :       
      58             :       // increment the number of clusters read
      59           0 :       fCurrentCnt++;
      60             :       
      61             :       // Move our cluster pointer to give us a cluster next time
      62             :       // The increment is defined as the size of the cluster data struct 
      63             :       // + the number of cells minus the one already included in the struct
      64             :       // times the amount of data for each cell (absolute ID (short) and amplitude fraction (float))
      65             : //      fCurrentClusterPtr = (AliHLTCaloClusterDataStruct*)((UChar_t*)fCurrentClusterPtr 
      66             : //                                                            + sizeof(AliHLTCaloClusterDataStruct) 
      67             : //                                                            + (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t)));
      68           0 :       fCurrentClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(reinterpret_cast<UChar_t*>(fCurrentClusterPtr)
      69           0 :                                                               + sizeof(AliHLTCaloClusterDataStruct) 
      70           0 :                                                               + sizeof(AliHLTCaloCellDataStruct)*(fCurrentClusterPtr->fNCells - 1));;
      71             :                                                               //+ (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t))
      72             :                                                               //- sizeof(Short_t)); //TODO: Why?;
      73             :                                                 
      74             :                                                               
      75             :       // return the cluster
      76             : //      printf("CR: Energy: %f, number of cells: %d, cluster pointer: %x, next cluster pointer: %x\n", tmpChannelPtr->fEnergy, tmpChannelPtr->fNCells, tmpChannelPtr, fCurrentClusterPtr);
      77             : //      if(fCurrentCnt < fMaxCnt-1) printf("CR: Next cluster Energy: %f, number of cells: %d, cluster pointer: %x\n", fCurrentClusterPtr->fEnergy, fCurrentClusterPtr->fNCells,  fCurrentClusterPtr);
      78             : 
      79           0 :       return tmpChannelPtr;
      80             :     }
      81             :   // if we have read our clusters we reset our memory pointer and returns 0;
      82             :   else
      83             :     {
      84           0 :       Reset();
      85           0 :       return 0;
      86             :     }
      87             : 
      88             :   // will never happen, but anyway...
      89             :   return 0;
      90           0 : }
      91             : 
      92             : bool
      93             : AliHLTCaloClusterReader::GetCell(AliHLTCaloClusterDataStruct *clusterPtr, UShort_t &cellId, Double32_t &cellAmp, UInt_t index)
      94             : {
      95             :   // See header file for documentation
      96             :   // check if the index is within bounds
      97           0 :   if(index < clusterPtr->fNCells)
      98             :     {
      99           0 :        cellId = (&(clusterPtr->fCaloCells))[index].fCellsAbsId;
     100           0 :        cellAmp = (&(clusterPtr->fCaloCells))[index].fCellsAmpFraction;
     101           0 :        return true;
     102             :     }
     103           0 :   else return false;
     104           0 : }
     105             : 
     106             : void
     107             : AliHLTCaloClusterReader::SetMemory(const AliHLTCaloClusterHeaderStruct* clusterHeaderPtr)
     108             : {
     109             :   //See header file for documentation
     110             :   //printf("CR: Number of clusters in event: %d, Number of digits in event: %d\n", clusterHeaderPtr->fNClusters, clusterHeaderPtr->fNDigits);
     111           0 :   fMaxCnt = clusterHeaderPtr->fNClusters;
     112           0 :   fCurrentClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>((UChar_t*)(clusterHeaderPtr) + sizeof(AliHLTCaloClusterHeaderStruct) + sizeof(AliHLTCaloDigitDataStruct)*clusterHeaderPtr->fNDigits);
     113           0 :   fNDigits = clusterHeaderPtr->fNDigits;
     114           0 :   fDigitsPointer = reinterpret_cast<AliHLTCaloDigitDataStruct*>((UChar_t*)(clusterHeaderPtr) + sizeof(AliHLTCaloClusterHeaderStruct));
     115           0 :   fIsSetMemory = true;
     116           0 : }
     117             : 
     118             : 
     119             : void
     120             : AliHLTCaloClusterReader::Reset()
     121             : {
     122             :   //See header file for documentation
     123           0 :   fCurrentCnt = 0;
     124           0 :   fIsSetMemory = false;
     125           0 : }

Generated by: LCOV version 1.11