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 "AliHLTPHOSSharedMemoryInterfacev2.h"
23 #include "AliHLTPHOSChannelDataHeaderStruct.h"
24 #include "AliHLTPHOSChannelDataStruct.h"
25 #include "AliHLTLogging.h"
26 #include "AliHLTPHOSMapper.h"
27 #include "AliHLTPHOSConstant.h"
30 AliHLTPHOSSharedMemoryInterfacev2::AliHLTPHOSSharedMemoryInterfacev2():
44 AliHLTPHOSSharedMemoryInterfacev2::~AliHLTPHOSSharedMemoryInterfacev2()
50 struct AliHLTPHOSChannelDataStruct
56 // Short_t fRawDataSize; //the size of the raw data
60 AliHLTPHOSChannelDataStruct*
61 AliHLTPHOSSharedMemoryInterfacev2::NextChannel()
64 AliHLTPHOSChannelDataStruct* tmpChannelPtr = 0;
65 if(fCurrentCnt < fMaxCnt)
67 tmpChannelPtr = reinterpret_cast<AliHLTPHOSChannelDataStruct*>(fChannelDataPtr);
69 fChannelDataPtr += sizeof(AliHLTPHOSChannelDataStruct);
70 if(fHasRawData == true)
72 fRawData.fEnergy = tmpChannelPtr->fEnergy;
73 fRawData.fTime = tmpChannelPtr->fTime;
74 fRawData.fChannelID = tmpChannelPtr->fChannelID;
75 fRawData.fCrazyness = tmpChannelPtr->fCrazyness;
77 //AliHLTPHOSMapper::ChannelId2Coordinate(const UShort_t channelId, AliHLTPHOSCoordinate &channelCoord)
78 // AliHLTPHOSMapper::ChannelId2Coordinate( fRawData.fChannelID, fRawData.fCoordinate);
80 if( fRawData.fChannelID == fRawDataPtr[0] )
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];
89 UShort_t tmpSamplesLeft = tmpTotSize -4;
91 fRawData.nSamplesUsed = tmpTotSize + tmpStartBin;
93 while(tmpSamplesLeft > 0)
95 for(int i=0; i < tmpBunchtSize; i++ )
97 fRawData.fDataPtr[i + tmpStartBin] = fRawDataPtr[ i+ 4];
101 fRawDataPtr+= tmpTotSize;
106 // cout << __FILE__ << __LINE__ << "ERROR! fRawData.fChannelID = "<< fRawData.fChannelID << " but fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
110 // HLTDebug("Raw data interface not yet implemented, ignoring raw data");
112 return tmpChannelPtr;
124 AliHLTPHOSSharedMemoryInterfacev2::NextRawChannel( )
126 if(fHasRawData == false )
128 cout << __FILE__ << __LINE__<< "ERROR: no raw data present" << endl;
132 for(int i = 0; i < 200 ; i++ )
135 cout << fRawDataPtr[i] << "\t";
146 AliHLTPHOSSharedMemoryInterfacev2::SetMemory(AliHLTPHOSChannelDataHeaderStruct* channelDataHeaderPtr)
148 //Shutting up rule checker
149 fHasRawData = channelDataHeaderPtr->fHasRawData;
150 fMaxCnt = channelDataHeaderPtr->fNChannels;
151 fChannelDataPtr = reinterpret_cast<AliHLTUInt8_t*>(channelDataHeaderPtr) + sizeof(AliHLTPHOSChannelDataHeaderStruct);
154 if(fHasRawData == true)
156 fRawDataPtr = reinterpret_cast< UShort_t* >(channelDataHeaderPtr);
157 int inc = sizeof (AliHLTPHOSChannelDataHeaderStruct) + fMaxCnt*sizeof(AliHLTPHOSChannelDataStruct);
158 fRawDataPtr += inc/sizeof(UShort_t );
166 AliHLTPHOSSharedMemoryInterfacev2::Reset()
168 //Shutting up rule checker
170 fIsSetMemory = false;
176 AliHLTPHOSSharedMemoryInterfacev2::Reset(AliHLTPHOSChannelRawDataStruct &str)
178 for(int i=0; i< 1008; i++ )