]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/OnlineDisplay/AliHLTEMCALOnlineDisplayEventTab.cxx
correcting placement of 'using' statements (Thorsten), minor coverity defect corrected
[u/mrichter/AliRoot.git] / HLT / EMCAL / OnlineDisplay / AliHLTEMCALOnlineDisplayEventTab.cxx
1 // $Id: AliHLTEMCALOnlineDisplayEventTab.cxx 35108 2009-09-30 01:58:37Z phille $
2
3 /**************************************************************************
4  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
5  *                                                                        *
6  * Authors: Per Thomas Hille for the ALICE                                *
7  * offline/HLT Project. Contributors are mentioned in the code where      *
8  * appropriate.                                                           *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 #include "AliHLTEMCALOnlineDisplayEventTab.h"
20 #include <iostream>
21 #include "TGFrame.h"
22 #include "AliHLTEMCALGetEventButton.h"
23 #include "AliHLTDataTypes.h"
24 #include "AliHLTHOMERData.h"
25 #include "AliHLTHOMERReader.h"
26 #include "AliHLTHOMERWriter.h"
27 #include "TRootEmbeddedCanvas.h"
28 #include "AliHLTEMCALOnlineDisplay.h"
29 #include "AliHLTCaloChannelDataStruct.h"
30 #include "AliHLTCaloChannelDataHeaderStruct.h"
31 //#include "AliHLTCaloSharedMemoryInterfacev2.h"
32 #include "AliHLTEMCALSharedMemoryInterface.h"
33 #include "AliHLTCaloCoordinate.h"
34 //#include "AliHLTCaloChannelRawDataStruct.h"
35
36 // MT Crap
37 #include <TMath.h>
38 #include "AliHLTEMCALOnlineDisplayTH2D.h"
39
40 using namespace std;
41
42 //#include <TEveManager.h>
43 //#include <TEveBoxSet.h>
44 //TEveBoxSet* gAliEveBoxSet = 0;
45
46
47 //gEve = new TEveManager(300, 300);
48
49 AliHLTEMCALOnlineDisplayEventTab::AliHLTEMCALOnlineDisplayEventTab()
50 {
51   cout << "ERROR: You cannot create a onlinedisplay Tab without arguments" << endl;
52 }
53
54
55 AliHLTEMCALOnlineDisplayEventTab::AliHLTEMCALOnlineDisplayEventTab(AliHLTEMCALOnlineDisplay * onlineDisplayPtr, TGTab  *tabPtr, 
56                                                                  AliHLTHOMERReader * homerSyncPtr, AliHLTHOMERReader * homerPtrs[MAXHOSTS], 
57                                                                  int nHosts,  int runnumber) :  AliHLTEMCALOnlineDisplayTab()
58 {
59   
60   //  gEve = new TEveManager(300, 300, kFALSE);
61   
62
63   //comment
64   /*
65   if(fIsSetRunNumber == true)
66     {
67       for(int i=0; i < NGAINS; i++)
68         {
69           fgLegoPlotPtr[gain]
70         }
71    }
72   */
73
74
75   // fShmPtr = new AliHLTEMCALSharedMemoryInterface();
76
77   // fShmPtr = new AliHLTEMCALSharedMemoryInterfacev2();
78  
79   fShmPtr = new AliHLTEMCALSharedMemoryInterface();
80
81   
82
83   fOnlineDisplayPtr =  onlineDisplayPtr;
84
85
86   for(int gain = 0; gain < NGAINS; gain ++ )
87     {
88       fgCanvasPtr[gain] = 0;
89       fgLegoPlotPtr[gain] = 0;
90  
91       
92       for(int mod =0; mod <NMODULES; mod ++)
93         {
94           for(int z = 0; z < NZROWSMOD ; z ++)
95               {
96                 for(int x = 0; x < NXCOLUMNSMOD; x ++)
97                   {
98                     fChannelData[mod][z][x][gain] = new int[ALTROMAXSAMPLES];
99                     fNChannelSamples[mod][z][x][gain] = 0;
100                     fChannelEnergy[mod][z][x][gain] = 0;
101                   }
102               }
103         }
104     }
105
106   for(int i=0; i<MAXHOSTS; i++)
107     {
108        fgHomerReadersPtr[i] = 0;
109     }
110
111   fgHomerReaderPtr = const_cast<AliHLTHOMERReader*>(homerSyncPtr);
112   
113   for(int i=0; i<nHosts; i++)
114     {
115       fgHomerReadersPtr[i] = homerPtrs[i] ;
116
117     }
118
119   fgNHosts = nHosts;
120   InitDisplay(tabPtr, runnumber);
121 }
122
123
124 AliHLTEMCALOnlineDisplayEventTab::~AliHLTEMCALOnlineDisplayEventTab()
125 {
126   //comment
127 }
128
129
130
131 Int_t
132 AliHLTEMCALOnlineDisplayEventTab::GetRawData(TH1D *histPtr, int x, int z, int gain)
133 {
134   //  int tmpModID = x/64;
135   
136   int tmpModID = (x*z)/(NZROWSMOD*NXCOLUMNSMOD);
137
138   // const int NZROWSMOD      =  48;            /**<Number of rows per module*/       
139   //  const int NXCOLUMNSMOD   =  24;     
140   //int tmpModID = x/64;
141
142   /* 
143      int tmpRcuZ = z/32;
144      int tmpRcuX = (x%64)/32;
145      int tmpZ = z%28;
146      int tmpX = x%32;
147   */
148
149   cout << __FILE__ << __LINE__ <<": Getting raw data for mod =" << tmpModID << ", z="<< z << ",x=" << x << endl;
150
151   for(  int i=0;  i <  fNChannelSamples[tmpModID][z][x][gain] ; i++)
152     {
153       histPtr->SetBinContent(i, fChannelData[tmpModID][z][x][gain][i]);  
154     }
155   return fNChannelSamples [tmpModID][z][x][gain];
156 }
157
158
159
160 int
161 AliHLTEMCALOnlineDisplayEventTab::GetNextEvent()
162 {
163   ResetDisplay();
164   DoGetNextEvent();
165   UpdateDisplay();
166   fgEvntCnt ++;
167 }
168
169
170 void
171 AliHLTEMCALOnlineDisplayEventTab::FindFourierBlocks(AliHLTHOMERReader * const homerReaderPtr) const
172 {
173   //comment
174  cout << "AliHLTEMCALOnlineDisplayEventTab::FindFourierBlocks" << endl; 
175   // unsigned long blk = homeReaderPtr->FindBlockNdx("RENELLEC","SOHP", 0xFFFFFFFF );
176   unsigned long blk = homerReaderPtr->FindBlockNdx(" TREIRUOF","SOHP", 0xFFFFFFFF );
177
178   while ( blk != ~(unsigned long)0 )
179     {
180       cout << "AliHLTEMCALOnlineDisplayEventTab::FindFourierBlocks(homerReaderPtr) FOUND FOURIER DATA !!!!!!!!!!!!!!" << endl;
181       blk = homerReaderPtr->FindBlockNdx("TREIRUOF","SOHP", 0xFFFFFFFF );
182     }
183 }
184
185
186 void 
187 AliHLTEMCALOnlineDisplayEventTab::ReadBlockData(AliHLTHOMERReader *homeReaderPtr)
188 {  
189   //  AliHLTEMCALChannelDataStruct *currentChannel =0;
190   AliHLTCaloChannelDataStruct *currentChannel =0; 
191
192  cout << "AliHLTEMCALOnlineDisplayEventTab::ReadBlockDat, Reading block data, therere are " <<  homeReaderPtr->GetBlockCnt() << " blocks " <<endl;
193   FindFourierBlocks(homeReaderPtr);
194   // unsigned long blk = homeReaderPtr->FindBlockNdx("RENELLEC","SOHP", 0xFFFFFFFF );
195   unsigned long blk = homeReaderPtr->FindBlockNdx("TLENNAHC","SOHP", 0xFFFFFFFF );
196   cout << __FILE__ << ":" << __LINE__ << "blk"  << blk  << endl ;
197   int cnt = 0;
198   //
199   //  AliHLTEMCALCoordinate tmpCoord;
200   AliHLTCaloCoordinate tmpCoord;
201   
202   long wcnt = 0;
203
204   //  cout << __FILE__ << ":" << __LINE__ << "TP0"   << endl ;
205   
206   while ( blk != ~(unsigned long)0 ) 
207     {
208       //     cout << __FILE__ << ":" << __LINE__ << "TP1"    << endl ;
209       //    cout << wcnt << "\t"; 
210
211       wcnt ++;
212  
213       //   AliHLTEMCALChannelDataHeaderStruct* cellEnergiesPtr = (AliHLTEMCALChannelDataHeaderStruct*)homeReaderPtr->GetBlockData( blk ); 
214       AliHLTCaloChannelDataHeaderStruct* cellEnergiesPtr = (AliHLTCaloChannelDataHeaderStruct*)homeReaderPtr->GetBlockData( blk );    
215
216       Int_t* tmpPtr = 0;
217       fShmPtr->SetMemory(cellEnergiesPtr);
218       currentChannel = fShmPtr->NextChannel();
219   
220       //    cout << __FILE__ << ":" << __LINE__ << "TP1.2"    << endl ;
221     
222       while(currentChannel != 0)
223         {
224           //      cout << cnt << "\t"; 
225
226           cnt ++;
227           //       cout << __FILE__ << ":" << __LINE__ << "TP1.3"    << endl ;
228           AliHLTEMCALMapper::ChannelId2Coordinate( currentChannel->fChannelID, tmpCoord );
229           //      cout << __FILE__ << ":" << __LINE__ << "TP1.4"    << endl ; 
230           fgLegoPlotPtr[ tmpCoord.fGain ]->Fill(  tmpCoord.fModuleId*NXCOLUMNSMOD +   tmpCoord.fX,   tmpCoord.fZ, currentChannel->fEnergy );
231           //      cout << __FILE__ << ":" << __LINE__ << "TP1.5"    << endl ;
232           fChannelEnergy[tmpCoord.fModuleId][tmpCoord.fZ][ tmpCoord.fX][tmpCoord.fGain] =  currentChannel->fEnergy;
233           cout << __FILE__ << ":" << __LINE__ << "TP1.6"    << endl ;
234           
235           /*
236           if(cellEnergiesPtr->fHasRawData == true)
237             {
238               FillRawData(fShmPtr->GetRawData());
239             }
240           */
241           
242           currentChannel = fShmPtr->NextChannel();
243
244           cout << __FILE__ << ":" << __LINE__ << "TP1.7"    << endl ;
245         }
246       //      blk = homeReaderPtr->FindBlockNdx("RENELLEC","SOHP", 0xFFFFFFFF, blk+1);
247       //   cout << __FILE__ << ":" << __LINE__ << "TP2"    << endl ;
248       blk = homeReaderPtr->FindBlockNdx("TLENNAHC","SOHP", 0xFFFFFFFF, blk+1 );
249       //   cout << __FILE__ << ":" << __LINE__ << "TP3"    << endl ;
250    }
251 }
252
253
254 void 
255 ///AliHLTEMCALOnlineDisplayEventTab::FillRawData(const AliHLTEMCALChannelRawDataStruct &rawStr)
256 AliHLTEMCALOnlineDisplayEventTab::FillRawData(const AliHLTCaloChannelRawDataStruct &rawStr)  
257
258 {
259   fNChannelSamples[ rawStr.fCoordinate.fModuleId ][ rawStr.fCoordinate.fZ ]  [ rawStr.fCoordinate.fX ][ rawStr.fCoordinate.fGain ] = rawStr.nSamplesUsed;
260   fChannelEnergy[ rawStr.fCoordinate.fModuleId ][ rawStr.fCoordinate.fZ ]  [ rawStr.fCoordinate.fX ][ rawStr.fCoordinate.fGain ] = rawStr.fEnergy;
261
262
263   /*
264   cout << __FILE__ << __LINE__<< "module ID = " << rawStr.fCoordinate.fModuleId  << endl;
265   cout << __FILE__ << __LINE__<< "fZ = " << rawStr.fCoordinate.fZ   << endl;
266   cout << __FILE__ << __LINE__<< "fX = " << rawStr.fCoordinate.fX   << endl;
267   cout << __FILE__ << __LINE__<< "fGain = " << rawStr.fCoordinate.fGain   << endl; 
268   cout << __FILE__ << __LINE__<< "nSamples = " <<    rawStr.nSamplesUsed   << endl; 
269   */
270
271   for(int i=0; i <  rawStr.nSamplesUsed; i++ )
272     {
273       //   cout <<  "i = "  << i << endl;
274       fChannelData[ rawStr.fCoordinate.fModuleId ][ rawStr.fCoordinate.fZ ]  [ rawStr.fCoordinate.fX ][ rawStr.fCoordinate.fGain ][i] =  rawStr.fDataPtr[i];  
275       //      fChannelData[ rawStr.fCoordinate.fModuleId ][   rawStr.fCoordinate.fX ]  [ rawStr.fCoordinate.fZ ][ rawStr.fCoordinate.fGain ][i] =  rawStr.fDataPtr[i];  
276     }
277
278
279 }
280
281
282
283 void
284 AliHLTEMCALOnlineDisplayEventTab::ResetDisplay()
285 {
286   //comment
287   if(fgAccumulate == kFALSE)
288     {
289       for(int gain=0; gain < NGAINS; gain++)
290         {
291           if(fgLegoPlotPtr[gain] !=0)
292             {
293               fgLegoPlotPtr[gain]->Reset(); 
294             }
295         }
296     } 
297 }
298
299
300 void
301 AliHLTEMCALOnlineDisplayEventTab::InitDisplay(TGTab  * tabPtr, int runnumber)
302 {
303   //  gStyle->SetOptLogy();
304   ///  gStyle->SetOptStat(true);
305
306   for(int gain=0; gain < NGAINS; gain++)
307     {
308       char gainLabel[100];
309       char label[256];
310  
311       //     Gain2Text
312       fOnlineDisplayPtr->Gain2Text(gain,gainLabel);
313       sprintf(label, "EMCAL HLT Online Display %s", gainLabel);
314       fgLegoPlotPtr[gain] = new AliHLTEMCALOnlineDisplayTH2D(fOnlineDisplayPtr, label, label, 
315                                                             NXCOLUMNSMOD*NMODULES , 0, NXCOLUMNSMOD*NMODULES,  
316                                                             NZROWSMOD,   0, NZROWSMOD);   
317       
318       //      cout << __FILE__ << ":" << __LINE__ << " Runnumber = "  << runnumber <<endl;
319    
320       fgLegoPlotPtr[gain]->SetRunNumber(runnumber);
321       fgLegoPlotPtr[gain]->SetMaximum(1023);
322       fgLegoPlotPtr[gain]->Reset();
323       //     fgLegoPlotPtr[gain]->GetXaxis()->SetRange(XRANGESTART, XRANGEEND);
324     }
325   
326
327   TGLayoutHints *fL1 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
328                                          kLHintsExpandY, 2, 2, 15, 1);
329
330   TGCompositeFrame * tf = tabPtr->AddTab("Event display");
331   fSubTab1 = new TGTab(tf, 100, 100);
332   TGCompositeFrame *tf2 = fSubTab1->AddTab("LEGO");  
333   fSubF1 = new TGCompositeFrame(tf2, 60, 20, kVerticalFrame);
334   fEc1 = new TRootEmbeddedCanvas("ec1", fSubF1, 100, 100);
335   fSubF1->AddFrame(fEc1, fL1);
336   fEc2 = new TRootEmbeddedCanvas("ec2", fSubF1, 100, 100);
337   fSubF1->AddFrame(fEc2, fL1);
338   tf2->AddFrame(fSubF1, fL1);
339   
340   tf2 = fSubTab1->AddTab("SCAT"); 
341   fSubF2 = new TGCompositeFrame(tf2, 60, 20, kVerticalFrame);
342   tf2->AddFrame(fSubF2, fL1);
343   fEc3 = new TRootEmbeddedCanvas("ec3", fSubF2, 100, 100);
344   fSubF2->AddFrame(fEc3, fL1);
345   fEc4 = new TRootEmbeddedCanvas("ec4", fSubF2, 100, 100);
346   fSubF2->AddFrame(fEc4, fL1);
347   
348   tf2 = fSubTab1->AddTab("SURF"); 
349   fSubF3 = new TGCompositeFrame(tf2, 60, 20, kVerticalFrame);
350   tf2->AddFrame(fSubF3, fL1);
351   fEc5 = new TRootEmbeddedCanvas("ec5", fSubF3, 100, 100);
352   fSubF3->AddFrame(fEc5, fL1);
353   fEc6 = new TRootEmbeddedCanvas("ec6", fSubF3, 100, 100);
354   fSubF3->AddFrame(fEc6, fL1);
355   fSubTab1->Resize();
356   tf->AddFrame(fSubTab1, fL1);
357
358   fgEventButtPtr = new  AliHLTEMCALGetEventButton(fSubF1, "get event", 'e');
359 }
360
361
362
363 void
364 AliHLTEMCALOnlineDisplayEventTab::UpdateDisplay()
365 {
366   // gStyle->SetOptLogy();
367   //  gStyle->SetOptStat(true);
368
369   fgCanvasPtr[HIGHGAIN] =  fEc1->GetCanvas();
370   fgCanvasPtr[HIGHGAIN]->cd();
371   fgLegoPlotPtr[HIGHGAIN]->Draw("LEGO2Z");
372   fgCanvasPtr[HIGHGAIN]->Update();
373   fgCanvasPtr[LOWGAIN] = fEc2->GetCanvas();
374   fgCanvasPtr[LOWGAIN]->cd();
375   fgLegoPlotPtr[LOWGAIN]->Draw("LEGO2Z");
376   fgCanvasPtr[LOWGAIN]->Update();
377
378   fgCanvasPtr[HIGHGAIN] =  fEc3->GetCanvas();
379   fgCanvasPtr[HIGHGAIN]->cd();
380   fgLegoPlotPtr[HIGHGAIN]->Draw("SCAT");
381   fgCanvasPtr[HIGHGAIN]->Update();
382   fgCanvasPtr[LOWGAIN] = fEc4->GetCanvas();
383   fgCanvasPtr[LOWGAIN]->cd();
384   fgLegoPlotPtr[LOWGAIN]->Draw("SCAT");
385   fgCanvasPtr[LOWGAIN]->Update();
386
387   /* 
388  fgCanvasPtr[HIGHGAIN] =  fEc5->GetCanvas();
389   fgCanvasPtr[HIGHGAIN]->cd();
390   fgLegoPlotPtr[HIGHGAIN]->Draw("CONTZ");
391   fgCanvasPtr[HIGHGAIN]->Update();
392   fgCanvasPtr[LOWGAIN] = fEc6->GetCanvas();
393   fgCanvasPtr[LOWGAIN]->cd();
394   fgLegoPlotPtr[LOWGAIN]->Draw("CONTZ");
395   fgCanvasPtr[LOWGAIN]->Update();
396   */
397
398   fgCanvasPtr[HIGHGAIN] =  fEc5->GetCanvas();
399   fgCanvasPtr[HIGHGAIN]->cd();
400   fgLegoPlotPtr[HIGHGAIN]->Draw("COLZ");
401   fgCanvasPtr[HIGHGAIN]->Update();
402   fgCanvasPtr[LOWGAIN] = fEc6->GetCanvas();
403   fgCanvasPtr[LOWGAIN]->cd();
404   fgLegoPlotPtr[LOWGAIN]->Draw("COLZ");
405   fgCanvasPtr[LOWGAIN]->Update();
406
407
408 }