]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/comp/AliHLTTPCDataCompressionDecoder.cxx
returning the number of clusters extracted from the block and added an optional info...
[u/mrichter/AliRoot.git] / HLT / TPCLib / comp / AliHLTTPCDataCompressionDecoder.cxx
1 // $Id$
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
7 //*                  for The ALICE HLT Project.                            *
8 //*                                                                        *
9 //* Permission to use, copy, modify and distribute this software and its   *
10 //* documentation strictly for non-commercial purposes is hereby granted   *
11 //* without fee, provided that the above copyright notice appears in all   *
12 //* copies and that both the copyright notice and this permission notice   *
13 //* appear in the supporting documentation. The authors make no claims     *
14 //* about the suitability of this software for any purpose. It is          *
15 //* provided "as is" without express or implied warranty.                  *
16 //**************************************************************************
17
18 /// @file   AliHLTTPCDataCompressionDecoder.cxx
19 /// @author Matthias Richter
20 /// @date   2011-10-04
21 /// @brief  Generic decoder class for compressed TPC data, works on a container
22 ///         class implementation which fills the actual target data struct
23
24 #include "AliHLTTPCDataCompressionDecoder.h"
25 #include "AliHLTDataInflaterSimple.h"
26 #include "AliHLTDataInflaterHuffman.h"
27 #include "TList.h"
28 #include <memory>
29
30 ClassImp(AliHLTTPCDataCompressionDecoder)
31
32 AliHLTTPCDataCompressionDecoder::AliHLTTPCDataCompressionDecoder()
33   : fVerbosity(0)
34 {
35   /// constructor
36 }
37
38 AliHLTTPCDataCompressionDecoder::~AliHLTTPCDataCompressionDecoder()
39 {
40   ///destructor
41 }
42
43 AliHLTDataInflater* AliHLTTPCDataCompressionDecoder::CreateInflater(int deflater, int mode) const
44 {
45   // create the inflater for the specified mode
46   vector<AliHLTTPCDefinitions::AliClusterParameterId_t> parameterids;
47   switch (mode) {
48   case 1:
49     parameterids.push_back(AliHLTTPCDefinitions::kPadRow );
50     parameterids.push_back(AliHLTTPCDefinitions::kPad    );
51     parameterids.push_back(AliHLTTPCDefinitions::kTime   );
52     parameterids.push_back(AliHLTTPCDefinitions::kSigmaY2);
53     parameterids.push_back(AliHLTTPCDefinitions::kSigmaZ2);
54     parameterids.push_back(AliHLTTPCDefinitions::kCharge );
55     parameterids.push_back(AliHLTTPCDefinitions::kQMax   );
56     break;
57   case 2:
58     parameterids.push_back(AliHLTTPCDefinitions::kResidualPad );
59     parameterids.push_back(AliHLTTPCDefinitions::kResidualTime);
60     parameterids.push_back(AliHLTTPCDefinitions::kSigmaY2);
61     parameterids.push_back(AliHLTTPCDefinitions::kSigmaZ2);
62     parameterids.push_back(AliHLTTPCDefinitions::kCharge );
63     parameterids.push_back(AliHLTTPCDefinitions::kQMax   );
64     break;
65   default:
66     HLTError("invalid mode %d for inflater initialization", mode);
67   }
68
69   switch (deflater) {
70   case 1:
71     {
72       std::auto_ptr<AliHLTDataInflaterSimple> inflatersimple(new AliHLTDataInflaterSimple);
73       if (!inflatersimple.get()) return NULL;
74       for (vector<AliHLTTPCDefinitions::AliClusterParameterId_t>::const_iterator id=parameterids.begin();
75            id!=parameterids.end(); id++) {
76         const AliHLTTPCDefinitions::AliClusterParameter& parameter=AliHLTTPCDefinitions::fgkClusterParameterDefinitions[*id];
77         if (inflatersimple->AddParameterDefinition(parameter.fName,
78                                                    parameter.fBitLength,
79                                                    parameter.fOptional)<0) {
80           HLTError("error adding parameter definition %s to inflater", parameter.fName);
81           return NULL;
82         }
83       }
84       return inflatersimple.release();
85     }
86     break;
87   case 2:
88     {
89       std::auto_ptr<AliHLTDataInflaterHuffman> inflaterhuffman(new AliHLTDataInflaterHuffman);
90       if (!inflaterhuffman.get()) return NULL;
91       TString cdbPath("HLT/ConfigTPC/TPCDataCompressorHuffmanTables");
92       TObject* pConf=AliHLTMisc::Instance().ExtractObject(AliHLTMisc::Instance().LoadOCDBEntry(cdbPath));
93       if (!pConf) {
94         HLTError("can not load configuration object %s", cdbPath.Data());
95         return NULL;
96       }
97       if (dynamic_cast<TList*>(pConf)==NULL) {
98         HLTError("huffman table configuration object of inconsistent type");
99         return NULL;
100       }
101       inflaterhuffman->InitDecoders(dynamic_cast<TList*>(pConf));
102       for (vector<AliHLTTPCDefinitions::AliClusterParameterId_t>::const_iterator id=parameterids.begin();
103            id!=parameterids.end(); id++) {
104         const AliHLTTPCDefinitions::AliClusterParameter& parameter=AliHLTTPCDefinitions::fgkClusterParameterDefinitions[*id];
105         if (inflaterhuffman->AddParameterDefinition(parameter.fName,
106                                                     parameter.fBitLength)<0) {
107           HLTError("error adding parameter definition %s to inflater", parameter.fName);
108           return NULL;
109         }
110       }
111       return inflaterhuffman.release();
112     }
113     break;
114   default:
115     HLTError("unknown inflater requested %d", deflater);
116   }
117   return NULL;
118 }