1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
5 * Primary Authors: Oystein Djuvsland *
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 **************************************************************************/
16 #include "AliHLTCaloClusterReader.h"
17 #include "AliHLTCaloClusterDataStruct.h"
18 #include "AliHLTCaloDigitDataStruct.h"
20 AliHLTCaloClusterReader::AliHLTCaloClusterReader():
21 fCurrentClusterPtr(0),
26 //See header file for documentation
30 AliHLTCaloClusterReader::~AliHLTCaloClusterReader()
32 //See header file for documentation
36 AliHLTCaloClusterDataStruct*
37 AliHLTCaloClusterReader::NextCluster()
39 // See header file for documentation
40 AliHLTCaloClusterDataStruct* tmpChannelPtr = 0;
42 // Check if we have set our memory buffer
43 if(fIsSetMemory == false)
48 // Check if we don't read more clusters than we have
49 if(fCurrentCnt < fMaxCnt)
51 // So, we get our cluster
52 tmpChannelPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(fCurrentClusterPtr);
54 // increment the number of clusters read
57 // Move our cluster pointer to give us a cluster next time
58 // The increment is defined as the size of the cluster data struct
59 // + the number of cells minus the one already included in the struct
60 // times the amount of data for each cell (absolute ID (short) and amplitude fraction (float))
61 fCurrentClusterPtr = (AliHLTCaloClusterDataStruct*)((UChar_t*)fCurrentClusterPtr
62 + sizeof(AliHLTCaloClusterDataStruct)
63 + (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t)));
67 // if we have read our clusters we reset our memory pointer and returns 0;
74 // will never happen, but anyway...
79 AliHLTCaloClusterReader::GetCell(AliHLTCaloClusterDataStruct *clusterPtr, UShort_t &cellId, Double32_t &cellAmp, UInt_t index)
81 // See header file for documentation
83 // check if the index is within bounds
84 if(index < clusterPtr->fNCells)
86 // the absolute ID is located in the memory address of the first ID plus the size of the pair of cell properties times the index
87 cellId = *(UShort_t*)((UChar_t*)(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t)));
88 // the amplitude fraction is located in the memory address of the first ID plus the size of the pair of cell properties times the index
89 cellAmp = *(Float_t*)((UChar_t*)(&(clusterPtr->fCellsAmpFraction)) + index * (sizeof(Short_t) + sizeof(Float_t)));
96 AliHLTCaloClusterReader::SetMemory(const AliHLTCaloClusterHeaderStruct* clusterHeaderPtr)
98 //See header file for documentation
100 fMaxCnt = clusterHeaderPtr->fNClusters;
101 fCurrentClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>((UChar_t*)(clusterHeaderPtr) + sizeof(AliHLTCaloClusterHeaderStruct) + sizeof(AliHLTCaloDigitDataStruct)*clusterHeaderPtr->fNDigits);
107 AliHLTCaloClusterReader::Reset()
109 //See header file for documentation
111 fIsSetMemory = false;