]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/OnlineDisplay/AliHLTTPCDisplayFront.cxx
dummy reconfiguration handler added
[u/mrichter/AliRoot.git] / HLT / TPCLib / OnlineDisplay / AliHLTTPCDisplayFront.cxx
CommitLineData
78b557c2 1// $Id$
2
86268ca8 3/**
78b557c2 4<pre>
5//_____________________________________________________________
6// AliHLTTPCDisplayFront
7//
8// Display class for the HLT TPC-Pad events.
9</pre>
10*/
11// Author: Jochen Thaeder <mailto:thaeder@kip.uni-heidelberg.de>
12//*-- Copyright &copy ALICE HLT Group
13
14#include <TH2.h>
15#include <TFile.h>
16#include <TStyle.h>
17#include <TAttText.h>
18#include <TAxis.h>
19#include <TCanvas.h>
20
21#ifdef use_aliroot
22#include <TClonesArray.h>
23#include <AliRun.h>
24#include <AliSimDigits.h>
25#include <AliTPCParam.h>
26#endif
27
28#include "AliHLTStdIncludes.h"
29#include "AliHLTTPCDefinitions.h"
30#include "AliHLTDataTypes.h"
31#include "AliHLTTPCSpacePointData.h"
32#include "AliHLTTPCClusterDataFormat.h"
33#include "AliHLTTPCLogging.h"
34#include "AliHLTTPCTransform.h"
78b557c2 35
36#include "AliHLTTPCDisplayMain.h"
37#include "AliHLTTPCDisplayFront.h"
5235c3e9 38#include "AliHLTTPCDisplayPad.h"
78b557c2 39#if __GNUC__ >= 3
40using namespace std;
41#endif
42
5235c3e9 43#define TESTCODE 0
44
78b557c2 45ClassImp(AliHLTTPCDisplayFront)
46
47//____________________________________________________________________________________________________
48AliHLTTPCDisplayFront::AliHLTTPCDisplayFront(AliHLTTPCDisplayMain* display) {
49 // constructor
50 fDisplay = display;
51
5235c3e9 52 fNTimes = display->GetNTimeBins();
53
78b557c2 54 fBinY[0] = 0;
55 fBinY[1] = AliHLTTPCTransform::GetNRows() - 1;
5235c3e9 56#if TESTCODE
57 fBinX[0] = (-4) * AliHLTTPCTransform::GetNPads(fBinY[1]);
58 fBinX[1] = (4) * AliHLTTPCTransform::GetNPads(fBinY[1]);
59 Int_t Bins = (8 * AliHLTTPCTransform::GetNPads(fBinY[1]) ) + 1;
60#else
78b557c2 61 fBinX[0] = 0;
62 fBinX[1] = AliHLTTPCTransform::GetNPads(fBinY[1]);
5235c3e9 63#endif
78b557c2 64 fTmpEvent = 0;
5235c3e9 65
66 Int_t fBinningFaktor = 4 ;
67
78b557c2 68
5235c3e9 69
70
71
72#if TESTCODE
73 fHistfront = new TH2F("fHistfront","FrontView of selected slice;Pad #;Padrow #",Bins,fBinX[0],fBinX[1],fBinY[1]+1,fBinY[0],fBinY[1]);
74#else
78b557c2 75 fHistfront = new TH2F("fHistfront","FrontView of selected slice;Pad #;Padrow #",fBinX[1]+1,fBinX[0],fBinX[1],fBinY[1]+1,fBinY[0],fBinY[1]);
f3f599e0 76 fHistfrontcl = new TH1F("fHistfrontcl","cvcv;ddd;kkk",fBinX[1]+1,fBinX[0],fBinX[1]);
77 gStyle->SetPalette(1);
5235c3e9 78#endif
78b557c2 79
80 fHistfront->SetOption("COLZ");
81 fHistfront->SetTitleSize(0.03);
82 fHistfront->GetXaxis()->SetLabelSize(0.03);
83 fHistfront->GetXaxis()->SetTitleSize(0.03);
84 fHistfront->GetYaxis()->SetLabelSize(0.03);
85 fHistfront->GetYaxis()->SetTitleSize(0.03);
86}
87
88//____________________________________________________________________________________________________
89AliHLTTPCDisplayFront::~AliHLTTPCDisplayFront() {
90 // destructor
91 if ( fHistfront ){
92 delete fHistfront;
93 fHistfront = NULL;
94 }
95}
96
97//____________________________________________________________________________________________________
98void AliHLTTPCDisplayFront::Reset(){
99 fHistfront->Reset();
100}
101
102//____________________________________________________________________________________________________
103void AliHLTTPCDisplayFront::Save(){
104 fCanvas->SaveAs("HLT-FrontView.eps");
105}
106
107//____________________________________________________________________________________________________
36782fc0 108void AliHLTTPCDisplayFront::Fill() {
5235c3e9 109 // Fill Pad Histogram
78b557c2 110
5235c3e9 111 Int_t timeSwitch = fDisplay->GetFrontDataSwitch();
78b557c2 112
5235c3e9 113 // --- TEST CODE beginn
114 Int_t fBinning = 8; // == 1/0.125
115 Int_t fBinningFaktor = 4; // binning / 2 because of width half
78b557c2 116
5235c3e9 117#if TESTCODE
118 // use sum
119 if (timeSwitch == 0) {
120 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
78b557c2 121
5235c3e9 122 Int_t width_half = AliHLTTPCTransform::GetNPads(row) * AliHLTTPCTransform::GetPadLength(row) * fBinningFaktor;
123 Int_t pad_corrected_loop = (Int_t) ( AliHLTTPCTransform::GetPadLength(row) *fBinning );
78b557c2 124
5235c3e9 125 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
78b557c2 126
5235c3e9 127 Int_t pad_corrected = ( pad * AliHLTTPCTransform::GetPadLength(row) * fBinning ) - width_half;
78b557c2 128
5235c3e9 129 UInt_t timeSum = 0;
130 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
131 timeSum += fDisplay->fRawData[row][pad][timeBin];
132 } // end time
133 for (Int_t ii=0;ii < pad_corrected_loop; ii++){
134 pad_corrected++;
135 fHistfront->Fill(pad_corrected,row,(Int_t) timeSum);
136 }
137 } // end pad
138 } // end row
139 } // end use sum
78b557c2 140
5235c3e9 141 return;
142 // --- TEST CODE end
143#endif
78b557c2 144
5235c3e9 145 // !!
146 // !! DO unrolling because of cache effects (avoid cache trashing) !!
147 // !!
148
149 if ( fDisplay->GetZeroSuppression() ){
150 // use sum
151 if (timeSwitch == 0) {
152 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
153 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
154 UInt_t timeSum = 0;
155 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
156 timeSum += fDisplay->fRawDataZeroSuppressed[row][pad][timeBin];
157 } // end time
158
159 fHistfront->Fill(pad,row,(Int_t) timeSum);
160 } // end pad
161 } // end row
162 } // end use sum
163
164 // use average
165 else if (timeSwitch == 1){
166 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
167 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
168 UInt_t timeSum = 0;
169 Int_t NTimeBins = 0;
170 Float_t timeAverage = 0.;
171 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
172 timeSum += fDisplay->fRawDataZeroSuppressed[row][pad][timeBin];
173 NTimeBins++;
174 } // end time
175
176 if (NTimeBins <= 0)
177 HLTFatal("Division by Zero - NTimeBins == 0");
178 else
179 timeAverage = ((Float_t) timeSum) / ((Float_t) NTimeBins);
180
181 fHistfront->Fill(pad,row, timeAverage);
182 } // end pad
183 } // end row
184 }// end use average
185
186 // use maximum
187 else if (timeSwitch == 2){
188 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
189 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
190 UInt_t timeMax = 0;
191 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
192 UInt_t tmp = fDisplay->fRawDataZeroSuppressed[row][pad][timeBin];
193 if (tmp > timeMax) timeMax = tmp;
194 } // end time
195
196 fHistfront->Fill(pad,row,(Int_t) timeMax);
197 } // end pad
198 } // end row
199 }// end use maximum
200 } // end - if ( fDisplay->GetZeroSuppression() ){
201
202 else {
203 // use sum
204 if (timeSwitch == 0) {
205 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
206 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
207 UInt_t timeSum = 0;
208 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
209 timeSum += fDisplay->fRawData[row][pad][timeBin];
210 } // end time
211
212 fHistfront->Fill(pad,row,(Int_t) timeSum);
213 } // end pad
214 } // end row
215 } // end use sum
216
217 // use average
218 else if (timeSwitch == 1){
219 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
220 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
221 UInt_t timeSum = 0;
222 Int_t NTimeBins = 0;
223 Float_t timeAverage = 0.;
224 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
225 timeSum += fDisplay->fRawData[row][pad][timeBin];
226 NTimeBins++;
227 } // end time
228
229 if (NTimeBins <= 0)
230 HLTFatal("Division by Zero - NTimeBins == 0");
231 else
232 timeAverage = ((Float_t) timeSum) / ((Float_t) NTimeBins);
233
234 fHistfront->Fill(pad,row, timeAverage);
235 } // end pad
236 } // end row
237 }// end use average
238
239 // use maximum
240 else if (timeSwitch == 2){
241 for (Int_t row=0; row < AliHLTTPCTransform::GetNRows(); row++){
242 for (Int_t pad=0; pad < AliHLTTPCTransform::GetNPads(row); pad++){
243 UInt_t timeMax = 0;
244 for (Int_t timeBin=fDisplay->GetTimeBinMin(); timeBin <= fDisplay->GetTimeBinMax(); timeBin++){
245 UInt_t tmp = fDisplay->fRawData[row][pad][timeBin];
246 if (tmp > timeMax) timeMax = tmp;
247 } // end time
78b557c2 248
5235c3e9 249 fHistfront->Fill(pad,row,(Int_t) timeMax);
250 } // end pad
251 } // end row
252 }// end use maximum
253 } // end - else of if ( fDisplay->GetZeroSuppression() ){
254
f3f599e0 255
36782fc0 256#if 0
f3f599e0 257 if (fDisplay->ExistsClusterData()){
36782fc0 258 for (Int_t patch=0; patch < 6; patch++){
f3f599e0 259 AliHLTTPCSpacePointData *points = fDisplay->GetSpacePointDataPointer(fDisplay->GetSlicePadRow(),patch);
260 if(!points) return;
261
262 cout << "fill" << patch << endl;
263
264 Float_t xyz[3];
265 for(Int_t i=0; i< fDisplay->GetNumberSpacePoints(fDisplay->GetSlicePadRow(),patch); i++){
266 xyz[0] = points[i].fX;
267 xyz[1] = points[i].fY;
268 xyz[2] = points[i].fZ;
269 Int_t padRow = AliHLTTPCTransform::GetPadRow(xyz[0]);
270
271
272 // select padrow to fill in histogramm
273 // if (padRow == AliHLTTPCTransform::GetPadRow(xyz[0])){
274 AliHLTTPCTransform::LocHLT2Raw(xyz, 0, padRow);
275 fHistfrontcl->Fill(xyz[1],padRow);
276 // }
277 }
278 }
279 } // END if (fDisplay->ExistsClusterData()){
36782fc0 280#endif
f3f599e0 281
78b557c2 282}
283
284//____________________________________________________________________________________________________
285void AliHLTTPCDisplayFront::Draw(){
36782fc0 286
78b557c2 287 fDisplay->GetCanvasFront()->cd();
288 fDisplay->GetCanvasFront()->Clear();
289
5235c3e9 290 if (fDisplay->GetSplitFront()){
291 fDisplay->GetCanvasFront()->Divide(1,2);
292 fDisplay->GetCanvasFront()->cd(1);
293 }
294
78b557c2 295 Char_t title[256];
296 sprintf(title,"FrontView of selected slice%d",fDisplay->GetSlicePadRow());
297
298 // Keep Zoom
299 if (!fDisplay->GetKeepView() ){
300 fBinY[0] = 0;
301 fBinY[1] = AliHLTTPCTransform::GetNRows() - 1;
302 fBinX[0] = 0;
303 fBinX[1] = AliHLTTPCTransform::GetNPads(fBinY[1]);
304 }
305
306 fHistfront->SetAxisRange(fBinX[0],fBinX[1]);
307 fHistfront->SetAxisRange(fBinY[0],fBinY[1],"Y");
308
309 fHistfront->SetTitle(title);
310 fHistfront->SetStats(kFALSE);
311 fHistfront->Draw("COLZ");
312
f3f599e0 313 if ( fDisplay->ExistsClusterData() ){
314 fHistfrontcl->SetAxisRange(fBinX[0],fBinX[1]);
315 fHistfrontcl->SetAxisRange(fBinY[0],fBinY[1],"Y");
316 fHistfrontcl->SetStats(kFALSE);
317 fHistfrontcl->SetMarkerStyle(28);
318 fHistfrontcl->SetMarkerSize(2);
319 fHistfrontcl->SetMarkerColor(1);
320 fHistfrontcl->Draw("psame");
f3f599e0 321 }
322
5235c3e9 323 if (fDisplay->GetSplitFront()){
324 fDisplay->GetCanvasFront()->cd(2);
325 fDisplay->GetPadPointer()->fHistpad2->Draw();
326 }
327
78b557c2 328 fDisplay->GetCanvasFront()->Modified();
329 fDisplay->GetCanvasFront()->Update();
330
331 // Select Pad
5235c3e9 332 fDisplay->GetCanvasFront()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliHLTTPCDisplayMain",(void*) fDisplay,"ExecPadEvent(Int_t,Int_t,Int_t,TObject*)");
78b557c2 333 // Keep Zoom
334 fDisplay->GetCanvasFront()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliHLTTPCDisplayFront",(void*) this,"ExecEvent(Int_t,Int_t,Int_t,TObject*)");
335}
336
337//____________________________________________________________________________________________________
338void AliHLTTPCDisplayFront::ExecEvent(Int_t event, Int_t px, Int_t py, TObject *selected){
339 // Saves the Zoom Position of the Histogram
340
341 // - Mouse down on Axis : StartPoint of Range
342 if (event == 1 && selected->InheritsFrom("TAxis"))
343 fTmpEvent = 1;
344
345 // - Mouse pressed on Axis : Real Zoom process not only click
346 else if (event == 21 && selected->InheritsFrom("TAxis") && fTmpEvent == 1)
347 fTmpEvent = 21;
348
349 // - Mouse pressed on Axis : Still pressed
350 else if (event == 21 && selected->InheritsFrom("TAxis") && fTmpEvent == 21)
351 return;
352
353 // - Mouse up on Axis : End Point of Rangex
354 else if (event == 11 && selected->InheritsFrom("TAxis") && fTmpEvent == 21){
355 TAxis * axis = (TAxis*) selected;
356
357 if (selected == fHistfront->GetXaxis() || selected == fHistfront->GetXaxis()){
358 fBinX[0] = axis->GetFirst() -1;
359 fBinX[1] = axis->GetLast() -1;
360 }
361 else {
362 fBinY[0] = axis->GetFirst() -1;
363 fBinY[1] = axis->GetLast() -1;
364 }
365
366 fTmpEvent = 0;
367 }
368 else fTmpEvent = 0;
369}