]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSSharedMemoryInterfacev2.cxx
- changes to make the clusterisation work for EMCAL
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSSharedMemoryInterfacev2.cxx
CommitLineData
1b41ab20 1// $Id$
2
94594220 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#include "AliHLTPHOSSharedMemoryInterfacev2.h"
23#include "AliHLTPHOSChannelDataHeaderStruct.h"
24#include "AliHLTPHOSChannelDataStruct.h"
25#include "AliHLTLogging.h"
37ff2dd6 26#include "AliHLTPHOSMapper.h"
4f4b7ba4 27#include "AliHLTPHOSConstant.h"
94594220 28
29
30AliHLTPHOSSharedMemoryInterfacev2::AliHLTPHOSSharedMemoryInterfacev2():
31 fCurrentChannel(0),
32 fChannelDataPtr(0),
33 fIsSetMemory(false),
34 fHasRawData(false),
35 fMaxCnt(0),
37ff2dd6 36 fCurrentCnt(0),
b210e538 37 fRawDataPtr(0),
38 fRawData()
94594220 39{
40
41}
42
43
44AliHLTPHOSSharedMemoryInterfacev2::~AliHLTPHOSSharedMemoryInterfacev2()
45{
46
47}
48
37ff2dd6 49/*
50struct AliHLTPHOSChannelDataStruct
51{
52 Float_t fEnergy;
53 Float_t fTime;
54 UShort_t fChannelID;
55 Short_t fCrazyness;
56 // Short_t fRawDataSize; //the size of the raw data
57};
58*/
94594220 59
60AliHLTPHOSChannelDataStruct*
61AliHLTPHOSSharedMemoryInterfacev2::NextChannel()
62{
63 // Comment
64 AliHLTPHOSChannelDataStruct* tmpChannelPtr = 0;
65 if(fCurrentCnt < fMaxCnt)
66 {
67 tmpChannelPtr = reinterpret_cast<AliHLTPHOSChannelDataStruct*>(fChannelDataPtr);
68 fCurrentCnt++;
69 fChannelDataPtr += sizeof(AliHLTPHOSChannelDataStruct);
70 if(fHasRawData == true)
71 {
37ff2dd6 72 fRawData.fEnergy = tmpChannelPtr->fEnergy;
73 fRawData.fTime = tmpChannelPtr->fTime;
74 fRawData.fChannelID = tmpChannelPtr->fChannelID;
75 fRawData.fCrazyness = tmpChannelPtr->fCrazyness;
76 Reset(fRawData);
77 //AliHLTPHOSMapper::ChannelId2Coordinate(const UShort_t channelId, AliHLTPHOSCoordinate &channelCoord)
44175a17 78// AliHLTPHOSMapper::ChannelId2Coordinate( fRawData.fChannelID, fRawData.fCoordinate);
37ff2dd6 79
80 if( fRawData.fChannelID == fRawDataPtr[0] )
81 {
82 Reset(fRawData);
83 // cout << __FILE__ << __LINE__ << "fRawData.fChannelID == fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
84 // cout << " copying raw dat not yet implemnted " << endl;
85 UShort_t tmpTotSize = fRawDataPtr[1];
86 UShort_t tmpStartBin = fRawDataPtr[2];
87 UShort_t tmpBunchtSize = fRawDataPtr[3];
88 // fRawDataPtr
89 UShort_t tmpSamplesLeft = tmpTotSize -4;
90
91 fRawData.nSamplesUsed = tmpTotSize + tmpStartBin;
92
93 while(tmpSamplesLeft > 0)
94 {
95 for(int i=0; i < tmpBunchtSize; i++ )
96 {
97 fRawData.fDataPtr[i + tmpStartBin] = fRawDataPtr[ i+ 4];
98 tmpSamplesLeft --;
99 }
100 }
101 fRawDataPtr+= tmpTotSize;
102
103 }
104 else
105 {
106 // cout << __FILE__ << __LINE__ << "ERROR! fRawData.fChannelID = "<< fRawData.fChannelID << " but fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
107 }
108
109
94594220 110 // HLTDebug("Raw data interface not yet implemented, ignoring raw data");
111 }
112 return tmpChannelPtr;
113 }
114 else
115 {
116 Reset();
117 return 0;
118 }
119 return 0;
120}
121
37ff2dd6 122
123void
124AliHLTPHOSSharedMemoryInterfacev2::NextRawChannel( )
125{
126 if(fHasRawData == false )
127 {
128 cout << __FILE__ << __LINE__<< "ERROR: no raw data present" << endl;
129 }
130 else
131 {
132 for(int i = 0; i < 200 ; i++ )
133
134 {
135 cout << fRawDataPtr[i] << "\t";
136 if(i%16 == 0)
137 {
138 cout << endl;
139 }
140 }
141 }
142}
143
144
94594220 145void
146AliHLTPHOSSharedMemoryInterfacev2::SetMemory(AliHLTPHOSChannelDataHeaderStruct* channelDataHeaderPtr)
147{
94594220 148 //Shutting up rule checker
149 fHasRawData = channelDataHeaderPtr->fHasRawData;
150 fMaxCnt = channelDataHeaderPtr->fNChannels;
151 fChannelDataPtr = reinterpret_cast<AliHLTUInt8_t*>(channelDataHeaderPtr) + sizeof(AliHLTPHOSChannelDataHeaderStruct);
37ff2dd6 152
153
94594220 154 if(fHasRawData == true)
155 {
37ff2dd6 156 fRawDataPtr = reinterpret_cast< UShort_t* >(channelDataHeaderPtr);
157 int inc = sizeof (AliHLTPHOSChannelDataHeaderStruct) + fMaxCnt*sizeof(AliHLTPHOSChannelDataStruct);
158 fRawDataPtr += inc/sizeof(UShort_t );
94594220 159 }
37ff2dd6 160
161 fIsSetMemory = true;
94594220 162}
163
164
165void
166AliHLTPHOSSharedMemoryInterfacev2::Reset()
167{
168 //Shutting up rule checker
169 fCurrentCnt = 0;
170 fIsSetMemory = false;
171 fHasRawData = false;
172}
37ff2dd6 173
174
175void
176AliHLTPHOSSharedMemoryInterfacev2::Reset(AliHLTPHOSChannelRawDataStruct &str)
177{
44175a17 178 for(int i=0; i< 1008; i++ )
37ff2dd6 179 {
180 str.fDataPtr[i] = 0;
181 }
182
183}