1 // $Id: AliHLTCaloSharedMemoryInterfacev2.cxx 35071 2009-09-29 05:26:09Z phille $
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 *
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 *
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 **************************************************************************/
22 #include "AliHLTCaloSharedMemoryInterfacev2.h"
23 #include "AliHLTCaloChannelDataHeaderStruct.h"
24 #include "AliHLTCaloChannelDataStruct.h"
25 #include "AliHLTLogging.h"
26 #include "AliHLTCaloMapper.h"
27 #include "AliHLTCaloConstants.h"
30 AliHLTCaloSharedMemoryInterfacev2::AliHLTCaloSharedMemoryInterfacev2(): fCurrentChannel(0),
40 // GetSpecFromDDLIndex
41 // AliHLTCaloMapper *fMapperPtr[32];
44 for(int i=0; i < 32; i++)
46 fMapperPtr[i] = new AliHLTCaloMapper( AliHLTCaloMapper::GetSpecFromDDLIndex(i) ) ;
53 AliHLTCaloSharedMemoryInterfacev2::~AliHLTCaloSharedMemoryInterfacev2()
60 struct AliHLTCaloChannelDataStruct
66 // Short_t fRawDataSize; //the size of the raw data
69 AliHLTCaloChannelDataStruct*
70 AliHLTCaloSharedMemoryInterfacev2::NextChannel()
73 AliHLTCaloChannelDataStruct* tmpChannelPtr = 0;
74 if(fCurrentCnt < fMaxCnt)
76 tmpChannelPtr = reinterpret_cast<AliHLTCaloChannelDataStruct*>(fChannelDataPtr);
78 fChannelDataPtr += sizeof(AliHLTCaloChannelDataStruct);
80 if(fHasRawData == true)
83 fRawData.fEnergy = tmpChannelPtr->fEnergy;
84 fRawData.fTime = tmpChannelPtr->fTime;
85 fRawData.fChannelID = tmpChannelPtr->fChannelID;
86 fRawData.fCrazyness = tmpChannelPtr->fCrazyness;
88 //AliHLTCaloMapper::ChannelId2Coordinate(const UShort_t channelId, AliHLTCaloCoordinate &channelCoord)
91 AliHLTCaloMapper::ChannelId2Coordinate( fRawData.fChannelID, fRawData.fCoordinate);
93 if( fRawData.fChannelID == fRawDataPtr[0] )
96 // cout << __FILE__ << __LINE__ << "fRawData.fChannelID == fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
97 // cout << " copying raw dat not yet implemnted " << endl;
98 UShort_t tmpTotSize = fRawDataPtr[1];
99 UShort_t tmpStartBin = fRawDataPtr[2];
100 UShort_t tmpBunchtSize = fRawDataPtr[3];
102 // UShort_t tmpSamplesLeft = tmpTotSize -4;
103 int tmpSamplesLeft = tmpTotSize -4;
105 fRawData.nSamplesUsed = tmpTotSize + tmpStartBin;
107 if(tmpSamplesLeft > 0 )
109 while(tmpSamplesLeft > 0)
111 for(int i=0; i < tmpBunchtSize; i++ )
113 fRawData.fDataPtr[i + tmpStartBin] = fRawDataPtr[ i+ 4];
117 fRawDataPtr+= tmpTotSize;
122 // cout << __FILE__ << __LINE__ << "ERROR! fRawData.fChannelID = "<< fRawData.fChannelID << " but fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
126 // HLTDebug("Raw data interface not yet implemented, ignoring raw data");
128 return tmpChannelPtr;
139 AliHLTCaloChannelDataStruct*
140 AliHLTCaloSharedMemoryInterfacev2::NextChannel()
142 cout << __FILE__ << __LINE__ << " TP0" << endl;
144 AliHLTCaloChannelDataStruct* tmpChannelPtr = 0;
145 if(fCurrentCnt < fMaxCnt)
147 cout << __FILE__ << __LINE__ << " TP1" << endl;
148 tmpChannelPtr = reinterpret_cast<AliHLTCaloChannelDataStruct*>(fChannelDataPtr);
150 fChannelDataPtr += sizeof(AliHLTCaloChannelDataStruct);
152 // if(fHasRawData == true)
155 cout << __FILE__ << __LINE__ << " TP2" << endl;
156 fRawData.fEnergy = tmpChannelPtr->fEnergy;
157 fRawData.fTime = tmpChannelPtr->fTime;
158 fRawData.fChannelID = tmpChannelPtr->fChannelID;
159 fRawData.fCrazyness = tmpChannelPtr->fCrazyness;
161 AliHLTCaloMapper::ChannelId2Coordinate( fRawData.fChannelID, fRawData.fCoordinate);
162 cout << __FILE__ << __LINE__ << " TP3" << endl;
163 if( fRawData.fChannelID == fRawDataPtr[0] )
165 cout << __FILE__ << __LINE__ << " TP4" << endl;
167 cout << __FILE__ << __LINE__ << " TP5" << endl;
168 UShort_t tmpTotSize = fRawDataPtr[1];
169 UShort_t tmpStartBin = fRawDataPtr[2];
170 UShort_t tmpBunchtSize = fRawDataPtr[3];
171 UShort_t tmpSamplesLeft = tmpTotSize -4;
172 fRawData.nSamplesUsed = tmpTotSize + tmpStartBin;
173 cout << __FILE__ << __LINE__ << " TP6" << endl;
175 while(tmpSamplesLeft > 0)
177 if ( (tmpBunchtSize < ( ALTROMAXSAMPLES +4)) && tmpBunchtSize > 0 )
179 cout << __FILE__ << __LINE__ << " TP7" << endl;
180 for(int i=0; i < tmpBunchtSize; i++ )
182 cout << __FILE__ << __LINE__ << " TMP tot size =" << tmpBunchtSize << tmpTotSize << endl;
183 cout << __FILE__ << __LINE__ << " TMP bunch size =" << tmpTotSize << endl;
184 cout << __FILE__ << __LINE__ << " TP8, i=" << i <<", tmpStartBin = "<< tmpStartBin << " fCurrentCnt = "<< fCurrentCnt << endl;
185 cout << __FILE__ << __LINE__ << " acessing fRawData.fDataPtr["<< i + tmpStartBin << "]" << endl;
186 fRawData.fDataPtr[ i + tmpStartBin ] = fRawDataPtr[ i+ 4];
187 // cout << __FILE__ << __LINE__ << " acessing fRawData.fDataPtr["<< i + tmpStartBin << "]" << endl;
190 fRawDataPtr+= tmpTotSize;
199 return tmpChannelPtr;
213 AliHLTCaloSharedMemoryInterfacev2::NextRawChannel( )
215 if(fHasRawData == false )
217 cout << __FILE__ << __LINE__<< "ERROR: no raw data present" << endl;
221 for(int i = 0; i < 200 ; i++ )
224 cout << fRawDataPtr[i] << "\t";
235 //AliHLTCaloSharedMemoryInterfacev2::SetMemory(AliHLTCaloChannelDataHeaderStruct* channelDataHeaderPtr, const unsigned long specification)
236 AliHLTCaloSharedMemoryInterfacev2::SetMemory(AliHLTCaloChannelDataHeaderStruct* channelDataHeaderPtr)
238 // fSpecification = specification;
240 //Shutting up rule checker
241 fHasRawData = channelDataHeaderPtr->fHasRawData;
242 fMaxCnt = channelDataHeaderPtr->fNChannels;
243 fChannelDataPtr = reinterpret_cast<AliHLTUInt8_t*>(channelDataHeaderPtr) + sizeof(AliHLTCaloChannelDataHeaderStruct);
246 if(fHasRawData == true)
248 fRawDataPtr = reinterpret_cast< UShort_t* >(channelDataHeaderPtr);
249 int inc = sizeof (AliHLTCaloChannelDataHeaderStruct) + fMaxCnt*sizeof(AliHLTCaloChannelDataStruct);
250 fRawDataPtr += inc/sizeof(UShort_t );
258 AliHLTCaloSharedMemoryInterfacev2::Reset()
260 //Shutting up rule checker
262 fIsSetMemory = false;
268 AliHLTCaloSharedMemoryInterfacev2::Reset(AliHLTCaloChannelRawDataStruct &str)
270 for(int i=0; i< ALTROMAXSAMPLES; i++ )