2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 //* for The ALICE HLT Project. *
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 //**************************************************************************
18 /// @file AliHLTTPCDataCompressionFilterComponent.cxx
19 /// @author Matthias Richter
21 /// @brief TPC component for data compression
24 #include "AliHLTTPCDataCompressionFilterComponent.h"
25 #include "AliHLTTPCDefinitions.h"
26 #include "AliHLTPluginBase.h"
27 #include "AliHLTSystem.h"
28 #include "AliHLTOUT.h"
31 ClassImp(AliHLTTPCDataCompressionFilterComponent)
33 AliHLTTPCDataCompressionFilterComponent::AliHLTTPCDataCompressionFilterComponent()
38 AliHLTTPCDataCompressionFilterComponent::~AliHLTTPCDataCompressionFilterComponent()
44 const char* AliHLTTPCDataCompressionFilterComponent::GetComponentID()
46 /// inherited from AliHLTComponent: id of the component
47 return "TPCDataCompressorFilter";
51 void AliHLTTPCDataCompressionFilterComponent::GetInputDataTypes( AliHLTComponentDataTypeList& tgtList)
53 /// inherited from AliHLTComponent: list of data types in the vector reference
55 tgtList.push_back(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
56 tgtList.push_back(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
59 AliHLTComponentDataType AliHLTTPCDataCompressionFilterComponent::GetOutputDataType()
61 /// inherited from AliHLTComponent: output data type of the component.
62 return kAliHLTMultipleDataType;
65 int AliHLTTPCDataCompressionFilterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
67 /// inherited from AliHLTComponent: multiple output data types of the component.
69 tgtList.push_back(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
70 tgtList.push_back(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
71 return tgtList.size();
74 void AliHLTTPCDataCompressionFilterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
76 /// inherited from AliHLTComponent: output data size estimator
78 inputMultiplier=1.; // there should not be more data than input
81 AliHLTComponent* AliHLTTPCDataCompressionFilterComponent::Spawn()
83 /// inherited from AliHLTComponent: spawn function.
84 return new AliHLTTPCDataCompressionFilterComponent;
87 int AliHLTTPCDataCompressionFilterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
88 AliHLTComponentTriggerData& /*trigData*/)
90 /// inherited from AliHLTProcessor: data processing
91 if (!IsDataEvent()) return 0;
93 if (GetFirstInputBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType())!=NULL) {
94 // This component is only used in conjunction with an emulation chain for compressed
95 // partition cluster blocks. Blocks which are missing in HLTOUT but are existing in
96 // the data stream from the parent, are forwarded. This scheme allows to automatically
97 // create missing partitions in the compressed data from raw data (e.g. if an input
98 // link of the HLT is broken and raw data recorded), and add it to the HLTOUT to
99 // have a consistent data set. This requires individual cluster data blocks, track
100 // model compression can not be used in the emulation because the clusters can not be
101 // related to a particular partition.
102 AliFatalClass("compressed track cluster data blocks can not be mixed. aborting");
106 std::map<AliHLTUInt32_t, bool> hltoutmap;
109 for (const AliHLTComponentBlockData* pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
110 pDesc!=NULL; pDesc=GetNextInputBlock()) {
112 InitMapFromHLTOUT(hltoutmap);
115 if (hltoutmap.find(pDesc->fSpecification)!=hltoutmap.end()) {
116 // block existing in HLTOUT
120 HLTInfo("inserting block 0x%08x", pDesc->fSpecification);
126 int AliHLTTPCDataCompressionFilterComponent::InitMapFromHLTOUT(std::map<AliHLTUInt32_t, bool>& hltoutmap)
128 // check the HLTOUT for availability of compressed data blocks
129 AliHLTSystem* pSystem=AliHLTPluginBase::GetInstance();
131 // global system not initialized
134 AliHLTOUT* pHLTOUT=pSystem->RequestHLTOUT();
136 // not HLTOUT, hence not clusters
140 for (bool bNextBlock=(pHLTOUT->SelectFirstDataBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType())>=0);
141 bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
142 AliHLTComponentDataType dt=kAliHLTVoidDataType;
143 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
144 if (pHLTOUT->GetDataBlockDescription(dt, spec)<0)
147 hltoutmap[spec]=true;
150 for (bool bNextBlock=(pHLTOUT->SelectFirstDataBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType())>=0);
151 bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
152 // the first version of this component will not implement support for track model compression data blocks
155 // - sort into index grid
156 // - check if there is at least one cluster in a partition, that is a sufficient condition
157 // to decide whether a partition was included or not
158 // The best would be to implement a class which supports the AliHLTTPCDataCompressionDecoder
159 // interface and stores unpacked data in AliHLTTPCRawCluster format and fills the index
160 // grid at the same time
161 AliFatalClass("this functionality needs to be implemented");
167 int AliHLTTPCDataCompressionFilterComponent::DoInit( int argc, const char** argv )
169 /// inherited from AliHLTComponent: component initialisation and argument scan.
172 // component configuration
173 //Stage 1: default initialization.
174 //No default values until now.
176 //Stage 2: OCDB. - disabled
177 //TString cdbPath("HLT/ConfigTPC/");
178 //cdbPath += GetComponentID();
180 //iResult = ConfigureFromCDBTObjString(cdbPath);
184 //Stage 3: command line arguments.
185 if (argc && (iResult = ConfigureFromArgumentString(argc, argv)) < 0)
191 int AliHLTTPCDataCompressionFilterComponent::DoDeinit()
193 /// inherited from AliHLTComponent: component cleanup
199 int AliHLTTPCDataCompressionFilterComponent::ScanConfigurationArgument(int argc, const char** argv)
201 /// inherited from AliHLTComponent: argument scan
203 if (argc<1) return 0;
206 TString argument=argv[i];
210 if (argument.CompareTo("-mode")==0) {
211 if ((bMissingParam=(++i>=argc))) break;
212 TString parameter=argv[i];
213 if (parameter.IsDigit()) {
217 HLTError("invalid parameter for argument %s, expecting number instead of %s", argument.Data(), parameter.Data());
222 } while (0); // using do-while only to have break available
225 HLTError("missing parameter for argument %s", argument.Data());