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"
29 ClassImp(AliHLTCaloSharedMemoryInterfacev2);
31 AliHLTCaloSharedMemoryInterfacev2::AliHLTCaloSharedMemoryInterfacev2(TString det): AliHLTCaloConstantsHandler(det),
42 // See header file for class documentation
43 for(Int_t i = 0; i < 32; i++)
49 AliHLTCaloSharedMemoryInterfacev2::~AliHLTCaloSharedMemoryInterfacev2()
54 AliHLTCaloChannelDataStruct*
55 AliHLTCaloSharedMemoryInterfacev2::NextChannel()
58 AliHLTCaloChannelDataStruct* tmpChannelPtr = 0;
59 if(fCurrentCnt < fMaxCnt)
61 tmpChannelPtr = reinterpret_cast<AliHLTCaloChannelDataStruct*>(fChannelDataPtr);
63 fChannelDataPtr += sizeof(AliHLTCaloChannelDataStruct);
65 if(fHasRawData == true)
68 fRawData.fEnergy = tmpChannelPtr->fEnergy;
69 fRawData.fTime = tmpChannelPtr->fTime;
70 fRawData.fChannelID = tmpChannelPtr->fChannelID;
71 fRawData.fCrazyness = tmpChannelPtr->fCrazyness;
73 //AliHLTCaloMapper::ChannelId2Coordinate(const UShort_t channelId, AliHLTCaloCoordinate &channelCoord)
76 AliHLTCaloMapper::ChannelId2Coordinate( fRawData.fChannelID, fRawData.fCoordinate);
78 if( fRawData.fChannelID == fRawDataPtr[0] )
81 // cout << __FILE__ << __LINE__ << "fRawData.fChannelID == fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
82 // cout << " copying raw dat not yet implemnted " << endl;
83 UShort_t tmpTotSize = fRawDataPtr[1];
84 UShort_t tmpStartBin = fRawDataPtr[2];
85 UShort_t tmpBunchtSize = fRawDataPtr[3];
87 // UShort_t tmpSamplesLeft = tmpTotSize -4;
88 int tmpSamplesLeft = tmpTotSize -4;
90 fRawData.nSamplesUsed = tmpTotSize + tmpStartBin;
92 if(tmpSamplesLeft > 0 )
94 while(tmpSamplesLeft > 0)
96 for(int i=0; i < tmpBunchtSize; i++ )
98 // fRawData.fDataPtr[i + tmpStartBin] = fRawDataPtr[ i+ 4];
102 fRawDataPtr+= tmpTotSize;
107 // cout << __FILE__ << __LINE__ << "ERROR! fRawData.fChannelID = "<< fRawData.fChannelID << " but fRawDataPtr[0] = " << fRawDataPtr[0] << endl;
111 // HLTDebug("Raw data interface not yet implemented, ignoring raw data");
113 return tmpChannelPtr;
124 AliHLTCaloSharedMemoryInterfacev2::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";
145 //AliHLTCaloSharedMemoryInterfacev2::SetMemory(AliHLTCaloChannelDataHeaderStruct* channelDataHeaderPtr, const unsigned long specification)
146 AliHLTCaloSharedMemoryInterfacev2::SetMemory(AliHLTCaloChannelDataHeaderStruct* channelDataHeaderPtr)
148 // fSpecification = specification;
150 //Shutting up rule checker
151 fHasRawData = channelDataHeaderPtr->fHasRawData;
152 fMaxCnt = channelDataHeaderPtr->fNChannels;
153 fChannelDataPtr = reinterpret_cast<AliHLTUInt8_t*>(channelDataHeaderPtr) + sizeof(AliHLTCaloChannelDataHeaderStruct);
156 if(fHasRawData == true)
158 fRawDataPtr = reinterpret_cast< UShort_t* >(channelDataHeaderPtr);
159 int inc = sizeof (AliHLTCaloChannelDataHeaderStruct) + fMaxCnt*sizeof(AliHLTCaloChannelDataStruct);
160 fRawDataPtr += inc/sizeof(UShort_t );
168 AliHLTCaloSharedMemoryInterfacev2::Reset()
170 //Shutting up rule checker
172 fIsSetMemory = false;