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