]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/util/AliHLTCaloClusterReader.cxx
- fixing compilation warnings
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTCaloClusterReader.cxx
CommitLineData
7fc04b67 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"
b4479a87 18#include "AliHLTCaloDigitDataStruct.h"
7fc04b67 19
20AliHLTCaloClusterReader::AliHLTCaloClusterReader():
21 fCurrentClusterPtr(0),
22 fIsSetMemory(false),
23 fMaxCnt(0),
cefad3b2 24 fCurrentCnt(0),
25 fDigitsPointer(0),
26 fNDigits(0)
7fc04b67 27{
28 //See header file for documentation
29}
30
31
32AliHLTCaloClusterReader::~AliHLTCaloClusterReader()
33{
34 //See header file for documentation
35}
36
37
38AliHLTCaloClusterDataStruct*
39AliHLTCaloClusterReader::NextCluster()
40{
41 // See header file for documentation
42 AliHLTCaloClusterDataStruct* tmpChannelPtr = 0;
43
44 // Check if we have set our memory buffer
45 if(fIsSetMemory == false)
46 {
47 return 0;
48 }
49
50 // Check if we don't read more clusters than we have
51 if(fCurrentCnt < fMaxCnt)
52 {
53 // So, we get our cluster
54 tmpChannelPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(fCurrentClusterPtr);
55
2a1edad1 56// printf("CR: Energy: %f, cluster pointer: %x\n", tmpChannelPtr->fEnergy, tmpChannelPtr);
57
7fc04b67 58 // increment the number of clusters read
59 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))
2a1edad1 65// fCurrentClusterPtr = (AliHLTCaloClusterDataStruct*)((UChar_t*)fCurrentClusterPtr
66// + sizeof(AliHLTCaloClusterDataStruct)
67// + (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t)));
68 fCurrentClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(reinterpret_cast<UChar_t*>(fCurrentClusterPtr)
7fdb2519 69 + sizeof(AliHLTCaloClusterDataStruct)
70 + sizeof(AliHLTCaloCellDataStruct)*(fCurrentClusterPtr->fNCells - 1));;
9a0cbaba 71 //+ (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t))
72 //- sizeof(Short_t)); //TODO: Why?;
2a1edad1 73
74
7fc04b67 75 // return the cluster
7fdb2519 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);
2a1edad1 78
7fc04b67 79 return tmpChannelPtr;
80 }
81 // if we have read our clusters we reset our memory pointer and returns 0;
82 else
83 {
84 Reset();
85 return 0;
86 }
87
88 // will never happen, but anyway...
89 return 0;
90}
91
92bool
93AliHLTCaloClusterReader::GetCell(AliHLTCaloClusterDataStruct *clusterPtr, UShort_t &cellId, Double32_t &cellAmp, UInt_t index)
94{
95 // See header file for documentation
7fc04b67 96 // check if the index is within bounds
7fdb2519 97 if(index < clusterPtr->fNCells)
7fc04b67 98 {
7fdb2519 99 cellId = (&(clusterPtr->fCaloCells))[index].fCellsAbsId;
100 cellAmp = (&(clusterPtr->fCaloCells))[index].fCellsAmpFraction;
101 return true;
7fc04b67 102 }
103 else return false;
104}
105
106void
107AliHLTCaloClusterReader::SetMemory(const AliHLTCaloClusterHeaderStruct* clusterHeaderPtr)
108{
109 //See header file for documentation
7c1d87a2 110 //printf("CR: Number of clusters in event: %d, Number of digits in event: %d\n", clusterHeaderPtr->fNClusters, clusterHeaderPtr->fNDigits);
7fc04b67 111 fMaxCnt = clusterHeaderPtr->fNClusters;
b4479a87 112 fCurrentClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>((UChar_t*)(clusterHeaderPtr) + sizeof(AliHLTCaloClusterHeaderStruct) + sizeof(AliHLTCaloDigitDataStruct)*clusterHeaderPtr->fNDigits);
7c1d87a2 113 fNDigits = clusterHeaderPtr->fNDigits;
114 fDigitsPointer = reinterpret_cast<AliHLTCaloDigitDataStruct*>((UChar_t*)(clusterHeaderPtr) + sizeof(AliHLTCaloClusterHeaderStruct));
7fc04b67 115 fIsSetMemory = true;
116}
117
118
119void
120AliHLTCaloClusterReader::Reset()
121{
122 //See header file for documentation
123 fCurrentCnt = 0;
124 fIsSetMemory = false;
125}