Line data Source code
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 AliHLTTPCDataCompressionMonitorComponent.cxx
19 : /// @author Matthias Richter
20 : /// @date 2011-09-12
21 : /// @brief TPC component for monitoring of data compression
22 : ///
23 :
24 : #include "AliHLTTPCDataCompressionMonitorComponent.h"
25 : #include "AliHLTTPCDataCompressionComponent.h"
26 : #include "AliHLTTPCDataCompressionDecoder.h"
27 : #include "AliHLTTPCDefinitions.h"
28 : #include "AliHLTTPCHWCFData.h"
29 : #include "AliHLTTPCDefinitions.h"
30 : #include "AliHLTTPCClusterDataFormat.h"
31 : #include "AliHLTTPCRawCluster.h"
32 : #include "AliHLTTPCGeometry.h"
33 : #include "AliHLTTPCTrackGeometry.h"
34 : #include "AliHLTTPCHWCFSpacePointContainer.h"
35 : #include "AliHLTTPCRawSpacePointContainer.h"
36 : #include "AliHLTErrorGuard.h"
37 : #include "AliHLTComponentBenchmark.h"
38 : #include "AliHLTCDHWrapper.h"
39 : #include "AliTPCclusterMI.h"
40 : #include "AliTPCROC.h"
41 : #include "TH1I.h"
42 : #include "TH1F.h"
43 : #include "TH1D.h"
44 : #include "TH2I.h"
45 : #include "TH2F.h"
46 : #include "TH2D.h"
47 : #include "TH3I.h"
48 : #include "TH3F.h"
49 : #include "TH3D.h"
50 : #include "TProfile.h"
51 : #include "TFile.h"
52 : #include "TObjArray.h"
53 : #include "TList.h"
54 : #include <memory>
55 :
56 6 : ClassImp(AliHLTTPCDataCompressionMonitorComponent)
57 :
58 : AliHLTTPCDataCompressionMonitorComponent::AliHLTTPCDataCompressionMonitorComponent()
59 3 : : AliHLTProcessor()
60 3 : , fpBenchmark(NULL)
61 3 : , fpDecoder(NULL)
62 3 : , fpHWClusterDecoder(NULL)
63 3 : , fHistoHWCFDataSize(NULL)
64 3 : , fHistoHWCFReductionFactor(NULL)
65 3 : , fHistoTotalReductionFactor(NULL)
66 3 : , fHistoNofClusters(NULL)
67 3 : , fHistoNofClustersReductionFactor(NULL)
68 3 : , fHistogramFile()
69 3 : , fMonitoringContainer(NULL)
70 3 : , fVerbosity(0)
71 3 : , fFlags(0)
72 3 : , fPublishingMode(kPublishSeparate)
73 15 : {
74 6 : }
75 :
76 : AliHLTTPCDataCompressionMonitorComponent::~AliHLTTPCDataCompressionMonitorComponent()
77 18 : {
78 : /// destructor
79 9 : }
80 :
81 :
82 : const char* AliHLTTPCDataCompressionMonitorComponent::GetComponentID()
83 : {
84 : /// inherited from AliHLTComponent: id of the component
85 420 : return "TPCDataCompressorMonitor";
86 : }
87 :
88 :
89 : void AliHLTTPCDataCompressionMonitorComponent::GetInputDataTypes( AliHLTComponentDataTypeList& tgtList)
90 : {
91 : /// inherited from AliHLTComponent: list of data types in the vector reference
92 0 : tgtList.clear();
93 0 : tgtList.push_back(AliHLTTPCDefinitions::fgkHWClustersDataType);
94 0 : tgtList.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
95 0 : tgtList.push_back(AliHLTTPCDefinitions::fgkRawClustersDataType);
96 0 : tgtList.push_back(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
97 0 : tgtList.push_back(AliHLTTPCDefinitions::ClusterTracksCompressedDataType());
98 0 : tgtList.push_back(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
99 0 : tgtList.push_back(AliHLTTPCDefinitions::ClusterIdTracksDataType());
100 0 : tgtList.push_back(AliHLTTPCDefinitions::ClustersFlagsDataType());
101 0 : }
102 :
103 : AliHLTComponentDataType AliHLTTPCDataCompressionMonitorComponent::GetOutputDataType()
104 : {
105 : /// inherited from AliHLTComponent: output data type of the component.
106 0 : return kAliHLTMultipleDataType;
107 : }
108 :
109 : int AliHLTTPCDataCompressionMonitorComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
110 : {
111 : /// inherited from AliHLTComponent: multiple output data types of the component.
112 0 : tgtList.clear();
113 0 : tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
114 0 : return tgtList.size();
115 : }
116 :
117 : void AliHLTTPCDataCompressionMonitorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
118 : {
119 : /// inherited from AliHLTComponent: output data size estimator
120 0 : constBase=10000000;
121 0 : inputMultiplier=1.0;
122 0 : }
123 :
124 : AliHLTComponent* AliHLTTPCDataCompressionMonitorComponent::Spawn()
125 : {
126 : /// inherited from AliHLTComponent: spawn function.
127 0 : return new AliHLTTPCDataCompressionMonitorComponent;
128 0 : }
129 :
130 : int AliHLTTPCDataCompressionMonitorComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
131 : const AliHLTComponentBlockData* /*inputBlocks*/,
132 : AliHLTComponentTriggerData& /*trigData*/,
133 : AliHLTUInt8_t* /*outputPtr*/,
134 : AliHLTUInt32_t& /*size*/,
135 : AliHLTComponentBlockDataList& /*outputBlocks*/ )
136 : {
137 : /// inherited from AliHLTProcessor: data processing
138 : int iResult=0;
139 :
140 0 : AliHLTUInt32_t eventType=gkAliEventTypeUnknown;
141 0 : if (!IsDataEvent(&eventType)) {
142 0 : if (eventType==gkAliEventTypeEndOfRun && fPublishingMode!=kPublishOff) {
143 0 : iResult=Publish(fPublishingMode);
144 0 : }
145 0 : return iResult;
146 : }
147 :
148 0 : if (GetBenchmarkInstance()) {
149 0 : GetBenchmarkInstance()->StartNewEvent();
150 0 : GetBenchmarkInstance()->Start(0);
151 0 : }
152 :
153 : const AliHLTComponentBlockData* pDesc=NULL;
154 : unsigned rawDataSize=0;
155 : unsigned rawEventSizeFromRCUtrailer=0;
156 : unsigned hwclustersDataSize=0;
157 : unsigned rawclustersDataSize=0;
158 : unsigned nofCompressedClusters=0;
159 : unsigned nofClusters=0;
160 : unsigned compDataSize=0;
161 :
162 : // check size of TPC raw data
163 0 : for (pDesc=GetFirstInputBlock(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC);
164 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
165 0 : fFlags|=kHaveRawData;
166 0 : rawDataSize+=pDesc->fSize;
167 : }
168 :
169 : bool bUseHWCFDataForClusterCalculations=true;
170 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RawClustersDataType());
171 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
172 : // first check the type of input, there has been a change in the input type
173 : // of the compression component in Jun 2013, see below
174 : // use a local variable here, which in general should do the job because
175 : // if there are is data available always HWCF and raw clusters should be
176 : // there is in the configuration. There shouldn't be any difference on
177 : // event basis.
178 0 : if (pDesc->fSize<sizeof(AliHLTTPCRawClusterData)) continue;
179 0 : const AliHLTTPCRawClusterData* clusterData = reinterpret_cast<const AliHLTTPCRawClusterData*>(pDesc->fPtr);
180 0 : if (!clusterData) continue;
181 0 : if (clusterData->fVersion==1) {
182 : bUseHWCFDataForClusterCalculations=false;
183 0 : break;
184 : }
185 0 : }
186 :
187 : // check size of HWCF data and add to the MonitoringContainer
188 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::fgkHWClustersDataType);
189 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
190 0 : fFlags|=kHaveHWClusters;
191 : // FIXME: the decoding can now be handled via the data container
192 0 : AliHLTCDHWrapper header(pDesc->fPtr);
193 0 : if (pDesc->fSize<=header.GetHeaderSize()) continue;
194 0 : if (fpHWClusterDecoder) {
195 0 : hwclustersDataSize+=pDesc->fSize;
196 0 : AliHLTUInt8_t* pData=reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr);
197 0 : pData+=header.GetHeaderSize();
198 0 : if (fpHWClusterDecoder->Init(pData, pDesc->fSize-header.GetHeaderSize())<0 ||
199 0 : (fpHWClusterDecoder->CheckVersion()<0 && (int)(pDesc->fSize-header.GetHeaderSize())>fpHWClusterDecoder->GetRCUTrailerSize())) {
200 0 : HLTError("data block of type %s corrupted: can not decode format",
201 : AliHLTComponent::DataType2Text(pDesc->fDataType).c_str());
202 : } else {
203 0 : if (bUseHWCFDataForClusterCalculations) nofClusters+=fpHWClusterDecoder->GetNumberOfClusters();
204 0 : if (fpHWClusterDecoder->GetRCUTrailer()) {
205 : // first word of the RCU trailer contains the payload size in 32bit words
206 0 : const AliHLTUInt32_t* pRCUTrailer=reinterpret_cast<const AliHLTUInt32_t*>(fpHWClusterDecoder->GetRCUTrailer());
207 0 : AliHLTUInt32_t payloadSize=(*pRCUTrailer)&0x00ffffff;
208 0 : rawEventSizeFromRCUtrailer+=header.GetHeaderSize()
209 0 : + payloadSize*sizeof(AliHLTUInt32_t)
210 0 : + fpHWClusterDecoder->GetRCUTrailerSize();
211 0 : }
212 : }
213 0 : }
214 0 : if (fMonitoringContainer && bUseHWCFDataForClusterCalculations) {
215 0 : fMonitoringContainer->AddRawData(pDesc);
216 : }
217 0 : }
218 :
219 0 : if (fMonitoringContainer && fpDecoder) {
220 0 : if (GetBenchmarkInstance()) {
221 0 : GetBenchmarkInstance()->Start(1);
222 0 : }
223 :
224 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
225 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
226 0 : iResult=fMonitoringContainer->AddClusterIds(pDesc);
227 : }
228 :
229 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::ClusterIdTracksDataType());
230 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
231 0 : iResult=fMonitoringContainer->AddClusterIds(pDesc);
232 : }
233 :
234 : // read data
235 0 : AliHLTTPCDataCompressionDecoder& decoder=*fpDecoder;
236 0 : decoder.Clear();
237 :
238 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::ClustersFlagsDataType());
239 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
240 0 : iResult=decoder.AddClusterFlags(pDesc);
241 : }
242 :
243 0 : if (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RawClustersDescriptorDataType())) {
244 0 : if ((iResult=decoder.AddRawClustersDescriptor(pDesc))<0) {
245 0 : return iResult;
246 : }
247 : }
248 : //CompressionDescriptor should have priority over rawcluster descriptor in case both are present, because this describes the actual compressed data.
249 0 : if (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::DataCompressionDescriptorDataType())) {
250 0 : if ((iResult=decoder.AddCompressionDescriptor(pDesc))<0) {
251 0 : return iResult;
252 : }
253 : }
254 :
255 : bool bHaveRawClusters=false;
256 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RawClustersDataType());
257 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
258 : // Note: until r51411 and v5-01-Rev-03 the compressed cluster format was sent with data
259 : // type {CLUSTRAW,TPC }, the version member indicated the actual type of data
260 : // These data do not include the 0.5 shift in pad position, that's why it has
261 : // to be added in the unpacking. This is a very special case, this data type and
262 : // data version==1 only occured in the early TPC data compression test runs with
263 : // v5-01-Rev-01
264 : // Additional correction 2015-02-26: the input data type of the compression component
265 : // has been changed to raw clusters instead of HWCF clusters on Jun 27 2013 in commit
266 : // 49bdc4660e6b95428c4c1fb9403fc17fad34dc9d. This has implications to the input of the
267 : // monitoring coponent. Raw clusters have now to be used to monitor the differences of
268 : // original and compressed cluster parameters. The case of reading compressed clusters
269 : // with data type {CLUSTRAW,TPC } and version!=1 has been removed as data with
270 : // this format have never been recorded.
271 0 : if (pDesc->fSize<sizeof(AliHLTTPCRawClusterData)) continue;
272 0 : const AliHLTTPCRawClusterData* clusterData = reinterpret_cast<const AliHLTTPCRawClusterData*>(pDesc->fPtr);
273 0 : if (!clusterData) continue;
274 0 : if (clusterData->fVersion==1) {
275 : // compressed clusters without the pad shift
276 : // data type {CLUSTRAW,TPC } with version==1
277 0 : decoder.SetPadShift(0.5);
278 : bHaveRawClusters=true;
279 0 : iResult=decoder.ReadClustersPartition(fMonitoringContainer->BeginRemainingClusterBlock(0, pDesc->fSpecification),
280 0 : reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr),
281 0 : pDesc->fSize,
282 0 : pDesc->fSpecification);
283 0 : if (iResult<0) {
284 0 : HLTError("reading of partition clusters failed with error %d", iResult);
285 : }
286 : } else {
287 0 : rawclustersDataSize+=pDesc->fSize;
288 0 : if (sizeof(AliHLTTPCRawClusterData)+clusterData->fCount*sizeof(AliHLTTPCRawCluster)==pDesc->fSize) {
289 0 : nofClusters+=clusterData->fCount;
290 0 : if (fMonitoringContainer) {
291 0 : fMonitoringContainer->AddRawData(pDesc);
292 0 : }
293 : } else {
294 0 : ALIHLTERRORGUARD(5, "inconsistent data block of raw clusters");
295 : }
296 : }
297 0 : }
298 :
299 0 : decoder.SetPadShift(0.0);
300 :
301 0 : if (!bHaveRawClusters) {
302 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
303 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
304 0 : iResult=decoder.ReadClustersPartition(fMonitoringContainer->BeginRemainingClusterBlock(0, pDesc->fSpecification),
305 0 : reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr),
306 0 : pDesc->fSize,
307 0 : pDesc->fSpecification);
308 0 : if (iResult>=0) {
309 0 : compDataSize+=pDesc->fSize;
310 0 : nofCompressedClusters+=iResult;
311 0 : }
312 : }
313 :
314 0 : for (pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType());
315 0 : pDesc!=NULL; pDesc=GetNextInputBlock()) {
316 0 : iResult=decoder.ReadTrackModelClustersCompressed(fMonitoringContainer->BeginTrackModelClusterBlock(0),
317 0 : reinterpret_cast<AliHLTUInt8_t*>(pDesc->fPtr),
318 0 : pDesc->fSize,
319 0 : pDesc->fSpecification);
320 0 : if (iResult>=0) {
321 0 : compDataSize+=pDesc->fSize;
322 0 : nofCompressedClusters+=iResult;
323 0 : }
324 : }
325 : } else {
326 0 : if (GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType()) ||
327 0 : GetFirstInputBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType())) {
328 0 : ALIHLTERRORGUARD(5, "conflicting data blocks, monitoring histograms already filled from raw cluster data, ignoring blocks of compressed partition and track clusters");
329 0 : }
330 : }
331 0 : if (GetBenchmarkInstance()) {
332 0 : GetBenchmarkInstance()->Stop(1);
333 0 : }
334 :
335 0 : fMonitoringContainer->Clear();
336 0 : }
337 :
338 0 : if ((fFlags&kHaveHWClusters)!=0 && (fFlags&kHaveRawData)!=0) {
339 0 : if (rawDataSize!=rawEventSizeFromRCUtrailer && rawEventSizeFromRCUtrailer>0) {
340 0 : HLTError("got different raw event size from raw data and rcu trailer: raw %d, rcu trailer %d", rawDataSize, rawEventSizeFromRCUtrailer);
341 : }
342 : }
343 0 : if (rawDataSize==0)
344 0 : rawDataSize=rawEventSizeFromRCUtrailer;
345 :
346 : float hwcfratio=0;
347 : float ratio=0;
348 : float totalratio=0;
349 0 : if (nofClusters==0 && nofCompressedClusters>0) {
350 : // no information from original data, skip calculations and print a short message
351 0 : HLTInfo("comp data %d, %d clusters\n", compDataSize, nofCompressedClusters);
352 : } else {
353 : // the monitoring component can now handle both cases of AliHLTTPCDataCompressionComponent input
354 : // 1) HWCF clusters: the original implementation
355 : // 2) RAW clusters: changed in commit 49bdc4660e6b95428c4c1fb9403fc17fad34dc9d Jun 27 2013
356 : // if there are no raw clusters as input we take the HWCF clusters as reference size
357 0 : if (hwclustersDataSize) {hwcfratio=(float)rawDataSize; hwcfratio/=hwclustersDataSize;}
358 0 : if (rawclustersDataSize==0) rawclustersDataSize=hwclustersDataSize;
359 0 : if (compDataSize) {ratio=(float)rawclustersDataSize; ratio/=compDataSize;}
360 0 : if (compDataSize) {totalratio=(float)rawDataSize; totalratio/=compDataSize;}
361 0 : if (fHistoHWCFDataSize) fHistoHWCFDataSize ->Fill(rawDataSize/1024, hwclustersDataSize/1024);
362 0 : if (fHistoHWCFReductionFactor) fHistoHWCFReductionFactor->Fill(rawDataSize/1024, hwcfratio);
363 0 : if (fHistoTotalReductionFactor && nofClusters>0)
364 0 : fHistoTotalReductionFactor->Fill(rawDataSize/1024, totalratio);
365 0 : if (fHistoNofClusters) fHistoNofClusters ->Fill(rawDataSize/1024, nofClusters);
366 0 : if (fHistoNofClustersReductionFactor && nofClusters>0)
367 0 : fHistoNofClustersReductionFactor ->Fill(nofClusters, ratio);
368 0 : HLTInfo("raw data %d, raw/hwcf cluster data %d, comp data %d, ratio %.2f, %d clusters, total compression ratio %.2f\n", rawDataSize, rawclustersDataSize, compDataSize, ratio, nofClusters, totalratio);
369 : }
370 :
371 0 : if (iResult>=0 && fPublishingMode!=kPublishOff) {
372 0 : iResult=Publish(fPublishingMode);
373 0 : }
374 :
375 0 : if (GetBenchmarkInstance()) {
376 0 : GetBenchmarkInstance()->Stop(0);
377 0 : GetBenchmarkInstance()->AddInput(compDataSize);
378 0 : HLTBenchmark("%s", GetBenchmarkInstance()->GetStatistics());
379 0 : }
380 :
381 : return iResult;
382 0 : }
383 :
384 : int AliHLTTPCDataCompressionMonitorComponent::Publish(int mode)
385 : {
386 : /// publish to output
387 : // additional histograms derived from the main ones to publish
388 0 : TObjArray *derivedHistos = new TObjArray();
389 0 : derivedHistos->SetOwner(kTRUE);
390 :
391 : // FIXME: code needs to be optimized, maybe a bit to much new and delete for the
392 : // moment, the data type might need adjustment
393 : int iResult=0;
394 0 : TObjArray* pArray=mode==kPublishArray?(new TObjArray):NULL;
395 0 : TList* pList=mode==kPublishList?(new TList):NULL;
396 0 : if (mode==kPublishSeparate) {
397 0 : if (fHistoHWCFDataSize && fHistoHWCFDataSize->GetEntries()) PushBack(fHistoHWCFDataSize , kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
398 0 : if (fHistoHWCFReductionFactor && fHistoHWCFReductionFactor->GetEntries()) PushBack(fHistoHWCFReductionFactor, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
399 0 : if (fHistoNofClusters && fHistoNofClusters->GetEntries()) PushBack(fHistoNofClusters , kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
400 0 : if (fHistoNofClustersReductionFactor && fHistoNofClusters->GetEntries()) PushBack(fHistoNofClustersReductionFactor, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
401 0 : if (fHistoTotalReductionFactor && fHistoNofClusters->GetEntries()) PushBack(fHistoTotalReductionFactor, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
402 0 : } else if (pList) {
403 0 : if (fHistoHWCFDataSize) pList->Add(fHistoHWCFDataSize->Clone());
404 0 : if (fHistoHWCFReductionFactor) pList->Add(fHistoHWCFReductionFactor->Clone());
405 0 : if (fHistoNofClusters) pList->Add(fHistoNofClusters->Clone());
406 0 : if (fHistoNofClustersReductionFactor) pList->Add(fHistoNofClustersReductionFactor->Clone());
407 0 : if (fHistoTotalReductionFactor) pList->Add(fHistoTotalReductionFactor->Clone());
408 0 : } else if (pArray) {
409 0 : if (fHistoHWCFDataSize) pArray->Add(fHistoHWCFDataSize->Clone());
410 0 : if (fHistoHWCFReductionFactor) pArray->Add(fHistoHWCFReductionFactor->Clone());
411 0 : if (fHistoNofClusters) pArray->Add(fHistoNofClusters->Clone());
412 0 : if (fHistoNofClustersReductionFactor) pArray->Add(fHistoNofClustersReductionFactor->Clone());
413 0 : if (fHistoTotalReductionFactor) pArray->Add(fHistoTotalReductionFactor->Clone());
414 : }
415 :
416 :
417 0 : if (fMonitoringContainer) {
418 : static const char* searchIds[] = {"fHistograms", "fHistograms2D", "fHistograms3D", NULL};
419 : const char** searchId=searchIds;
420 0 : while (*searchId && iResult>=0) {
421 0 : const TObject* o=fMonitoringContainer->FindObject(*searchId);
422 0 : if (o) {
423 0 : const TObjArray* histograms=dynamic_cast<const TObjArray*>(o);
424 0 : if (histograms) {
425 0 : for (int i=0; i<histograms->GetEntriesFast() && iResult>=0; i++) {
426 0 : if (!histograms->At(i)) continue;
427 : ///
428 0 : TString name=histograms->At(i)->GetName();
429 0 : if( (name.CompareTo(fgkHistogramDefinitions2D[kHistogramQMaxSector].fName)==0) ||
430 0 : (name.CompareTo(fgkHistogramDefinitions2D[kHistogramSigmaY2Sector].fName)==0) ||
431 0 : (name.CompareTo(fgkHistogramDefinitions2D[kHistogramSigmaZ2Sector].fName)==0) ){
432 0 : TH2F *h1=(TH2F*)histograms->At(i);
433 0 : TProfile *h2 = (TProfile*)(h1->ProfileX());
434 0 : derivedHistos->Add(h2);
435 0 : }
436 0 : if( name.CompareTo(fgkHistogramDefinitions3D[kHistogramPadrowPadSector].fName)==0) {
437 0 : TH3F *h1=(TH3F*)histograms->At(i);
438 0 : for (int j=1; j<=72; j++) {
439 0 : h1->GetXaxis()->SetRange(j,j);
440 0 : TString histoname = Form("zy_%d",j);
441 0 : TH2F *h2 = (TH2F*)h1->Project3D(histoname.Data());
442 0 : derivedHistos->Add(h2);
443 0 : }
444 0 : }
445 : ///
446 0 : if (mode==kPublishSeparate) {
447 0 : if (histograms->At(i) && ((TH1*)histograms->At(i))->GetEntries())
448 0 : iResult=PushBack(histograms->At(i), kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
449 0 : } else if (pList) {
450 0 : pList->Add(histograms->At(i)->Clone());
451 0 : } else if (pArray) {
452 0 : pArray->Add(histograms->At(i)->Clone());
453 : }
454 0 : }
455 0 : for (int i=0; i<derivedHistos->GetEntriesFast() && iResult>=0; i++) {
456 0 : if (mode==kPublishSeparate) {
457 0 : if (derivedHistos->At(i) && ((TH1*)derivedHistos->At(i))->GetEntries())
458 0 : iResult=PushBack(derivedHistos->At(i), kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
459 0 : } else if (pList) {
460 0 : pList->Add(derivedHistos->At(i)->Clone());
461 0 : } else if (pArray) {
462 0 : pArray->Add(derivedHistos->At(i)->Clone());
463 0 : }
464 : }
465 0 : }
466 0 : } else {
467 0 : HLTError("failed to find object \"%s\"", *searchId);
468 : }
469 0 : searchId++;
470 : }
471 0 : }
472 :
473 0 : if (pArray) {
474 0 : iResult=PushBack(pArray, kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
475 0 : pArray->SetOwner(kTRUE);
476 0 : delete pArray;
477 : pArray=NULL;
478 0 : }
479 0 : if (pList) {
480 0 : iResult=PushBack(pList, kAliHLTDataTypeTObject|kAliHLTDataOriginTPC);
481 0 : pList->SetOwner(kTRUE);
482 0 : delete pList;
483 : pList=NULL;
484 0 : }
485 0 : return iResult;
486 0 : }
487 :
488 : int AliHLTTPCDataCompressionMonitorComponent::DoInit( int argc, const char** argv )
489 : {
490 : /// inherited from AliHLTComponent: component initialisation and argument scan.
491 : int iResult=0;
492 :
493 : // component configuration
494 : //Stage 1: default initialization.
495 : //Default values.
496 0 : fFlags=0;
497 :
498 : //Stage 2: OCDB.
499 0 : TString cdbPath("HLT/ConfigTPC/");
500 0 : cdbPath += GetComponentID();
501 : //
502 : // iResult = ConfigureFromCDBTObjString(cdbPath);
503 : // if (iResult < 0)
504 : // return iResult;
505 :
506 : //Stage 3: command line arguments.
507 0 : if (argc && (iResult = ConfigureFromArgumentString(argc, argv)) < 0)
508 0 : return iResult;
509 :
510 0 : std::auto_ptr<AliHLTTPCHWCFData> hwClusterDecoder(new AliHLTTPCHWCFData);
511 0 : std::auto_ptr<AliDataContainer> dataContainer(new AliDataContainer);
512 :
513 0 : std::auto_ptr<TH2I> histoHWCFDataSize(new TH2I("HWCFDataSize",
514 : "HW ClusterFinder Size",
515 : 100, 0., 80000., 100, 0., 80000.));
516 0 : if (histoHWCFDataSize.get()) {
517 0 : TAxis* xaxis=histoHWCFDataSize->GetXaxis();
518 0 : if (xaxis) xaxis->SetTitle("raw data size [kB]");
519 0 : TAxis* yaxis=histoHWCFDataSize->GetYaxis();
520 0 : if (yaxis) yaxis->SetTitle("compressed data size [kb]");
521 0 : }
522 :
523 0 : std::auto_ptr<TH2I> histoHWCFReductionFactor(new TH2I("HWCFReductionFactor",
524 : "Data reduction HW ClusterFinder vs. raw data size",
525 : 100, 0., 80000., 30, 0., 3.));
526 0 : if (histoHWCFReductionFactor.get()) {
527 0 : TAxis* xaxis=histoHWCFReductionFactor->GetXaxis();
528 0 : if (xaxis) xaxis->SetTitle("raw data size [kB]");
529 0 : TAxis* yaxis=histoHWCFReductionFactor->GetYaxis();
530 0 : if (yaxis) yaxis->SetTitle("reduction factor");
531 0 : }
532 :
533 0 : std::auto_ptr<TH2I> histoTotalReductionFactor(new TH2I("TotalReductionFactor",
534 : "Total reduction Factor vs. raw data size",
535 : 100, 0., 80000., 100, 0., 10.));
536 0 : if (histoTotalReductionFactor.get()) {
537 0 : TAxis* xaxis=histoTotalReductionFactor->GetXaxis();
538 0 : if (xaxis) xaxis->SetTitle("raw data size [kB]");
539 0 : TAxis* yaxis=histoTotalReductionFactor->GetYaxis();
540 0 : if (yaxis) yaxis->SetTitle("reduction factor");
541 0 : }
542 :
543 0 : std::auto_ptr<TH2I> histoNofClusters(new TH2I("NofClusters",
544 : "Number of HLT TPC clusters",
545 : 100, 0., 80000., 500, 0., 3000000.));
546 0 : if (histoNofClusters.get()) {
547 0 : TAxis* xaxis=histoNofClusters->GetXaxis();
548 0 : if (xaxis) xaxis->SetTitle("raw data size [kB]");
549 0 : TAxis* yaxis=histoNofClusters->GetYaxis();
550 0 : if (yaxis) yaxis->SetTitle("N. of clusters");
551 0 : }
552 :
553 0 : std::auto_ptr<TH2I> histoNofClustersReductionFactor(new TH2I("ReductionFactorVsNofClusters",
554 : "Reduction Factor vs. Number of HLT TPC clusters",
555 : 500, 0., 3000000., 100, 0., 10.));
556 0 : if (histoNofClustersReductionFactor.get()) {
557 0 : TAxis* xaxis=histoNofClustersReductionFactor->GetXaxis();
558 0 : if (xaxis) xaxis->SetTitle("N. of clusters");
559 0 : TAxis* yaxis=histoNofClustersReductionFactor->GetYaxis();
560 0 : if (yaxis) yaxis->SetTitle("reduction factor");
561 0 : }
562 :
563 0 : std::auto_ptr<AliHLTComponentBenchmark> benchmark(new AliHLTComponentBenchmark);
564 0 : if (benchmark.get()) {
565 0 : benchmark->SetTimer(0,"total");
566 0 : benchmark->SetTimer(1,"clusterdecoding");
567 : } else {
568 0 : return -ENOMEM;
569 : }
570 :
571 0 : auto_ptr<AliHLTTPCDataCompressionDecoder> decoder(new AliHLTTPCDataCompressionDecoder);
572 0 : if (!decoder.get()) {
573 0 : return -ENOMEM;
574 : }
575 :
576 :
577 0 : fHistoHWCFDataSize=histoHWCFDataSize.release();
578 0 : fHistoHWCFReductionFactor=histoHWCFReductionFactor.release();
579 0 : fHistoTotalReductionFactor=histoTotalReductionFactor.release();
580 0 : fHistoNofClusters=histoNofClusters.release();
581 0 : fHistoNofClustersReductionFactor=histoNofClustersReductionFactor.release();
582 :
583 0 : fpHWClusterDecoder=hwClusterDecoder.release();
584 0 : fMonitoringContainer=dataContainer.release();
585 0 : fpBenchmark=benchmark.release();
586 0 : fpDecoder=decoder.release();
587 :
588 0 : return iResult;
589 0 : }
590 :
591 : int AliHLTTPCDataCompressionMonitorComponent::DoDeinit()
592 : {
593 : /// inherited from AliHLTComponent: component cleanup
594 : int iResult=0;
595 :
596 0 : if (fpBenchmark) delete fpBenchmark; fpBenchmark=NULL;
597 0 : if (fpDecoder) delete fpDecoder;
598 0 : fpDecoder=NULL;
599 0 : if (fpHWClusterDecoder) delete fpHWClusterDecoder;
600 0 : fpHWClusterDecoder=NULL;
601 :
602 0 : if (!fHistogramFile.IsNull()) {
603 0 : TFile out(fHistogramFile, "RECREATE");
604 0 : if (!out.IsZombie()) {
605 0 : out.cd();
606 0 : if (fHistoHWCFDataSize) fHistoHWCFDataSize->Write();
607 0 : if (fHistoHWCFReductionFactor) fHistoHWCFReductionFactor->Write();
608 0 : if (fHistoTotalReductionFactor) fHistoTotalReductionFactor->Write();
609 0 : if (fHistoNofClusters) fHistoNofClusters->Write();
610 0 : if (fHistoNofClustersReductionFactor) fHistoNofClustersReductionFactor->Write();
611 0 : if (fMonitoringContainer) {
612 0 : const TObject* o1=fMonitoringContainer->FindObject("fHistograms");
613 0 : const TObject* o2=fMonitoringContainer->FindObject("fHistograms2D");
614 0 : const TObject* o3=fMonitoringContainer->FindObject("fHistograms3D");
615 0 : if (o1) o1->Write();
616 0 : if (o2) o2->Write();
617 0 : if (o3) o3->Write();
618 0 : }
619 0 : out.Close();
620 : }
621 0 : }
622 0 : if (fHistoHWCFDataSize) delete fHistoHWCFDataSize;
623 0 : fHistoHWCFDataSize=NULL;
624 0 : if (fHistoHWCFReductionFactor) delete fHistoHWCFReductionFactor;
625 0 : fHistoHWCFReductionFactor=NULL;
626 0 : if (fHistoTotalReductionFactor) delete fHistoTotalReductionFactor;
627 0 : fHistoTotalReductionFactor=NULL;
628 0 : if (fHistoNofClusters) delete fHistoNofClusters;
629 0 : fHistoNofClusters=NULL;
630 0 : if (fHistoNofClustersReductionFactor) delete fHistoNofClustersReductionFactor;
631 0 : fHistoNofClustersReductionFactor=NULL;
632 0 : if (fMonitoringContainer) {
633 0 : fMonitoringContainer->Clear();
634 0 : delete fMonitoringContainer;
635 : }
636 0 : fMonitoringContainer=NULL;
637 :
638 :
639 0 : return iResult;
640 0 : }
641 :
642 : int AliHLTTPCDataCompressionMonitorComponent::ScanConfigurationArgument(int argc, const char** argv)
643 : {
644 : /// inherited from AliHLTComponent: argument scan
645 : int iResult=0;
646 0 : if (argc<1) return 0;
647 : int bMissingParam=0;
648 : int i=0;
649 0 : TString argument=argv[i];
650 :
651 : do {
652 : // -histogram-file
653 0 : if (argument.CompareTo("-histogram-file")==0) {
654 0 : if ((bMissingParam=(++i>=argc))) break;
655 0 : fHistogramFile=argv[i++];
656 0 : return i;
657 : }
658 : // -publishing-mode
659 0 : if (argument.CompareTo("-publishing-mode")==0) {
660 0 : if ((bMissingParam=(++i>=argc))) break;
661 0 : TString option=argv[i++];
662 0 : if (option.CompareTo("off")==0) fPublishingMode=kPublishOff ;
663 0 : else if (option.CompareTo("separate")==0) fPublishingMode=kPublishSeparate;
664 0 : else if (option.CompareTo("list")==0) fPublishingMode=kPublishList ;
665 0 : else if (option.CompareTo("array")==0) fPublishingMode=kPublishArray ;
666 : else {
667 0 : HLTError("invalid option \"%s\" for argument \"%s\", expecting 'off', 'separate', 'list', or 'array'", option.Data(), argument.Data());
668 0 : return -EPROTO;
669 : }
670 0 : return i;
671 0 : }
672 : } while (0); // using do-while only to have break available
673 :
674 0 : if (bMissingParam) {
675 0 : HLTError("missing parameter for argument %s", argument.Data());
676 : iResult=-EPROTO;
677 0 : }
678 :
679 0 : return iResult;
680 0 : }
681 :
682 0 : AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::AliDataContainer()
683 0 : : fHistograms(new TObjArray)
684 0 : , fHistograms2D(new TObjArray)
685 0 : , fHistograms3D(new TObjArray)
686 0 : , fHistogramPointers()
687 0 : , fHistogram2DPointers()
688 0 : , fHistogram3DPointers()
689 0 : , fRemainingClusterIds()
690 0 : , fTrackModelClusterIds()
691 0 : , fCurrentClusterIds(NULL)
692 0 : , fRawData(NULL)
693 0 : , fCurrentCluster()
694 0 : , fSector(-1)
695 0 : , fBegin()
696 0 : , fMaxSigmaY2Scaled((0x1<<AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaY2].fBitLength)-1)
697 0 : , fMaxSigmaZ2Scaled((0x1<<AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaZ2].fBitLength)-1)
698 0 : {
699 : /// constructor
700 0 : memset(&fCurrentCluster, 0, sizeof(AliHLTTPCRawCluster));
701 0 : if (fHistograms) {
702 0 : fHistograms->SetOwner(kTRUE);
703 0 : fHistogramPointers.resize(kNumberOfHistograms, NULL);
704 0 : for (const AliHistogramDefinition* definition=fgkHistogramDefinitions;
705 0 : definition->fName!=NULL; definition++) {
706 0 : fHistogramPointers[definition->fId]=new TH1D(definition->fName,
707 0 : definition->fTitle,
708 0 : definition->fBins,
709 0 : definition->fLowerBound,
710 0 : definition->fUpperBound
711 : );
712 0 : if (fHistogramPointers[definition->fId]) {
713 0 : fHistogramPointers[definition->fId]->SetOption(definition->fDrawOptions);
714 0 : fHistograms->AddAt(fHistogramPointers[definition->fId], definition->fId);
715 : }
716 : }
717 0 : }
718 : ///
719 0 : if (fHistograms2D) {
720 0 : fHistograms2D->SetOwner(kTRUE);
721 0 : fHistogram2DPointers.resize(kNumberOfHistograms2D, NULL);
722 0 : for (const AliHistogramDefinition2D* definition=fgkHistogramDefinitions2D;
723 0 : definition->fName!=NULL; definition++) {
724 0 : fHistogram2DPointers[definition->fId]=new TH2D(definition->fName,
725 0 : definition->fTitle,
726 0 : definition->fBinsX,
727 0 : definition->fLowerBoundX,
728 0 : definition->fUpperBoundX,
729 0 : definition->fBinsY,
730 0 : definition->fLowerBoundY,
731 0 : definition->fUpperBoundY
732 : );
733 0 : if (fHistogram2DPointers[definition->fId]) {
734 0 : fHistogram2DPointers[definition->fId]->SetOption(definition->fDrawOptions);
735 0 : fHistograms2D->AddAt(fHistogram2DPointers[definition->fId], definition->fId);
736 : }
737 : }
738 0 : }
739 : ///
740 0 : if (fHistograms3D) {
741 0 : fHistograms3D->SetOwner(kTRUE);
742 0 : fHistogram3DPointers.resize(kNumberOfHistograms3D, NULL);
743 0 : for (const AliHistogramDefinition3D* definition=fgkHistogramDefinitions3D;
744 0 : definition->fName!=NULL; definition++) {
745 0 : fHistogram3DPointers[definition->fId]=new TH3D(definition->fName,
746 0 : definition->fTitle,
747 0 : definition->fBinsX,
748 0 : definition->fLowerBoundX,
749 0 : definition->fUpperBoundX,
750 0 : definition->fBinsY,
751 0 : definition->fLowerBoundY,
752 0 : definition->fUpperBoundY,
753 0 : definition->fBinsZ,
754 0 : definition->fLowerBoundZ,
755 0 : definition->fUpperBoundZ
756 : );
757 0 : if (fHistogram3DPointers[definition->fId]) {
758 0 : fHistogram3DPointers[definition->fId]->SetOption(definition->fDrawOptions);
759 0 : fHistograms3D->AddAt(fHistogram3DPointers[definition->fId], definition->fId);
760 : }
761 : }
762 0 : }
763 :
764 0 : }
765 :
766 : const AliHLTTPCDataCompressionMonitorComponent::AliHistogramDefinition AliHLTTPCDataCompressionMonitorComponent::fgkHistogramDefinitions[] = {
767 : {kHistogramPadrow, "padrow" , "padrow; padrow; counts" , 160, 0., 160., ""},
768 : {kHistogramHWCFPad, "hwcfpad" , "hwcfpad; pad; counts" , 280, 0., 140., ""},
769 : {kHistogramPad, "pad" , "pad; pad; counts" , 280, 0., 140., ""},
770 : {kHistogramTime, "timebin" , "timebin; time; counts" , 1024, 0., 1024., ""},
771 : {kHistogramSigmaY2, "sigmaY2" , "sigmaY2; #sigma_{Y}^{2}; counts" , 100, 0., 1., ""},
772 : {kHistogramSigmaZ2, "sigmaZ2" , "sigmaZ2; #sigma_{Z}^{2}; counts" , 100, 0., 1., ""},
773 : {kHistogramCharge, "charge" , "charge; charge; counts" , 1024, 0., 65536., ""},
774 : {kHistogramQMax, "qmax" , "qmax; Q_{max}; counts" , 128, 0., 1024., ""},
775 : {kHistogramDeltaPadrow, "d_padrow" , "d_padrow; #Delta padrow; counts" , 1000, -1., 1., ""},
776 : {kHistogramDeltaPad, "d_pad" , "d_pad; #Delta pad; counts" , 1000, -1., 1., ""},
777 : {kHistogramDeltaTime, "d_time" , "d_time; #Delta time; counts" , 1000, -1., 1., ""},
778 : {kHistogramDeltaSigmaY2, "d_sigmaY2", "d_sigmaY2; #Delta #sigma_{Y}^{2}; counts", 1000, -1., 1., ""},
779 : {kHistogramDeltaSigmaZ2, "d_sigmaZ2", "d_sigmaZ2; #Delta #sigma_{Z}^{2}; counts", 1000, -1., 1., ""},
780 : {kHistogramDeltaCharge, "d_charge" , "d_charge; #Delta charge" , 1000, -1., 1., ""},
781 : {kHistogramDeltaQMax, "d_qmax" , "d_qmax; #Delta Q_{max}" , 1000, -1., 1., ""},
782 : {kHistogramOutOfRange, "ResError" , "Residual Error; padrow; counts" , 159, 0., 159., ""},
783 : {kNumberOfHistograms, NULL, NULL, 0,0.,0., NULL}
784 : };
785 :
786 : const AliHLTTPCDataCompressionMonitorComponent::AliHistogramDefinition2D AliHLTTPCDataCompressionMonitorComponent::fgkHistogramDefinitions2D[] = {
787 : {kHistogramQMaxSector, "qmaxsector" , "qmaxsector; sector; Q_{max}" , 72, 0., 72., 1024, 0., 1024., "colz"},
788 : {kHistogramSigmaY2Sector, "sigmaY2sector", "sigmaY2sector; sector; #sigma_{Y}^{2}" , 72, 0., 72., 100, 0., 1., "colz"},
789 : {kHistogramSigmaZ2Sector, "sigmaZ2sector", "sigmaZ2sector; sector; #sigma_{Z}^{2}" , 72, 0., 72., 100, 0., 1., "colz"},
790 : {kHistogramXYA, "XYA", "XY - A side; X[cm]; Y[cm]" , 100,-300., 300., 100,-300., 300., "colz"},
791 : {kHistogramXYC, "XYC", "XY - C side; X[cm]; Y[cm]" , 100,-300., 300., 100,-300., 300., "colz"},
792 : {kNumberOfHistograms2D, NULL, NULL, 0,0.,0., 0,0.,0., NULL}
793 : };
794 :
795 : const AliHLTTPCDataCompressionMonitorComponent::AliHistogramDefinition3D AliHLTTPCDataCompressionMonitorComponent::fgkHistogramDefinitions3D[] = {
796 : {kHistogramPadrowPadSector,"padrowpadsector","padrowpadsector; sector; pad;padrow", 72,0.,72., 140,0.,140., 159,0.,159., ""},
797 : {kNumberOfHistograms3D, NULL, NULL, 0,0.,0., 0,0.,0., 0,0.,0., NULL}
798 : };
799 :
800 : AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::~AliDataContainer()
801 0 : {
802 : /// dectructor
803 0 : if (fRawData) delete fRawData;
804 0 : if (fHistograms) delete fHistograms;
805 0 : if (fHistograms2D) delete fHistograms2D;
806 0 : if (fHistograms3D) delete fHistograms3D;
807 0 : }
808 :
809 : AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::iterator& AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::BeginPartitionClusterBlock(int /*count*/, AliHLTUInt32_t specification)
810 : {
811 : /// iterator of remaining clusters block of specification
812 0 : AliHLTUInt8_t slice=AliHLTTPCDefinitions::GetMinSliceNr(specification);
813 0 : AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(specification);
814 0 : unsigned index=slice*AliHLTTPCGeometry::GetNumberOfPatches()+partition;
815 0 : if (index<fRemainingClusterIds.size())
816 0 : fCurrentClusterIds=&fRemainingClusterIds[index];
817 : else
818 0 : fCurrentClusterIds=NULL;
819 0 : fBegin=iterator(this);
820 0 : return fBegin;
821 : }
822 :
823 : AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::iterator& AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::BeginTrackModelClusterBlock(int /*count*/)
824 : {
825 : /// iterator of track model clusters
826 0 : if (fTrackModelClusterIds.fIds && fTrackModelClusterIds.fSize>0)
827 0 : fCurrentClusterIds=&fTrackModelClusterIds;
828 : else
829 0 : fCurrentClusterIds=NULL;
830 0 : fBegin=iterator(this);
831 0 : return fBegin;
832 : }
833 :
834 : int AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::AddRawData(const AliHLTComponentBlockData* pDesc)
835 : {
836 : /// add raw data block
837 : int iResult=0;
838 : AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pSpacePointGrid=NULL;
839 0 : if (!fRawData && pDesc->fDataType==AliHLTTPCDefinitions::HWClustersDataType()) {
840 0 : fRawData=new AliHLTTPCHWCFSpacePointContainer(AliHLTTPCHWCFSpacePointContainer::kModeCreateMap);
841 0 : pSpacePointGrid=AliHLTTPCHWCFSpacePointContainer::AllocateIndexGrid();
842 0 : } else if (!fRawData && pDesc->fDataType==AliHLTTPCDefinitions::RawClustersDataType()) {
843 0 : fRawData=new AliHLTTPCRawSpacePointContainer(AliHLTTPCRawSpacePointContainer::kModeCreateMap);
844 0 : pSpacePointGrid=AliHLTTPCRawSpacePointContainer::AllocateIndexGrid();
845 0 : }
846 : {
847 0 : if (!fRawData) return -ENOMEM;
848 0 : if ((iResult=fRawData->AddInputBlock(pDesc))<0) return iResult;
849 0 : if (pSpacePointGrid) {
850 0 : fRawData->PopulateAccessGrid(pSpacePointGrid, pDesc->fSpecification);
851 0 : fRawData->SetSpacePointPropertyGrid(pDesc->fSpecification, pSpacePointGrid);
852 0 : }
853 0 : return 0;
854 : }
855 : return -ENODATA;
856 0 : }
857 :
858 : int AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::AddClusterIds(const AliHLTComponentBlockData* pDesc)
859 : {
860 : /// add cluster id block for remaining or track model clusters
861 0 : if (!pDesc) return -EINVAL;
862 0 : if (pDesc->fDataType==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
863 0 : fTrackModelClusterIds.fIds=reinterpret_cast<AliHLTUInt32_t*>(pDesc->fPtr);
864 0 : fTrackModelClusterIds.fSize=pDesc->fSize/sizeof(AliHLTUInt32_t);
865 0 : return 0;
866 : }
867 0 : if (pDesc->fDataType==AliHLTTPCDefinitions::RemainingClusterIdsDataType()) {
868 0 : AliHLTUInt8_t slice=AliHLTTPCDefinitions::GetMinSliceNr(pDesc->fSpecification);
869 0 : AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(pDesc->fSpecification);
870 0 : unsigned index=slice*AliHLTTPCGeometry::GetNumberOfPatches()+partition;
871 0 : if (fRemainingClusterIds.size()<=index) {
872 0 : if ((int)fRemainingClusterIds.size()<AliHLTTPCGeometry::GetNSlice()*AliHLTTPCGeometry::GetNumberOfPatches()) {
873 0 : fRemainingClusterIds.resize(AliHLTTPCGeometry::GetNSlice()*AliHLTTPCGeometry::GetNumberOfPatches());
874 0 : } else {
875 0 : fRemainingClusterIds.resize(index+1);
876 : }
877 : }
878 0 : fRemainingClusterIds[index].fIds=reinterpret_cast<AliHLTUInt32_t*>(pDesc->fPtr);
879 0 : fRemainingClusterIds[index].fSize=pDesc->fSize/sizeof(AliHLTUInt32_t);
880 : return 0;
881 : }
882 0 : return -ENODATA;
883 0 : }
884 :
885 : AliHLTUInt32_t AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::GetClusterId(int clusterNo) const
886 : {
887 : /// get the cluster id from the current cluster id block (optional)
888 0 : if (!fCurrentClusterIds ||
889 0 : clusterNo<0 ||
890 0 : (int)fCurrentClusterIds->fSize<=clusterNo)
891 0 : return kAliHLTVoidDataSpec;
892 0 : return fCurrentClusterIds->fIds[clusterNo];
893 0 : }
894 :
895 : AliHLTUInt32_t AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FindNearestCluster(int slice, int partition, const AliHLTTPCRawCluster& cluster) const
896 : {
897 : /// get the cluster id of the nearest original cluster
898 0 : if (!fRawData) return kAliHLTVoidDataSpec;
899 0 : AliHLTUInt32_t key=AliHLTTPCDefinitions::EncodeDataSpecification(slice, slice, partition, partition);
900 : // FIXME: AliHLTIndexGrid::Index is not declared const
901 0 : AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pGrid=const_cast<AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid*>(GetClusterSpacePointPropertyGrid(key));
902 0 : if (!pGrid) return kAliHLTVoidDataSpec;
903 : AliHLTUInt32_t clusterId=kAliHLTVoidDataSpec;
904 : // search a 4x4 matrix out of the 9x9 matrix around the cell addressed by
905 : // pad and time
906 0 : float padrow=(float)cluster.GetPadRow()-AliHLTTPCGeometry::GetFirstRow(partition);
907 0 : float pad=cluster.GetPad();
908 0 : float time=cluster.GetTime();
909 : float minr2=-1.;
910 0 : const float padpitch=AliHLTTPCGeometry::GetPadPitchWidth(partition);
911 0 : const float zwidth=AliHLTTPCGeometry::GetZWidth();
912 0 : float maxDeltaPad=AliHLTTPCDefinitions::GetMaxClusterDeltaPad();
913 0 : float maxDeltaTime=AliHLTTPCDefinitions::GetMaxClusterDeltaTime();
914 0 : int rowindex=pGrid->GetXIndex(padrow);
915 0 : int padstartindex=pGrid->GetYIndex(pad);
916 0 : int timestartindex=pGrid->GetZIndex(time);
917 0 : int cellindex=pGrid->Index(rowindex, padstartindex, timestartindex);
918 0 : float centerpad=pGrid->GetCenterY(cellindex);
919 0 : float centertime=pGrid->GetCenterZ(cellindex);
920 0 : if ((TMath::Abs(centerpad-pad)>maxDeltaPad && pad>0.) ||
921 0 : (TMath::Abs(centertime-time)>maxDeltaTime && time>0.)) {
922 0 : ALIHLTERRORGUARD(20, "invalid pad center calculation, please check dimensions if dimensions of index grid match the maximum possible deviation");
923 0 : }
924 :
925 : int paddirection=1;
926 : int timedirection=1;
927 0 : if (centerpad>pad) paddirection=-1;
928 0 : if (centertime>time) timedirection=-1;
929 0 : for (int padcount=0, padindex=padstartindex; padcount<2; padcount++, padindex+=paddirection) {
930 0 : if (padindex<0) continue;
931 0 : if (padindex>=pGrid->GetDimensionY()) break;
932 0 : for (int timecount=0, timeindex=timestartindex; timecount<2; timecount++, timeindex+=timedirection) {
933 0 : if (timeindex<0) continue;
934 0 : if (timeindex>=pGrid->GetDimensionZ()) break;
935 0 : cellindex=pGrid->Index(rowindex, padindex, timeindex);
936 0 : float cellpad=pGrid->GetCenterY(cellindex);
937 0 : float celltime=pGrid->GetCenterZ(cellindex);
938 0 : for (AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid::iterator& cl=pGrid->begin((float)padrow, cellpad, celltime);
939 0 : cl!=pGrid->end(); cl++) {
940 0 : if (cl.Data().fTrackId>=0) continue;
941 0 : if (GetClusterCharge(cl.Data().fId)!=cluster.GetCharge() ||
942 0 : GetClusterQMax(cl.Data().fId)!=cluster.GetQMax()) continue;
943 0 : if (TMath::Abs(padrow-GetClusterX(cl.Data().fId))>=1.) {
944 0 : HLTError("slice %d, partition %d, cluster 0x%08x: mismatch on padrow: %f vs. cluster %f", slice, partition, cl.Data().fId, padrow, GetClusterX(cl.Data().fId));
945 : continue;
946 : }
947 0 : float clusterpad=GetClusterY(cl.Data().fId);
948 0 : float clustertime=GetClusterZ(cl.Data().fId);
949 0 : clusterpad-=pad;
950 0 : clusterpad*=padpitch;
951 0 : clustertime-=time;
952 0 : clustertime*=zwidth;
953 0 : float r2=clusterpad*clusterpad+clustertime*clustertime;
954 0 : if (minr2<0. || r2<minr2) {
955 0 : clusterId=cl.Data().fId;
956 0 : cl.Data().fTrackId=1;
957 : minr2=r2;
958 0 : }
959 0 : }
960 0 : }
961 0 : }
962 : return clusterId;
963 0 : }
964 :
965 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillPadRow(int row, int slice, AliHLTUInt32_t /*clusterId*/)
966 : {
967 : /// fill padrow histogram
968 : unsigned index=kHistogramPadrow;
969 0 : fCurrentCluster.SetPadRow(row);
970 : // the inner sectors consist of readout partitions 0 and 1, if the row
971 : // is smaller than first row of readout partition 2, its an inner sector
972 0 : if (row<AliHLTTPCGeometry::GetFirstRow(2)) {
973 0 : fSector = slice;
974 0 : } else {
975 0 : fSector = slice+AliHLTTPCGeometry::GetNSlice();
976 : }
977 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
978 0 : fHistogramPointers[index]->Fill(row);
979 0 : }
980 :
981 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillPad(float pad, AliHLTUInt32_t /*clusterId*/)
982 : {
983 : /// fill pad histogram
984 0 : fCurrentCluster.SetPad(pad);
985 0 : int currentRow=fCurrentCluster.GetPadRow();
986 : unsigned index=kHistogramPad;
987 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
988 0 : fHistogramPointers[index]->Fill(pad);
989 :
990 : index=kHistogramPadrowPadSector;
991 0 : if (index<fHistogram3DPointers.size() && fHistogram3DPointers[index]!=NULL)
992 0 : fHistogram3DPointers[index]->Fill(fSector,pad,currentRow);
993 :
994 0 : AliTPCROC *roc=AliTPCROC::Instance();
995 0 : if (roc) {
996 0 : Float_t pos[3]={0.,0.,0.};
997 0 : roc->GetPositionGlobal(fSector, fSector>35?currentRow-63:currentRow, (int)pad, pos);
998 0 : if (fSector<=17 || (fSector>=36&&fSector<=53))
999 : //Sectors 0 to 17 and 36 to 53 are on the A side, sectors 18 to 35 and 54 to 71 are on the C side.
1000 : {
1001 : index=kHistogramXYA;
1002 0 : if (index<fHistogram2DPointers.size() && fHistogram2DPointers[index]!=NULL)
1003 0 : fHistogram2DPointers[index]->Fill(pos[0],pos[1]);
1004 : } else {
1005 : index=kHistogramXYC;
1006 0 : if (index<fHistogram2DPointers.size() && fHistogram2DPointers[index]!=NULL)
1007 0 : fHistogram2DPointers[index]->Fill(pos[0],pos[1]);
1008 : }
1009 0 : }
1010 :
1011 0 : }
1012 :
1013 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillTime(float time, AliHLTUInt32_t /*clusterId*/)
1014 : {
1015 : /// fill pad histogram
1016 0 : fCurrentCluster.SetTime(time);
1017 : unsigned index=kHistogramTime;
1018 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
1019 0 : fHistogramPointers[index]->Fill(time);
1020 0 : }
1021 :
1022 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillSigmaY2(float sigmaY2, AliHLTUInt32_t /*clusterId*/, int partition)
1023 : {
1024 : /// fill sigmaY2 histogram
1025 0 : fCurrentCluster.SetSigmaPad2(sigmaY2);
1026 : unsigned index=kHistogramSigmaY2;
1027 : /// take account for different pad widths
1028 0 : float weight=AliHLTTPCGeometry::GetPadPitchWidth(partition);
1029 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
1030 0 : fHistogramPointers[index]->Fill(sigmaY2*weight*weight);
1031 :
1032 : index=kHistogramSigmaY2Sector;
1033 0 : if (index<fHistogram2DPointers.size() && fHistogram2DPointers[index]!=NULL)
1034 0 : fHistogram2DPointers[index]->Fill(fSector,sigmaY2*weight*weight);
1035 :
1036 0 : }
1037 :
1038 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillSigmaZ2(float sigmaZ2, AliHLTUInt32_t /*clusterId*/)
1039 : {
1040 : /// fill sigmaZ2 histogram
1041 0 : fCurrentCluster.SetSigmaTime2(sigmaZ2);
1042 : unsigned index=kHistogramSigmaZ2;
1043 : // FIXME: this is just a fixed value, to be correct the values from the global
1044 : // parameter block has to be used
1045 0 : float weight=AliHLTTPCGeometry::GetZWidth();
1046 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
1047 0 : fHistogramPointers[index]->Fill(sigmaZ2*weight*weight);
1048 :
1049 : index=kHistogramSigmaZ2Sector;
1050 0 : if (index<fHistogram2DPointers.size() && fHistogram2DPointers[index]!=NULL)
1051 0 : fHistogram2DPointers[index]->Fill(fSector,sigmaZ2*weight*weight);
1052 :
1053 0 : }
1054 :
1055 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillCharge(unsigned charge, AliHLTUInt32_t /*clusterId*/)
1056 : {
1057 : /// fill charge histogram
1058 0 : fCurrentCluster.SetCharge(charge);
1059 : unsigned index=kHistogramCharge;
1060 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
1061 0 : fHistogramPointers[index]->Fill(charge);
1062 0 : }
1063 :
1064 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillFlags(unsigned short flags, AliHLTUInt32_t /*clusterId*/)
1065 : {
1066 0 : fCurrentCluster.SetFlags(flags);
1067 0 : }
1068 :
1069 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FillQMax(unsigned qmax, AliHLTUInt32_t /*clusterId*/)
1070 : {
1071 : /// fill qmax histogram
1072 0 : fCurrentCluster.SetQMax(qmax);
1073 : unsigned index=kHistogramQMax;
1074 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
1075 0 : fHistogramPointers[index]->Fill(qmax);
1076 :
1077 : index=kHistogramQMaxSector;
1078 0 : if (index<fHistogram2DPointers.size() && fHistogram2DPointers[index]!=NULL)
1079 0 : fHistogram2DPointers[index]->Fill(fSector,qmax);
1080 0 : }
1081 :
1082 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::Fill(int slice, int partition, AliHLTUInt32_t clusterId)
1083 : {
1084 : /// fill cluster histograms requiring the full cluster information
1085 :
1086 : // TODO: the complete filling of histograms can be moved to this function
1087 : // and the cluster struct be filled in the iterator
1088 : // The delta histograms are filled here either by using the specified
1089 : // cluster, or the nearest cluster on the padrow with identical charge
1090 : // and qmax is searched for comparison.
1091 0 : if (clusterId==kAliHLTVoidDataSpec) {
1092 0 : clusterId=FindNearestCluster(slice, partition, fCurrentCluster);
1093 0 : }
1094 0 : if (clusterId==kAliHLTVoidDataSpec) return;
1095 : bool bResidualError=false;
1096 0 : int currentRow=fCurrentCluster.GetPadRow();
1097 :
1098 0 : if (fRawData) {
1099 : unsigned index=kHistogramDeltaPadrow;
1100 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1101 0 : if (CheckClusterID(clusterId)) {
1102 0 : fHistogramPointers[index]->Fill(fCurrentCluster.GetPadRow()-GetClusterX(clusterId));
1103 0 : }
1104 : }
1105 :
1106 : index=kHistogramDeltaPad;
1107 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1108 0 : if (CheckClusterID(clusterId)) {
1109 0 : float dPad=fCurrentCluster.GetPad()-GetClusterY(clusterId);
1110 0 : fHistogramPointers[index]->Fill(dPad);
1111 : static const float maxdPad=0.015; // better 100um for 4 and 6mm pad width
1112 0 : if (TMath::Abs(dPad)>maxdPad) {
1113 : //HLTError("cluster 0x%08x slice %d partition %d: pad difference %f - max %f", clusterId, slice, partition, dPad, maxdPad);
1114 : bResidualError=true;
1115 0 : }
1116 0 : }
1117 : }
1118 :
1119 : index=kHistogramDeltaTime;
1120 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1121 0 : if (CheckClusterID(clusterId)) {
1122 0 : float dTime=fCurrentCluster.GetTime()-GetClusterZ(clusterId);
1123 0 : fHistogramPointers[index]->Fill(dTime);
1124 : static const float maxdTime=0.04; // corresponds to 100um
1125 0 : if (TMath::Abs(dTime)>maxdTime) {
1126 : //HLTError("cluster 0x%08x slice %d partition %d: time difference %f - max %f", clusterId, slice, partition, dTime, maxdTime);
1127 : bResidualError=true;
1128 0 : }
1129 0 : }
1130 : }
1131 :
1132 : index=kHistogramDeltaSigmaY2;
1133 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1134 0 : if (CheckClusterID(clusterId)) {
1135 0 : float factor=AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaY2].fScale;
1136 0 : float sigma=GetClusterYWidth(clusterId)*factor;
1137 0 : if (sigma>fMaxSigmaY2Scaled) sigma=fMaxSigmaY2Scaled;
1138 0 : sigma/=factor;
1139 0 : fHistogramPointers[index]->Fill(fCurrentCluster.GetSigmaPad2()-sigma);
1140 0 : }
1141 : }
1142 :
1143 : index=kHistogramDeltaSigmaZ2;
1144 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1145 0 : if (CheckClusterID(clusterId)) {
1146 0 : float factor=AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaZ2].fScale;
1147 0 : float sigma=GetClusterZWidth(clusterId)*factor;
1148 0 : if (sigma>fMaxSigmaZ2Scaled) sigma=fMaxSigmaZ2Scaled;
1149 0 : sigma/=factor;
1150 0 : fHistogramPointers[index]->Fill(fCurrentCluster.GetSigmaTime2()-sigma);
1151 0 : }
1152 : }
1153 :
1154 : index=kHistogramDeltaCharge;
1155 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1156 0 : if (CheckClusterID(clusterId)) {
1157 0 : fHistogramPointers[index]->Fill(fCurrentCluster.GetCharge()-GetClusterCharge(clusterId));
1158 0 : }
1159 : }
1160 :
1161 : index=kHistogramDeltaQMax;
1162 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1163 0 : if (CheckClusterID(clusterId)) {
1164 0 : fHistogramPointers[index]->Fill(fCurrentCluster.GetQMax()-GetClusterQMax(clusterId));
1165 0 : }
1166 : }
1167 :
1168 0 : if (bResidualError) {
1169 : index=kHistogramOutOfRange;
1170 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL) {
1171 0 : fHistogramPointers[index]->Fill(currentRow>=0?currentRow:0);
1172 0 : }
1173 : }
1174 :
1175 : index=kHistogramHWCFPad;
1176 0 : if (index<fHistogramPointers.size() && fHistogramPointers[index]!=NULL)
1177 0 : fHistogramPointers[index]->Fill(GetClusterY(clusterId));
1178 0 : }
1179 0 : }
1180 :
1181 : void AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::Clear(Option_t * option)
1182 : {
1183 : /// internal cleanup
1184 0 : if (fRawData) fRawData->Clear(option);
1185 0 : }
1186 :
1187 : TObject* AliHLTTPCDataCompressionMonitorComponent::AliDataContainer::FindObject(const char *name) const
1188 : {
1189 : /// get histogram object
1190 0 : if (!name) return NULL;
1191 0 : if ( strcmp(name,"fHistograms") == 0 )
1192 0 : return fHistograms;
1193 0 : if ( strcmp(name,"fHistograms2D") == 0 )
1194 0 : return fHistograms2D;
1195 0 : if ( strcmp(name,"fHistograms3D") == 0 )
1196 0 : return fHistograms3D;
1197 :
1198 0 : return NULL;
1199 0 : }
|