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
70 AliHLTCaloChannelDataStruct*
71 AliHLTCaloSharedMemoryInterfacev2::NextChannel()
74 AliHLTCaloChannelDataStruct* tmpChannelPtr = 0;
75 if(fCurrentCnt < fMaxCnt)
77 tmpChannelPtr = reinterpret_cast<AliHLTCaloChannelDataStruct*>(fChannelDataPtr);
79 fChannelDataPtr += sizeof(AliHLTCaloChannelDataStruct);
80 if(fHasRawData == true)
82 fRawData.fEnergy = tmpChannelPtr->fEnergy;
83 fRawData.fTime = tmpChannelPtr->fTime;
84 fRawData.fChannelID = tmpChannelPtr->fChannelID;
85 fRawData.fCrazyness = tmpChannelPtr->fCrazyness;
87 //AliHLTCaloMapper::ChannelId2Coordinate(const UShort_t channelId, AliHLTCaloCoordinate &channelCoord)
90 AliHLTCaloMapper::ChannelId2Coordinate( fRawData.fChannelID, fRawData.fCoordinate);
96 if( fRawData.fChannelID == fRawDataPtr[0] )
99 // cout << __FILE__ << __LINE__ << "fRawData.fChannelID == fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
100 // cout << " copying raw dat not yet implemnted " << endl;
101 UShort_t tmpTotSize = fRawDataPtr[1];
102 UShort_t tmpStartBin = fRawDataPtr[2];
103 UShort_t tmpBunchtSize = fRawDataPtr[3];
105 UShort_t tmpSamplesLeft = tmpTotSize -4;
107 fRawData.nSamplesUsed = tmpTotSize + tmpStartBin;
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;
140 AliHLTCaloSharedMemoryInterfacev2::NextRawChannel( )
142 if(fHasRawData == false )
144 cout << __FILE__ << __LINE__<< "ERROR: no raw data present" << endl;
148 for(int i = 0; i < 200 ; i++ )
151 cout << fRawDataPtr[i] << "\t";
162 //AliHLTCaloSharedMemoryInterfacev2::SetMemory(AliHLTCaloChannelDataHeaderStruct* channelDataHeaderPtr, const unsigned long specification)
163 AliHLTCaloSharedMemoryInterfacev2::SetMemory(AliHLTCaloChannelDataHeaderStruct* channelDataHeaderPtr)
165 // fSpecification = specification;
167 //Shutting up rule checker
168 fHasRawData = channelDataHeaderPtr->fHasRawData;
169 fMaxCnt = channelDataHeaderPtr->fNChannels;
170 fChannelDataPtr = reinterpret_cast<AliHLTUInt8_t*>(channelDataHeaderPtr) + sizeof(AliHLTCaloChannelDataHeaderStruct);
173 if(fHasRawData == true)
175 fRawDataPtr = reinterpret_cast< UShort_t* >(channelDataHeaderPtr);
176 int inc = sizeof (AliHLTCaloChannelDataHeaderStruct) + fMaxCnt*sizeof(AliHLTCaloChannelDataStruct);
177 fRawDataPtr += inc/sizeof(UShort_t );
185 AliHLTCaloSharedMemoryInterfacev2::Reset()
187 //Shutting up rule checker
189 fIsSetMemory = false;
195 AliHLTCaloSharedMemoryInterfacev2::Reset(AliHLTCaloChannelRawDataStruct &str)
197 for(int i=0; i< ALTROMAXSAMPLES; i++ )