]>
Commit | Line | Data |
---|---|---|
1b41ab20 | 1 | // $Id$ |
2 | ||
14ff16ed | 3 | /************************************************************************** |
4 | * This file is property of and copyright by the Experimental Nuclear * | |
5 | * Physics Group, Dep. of Physics * | |
6 | * University of Oslo, Norway, 2007 * | |
7 | * * | |
8 | * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.* | |
9 | * Contributors are mentioned in the code where appropriate. * | |
10 | * Please report bugs to perthi@fys.uio.no * | |
11 | * * | |
12 | * Permission to use, copy, modify and distribute this software and its * | |
13 | * documentation strictly for non-commercial purposes is hereby granted * | |
14 | * without fee, provided that the above copyright notice appears in all * | |
15 | * copies and that both the copyright notice and this permission notice * | |
16 | * appear in the supporting documentation. The authors make no claims * | |
17 | * about the suitability of this software for any purpose. It is * | |
18 | * provided "as is" without express or implied warranty. * | |
19 | **************************************************************************/ | |
20 | ||
21 | ||
22 | ||
23 | #include "AliHLTPHOSSharedMemoryInterface.h" | |
24 | #include "AliHLTPHOSRcuCellEnergyDataStruct.h" | |
25 | #include "AliHLTPHOSValidCellDataStruct.h" | |
26 | #include <iostream> | |
27 | ||
28 | ||
b444d727 | 29 | AliHLTPHOSSharedMemoryInterface::AliHLTPHOSSharedMemoryInterface(): fCurrentChannel(0), |
30 | fCellEnergiesPtr(0), | |
31 | fIsSetMemory(false), | |
6f66f946 | 32 | fHasRawData(false), |
14ff16ed | 33 | fMaxCnt(0), |
b444d727 | 34 | fCurrentCnt(0), |
25b7f84c | 35 | fCurrentX(0), |
36 | fCurrentZ(0), | |
37 | fCurrentGain(0), | |
b444d727 | 38 | fCharDataOffset(0), |
39 | fCharPtr(0), | |
6f66f946 | 40 | fIntPtr(0), |
41 | fRawDataPtr(0) | |
14ff16ed | 42 | { |
b444d727 | 43 | fCharDataOffset = sizeof(AliHLTPHOSRcuCellEnergyDataStruct); |
14ff16ed | 44 | } |
45 | ||
46 | ||
47 | AliHLTPHOSSharedMemoryInterface::~AliHLTPHOSSharedMemoryInterface() | |
48 | { | |
49 | ||
50 | } | |
51 | ||
52 | ||
53 | AliHLTPHOSValidCellDataStruct* | |
54 | AliHLTPHOSSharedMemoryInterface::NextChannel() | |
55 | { | |
56 | // Returns the next channel of the current AliHLTPHOSRcuCellEnergyDataStruct | |
57 | // Returns zero when all cannels are read | |
d949e02e | 58 | /* |
14ff16ed | 59 | if(fCurrentCnt < fMaxCnt) |
60 | { | |
61 | fCurrentChannel = &fCellEnergiesPtr->fValidData[fCurrentCnt]; | |
62 | fCurrentChannel->fData = fIntPtr; | |
63 | fIntPtr += fCurrentChannel->fNSamples; | |
64 | fCurrentCnt ++; | |
65 | return fCurrentChannel; | |
66 | } | |
d949e02e | 67 | */ |
d949e02e | 68 | |
25b7f84c | 69 | // Changed by OD |
d949e02e | 70 | if(fCurrentCnt < fMaxCnt) |
71 | { | |
6f66f946 | 72 | fCurrentChannel = &(fCellEnergiesPtr->fValidData[fCurrentCnt]); |
73 | fCurrentCnt++; | |
74 | if(fCellEnergiesPtr->fHasRawData == true) | |
d949e02e | 75 | { |
6f66f946 | 76 | fRawDataPtr = fIntPtr + 1; |
77 | fIntPtr = fIntPtr + *fIntPtr + 1; | |
d949e02e | 78 | } |
6f66f946 | 79 | return fCurrentChannel; |
d949e02e | 80 | } |
14ff16ed | 81 | else |
82 | { | |
83 | Reset(); | |
84 | return 0; | |
85 | } | |
b444d727 | 86 | |
87 | return 0; | |
14ff16ed | 88 | } |
89 | ||
6f66f946 | 90 | Int_t* |
91 | AliHLTPHOSSharedMemoryInterface::GetRawData(Int_t& nSamples) | |
92 | { | |
93 | //Added by OD | |
94 | ||
95 | if(fHasRawData == true) | |
96 | { | |
97 | nSamples = *(fRawDataPtr-1); | |
98 | return fRawDataPtr; | |
99 | } | |
100 | else | |
101 | { | |
102 | return 0; | |
103 | } | |
104 | } | |
14ff16ed | 105 | |
106 | void | |
107 | AliHLTPHOSSharedMemoryInterface::SetMemory(AliHLTPHOSRcuCellEnergyDataStruct *rcuCellEnergyPtr) | |
108 | { | |
109 | //Shutting up rule checker | |
110 | fCellEnergiesPtr = rcuCellEnergyPtr; | |
111 | fMaxCnt = fCellEnergiesPtr->fCnt; | |
6f66f946 | 112 | if(fCellEnergiesPtr->fHasRawData == true) |
113 | { | |
114 | PingPongPointer(); | |
115 | fHasRawData = true; | |
116 | } | |
14ff16ed | 117 | fIsSetMemory = true; |
118 | } | |
119 | ||
120 | ||
121 | void | |
122 | AliHLTPHOSSharedMemoryInterface::Reset() | |
123 | { | |
124 | //Shutting up rule checker | |
125 | fMaxCnt =0; | |
126 | fCurrentCnt = 0; | |
d949e02e | 127 | fCurrentX = 0; |
128 | fCurrentZ = 0; | |
129 | fCurrentGain = 0; | |
14ff16ed | 130 | fIsSetMemory = false; |
6f66f946 | 131 | fHasRawData = false; |
14ff16ed | 132 | } |
133 | ||
14ff16ed | 134 | void |
135 | AliHLTPHOSSharedMemoryInterface::PingPongPointer() | |
136 | { | |
137 | // ping pong ping ping pong ping pong | |
6f66f946 | 138 | |
14ff16ed | 139 | fCharPtr = (char *)fCellEnergiesPtr ; |
140 | fCharPtr += fCharDataOffset; | |
6f66f946 | 141 | fIntPtr = (Int_t *)fCharPtr; |
142 | ||
14ff16ed | 143 | } |