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