bugfixes for HOMER reader working on data buffer; minor changes in documentation
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTOUTRawReader.cxx
CommitLineData
176d8684 1// $Id$
2
3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
6 * *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
19/** @file AliHLTOUTRawReader.cxx
20 @author Matthias Richter
21 @date
22 @brief HLTOUT data wrapper for AliRawReader. */
23
24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
30#include "AliHLTOUTRawReader.h"
31#include "AliHLTHOMERLibManager.h"
32#include "AliRawReader.h"
33#include "AliHLTHOMERReader.h"
34
35/** ROOT macro for the implementation of ROOT specific class methods */
36ClassImp(AliHLTOUTRawReader)
37
38AliHLTOUTRawReader::AliHLTOUTRawReader(AliRawReader* pRawreader)
39 :
40 AliHLTOUTHomerBuffer(NULL, 0),
41 fpRawreader(pRawreader),
42 fpCurrent(NULL)
43{
44 // see header file for class documentation
45 // or
46 // refer to README to build package
47 // or
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49}
50
51const int AliHLTOUTRawReader::fgkIdShift=16;
52
53AliHLTOUTRawReader::~AliHLTOUTRawReader()
54{
55 // see header file for class documentation
56 if (fpManager) {
57 if (fpCurrent) fpManager->DeleteReader(fpCurrent);
58 fpCurrent=NULL;
59 }
60}
61
62int AliHLTOUTRawReader::GenerateIndex()
63{
64 // see header file for class documentation
65 // step through all HLT ddls, create HOMER reader and
66 // scan data block
67 int iResult=0;
68 if (fpRawreader && fpManager) {
69 fpRawreader->Reset();
70 fpRawreader->Select("HLT");
71 UChar_t* pSrc=NULL;
72 while (fpRawreader->ReadNextData(pSrc) && pSrc!=NULL && iResult>=0) {
73 AliHLTUInt32_t id=(fpRawreader->GetEquipmentId())<<fgkIdShift;
74 int size=fpRawreader->GetDataSize();
75 AliHLTHOMERReader* pReader=fpManager->OpenReader(pSrc, size);
76 if (pReader) {
77 iResult=ScanReader(pReader, id);
78 fpManager->DeleteReader(pReader);
79 }
80 }
81 } else {
82 iResult=-ENODEV;
83 }
84 return iResult;
85}
86
87int AliHLTOUTRawReader::GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer,
88 AliHLTUInt32_t& size)
89{
90 // see header file for class documentation
91 int iResult=0;
92 if (fpManager) {
d76bc02a 93 Int_t id = Int_t(index>>fgkIdShift);
176d8684 94 AliHLTUInt32_t blockNo=index&((0x1<<fgkIdShift)-1);
95
96 // block from the same ddl requested?
97 if (fpCurrent && fpRawreader->GetEquipmentId()!=id) {
98 fpManager->DeleteReader(fpCurrent);
99 fpCurrent=NULL;
100 }
101
102 // open ddl for equipment id and create HOMER reader
103 if (!fpCurrent) {
104 fpRawreader->Reset();
105 fpRawreader->SelectEquipment(-1, id, id);
106 UChar_t* pSrc=NULL;
107 if (fpRawreader->ReadNextData(pSrc) && pSrc!=NULL) {
108 fpCurrent=fpManager->OpenReader(pSrc, size);
109 } else {
110 iResult=-ENOSYS;
111 }
112 }
113
114 // get data
115 if (fpCurrent) {
a183f221 116 AliHLTMonitoringReader* pReader=fpCurrent;
117 if ((pBuffer=static_cast<const AliHLTUInt8_t*>(pReader->GetBlockData(blockNo)))!=NULL) {
118 size=pReader->GetBlockDataLength(blockNo);
176d8684 119 } else {
120 iResult=-ENOENT;
121 }
122 }
123 } else {
124 iResult=-ENODEV;
125 }
126 return iResult;
127}