]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/hlt-macros/onlineDisplay.C
Converting PWGPPpid to native cmake
[u/mrichter/AliRoot.git] / EVE / hlt-macros / onlineDisplay.C
1 //-*- Mode: C++ -*-
2
3 // ** USED macros :
4 // ***************************************************
5 // - hlt_alieve_init.C
6 // - VizDB_scan.C
7 // - geom_gentle_hlt.C
8 // - geom_gentle_muon.C
9 // ***************************************************
10
11 #if !defined(__CINT__) || defined(__MAKECINT__)
12
13 //****************** ROOT ******************************************
14 #include "TTimer.h"
15 #include "TRandom.h"
16 #include "TVirtualPad.h"
17 #include "TGLViewer.h"
18 #include "TThread.h"
19 #include "TGFileBrowser.h"
20 #include "TStyle.h"
21 #include "TList.h"
22 #include "TDirectory.h"
23 #include "TFile.h"
24 #include "TH2.h"
25 #include "TCanvas.h"
26 #include "TColor.h"
27 #include "TVector3.h"
28
29 //****************** ROOT/EVE **************************************
30 #include "TEveManager.h"
31 #include "TEvePointSet.h"
32 #include "TEveTrack.h"
33 #include "TEveVSDStructs.h"
34 #include "TEveTrackPropagator.h"
35 #include "TEveScene.h"
36 #include "TEveElement.h"
37 #include "TEveUtil.h"
38 #include "TEveEventManager.h"
39 #include "TEveProjectionAxes.h"
40 #include "TEveWindowManager.h"
41 #include "TEveViewer.h"
42 #include "TEveText.h"
43 #include "TEveProjectionManager.h"
44 #include "TEveGeoShape.h"
45 #include "TEveBoxSet.h"
46 #include "TEveTrans.h"
47 #include "TEveRGBAPalette.h"
48 #include "TLine.h"
49 #include "TEveStraightLineSet.h"
50 #include "TGeoNode.h"
51 #include "TGeoManager.h"
52 #include "TGLOverlayButton.h"
53
54 //****************** AliRoot ***************************************
55 #include "AliESDEvent.h"
56 #include "AliCDBManager.h"
57 #include "AliRawReaderMemory.h"
58 #include "AliTPCRawStream.h"
59 #include "AliGeomManager.h"
60
61 //****************** AliRoot/EVE ***********************************
62 #include "AliHLTHOMERManager.h"
63 #include "AliEveHOMERManager.h"
64 #include "AliEveTPCLoader.h" 
65 #include "AliEveTPCData.h"
66 #include "AliEveITSDigitsInfo.h"
67 #include "AliEveITSModule.h"
68 #include "AliEveMacroExecutor.h"
69 #include "AliEveMacro.h"
70 #include "AliEveTrack.h"
71
72 //****************** AliRoot/HLT ***********************************
73 #include "AliHLTHOMERBlockDesc.h"
74 #include "AliHLTHOMERReader.h"
75 #include "AliHLTMUONUtils.h"
76 #include "AliHLTMUONDataBlockReader.h"
77 #include "AliHLTTriggerDecision.h"
78 #include "AliHLTGlobalTriggerDecision.h"
79 #include "AliHLTTPCCATrackParam.h"
80
81 //****************** AliRoot/MUON **********************************
82 #include "AliMUONCalibrationData.h"
83 #include "AliMUONVCalibParam.h"
84 #include "AliMUONGeometryTransformer.h"
85 #include "AliMUONGeometryDetElement.h"
86 #include "AliMUONConstants.h"
87
88 #include "AliMpCDB.h"
89 #include "AliMpDDLStore.h"
90 #include "AliMpDetElement.h"
91 #include "AliMpDEIterator.h"
92 #include "AliMpVSegmentation.h"
93 #include "AliMpSegmentation.h"
94 #include "AliMpTriggerCrate.h"
95 #include "AliMpLocalBoard.h"
96
97 //****************** AliRoot/ITS ***********************************
98 #include "AliITSRecPoint.h"
99
100 //****************** AliRoot/TRD ***********************************
101 #include "AliHLTTRDCluster.h"
102 #include "AliTRDcluster.h"
103 #include "AliTRDCalibraVdriftLinearFit.h"
104
105 //****************** AliRoot/EMCAL *********************************
106 #include "AliHLTCaloClusterDataStruct.h"
107 #include "AliHLTCaloClusterReader.h"
108
109 #include "HLT/CALO/AliHLTCaloChannelDataHeaderStruct.h"
110 #include "HLT/CALO/AliHLTCaloChannelDataStruct.h"
111
112 //****************** AliRoot/PHOS **********************************
113 #include "AliPHOSGeometry.h"
114 #include "HLT/PHOS/AliHLTPHOSDigitDataStruct.h"
115 #include  "AliHLTPHOSChannelDataHeaderStruct.h"
116 #include  "AliHLTPHOSChannelDataStruct.h"
117 #include  "HLT/CALO/AliHLTCaloChannelDataHeaderStruct.h"
118 #include  "HLT/CALO/AliHLTCaloChannelDataStruct.h"
119 #include "AliHLTCaloDigitDataStruct.h"
120 //****************** Macros ****************************************
121 #include "hlt_structs.C"
122 #include "hlt_alieve_init.C"
123 #include "geom_gentle_hlt.C"
124 #include "alice-macros/esd_tracks.C"
125 #include "hlt_esd_tracks.C"
126
127 //#include "alieve_vizdb.C"
128
129 #endif
130
131 class TEveTrackList;
132 class TEveProjectionManager;
133 class TEveGeoShape;
134 class TEveUtil;
135 class AliEveMacroExecutor;
136 class TEveScene;
137 class TEveElement;
138 class TEveText;
139 class AliHLTTriggerDecision;
140 class TEvePointSet;
141 class TEvePointSetArray;
142 class AliHLTHOMERBlockDesc;
143
144 class TEveViewer;
145
146
147 // -----------------------------------------------------------------
148 // --                       Geometry / Scenes                     --
149 // -----------------------------------------------------------------
150
151 TEveGeoShape *gGeomGentle     = 0;
152 TEveGeoShape *gGeomGentleRPhi = 0;
153 TEveGeoShape *gGeomGentleRhoZ = 0;
154 TEveGeoShape *gGeomGentleTRD  = 0;
155 TEveGeoShape *gGeomGentleMUON = 0;
156
157 TEveScene *gRPhiGeomScene  = 0;
158 TEveScene *gRhoZGeomScene  = 0;
159 TEveScene *gRPhiEventScene = 0;
160 TEveScene *gRhoZEventScene = 0;
161
162 TEveProjectionManager *gRPhiMgr = 0;
163 TEveProjectionManager *gRhoZMgr = 0;
164
165 TEveViewer *g3DView   = 0;
166 TEveViewer *gRPhiView = 0;
167 TEveViewer *gRhoZView = 0;
168
169 // -----------------------------------------------------------------
170 // --                Geometry / Scenes Parameters                 --
171 // -----------------------------------------------------------------
172
173 // -- Parameters to show different geometries
174 Bool_t gShowMUON     = kTRUE;
175 Bool_t gShowMUONRPhi = kFALSE;
176 Bool_t gShowMUONRhoZ = kTRUE;
177 Bool_t gShowTRD      = kFALSE;
178
179 Bool_t gCenterProjectionsAtPrimaryVertex = kFALSE;
180
181 // -----------------------------------------------------------------
182 // --                         Members                            --
183 // -----------------------------------------------------------------
184
185 // -- Timer for automatic event loop
186 TTimer                                    eventTimer;
187 TTimer                                    eventTimerFast;
188
189 // -- HOMERManager
190 AliEveHOMERManager*                       gHomerManager      = 0;
191
192 // -- Geometry Manager 
193 TGeoManager*                              gGeoManager        = 0;
194 AliPHOSGeometry*                          gPHOSGeom          = 0;
195
196 // -- Cluster members
197 TEvePointSet*                             gSPDClusters       = 0;
198 TEvePointSet*                             gSSDClusters       = 0;
199 TEvePointSet*                             gSDDClusters       = 0;
200 TEvePointSet*                             gTRDClusters       = 0;
201 TEvePointSetArray*                        gTRDColClusters    = 0;
202 TEvePointSet*                             gTPCClusters       = 0;
203 TEvePointSet*                             gTPCTestClusters       = 0;
204 TEvePointSetArray*                        gTPCColClusters    = 0;
205 TEveBoxSet*                               gPHOSBoxSet[5]     = {0, 0, 0, 0, 0}; 
206 TEveBoxSet*                               gEMCALBoxSet[13]   = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
207 TEvePointSet*                             gMUONClusters      = 0;
208 TEveStraightLineSet*                      gMUONTracks        = 0;
209
210 // -- Text output members
211 TEveText*                                 gHLTText           = 0;
212
213 // -- Tracks members
214 TEveTrackList*                            gTPCTrack          = 0;
215
216 // -- Canvas for histograms
217 TCanvas*                                  gTRDCanvas         = 0;
218 TCanvas*                                  gTPCCanvas         = 0;
219 TCanvas*                                  gTPCClustCanvas          = 0;
220 TCanvas*                                  gTRDCalibCanvas    = 0;
221 TCanvas*                                  gTRDEORCanvas      = 0;
222 TCanvas*                                  gPrimVertexCanvas  = 0;
223 TCanvas*                                  gSPDVertexCanvas   = 0;
224 TCanvas*                                  gITSCanvas         = 0;
225 TCanvas*                                  gSSDCanvas0        = 0;
226 TCanvas*                                  gSSDCanvas1        = 0;
227 TCanvas*                                  gV0Canvas          = 0;
228 TCanvas*                                  gPHOSCanvas          = NULL;
229 TCanvas*                                  gEMCALCanvas          = 0;
230
231 // -- vertex --
232 Int_t                                     gSPDVertexHistoCount  = 0;
233
234
235 // -- ITS --
236 Int_t                                     gITSHistoCount     = 0;
237 Int_t                                     gSSDHistoCount0    = 0;
238 Int_t                                     gSSDHistoCount1    = 0;
239
240 // -- TRD --
241 Int_t                                     gTRDHistoCount     = 0;
242 Int_t                                     gTRDEvents         = 0;
243 Int_t                                     gTRDBins           = 12;
244
245 // -- TPC --
246 Int_t                                     gTPCBins           = 15;
247 TH1F*                                     gTPCCharge         = 0;
248 TH1F*                                     gTPCQMax           = 0;
249 TH1F*                                     gTPCQMaxOverCharge = 0;
250
251 TH1F*                                     gTPCPt        = 0; // KK
252 TH1F*                                     gTPCEta       = 0; 
253 TH1F*                                     gTPCPsi       = 0; 
254 TH1F*                                     gTPCnClusters = 0; 
255 TH1F*                                     gTPCMult      = 0;
256
257 // -- PHOS --
258 TEveElementList*                          gPHOSElementList   = 0;
259 Int_t                                     gPHOSHistoCount    =0;
260 // -- EMCAL
261 TEveElementList*                          gEMCALElementList  = 0;
262 TGeoNode*                                 gEMCALNode         = 0;
263 Int_t                                     gEMCALHistoCount    =0;
264
265 // --- Flag if eventloop is running
266 Bool_t                                    gEventLoopStarted = kFALSE;
267
268
269 //Container for gGeoManager till it is broken
270 TGeoManager *fGeoManager = 0;
271 // -----------------------------------------------------------------
272 // --                          Methods                            --
273 // -----------------------------------------------------------------
274
275 Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode );
276
277 void nextEvent();
278
279 Int_t processEvent();
280
281 Int_t processPHOSClusters( AliHLTHOMERBlockDesc* block);
282 Int_t processPHOSDigits(AliHLTHOMERBlockDesc* block);
283
284 Int_t processEMCALClusters( AliHLTHOMERBlockDesc* block);
285
286 Int_t processEsdTracks( AliHLTHOMERBlockDesc* block, TEveTrackList* cont );
287
288 Int_t processHLTRDLST( AliHLTHOMERBlockDesc* block );
289
290 Int_t processROOTTOBJ( AliHLTHOMERBlockDesc* block, TEveText* text );
291
292 Int_t processTPCClusters( AliHLTHOMERBlockDesc * block, TEvePointSet *cont, TEvePointSetArray *contCol = NULL );
293
294 Int_t processTRDClusters( AliHLTHOMERBlockDesc * block, TEvePointSet *cont, TEvePointSetArray *contCol);
295
296 Int_t processTRDHistograms( AliHLTHOMERBlockDesc * block, TCanvas * canvas );
297
298 Int_t processITSHistograms( AliHLTHOMERBlockDesc * block, TCanvas * canvas );
299
300 Int_t processSSDHistograms( AliHLTHOMERBlockDesc * block, TCanvas * canvas, TCanvas * canvas1 );
301
302 Int_t processPrimVertexHistograms( AliHLTHOMERBlockDesc * block, TCanvas * canvas );
303
304 Int_t processSPDVertexHistograms( AliHLTHOMERBlockDesc * block, TCanvas * canvas );
305
306 Int_t processV0Histograms( AliHLTHOMERBlockDesc * block, TCanvas * canvas );
307
308 Int_t processTRDCalibHistograms( AliHLTHOMERBlockDesc *block, TCanvas *canvas );
309
310 Int_t processMUONClusters( AliHLTHOMERBlockDesc* block );
311
312 Int_t processMUONTracks( AliHLTHOMERBlockDesc* block );
313
314 Int_t processITSClusters( AliHLTHOMERBlockDesc* block, TEvePointSet* cont );
315
316 Int_t processITSHist( AliHLTHOMERBlockDesc* block );
317
318 //Global functions
319
320 Int_t processBlock( AliHLTHOMERBlockDesc* block );
321
322 void resetDisplay();
323
324 //Detector specific block handlers
325 Int_t processTRDBlock(AliHLTHOMERBlockDesc * block);
326 void processISPDBlock(AliHLTHOMERBlockDesc * block);
327 void processISDDBlock(AliHLTHOMERBlockDesc * block);
328 void processISSDBlock(AliHLTHOMERBlockDesc * block);
329 void processMUONBlock(AliHLTHOMERBlockDesc * block);
330 Int_t processPHOSBlock (AliHLTHOMERBlockDesc * block);
331 TEveElementList * createPHOSElementList();
332 void processEMCALBlock(AliHLTHOMERBlockDesc * block);
333 TEveElementList * createEMCALElementList();
334 void processHLTBlock(AliHLTHOMERBlockDesc * block);
335 void processTPCBlock(AliHLTHOMERBlockDesc * block);
336 void processITSBlock(AliHLTHOMERBlockDesc * block);
337 //Generic functions
338
339 TCanvas * CreateCanvas(TString  tabTitle, TString  canvasTitle );
340
341 Int_t updateDisplay();
342
343 Int_t AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount );
344
345 void writeToFile();
346
347
348 // #################################################################
349 // #################################################################
350 // #################################################################
351
352 // -----------------------------------------------------------------
353 void onlineDisplay(Bool_t TPCMode = kTRUE, Bool_t MUONMode = kFALSE, Bool_t TRDMode = kFALSE) {
354
355   // -- Loading Geometry
356   // ---------------------
357   Int_t run = 67179;
358   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
359   AliCDBManager::Instance()->SetRun(run);
360   AliGeomManager::LoadGeometry();
361
362   // Get the pointer to gGeoManager before it's broken (bug in alieve)
363   fGeoManager = gGeoManager;
364
365   // -- Create new hM object
366   // -------------------------
367   gHomerManager = new AliEveHOMERManager();
368   gHomerManager->SetRetryCount(100,10);
369
370   Int_t iResult = gHomerManager->Initialize();
371   if (iResult) { 
372     printf("Error Initializing AliHLTHOMERManager, quitting");
373     return; 
374   }
375
376   // -- Add hM to EveTree
377   // ----------------------
378   gEve->AddToListTree(gHomerManager, kTRUE);
379
380   // -- Create SourceList
381   // ----------------------
382   iResult = gHomerManager->CreateEveSourcesListLoop();
383   if (iResult) {
384     printf ("Couldn't find active services. returning\n");
385     return;
386   } 
387
388   // -- Initialize pointsets and add macros
389   // ----------------------------------------
390   //TEveUtil::LoadMacro("hlt_alieve_init.C");
391   //hlt_alieve_init(".", -1);
392
393   // -- Initialize Eve
394   // -------------------
395   initializeEveViewer( TPCMode, MUONMode, TRDMode);
396
397   // -- Reset gGeoManager to the original pointer
398   // ----------------------------------------------
399   gGeoManager = fGeoManager;
400   gPHOSGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
401
402   // -- Finalize Eve
403   // -----------------
404   gSystem->ProcessEvents();
405   gEve->Redraw3D(kTRUE);
406
407   if ( TPCMode ) {
408     gHomerManager->ConnectEVEtoHOMER("TPC" );
409   } else if ( MUONMode ) {
410     gHomerManager->ConnectEVEtoHOMER("MUON");
411   } else if( TRDMode ) {
412     gHomerManager->ConnectEVEtoHOMER("TRD");  
413   } else {
414     cout<<" No detectors selected, nothing will be displayed"<<endl;
415   }     
416
417   g_esd_tracks_true_field = kFALSE;
418
419 }
420
421 // -------------------------------------------------------------------------
422 Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
423   
424   //=============================================================================
425   // Visualization database
426   //============================================================================
427
428   TEveUtil::AssertMacro("VizDB_scan.C");
429   
430   //  alieve_vizdb();
431
432   //==============================================================================
433   // -- Geometry, scenes, projections and viewers
434   //==============================================================================
435
436
437   TEveBrowser         *browser = gEve->GetBrowser();
438   browser->ShowCloseTab(kFALSE);
439   
440   // -- Disable extra geometry
441   // ---------------------------
442   if (!MUONMode)
443     gShowMUON = gShowMUONRPhi = gShowMUONRhoZ = kFALSE;
444   
445   // -- Load Geometry
446   // ------------------
447   TEveUtil::LoadMacro("geom_gentle_hlt.C");
448   gGeomGentle = geom_gentle_hlt();
449   gGeomGentleRPhi = geom_gentle_rphi(); gGeomGentleRPhi->IncDenyDestroy();
450   gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();
451   gGeomGentleTRD  = geom_gentle_trd();
452
453   gGeoManager = fGeoManager;
454
455   gEMCALNode = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
456
457   TEveGeoTopNode* emcal_re = new TEveGeoTopNode(gGeoManager, gEMCALNode);
458   gEve->AddGlobalElement(emcal_re);
459   gEve->Redraw3D();
460
461   if (gShowMUON) 
462     gGeomGentleMUON = geom_gentle_muon(kFALSE);
463   
464   // -- Scenes
465   // -----------
466   gRPhiGeomScene  = gEve->SpawnNewScene("RPhi Geometry",
467                     "Scene holding projected geometry for the RPhi view.");
468   gRhoZGeomScene  = gEve->SpawnNewScene("RhoZ Geometry",
469                     "Scene holding projected geometry for the RhoZ view.");
470   gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",
471                     "Scene holding projected geometry for the RPhi view.");
472   gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",
473                     "Scene holding projected geometry for the RhoZ view.");
474
475   // -- Projection managers
476   // ------------------------
477
478   gRPhiMgr = new TEveProjectionManager();
479   gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);
480   gEve->AddToListTree(gRPhiMgr, kFALSE);
481   {
482     TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);
483     a->SetMainColor(kWhite);
484     a->SetTitle("R-Phi");
485     a->SetTitleSize(0.05);
486     a->SetTitleFont(102);
487     a->SetLabelSize(0.025);
488     a->SetLabelFont(102);
489     gRPhiGeomScene->AddElement(a);
490   }
491   gRPhiMgr->SetCurrentDepth(-10);
492   gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);
493   gRPhiMgr->SetCurrentDepth(0);
494   gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);
495   if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);
496
497   gRhoZMgr = new TEveProjectionManager();
498   gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);
499   gEve->AddToListTree(gRhoZMgr, kFALSE);
500   {
501     TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);
502     a->SetMainColor(kWhite);
503     a->SetTitle("Rho-Z");
504     a->SetTitleSize(0.05);
505     a->SetTitleFont(102);
506     a->SetLabelSize(0.025);
507     a->SetLabelFont(102);
508     gRhoZGeomScene->AddElement(a);
509   }
510   gRhoZMgr->SetCurrentDepth(-10);
511   gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);
512   gRhoZMgr->SetCurrentDepth(0);
513   if (gShowTRD)      gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);
514   if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);
515
516   // -- Viewers
517   // ------------
518
519   TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
520   TEveWindowPack *pack = slot->MakePack();
521   pack->SetElementName("Multi View");
522   pack->SetHorizontal();
523   pack->SetShowTitleBar(kFALSE);
524   pack->NewSlot()->MakeCurrent();
525   g3DView = gEve->SpawnNewViewer("3D View", "");
526   g3DView->AddScene(gEve->GetGlobalScene());
527   g3DView->AddScene(gEve->GetEventScene());
528
529
530   pack = pack->NewSlot()->MakePack();
531   pack->SetShowTitleBar(kFALSE);
532   pack->NewSlot()->MakeCurrent();
533   gRPhiView = gEve->SpawnNewViewer("RPhi View", "");
534   gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
535   gRPhiView->AddScene(gRPhiGeomScene);
536   gRPhiView->AddScene(gRPhiEventScene);
537
538   pack->NewSlot()->MakeCurrent();
539   gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
540   gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
541   gRhoZView->AddScene(gRhoZGeomScene);
542   gRhoZView->AddScene(gRhoZEventScene);
543
544
545    
546   //Add HLT Text to windows
547  
548   TGLOverlayButton *ob1 = new TGLOverlayButton(g3DView->GetGLViewer(),  "HLT", 0, 20, 110, 60);
549   ob1->SetAlphaValues(0.8, 0.8);
550   //  cout << "color" << ob1->GetBackColor() << endl;
551   //ob1->SetBackColor(8421631);
552   ob1->SetBackColor(10492431);
553   TGLOverlayButton *ob2 = new TGLOverlayButton(g3DView->GetGLViewer(),  "ALICE", 0, 0, 110, 20);
554   ob2->SetAlphaValues(0.8, 0.8);
555   ob1->SetBackColor(0.2);
556   TGLOverlayButton *ob3 = new TGLOverlayButton(gEve->GetDefaultGLViewer(),  "HLT", 0, 20, 110, 60);
557   ob3->SetAlphaValues(0.8, 0.8);
558   TGLOverlayButton *ob4 = new TGLOverlayButton(gEve->GetDefaultGLViewer(),  "ALICE", 0, 0, 110, 20);
559   ob4->SetAlphaValues(0.8, 0.8);
560
561
562   // -- List of Viewers
563   // --------------------
564
565   TEveViewerList *viewerlist = new TEveViewerList();
566   viewerlist->AddElement(gEve->GetDefaultViewer());
567
568   viewerlist->AddElement(g3DView);
569   viewerlist->AddElement(gRhoZView);
570   viewerlist->AddElement(gRPhiView);
571   viewerlist->SwitchColorSet();
572
573   //==============================================================================
574   // -- Macros / QA histograms
575   //==============================================================================
576
577   // -- Registration of per-event macros
578   // -------------------------------------
579
580   AliEveMacroExecutor *exec    = new AliEveMacroExecutor();
581   
582
583 #if 0
584   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Track",   "kine_tracks.C", "kine_tracks", "", kFALSE));
585
586   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit ITS", "its_hits.C",    "its_hits",    "", kFALSE));
587   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit TPC", "tpc_hits.C",    "tpc_hits",    "", kFALSE));
588   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit T0",  "t0_hits.C",     "t0_hits",     "", kFALSE));
589   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "SIM Hit FMD", "fmd_hits.C",    "fmd_hits",    "", kFALSE));
590
591   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "DIG FMD",     "fmd_digits.C",  "fmd_digits",  "", kFALSE));
592
593   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW TPC",     "tpc_raw.C",     "tpc_raw",     "", kFALSE));
594   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW T0",      "t0_raw.C",      "t0_raw",      "", kFALSE));
595   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW FMD",     "fmd_raw.C",     "fmd_raw",     "", kFALSE));
596   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW VZERO",   "vzero_raw.C",   "vzero_raw",   "", kFALSE));
597   exec->AddMacro(new AliEveMacro(AliEveMacro::kRawReader, "RAW ACORDE",  "acorde_raw.C",  "acorde_raw",  "", kFALSE));
598
599   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex",             "",                kTRUE));
600   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse",     "",                kTRUE));
601   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box",         "kFALSE, 3, 3, 3", kFALSE));
602   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_spd",         "",                kTRUE));
603   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_spd", "",                kTRUE));
604   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_spd",     "kFALSE, 3, 3, 3", kFALSE));
605   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX",         "primary_vertex.C", "primary_vertex_tpc",         "",                kFALSE));
606   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Ellipse", "primary_vertex.C", "primary_vertex_ellipse_tpc", "",                kFALSE));
607   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC PVTX Box",     "primary_vertex.C", "primary_vertex_box_tpc",     "kFALSE, 3, 3, 3", kFALSE));
608 #endif
609   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0_points.C",       "esd_V0_points_onfly"));
610   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0_points.C",       "esd_V0_points_offline"));
611   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC V0",   "esd_V0.C",              "esd_V0"));
612   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade_points.C",  "esd_cascade_points"));
613   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC CSCD", "esd_cascade.C",         "esd_cascade"));
614   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink_points.C",     "esd_kink_points"));
615   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC KINK", "esd_kink.C",            "esd_kink"));
616
617   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks",             "", kFALSE));
618   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_MI",          "", kFALSE));
619   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Track", "esd_tracks.C", "esd_tracks_by_category", "", kTRUE));
620
621   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC Tracklet", "esd_spd_tracklets.C", "esd_spd_tracklets", "", kFALSE));
622
623   exec->AddMacro(new AliEveMacro(AliEveMacro::kESD, "REC ZDC",      "esd_zdc.C", "esd_zdc", "", kFALSE));
624 #if 0
625   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus",     "clusters.C+",     "clusters", "", kFALSE));
626   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus ITS", "its_clusters.C+", "its_clusters"));
627   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "tpc_clusters.C+", "tpc_clusters"));
628   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TRD", "trd_clusters.C+", "trd_clusters"));
629   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TOF", "tof_clusters.C+", "tof_clusters"));
630
631   exec->AddMacro(new AliEveMacro(AliEveMacro::kRunLoader, "REC Clus TPC", "vplot_tpc.C+",    "vplot_tpc", "", kFALSE));
632
633   exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA HF",   "aod_HF.C",   "aod_HF",   "", kFALSE));
634   exec->AddMacro(new AliEveMacro(AliEveMacro::kAOD, "ANA Jets", "jetplane.C", "jetplane", "", kFALSE));
635
636   // -- QA Viewer
637   // --------------
638 # endif
639
640
641   //==============================================================================
642   // -- Histograms
643   //==============================================================================
644
645
646   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
647   slot->StartEmbedding();  
648   gPrimVertexCanvas = new TCanvas("canvasPrimVertex","canvasPrimVertex", 600, 400);
649   slot->StopEmbedding("Primary Vertex");
650
651   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
652   slot->StartEmbedding();  
653   gSPDVertexCanvas = new TCanvas("canvasSPDVertex","canvasSPDVertex", 600, 400);
654   slot->StopEmbedding("SPD Vertex");
655
656   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
657   slot->StartEmbedding();  
658   gV0Canvas = new TCanvas("canvasV0","canvasV0", 600, 400);
659   slot->StopEmbedding("V0");
660
661
662   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
663   slot->StartEmbedding();
664   gSSDCanvas0 = new TCanvas("canvasSSD0","canvasSSD0", 600, 400);
665   slot->StopEmbedding("SSD QA 0");
666
667   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
668   slot->StartEmbedding();
669   gSSDCanvas1 = new TCanvas("canvasSSD1","canvasSSD1", 600, 400);
670   slot->StopEmbedding("SSD QA 1");
671
672   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
673   slot->StartEmbedding();
674   gTPCClustCanvas = new TCanvas("canvasTPCClust","canvasTPCClust", 600, 400);
675   gTPCClustCanvas->Divide(3, 2);
676   slot->StopEmbedding("TPC Cluster QA Histograms ");
677
678
679   //==============================================================================
680   // -- Additional GUI components
681   //==============================================================================
682   
683   slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
684   TEveWindowTab *storeTab = slot->MakeTab();
685   storeTab->SetElementNameTitle("WindowStore",
686                                  "Undocked windows whose previous container is not known\n"
687                                  "are placed here when the main-frame is closed.");
688   gEve->GetWindowManager()->SetDefaultContainer(storeTab);
689   
690   
691
692   return 0;
693 }
694
695 // -----------------------------------------------------------------
696 void nextEvent() {
697
698   if ( gHomerManager->NextEvent() ) {
699     if (gEventLoopStarted) {
700       cout << "HomerManager failed getting next event, trying to reconnect" << endl;
701
702       gHomerManager->DisconnectHOMER();
703       gHomerManager->ConnectEVEtoHOMER();
704       nextEvent();
705    
706     } else {
707       return;
708     }
709   }
710
711   processEvent();
712 }
713
714 TCanvas * CreateCanvas(TString  tabTitle, TString  canvasTitle ) {
715
716   
717
718 //   TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
719 //   slot->StartEmbedding();
720 //   TCanvas * canvas = new TCanvas(canvasTitle.Data(),canvasTitle.Data(), 600, 400);
721 //   slot->StopEmbedding(tabTitle.Data());
722  
723   cout << "Create"<<endl;
724
725   TCanvas * canvas = gEve->AddCanvasTab(canvasTitle.Data());
726   return canvas;
727 }
728
729
730 // -----------------------------------------------------------------
731 Int_t processEvent() {
732
733   Int_t iResult = 0;
734
735   gStyle->SetPalette(1, 0);
736   gEve->DisableRedraw();
737
738   resetDisplay();
739   
740   //==============================================================================
741   // -- Process Blocks
742   //==============================================================================
743
744   AliHLTHOMERBlockDesc* block = 0;
745
746   if ( gHomerManager->GetBlockList() == NULL) {
747     printf ("onlineDisplay:   No regular BlockList ... \n");
748     cout << endl;
749     //return -1;
750     
751   } else {
752     
753     if (gHomerManager->GetBlockList()->IsEmpty() ) {
754       printf ("onlineDisplay:   No Sync Blocks in list ... \n");
755       cout<<endl;
756       return -2;
757     }  
758     
759     
760     TIter next(gHomerManager->GetBlockList());
761     
762     while ((block = (AliHLTHOMERBlockDesc*)next())) {
763       iResult = processBlock(block);
764     } 
765   }
766
767   //Read out histograms and elements from detectors outside physics 1 partition
768   TIter anext(gHomerManager->GetAsyncBlockList());
769   
770   while ( (block = (AliHLTHOMERBlockDesc*)anext()) ) {
771     iResult = processBlock(block);
772   }
773   
774   updateDisplay();
775
776   return iResult;
777 }
778
779
780 void resetDisplay() {
781
782
783   //==============================================================================
784   // -- Reset
785   //==============================================================================
786   
787   if ( gTRDCanvas ) {
788     gTRDCanvas->Clear();
789     gTRDCanvas->Divide(3,2);
790   }
791   if(gTRDCalibCanvas){
792     gTRDCalibCanvas->Clear();
793     gTRDCalibCanvas->Divide(2,2);
794   }
795   if(gTRDEORCanvas){
796     gTRDEORCanvas->Clear();
797     gTRDEORCanvas->Divide(3,2);
798   }
799   
800   if(gSSDCanvas0) {
801     gSSDCanvas0->Clear();
802     gSSDCanvas0->Divide(6,6);
803   }
804
805   if(gSSDCanvas1) {
806     gSSDCanvas1->Clear();
807     gSSDCanvas1->Divide(2,3);
808   }
809   
810   if(gITSCanvas) {
811     gITSCanvas->Clear();
812     gITSCanvas->Divide(3,3);
813   }
814
815   if(gPrimVertexCanvas) {
816     gPrimVertexCanvas->Clear();
817     gPrimVertexCanvas->Divide(2,2);
818   }
819
820   if(gSPDVertexCanvas) {
821     gSPDVertexCanvas->Clear();
822     gSPDVertexCanvas->Divide(2,2);
823   }
824
825   if(gV0Canvas) {
826     gV0Canvas->Clear();
827     gV0Canvas->Divide(2,2);
828   }
829
830   if(gPHOSCanvas) {
831     gPHOSCanvas->Clear();
832     gPHOSCanvas->Divide(3, 3);
833   }
834
835   if(gEMCALCanvas) {
836     gEMCALCanvas->Clear();
837     gEMCALCanvas->Divide(3, 3);
838   }
839
840   if ( gTPCTrack )     gTPCTrack->DestroyElements();
841
842   if ( gSPDClusters )  gSPDClusters->Reset();
843   if ( gSSDClusters )  gSSDClusters->Reset();
844   if ( gSDDClusters )  gSDDClusters->Reset();
845   if ( gTPCClusters )  gTPCClusters->Reset();
846   if ( gTPCTestClusters )  gTPCTestClusters->Reset();
847   if ( gTRDClusters )  gTRDClusters->Reset();
848   if ( gMUONClusters ) gMUONClusters->Reset();
849   if ( gMUONTracks ){
850     gMUONTracks->Destroy();
851     gMUONTracks = 0x0;
852   }
853
854   if ( gPHOSBoxSet[1] )
855     for(int im = 0; im < 5; im++)
856       gPHOSBoxSet[im]->Reset();   
857
858   if ( gEMCALElementList)
859     for(int i = 0; i < 12; i++) {
860       gEMCALBoxSet[i]->Reset();
861     }
862   
863   if ( gTPCColClusters )
864     for (Int_t ii = 0; ii <= gTPCBins+1; ++ii) 
865       gTPCColClusters->GetBin(ii)->Reset();
866   
867   if ( gTRDColClusters )
868     for (Int_t ii = 0; ii <= gTRDBins+1; ++ii) 
869       gTRDColClusters->GetBin(ii)->Reset();
870
871   gTRDHistoCount = 0;
872   gSPDVertexHistoCount = 0;
873   gSSDHistoCount0 = 0;
874   gSSDHistoCount1 = 0;
875   gITSHistoCount = 0;
876   gPHOSHistoCount = 0;
877   gEMCALHistoCount = 0;
878
879   
880 }
881
882
883 Int_t updateDisplay() {
884   Int_t iResult = 0;
885
886   
887   //==============================================================================
888   // -- Update Objects
889   //==============================================================================
890   
891   // -- TPC Histograms
892   if ( gTPCCanvas && gTPCCharge && gTPCQMax) {
893
894     gTPCCanvas->Clear();    
895     gTPCCanvas->Divide(1,3);
896
897     gTPCCanvas->cd(1);
898     gTPCCharge->Draw();
899
900     gTPCCanvas->cd(2);
901     gTPCQMax->Draw();
902
903     gTPCCanvas->cd(3);
904     gTPCQMaxOverCharge->Draw();
905
906     gTPCCanvas->Update();
907   }
908
909   if ( gTPCClusters ) gTPCClusters->ResetBBox();
910   if ( gTPCTestClusters ) gTPCTestClusters->ResetBBox();
911   if ( gTRDClusters ) gTRDClusters->ResetBBox();
912   if ( gSPDClusters ) gSPDClusters->ResetBBox();
913   if ( gSDDClusters ) gSDDClusters->ResetBBox();
914   if ( gSSDClusters ) gSSDClusters->ResetBBox();
915   if ( gMUONClusters ) gMUONClusters->ResetBBox();
916
917   if ( gPHOSBoxSet[1] )
918     for(int im = 0; im < 5; im++)
919       gPHOSBoxSet[im]->ResetBBox();      
920
921   if ( gEMCALElementList )
922     for(int sm = 0; sm < 12; sm++) 
923       gEMCALBoxSet[sm]->ResetBBox();
924     
925   //==============================================================================
926   // -- Set EventID in Window Title  
927   // -- Update Objects
928   //==============================================================================
929
930   TString winTitle("Eve Main Window -- Event ID : ");
931   winTitle += Form("0x%016X ", gHomerManager->GetEventID() );
932   gEve->GetBrowser()->SetWindowName(winTitle);
933
934   //==============================================================================
935   // -- Set Projections
936   //==============================================================================
937
938   // XXX Primary vertex ... to be retrieved from the ESD
939   Double_t x[3] = { 0, 0, 0 };
940   
941   TEveElement* top = gEve->GetCurrentEvent();
942   
943   if (gRPhiMgr && top) {
944     gRPhiEventScene->DestroyElements();
945     if (gCenterProjectionsAtPrimaryVertex)
946       gRPhiMgr->SetCenter(x[0], x[1], x[2]);
947     gRPhiMgr->ImportElements(top, gRPhiEventScene);
948   }
949   
950   if (gRhoZMgr && top) {
951     gRhoZEventScene->DestroyElements();
952     if (gCenterProjectionsAtPrimaryVertex)
953       gRhoZMgr->SetCenter(x[0], x[1], x[2]);
954     gRhoZMgr->ImportElements(top, gRhoZEventScene);
955   }
956
957   //==============================================================================
958
959   gEve->Redraw3D(0,1); // (0, 1)
960   gEve->EnableRedraw(); 
961
962   return iResult;
963
964 }
965
966
967 // -----------------------------------------------------------------
968 Int_t processITSHist(AliHLTHOMERBlockDesc* /*block*/) {
969   return 0;
970 }
971
972 // -----------------------------------------------------------------
973 Int_t processHLTRDLST(AliHLTHOMERBlockDesc* /*block*/) {
974   return 0;
975 }
976
977 // -----------------------------------------------------------------
978 Int_t processROOTTOBJ(AliHLTHOMERBlockDesc* block, TEveText* /*et*/) {
979   
980   // -- AliHLTGlobalTriggerDecision
981   if ( ! block->GetClassName().CompareTo("AliHLTGlobalTriggerDecision") ) {
982
983     AliHLTGlobalTriggerDecision *trig = dynamic_cast<AliHLTGlobalTriggerDecision*>( block->GetTObject());
984     trig->Print(); 
985     
986     // et->SetText("balle");;
987
988     // TEveText* tt = new TEveText("Trigger: Class is known ;-) ");
989     // gEve->AddElement(tt);
990
991   }
992   else {
993     printf(" Unknown root object %s",block->GetClassName().Data() );
994   }
995
996   return 0;
997 }
998
999 // -----------------------------------------------------------------
1000 Int_t processEsdTracks( AliHLTHOMERBlockDesc* block, TEveTrackList* cont ) {
1001
1002   AliESDEvent* esd = (AliESDEvent *) (block->GetTObject());
1003   esd->GetStdContent();
1004   
1005   esd_track_propagator_setup(cont->GetPropagator(),-0.1*esd->GetMagneticField(), 520);
1006
1007   //  printf( "Number of ESD Tracks : %d \n", esd->GetNumberOfTracks());
1008
1009   for (Int_t iter = 0; iter < esd->GetNumberOfTracks(); ++iter) {
1010     //AliEveTrack* track = dynamic_cast<AliEveTrack*>(esd_make_track(esd->GetTrack(iter), cont));
1011     AliEveTrack* track = dynamic_cast<AliEveTrack*>(hlt_esd_make_track(esd->GetTrack(iter), cont));
1012     cont->AddElement(track);
1013     
1014 //     gTPCPt->Fill(esd->GetTrack(iter)->GetSignedPt()); // KK
1015 //     gTPCEta->Fill(esd->GetTrack(iter)->GetSnp());
1016 //     gTPCPsi->Fill(esd->GetTrack(iter)->GetTgl());
1017 //     gTPCnClusters->Fill(esd->GetTrack(iter)->GetTPCNcls());  
1018   }
1019   
1020 //   gTPCMult->Fill(esd->GetNumberOfTracks()); // KK
1021   
1022 //   Int_t icd = 0;
1023 //   gTPCClustCanvas->Clear();
1024 //   gTPCClustCanvas->Divide(2, 2);
1025 //   gTPCClustCanvas->cd(icd++);
1026 //   gTPCPt->Draw();
1027 //   gTPCClustCanvas->cd(icd++);
1028 //   gTPCEta->Draw();
1029 //   gTPCClustCanvas->cd(icd++);
1030 //   gTPCPsi->Draw();
1031 //   gTPCClustCanvas->cd(icd++);
1032 //   gTPCnClusters->Draw();
1033 //   gTPCClustCanvas->cd(icd++);
1034 //   gTPCMult->Draw();
1035 //   gTPCClustCanvas->Update();
1036
1037   
1038   cont->SetTitle(Form("N=%d", esd->GetNumberOfTracks()) );
1039   cont->MakeTracks();
1040   
1041   return 0;
1042 }
1043
1044 // // -----------------------------------------------------------------
1045 // Int_t processPHOSClusters(AliHLTHOMERBlockDesc* block) {
1046
1047
1048 //   cout <<"Processgin phos clusters"<<endl;
1049    
1050 //   AliHLTCaloChannelDataHeaderStruct *chh = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*> (block->GetData());
1051   
1052 //   AliHLTCaloChannelDataStruct *chd = reinterpret_cast<AliHLTCaloChannelDataStruct*>(chh+1);
1053
1054 //   for(Int_t i = 0; i < chh->fNChannels; i++, chd++) {
1055     
1056 //     Int_t gain = (chd->fChannelID >> 12)&0x1;    
1057 //     Int_t module = (chd->fChannelID >> 13)&0x1f;
1058 //     module = 4 -module;
1059    
1060
1061 //     if(gain == 1)
1062       
1063 //       {
1064 //      Float_t x = (static_cast<Float_t>(chd->fChannelID&0x3f) - 32)* 2.2;
1065 //      Float_t z = (static_cast<Float_t>((chd->fChannelID >> 6)&0x3f) - 28) * 2.2;
1066 //      //      gPHOSBoxSet[ds->fModule]->AddBox(ds->fLocX, 0, ds->fLocZ, 2.2, ds->fEnergy*20, 2.2);
1067 //      gPHOSBoxSet[module]->AddBox(x, 0, z, 2.2, chd->fEnergy/1, 2.2);
1068 //      gPHOSBoxSet[module]->DigitValue(static_cast<Int_t>(chd->fEnergy));
1069 //       }
1070
1071
1072
1073 //   }
1074 // cout <<"done with phos"<<endl;
1075
1076
1077 //   return 0;
1078 // }
1079
1080
1081
1082 // // -----------------------------------------------------------------
1083 Int_t processPHOSDigits(AliHLTHOMERBlockDesc* block) {
1084
1085   AliHLTCaloDigitDataStruct *ds = reinterpret_cast<AliHLTCaloDigitDataStruct*> (block->GetData());
1086   UInt_t nDigits = block->GetSize()/sizeof(AliHLTCaloDigitDataStruct);
1087     
1088
1089   for(UInt_t i = 0; i < nDigits; i++, ds++) {
1090
1091     Float_t x = (ds->fX - 32)* 2.2;
1092       Float_t z = (ds->fZ - 28) * 2.2;
1093
1094       cout << "MODULE DIGITTYP  :" << ds->fModule;
1095
1096     gPHOSBoxSet[4-ds->fModule]->AddBox(x, 0, z, 2.2, ds->fEnergy*20, 2.2);
1097     gPHOSBoxSet[4-ds->fModule]->DigitValue(static_cast<Int_t>(ds->fEnergy*10));
1098   }
1099
1100   return 0;
1101 }
1102
1103
1104 // -----------------------------------------------------------------
1105 Int_t processPHOSClusters(AliHLTHOMERBlockDesc* block) {
1106
1107   AliHLTCaloClusterHeaderStruct *dh = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
1108   AliHLTCaloClusterReader * clusterReader = new AliHLTCaloClusterReader();
1109   clusterReader->SetMemory(dh);  
1110
1111   AliHLTCaloClusterDataStruct * ds;
1112
1113   Int_t nc = 0;
1114
1115   
1116   while( (ds = clusterReader->NextCluster()) ){
1117     nc++;
1118     cout << "Cluster nr " << nc  << "   Energy  " << ds->fEnergy<< "      " << ds->fGlobalPos[0] << " " << ds->fGlobalPos[1] << " " << ds->fGlobalPos[2] << endl;
1119
1120
1121     gPHOSBoxSet[2]->AddBox(ds->fGlobalPos[0], 0, ds->fGlobalPos[2], 2.2, -ds->fEnergy*20, 2.2);
1122     gPHOSBoxSet[2]->DigitValue(static_cast<Int_t>(ds->fEnergy*10));
1123   }
1124
1125   return 0;
1126 }
1127
1128
1129
1130 // -----------------------------------------------------------------
1131 Int_t processEMCALClusters(AliHLTHOMERBlockDesc* block) {
1132
1133   cout << "EMCAL"<<endl;
1134
1135   AliHLTCaloChannelDataHeaderStruct *dhs = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*> (block->GetData());
1136   Short_t nC = dhs->fNChannels;
1137   AliHLTUInt8_t *ui = reinterpret_cast<AliHLTUInt8_t*>(dhs) + sizeof(AliHLTCaloChannelDataHeaderStruct);
1138   AliHLTCaloChannelDataStruct *ds = reinterpret_cast<AliHLTCaloChannelDataStruct*>(ui);
1139   
1140   UShort_t fX =0;
1141   UShort_t fZ =0;
1142   UShort_t fGain =0;
1143   UShort_t fModuleId =0;
1144   
1145
1146
1147   for(Short_t s = 0; s < nC; s++ ) {
1148       
1149     fX = ds->fChannelID&0x3f;
1150     fZ = (ds->fChannelID >> 6)&0x3f;
1151     fGain = (ds->fChannelID >> 12)&0x1;
1152     fModuleId  = (ds->fChannelID >> 13)&0x1f;
1153     
1154     //    cout << fX << " " << fZ << " " << fGain << " " << fModuleId <<endl;
1155    
1156     if ( (  fModuleId < 12 ) ) {
1157       gEMCALBoxSet[fModuleId]->AddBox(10, fX*6-12*6, fZ*6-24*6, ds->fEnergy/4, 6, 6);
1158       gEMCALBoxSet[fModuleId]->DigitValue(static_cast<Int_t>(ds->fEnergy));
1159     } 
1160     ds++;
1161     
1162   }
1163   
1164   return 0;
1165 }
1166
1167 // -----------------------------------------------------------------
1168 Int_t processITSClusters(AliHLTHOMERBlockDesc* block, TEvePointSet* cont) {
1169
1170   AliHLTITSClusterData *cd = reinterpret_cast<AliHLTITSClusterData*> (block->GetData());
1171   UChar_t *data            = reinterpret_cast<UChar_t*> (cd->fSpacePoints);
1172   
1173   if ( cd->fSpacePointCnt != 0 ) {
1174     for (Int_t iter = 0; iter < cd->fSpacePointCnt; ++iter, data += sizeof(AliHLTITSSpacePointData)) {
1175       AliHLTITSSpacePointData *sp = reinterpret_cast<AliHLTITSSpacePointData*> (data);
1176   
1177       Int_t lab[4]   = {0,0,0,0};
1178       Float_t hit[6] = {0,0,0,0,0,0};
1179       Int_t info[3]  = {0,0,0};
1180                                  
1181       lab[0]  = sp->fTracks[0];
1182       lab[1]  = sp->fTracks[1];
1183       lab[2]  = sp->fTracks[2];
1184       lab[3]  = sp->fIndex;
1185       hit[0]  = sp->fY;
1186       hit[1]  = sp->fZ;
1187       hit[2]  = sp->fSigmaY2;
1188       hit[3]  = sp->fSigmaZ2;
1189       hit[4]  = sp->fQ;
1190       hit[5]  = sp->fSigmaYZ;
1191       info[0] = sp->fNy;
1192       info[1] = sp->fNz;
1193       info[2] = sp->fLayer;
1194       
1195       Float_t xyz[3];
1196       AliITSRecPoint recpoint(lab,hit,info);
1197       recpoint.GetGlobalXYZ(xyz);
1198
1199       cont->SetNextPoint(xyz[0], xyz[1], xyz[2]);
1200     }
1201   }
1202   return 0;
1203 }
1204
1205 // -----------------------------------------------------------------
1206 Int_t processTPCClusters(AliHLTHOMERBlockDesc* block, TEvePointSet* cont, TEvePointSetArray *contCol ) {
1207
1208   
1209
1210   Int_t   slice = block->GetSubDetector();
1211   Float_t phi   = ( slice + 0.5 ) * TMath::Pi() / 9.0;  
1212   Float_t cos   = TMath::Cos( phi );
1213   Float_t sin   = TMath::Sin( phi );
1214   
1215   AliHLTTPCClusterData *cd = reinterpret_cast<AliHLTTPCClusterData*> (block->GetData());
1216   UChar_t *data            = reinterpret_cast<UChar_t*> (cd->fSpacePoints);
1217
1218
1219   if(!gTPCCanvas){
1220     gTPCCanvas = gEve->AddCanvasTab("TPC QA");
1221     gTPCCharge = new TH1F("ClusterCharge","ClusterCharge",100,0,500);
1222     gTPCQMax = new TH1F("QMax","QMax",50,0,250);
1223     gTPCQMaxOverCharge = new TH1F("QMaxOverCharge","QMaxOverCharge",50,0,1);
1224   }
1225
1226
1227
1228   
1229
1230
1231
1232
1233
1234   if ( cd->fSpacePointCnt != 0 ) {
1235     for (Int_t iter = 0; iter < cd->fSpacePointCnt; ++iter, data += sizeof(AliHLTTPCSpacePointData)) {
1236       AliHLTTPCSpacePointData *sp = reinterpret_cast<AliHLTTPCSpacePointData*> (data);
1237       cont->SetNextPoint(cos*sp->fX - sin*sp->fY, sin*sp->fX + cos*sp->fY, sp->fZ);
1238       if (contCol)
1239         contCol->Fill(cos*sp->fX - sin*sp->fY, sin*sp->fX + cos*sp->fY, sp->fZ, sp->fCharge);
1240
1241       gTPCCharge->Fill(sp->fCharge);
1242       gTPCQMax->Fill(sp->fQMax);
1243       gTPCQMaxOverCharge->Fill(((Float_t)sp->fQMax)/((Float_t)sp->fCharge));
1244     }
1245   }
1246   
1247   return 0;
1248 }
1249
1250 // -----------------------------------------------------------------
1251 Int_t processMUONClusters(AliHLTHOMERBlockDesc* block) {
1252   
1253   Int_t iResult = 0;
1254   
1255   unsigned long size = block->GetSize();
1256   Int_t * buffer ;
1257
1258   buffer = (Int_t *)block->GetData();
1259 //   cout<<"block size : "<<size<<", buffer : "<<buffer<<", DataType : "<<block->GetDataType()<<endl;
1260
1261 // //   for(int idata=0;idata<int(size);idata++)
1262 // //     printf("\tbuffer[%d] : %d\n",idata,buffer[idata]);
1263   
1264   
1265   
1266   if(block->GetDataType().CompareTo("RECHITS") == 0){
1267
1268     AliHLTMUONRecHitsBlockReader trackblock((char*)buffer, size);
1269     const AliHLTMUONRecHitStruct* hit = trackblock.GetArray();
1270     
1271     for(AliHLTUInt32_t ientry = 0; ientry < trackblock.Nentries(); ientry++){
1272 //       cout << setw(13) << left << hit->fX << setw(0);
1273 //       cout << setw(13) << left << hit->fY << setw(0);
1274 //       cout << hit->fZ << setw(0) << endl;
1275       if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0)
1276         gMUONClusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
1277       hit++;
1278       
1279     }// track hit loop
1280   }
1281
1282   else{// if rechits
1283     //     if(!strcmp((BlockType(ULong64_t(reader->GetBlockDataType(i)))).Data(),"TRIGRECS")){
1284   
1285     AliHLTMUONTriggerRecordsBlockReader trigblock(buffer, size);
1286     const AliHLTMUONTriggerRecordStruct* trigrec = trigblock.GetArray();
1287     for(AliHLTUInt32_t ientry = 0; ientry < trigblock.Nentries(); ientry++){
1288       
1289       const AliHLTMUONRecHitStruct* hit = &trigrec->fHit[0];
1290       for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
1291         {
1292 //        cout << setw(10) << left << ch + 11 << setw(0);
1293 //        cout << setw(13) << left << hit->fX << setw(0);
1294 //        cout << setw(13) << left << hit->fY << setw(0);
1295 //        cout << hit->fZ << setw(0) << endl;
1296           if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0)
1297             gMUONClusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
1298           hit++;
1299         }// trig chamber loop
1300       trigrec++;
1301     }//trig hit loop
1302   }//else trigger
1303
1304   return iResult;
1305 }
1306
1307 // -----------------------------------------------------------------
1308 Int_t processMUONTracks(AliHLTHOMERBlockDesc* block) {
1309   
1310   Int_t iResult = 0;
1311   
1312   unsigned long size = block->GetSize();
1313   Int_t * buffer = (Int_t *)block->GetData();
1314   AliHLTMUONRecHitStruct hit1,hit2;
1315   hit1.fX = hit1.fY = hit1.fZ = hit2.fX = hit2.fY = hit2.fZ = 0;
1316   Int_t ch1=0, ch2=0;
1317   Float_t x0=0.0,y0=0.0,z0=0.0;
1318   Float_t x3=0.0,y3=0.0,z3=0.0;
1319   if(block->GetDataType().CompareTo("MANTRACK") == 0){  
1320     AliHLTMUONMansoTracksBlockReader mantrackblock(buffer, size);
1321     const AliHLTMUONMansoTrackStruct* mtrack = mantrackblock.GetArray();
1322     for(AliHLTUInt32_t ientry = 0; ientry < mantrackblock.Nentries(); ientry++){
1323       const AliHLTMUONRecHitStruct* hit = &mtrack->fHit[0];
1324       for(AliHLTUInt32_t ch = 0; ch < 4; ch++){
1325         // cout << setw(10) << left << ch + 7 << setw(0);
1326         // cout << setw(13) << left << hit->fX << setw(0);
1327         // cout << setw(13) << left << hit->fY << setw(0);
1328         // cout << hit->fZ << setw(0) << endl;
1329         if(hit->fZ != 0.0){
1330           if(ch==0 || ch==1){
1331             hit1 = *hit; ch1 = ch+6;
1332           }else{
1333             hit2 = *hit; ch2 = ch+6;
1334           }
1335         }
1336         hit++;
1337       }// trig chamber loop
1338       // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch1,hit1.fX,hit1.fY,hit1.fZ);
1339       // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch2,hit2.fX,hit2.fY,hit2.fZ);
1340       // meminfo();
1341       z3 = AliMUONConstants::DefaultChamberZ(ch2+4);
1342       y3 =  hit1.fY - (hit1.fZ-z3)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ;
1343       x3 =  hit1.fX - (hit1.fZ-z3)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ;
1344
1345       z0 = AliMUONConstants::DefaultChamberZ(ch1);
1346       y0 =  hit1.fY - (hit1.fZ-z0)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ;
1347       x0 =  hit1.fX - (hit1.fZ-z0)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ;
1348       
1349
1350       gMUONTracks->AddLine(x0,y0,z0,x3,y3,z3);
1351       mtrack++;
1352     }
1353     cout<<"NofManso Tracks : "<<mantrackblock.Nentries()<<endl;
1354   }
1355   
1356   return iResult;
1357
1358 }
1359
1360  
1361 // -----------------------------------------------------------------
1362 Int_t processTRDClusters(AliHLTHOMERBlockDesc* block, TEvePointSet *cont, TEvePointSetArray *contCol) {
1363   
1364   Int_t iResult = 0;
1365
1366   Int_t sm = block->GetSubDetector();
1367   if ( sm == 6 ) sm = 7;
1368   
1369   Float_t phi   = ( sm + 0.5 ) * TMath::Pi() / 9.0;  
1370   Float_t cos   = TMath::Cos( phi );
1371   Float_t sin   = TMath::Sin( phi );
1372   
1373   Byte_t* ptrData = reinterpret_cast<Byte_t*>(block->GetData());
1374   UInt_t ptrSize = block->GetSize();
1375
1376   for (UInt_t size = 0; size+sizeof(AliHLTTRDCluster) <= ptrSize; size+=sizeof(AliHLTTRDCluster) ) {
1377     AliHLTTRDCluster *cluster = reinterpret_cast<AliHLTTRDCluster*>(&(ptrData[size]));
1378    
1379     AliTRDcluster *trdCluster = new AliTRDcluster;
1380     cluster->ExportTRDCluster( trdCluster );
1381    
1382     contCol->Fill(cos*trdCluster->GetX() - sin*trdCluster->GetY(), 
1383                    sin*trdCluster->GetX() + cos*trdCluster->GetY(), 
1384                    trdCluster->GetZ(),
1385                    trdCluster->GetQ() );    
1386      
1387     cont->SetNextPoint(cos*trdCluster->GetX() - sin*trdCluster->GetY(), 
1388                        sin*trdCluster->GetX() + cos*trdCluster->GetY(), trdCluster->GetZ());
1389   }
1390   
1391   return iResult;
1392 }
1393
1394 // -----------------------------------------------------------------
1395 Int_t processTRDHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
1396
1397   Int_t iResult = 0;
1398
1399   if ( ! block->GetClassName().CompareTo("TH1F")) {
1400     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
1401     ++gTRDHistoCount;
1402   
1403     TVirtualPad* pad = canvas->cd(gTRDHistoCount);
1404     histo->Draw();
1405     pad->SetGridy();
1406     pad->SetGridx();
1407
1408     if ( ! strcmp(histo->GetName(), "nscls") ) {
1409       gTRDEvents = static_cast<Int_t>(histo->GetEntries());
1410          histo->GetXaxis()->SetRangeUser(0.,15.);
1411     }
1412
1413     if ( ! strcmp(histo->GetName(),"sclsdist") ||
1414          ! strcmp(histo->GetName(),"evSize") )
1415       pad->SetLogy();
1416   }
1417
1418   gTRDCanvas->Update();
1419
1420   return iResult;
1421 }
1422
1423 // -----------------------------------------------------------------
1424 Int_t processPrimVertexHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
1425
1426   Int_t iResult = 0;
1427
1428   if ( ! block->GetClassName().CompareTo("TH1F")) {
1429     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
1430     if( histo ){
1431       TString name(histo->GetName());
1432       if( !name.CompareTo("primVertexZ") ){
1433         canvas->cd(2);
1434         histo->Draw();
1435       }else if( !name.CompareTo("primVertexX") ){
1436         canvas->cd(3);
1437         histo->Draw();
1438       }else if( !name.CompareTo("primVertexY") ){
1439         canvas->cd(4);
1440         histo->Draw();
1441       }
1442     }
1443   }  else if ( ! block->GetClassName().CompareTo("TH2F")) {
1444     TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
1445     if (hista ){
1446        TString name(hista->GetName());
1447        if( !name.CompareTo("primVertexXY")) {      
1448          canvas->cd(1);
1449          hista->Draw();
1450        }
1451     }
1452   }
1453   canvas->cd();
1454
1455   return iResult;
1456 }
1457
1458 // -----------------------------------------------------------------
1459 Int_t processSPDVertexHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
1460
1461   Int_t iResult = 0;
1462
1463   if ( ! block->GetClassName().CompareTo("TH1F")) {
1464     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
1465     ++gSPDVertexHistoCount;
1466   
1467     canvas->cd(gSPDVertexHistoCount);
1468     histo->Draw();
1469
1470   }  
1471   else if ( ! block->GetClassName().CompareTo("TH2F")) {
1472     TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
1473     if (hista) {
1474       ++gSPDVertexHistoCount;
1475   
1476       canvas->cd(gSPDVertexHistoCount);
1477       hista->Draw();
1478     }
1479   }
1480   canvas->cd();
1481
1482   return iResult;
1483 }
1484
1485 // -----------------------------------------------------------------
1486 Int_t processV0Histograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
1487
1488   cout << "Processing to see if it's V0 histogram, !!!!!!!!!"<<endl;
1489
1490   Int_t iResult = 0;
1491   bool update = 0;
1492   if ( ! block->GetClassName().CompareTo("TH1F")) {
1493     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
1494     if( histo ){
1495       TString name(histo->GetName());
1496       if( !name.CompareTo("hKShort") ){
1497         canvas->cd(1);
1498         histo->Draw();
1499         update = 1;
1500       }else if( !name.CompareTo("hLambda") ){
1501         canvas->cd(3);
1502         histo->Draw();
1503         update = 1;
1504       }
1505     }
1506   }  else if ( ! block->GetClassName().CompareTo("TH2F")) {
1507     TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
1508     if (hista ){
1509        TString name(hista->GetName());
1510        if( !name.CompareTo("hAP")) {      
1511          canvas->cd(2);
1512          hista->Draw();
1513          update = 1;
1514        }
1515        else if( !name.CompareTo("hGammaXY")) {      
1516          canvas->cd(4);
1517          hista->Draw();
1518          update = 1;
1519        }
1520     }
1521   }
1522   if( update ){
1523     canvas->cd();
1524     canvas->Update();
1525   }
1526   return iResult;
1527 }
1528
1529
1530 // -----------------------------------------------------------------
1531 Int_t processITSHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
1532
1533   Int_t iResult = 0;
1534
1535   if ( ! block->GetClassName().CompareTo("TH1F")) {
1536     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
1537     ++gITSHistoCount;
1538   
1539     canvas->cd(gITSHistoCount);
1540     histo->Draw();
1541
1542   } 
1543   else if ( ! block->GetClassName().CompareTo("TH2F")) {
1544     TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
1545     if (hista) {
1546       ++gITSHistoCount;
1547       
1548       canvas->cd(gITSHistoCount);
1549       hista->Draw("COLZ");
1550     }
1551   }
1552   canvas->cd();
1553
1554   return iResult;
1555 }
1556
1557
1558 Int_t AddHistogramsToCanvas(AliHLTHOMERBlockDesc * block, TCanvas * canvas, Int_t &cdCount ) {
1559
1560   if (canvas == NULL) 
1561     cout <<"fucked canvasn"<<endl;
1562     
1563
1564   Int_t iResult = 0;
1565
1566   if ( ! block->GetClassName().CompareTo("TObjArray")) {
1567     TIter next((TObjArray*)(block->GetTObject()));
1568     TObject *object;
1569     while (( object = (TObject*) next())) {
1570       TH1* histo = dynamic_cast<TH1*>(object);
1571       cout <<" cd "<< cdCount << endl;
1572       canvas->cd(++cdCount);
1573       cout <<"draw"<<endl;
1574       histo->Draw();
1575       cout <<"drew"<<endl;
1576     }
1577   }
1578
1579   //  canvas->cd();
1580   canvas->Update();
1581
1582   return iResult;
1583 }
1584
1585
1586 // -----------------------------------------------------------------
1587 Int_t processSSDHistograms(AliHLTHOMERBlockDesc* block, TCanvas *canvas0, TCanvas *canvas1) {
1588
1589   Int_t iResult = 0;
1590
1591   if ( ! block->GetClassName().CompareTo("TH1F")) {
1592     TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
1593     ++gSSDHistoCount0;
1594   
1595     canvas0->cd(gSSDHistoCount0);
1596     histo->Draw();
1597   }  
1598   else if ( ! block->GetClassName().CompareTo("TH2F")) {
1599     TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
1600     if (hista) {
1601       ++gSSDHistoCount1;
1602   
1603       canvas1->cd(gSSDHistoCount1);
1604       hista->Draw("COLZ");
1605     }
1606   }  else if ( ! block->GetClassName().CompareTo("TObjArray")) {
1607     TIter next((TObjArray*)(block->GetTObject()));
1608     TObject *object;
1609     while (( object = (TObject*) next())) {
1610       TString string;
1611       string = "TH1F";
1612       TString string2;
1613       string2 = "TH2F";
1614
1615       if ( !(string.CompareTo(object->ClassName())) ) {
1616         TH1F* histo = reinterpret_cast<TH1F*>(object);
1617         ++gSSDHistoCount0;
1618         
1619         canvas0->cd(gSSDHistoCount0);
1620         histo->Draw();
1621         
1622       } 
1623       else if ( !(string2.CompareTo(object->ClassName()) ) ) {
1624         TH2F* histo = reinterpret_cast<TH2F*>(object);
1625         ++gSSDHistoCount1;
1626         
1627         canvas1->cd(gSSDHistoCount1);
1628         histo->Draw("COLZ");
1629       }
1630     }
1631   }
1632
1633   canvas0->cd();  canvas1->cd();
1634   
1635   return iResult;
1636 }
1637
1638
1639 //*-------------------------------------------------------------------------------------- 
1640 Int_t processTRDCalibHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
1641   Int_t iResult = 0;
1642
1643   TObjArray *HistArray=(TObjArray*)block->GetTObject();
1644   Int_t nCalibHistos=HistArray->GetEntriesFast();
1645   for(Int_t CalibHistoCount=0;CalibHistoCount<nCalibHistos;CalibHistoCount++){
1646     canvas->cd(CalibHistoCount+1);
1647     
1648     if(HistArray->At(CalibHistoCount)->InheritsFrom("TH2S")){
1649          TH2S *histCalib=(TH2S*)(HistArray->At(CalibHistoCount));
1650          histCalib->Draw("colz");
1651        }
1652      else if(HistArray->At(CalibHistoCount)->InheritsFrom("TH2")){
1653       //TH2D *histCalib=dynamic_cast<TH2D*>(HistArray->At(CalibHistoCount));
1654       TH2D *histCalib=(TH2D*)(HistArray->At(CalibHistoCount));
1655       histCalib->Draw("lego2");
1656     }
1657     else if(HistArray->At(CalibHistoCount)->InheritsFrom("TH1")){
1658       //TH1D *histCalib=dynamic_cast<TH1D*>(HistArray->At(CalibHistoCount));
1659       TH1D *histCalib=(TH1D*)(HistArray->At(CalibHistoCount));
1660       histCalib->Draw();
1661     }
1662     else if(HistArray->At(CalibHistoCount)->InheritsFrom("AliTRDCalibraVdriftLinearFit")){
1663       //TH2S *histCalib = ((dynamic_cast<AliTRDCalibraVdriftLinearFit*>(HistArray->At(CalibHistoCount)))->GetLinearFitterHisto(10,kTRUE));
1664       TH2S *histCalib =(TH2S*)(((AliTRDCalibraVdriftLinearFit*)HistArray->At(CalibHistoCount))->GetLinearFitterHisto(10,kTRUE));
1665
1666       histCalib->Draw();
1667     }
1668     
1669    
1670   }
1671   
1672   gTRDCalibCanvas->Update();
1673
1674  return iResult;
1675 }
1676 //****************************************************************************
1677
1678
1679
1680 void writeToFile(){
1681
1682   TList * bList = gHomerManager->GetBlockList();
1683   TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", gHomerManager->GetEventID()), "RECREATE"); 
1684   bList->Write("blockList", TObject::kSingleKey);
1685   file->Close();
1686   
1687   bList = gHomerManager->GetAsyncBlockList();
1688   TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", gHomerManager->GetEventID()), "RECREATE"); 
1689   bList->Write("blockList", TObject::kSingleKey);
1690   afile->Close();
1691
1692
1693 //   TIter next(bList);
1694   
1695 //   AliHLTHOMERBlockDesc* block = 0;
1696   
1697 //   // -- Iterate over blocks in the block list
1698 //   // ------------------------------------------
1699 //   while ((block = (AliHLTHOMERBlockDesc*)next())) {
1700 //     cout << "balle " << endl;
1701 //   }
1702   
1703 }
1704
1705
1706 // -----------------------------------------------------------------
1707 void loopEvent() {
1708   eventTimer.SetCommand("nextEvent()");
1709   eventTimer.Start(6000);
1710 }
1711
1712 // -----------------------------------------------------------------
1713 void stopLoopEvent() {
1714   eventTimer.Stop();
1715 }
1716
1717
1718 // -----------------------------------------------------------------
1719 void loopEventFast() {
1720   eventTimerFast.SetCommand("nextEvent()");
1721   eventTimerFast.Start(500);
1722 }
1723
1724 // -----------------------------------------------------------------
1725 void stopLoopEventFast() {
1726   eventTimerFast.Stop();
1727 }
1728
1729 // -----------------------------------------------------------------
1730 void EventLoopFast() {
1731   
1732   // Start/stop event loop
1733   if ( gEventLoopStarted ) {
1734     loopEventFast();
1735     gEventLoopStarted = kTRUE;
1736   
1737   } else {  
1738     stopLoopEventFast();
1739     gEventLoopStarted = kFALSE;
1740   
1741   }
1742 }
1743
1744
1745
1746 Int_t processBlock (AliHLTHOMERBlockDesc * block ){
1747
1748   
1749 #if 1//DEBUG
1750    printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
1751    printf( "Detector           : %s\n", block->GetDetector().Data() );
1752    printf( "Datatype           : %s\n", block->GetDataType().Data() );
1753    if (block->IsTObject() )
1754      printf( "Is TObject of class: %s\n", block->GetClassName().Data() );
1755    printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
1756 #endif
1757
1758   
1759   Int_t iResult = 0;
1760
1761   if ( ! block->GetDetector().CompareTo("HLT") ) 
1762     processHLTBlock(block);
1763   
1764   else if ( ! block->GetDetector().CompareTo("TPC") ) 
1765     processTPCBlock(block);
1766   
1767   else if ( ! block->GetDetector().CompareTo("TRD") ) 
1768     iResult = processTRDBlock(block);
1769
1770   else if ( ! block->GetDetector().CompareTo("MUON") && gShowMUON ) 
1771     processMUONBlock(block);
1772
1773   else if ( ! block->GetDetector().CompareTo("ISPD") )
1774     processISPDBlock(block);
1775
1776   else if ( ! block->GetDetector().CompareTo("ISDD") )
1777     processISDDBlock(block);
1778
1779   else if ( ! block->GetDetector().CompareTo("ISSD") )
1780     processISSDBlock(block);
1781
1782   else if ( ! block->GetDetector().CompareTo("PHOS") ) 
1783     processPHOSBlock(block);
1784
1785   else if ( ! block->GetDetector().CompareTo("EMCA") )
1786     processEMCALBlock(block);
1787
1788   else if ( ! block->GetDetector().CompareTo("ITS") )
1789     processITSBlock(block);
1790  
1791   
1792
1793   if ( block->GetDataType().CompareTo("ROOTHIST") == 0 )     
1794     processV0Histograms( block , gV0Canvas);
1795    
1796   return iResult;
1797
1798
1799
1800 void processITSBlock(AliHLTHOMERBlockDesc * block) {
1801   
1802   if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
1803     if(!gITSCanvas){
1804       gITSCanvas = gEve->AddCanvasTab("ITS QA");
1805     }
1806     processITSHistograms( block , gITSCanvas);
1807     gITSCanvas->Update();
1808   } 
1809 }
1810
1811
1812  Int_t processTRDBlock (AliHLTHOMERBlockDesc * block) {
1813
1814    Int_t iResult = 0;
1815
1816   if ( ! block->GetDataType().CompareTo("CLUSTERS") ) {
1817      
1818     if(!gTRDClusters){
1819       gTRDClusters = new TEvePointSet("TRD Clusters");
1820       gTRDClusters->SetMainColor(kBlue);
1821       gTRDClusters->SetMarkerStyle((Style_t)kFullDotSmall);
1822       //gEve->AddElement(gTRDClusters);
1823     } 
1824
1825     if(!gTRDColClusters){
1826       gTRDColClusters = new TEvePointSetArray("TRD Clusters Colorized");
1827       gTRDColClusters->SetMainColor(kRed);
1828       gTRDColClusters->SetMarkerStyle(4); // antialiased circle
1829       //          gTRDColClusters->SetMarkerStyle((Style_t)kFullDotSmall);
1830       gTRDColClusters->SetMarkerSize(0.4);
1831       gTRDColClusters->InitBins("Cluster Charge", gTRDBins, 0., gTRDBins*100.);
1832
1833       //TColor::SetPalette(1, 0); // Spectrum palette
1834       const Int_t nCol = TColor::GetNumberOfColors();
1835       for (Int_t ii = 0; ii < gTRDBins+1; ++ii)
1836         gTRDColClusters->GetBin(ii)->SetMainColor(TColor::GetColorPalette(ii * nCol / (gTRDBins+2)));
1837           
1838       gEve->AddElement(gTRDColClusters);
1839     } 
1840
1841     iResult = processTRDClusters( block, gTRDClusters, gTRDColClusters );
1842     //gTRDClusters->ElementChanged();
1843     gTRDColClusters->ElementChanged();
1844   }
1845
1846   // -- Process TRD Histograms
1847   else if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
1848     if(!gTRDCanvas) {
1849       gTRDCanvas = gEve->AddCanvasTab("TRD");
1850       gTRDCanvas->Divide(3,2);
1851     }
1852     iResult = processTRDHistograms( block, gTRDCanvas );     
1853   }
1854
1855   else if(block->GetDataType().CompareTo("CALIBRAH")==0){
1856      
1857     if(!gTRDCalibCanvas){
1858       gTRDCalibCanvas = gEve->AddCanvasTab("TRD Calib");
1859       gTRDCalibCanvas->Divide(2,2);
1860     }
1861      
1862     iResult=processTRDCalibHistograms(block,gTRDCalibCanvas);
1863   }
1864
1865   else if(block->GetDataType().CompareTo("CALIBEOR")==0){
1866      
1867     if(!gTRDEORCanvas){
1868       gTRDEORCanvas = gEve->AddCanvasTab("TRD QA");
1869       gTRDEORCanvas->Divide(3,2);       
1870     }
1871   
1872     iResult=processTRDCalibHistograms(block,gTRDEORCanvas);
1873   }
1874   return iResult;
1875 }
1876
1877 void processMUONBlock(AliHLTHOMERBlockDesc * block){
1878
1879    // -- Process MUON Clusters
1880    if ( (block->GetDataType().CompareTo("RECHITS") == 0) || (block->GetDataType().CompareTo("TRIGRECS") == 0) ) {
1881         
1882      if ( !gMUONClusters ) {
1883        gMUONClusters = new TEvePointSet("MUON RecHits");
1884        gMUONClusters->SetMainColor(kBlue);
1885        gMUONClusters->SetMarkerStyle(20);
1886        gEve->AddElement(gMUONClusters);
1887      }
1888         
1889      processMUONClusters( block );
1890      gMUONClusters->ElementChanged();
1891         
1892    }else if(block->GetDataType().CompareTo("MANTRACK") == 0){
1893         
1894      if ( !gMUONTracks ) {
1895        gMUONTracks = new TEveStraightLineSet("MUON Tracks");
1896        gMUONTracks->SetMainColor(kRed);
1897        gMUONTracks->SetLineWidth(3);
1898        gEve->AddElement(gMUONTracks);
1899      }
1900
1901      processMUONTracks( block );
1902      gMUONTracks->ElementChanged();
1903
1904
1905    } 
1906 }
1907
1908
1909 void processISPDBlock( AliHLTHOMERBlockDesc * block) {
1910
1911   if ( block->GetDataType().CompareTo("CLUSTERS") == 0 ) {
1912     
1913     if(!gSPDClusters){
1914       gSPDClusters = new TEvePointSet("SPD Clusters");
1915       gSPDClusters->SetMainColor(kBlack);
1916       gSPDClusters->SetMarkerStyle((Style_t)kFullDotMedium);
1917       gEve->AddElement(gSPDClusters);
1918     } 
1919     
1920     processITSClusters( block , gSPDClusters);
1921     gSPDClusters->ElementChanged();
1922
1923   } else if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
1924     processSPDVertexHistograms( block , gSPDVertexCanvas);
1925     gSPDVertexCanvas->Update();
1926   } 
1927
1928
1929 void processISDDBlock(AliHLTHOMERBlockDesc * block){
1930   
1931   if ( block->GetDataType().CompareTo("CLUSTERS") == 0 ) {
1932     
1933     if(!gSDDClusters){
1934       gSDDClusters = new TEvePointSet("SDD Clusters");
1935       gSDDClusters->SetMainColor(kPink);
1936       gSDDClusters->SetMarkerStyle((Style_t)kFullDotMedium);
1937       gEve->AddElement(gSDDClusters);
1938     } 
1939     
1940     processITSClusters( block , gSDDClusters);
1941     gSDDClusters->ElementChanged();
1942   } 
1943 }
1944
1945 void processISSDBlock(AliHLTHOMERBlockDesc * block){
1946   if ( block->GetDataType().CompareTo("CLUSTERS") == 0 ) {
1947     
1948     if(!gSSDClusters){
1949       gSSDClusters = new TEvePointSet("SSD Clusters");
1950       gSSDClusters->SetMainColor(kBlue);
1951       gSSDClusters->SetMarkerStyle((Style_t)kFullDotMedium);
1952       gEve->AddElement(gSSDClusters);
1953     } 
1954     
1955     processITSClusters( block , gSSDClusters);
1956     gSSDClusters->ElementChanged();
1957   } 
1958   
1959   else if ( block->GetDataType().CompareTo("ROOTOBAR") == 0 ) {
1960     processSSDHistograms( block , gSSDCanvas0, gSSDCanvas1);
1961     gSSDCanvas0->Update();
1962     gSSDCanvas1->Update();
1963   } 
1964 }
1965  
1966         
1967
1968 Int_t processPHOSBlock(AliHLTHOMERBlockDesc * block) { 
1969   
1970   Int_t iResult = 0;
1971
1972   if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) { 
1973     
1974     if(!gPHOSCanvas) {
1975       gPHOSCanvas = CreateCanvas("PHOS QA", "PHOS QA");
1976       gPHOSCanvas->Divide(3, 2);
1977     }
1978     
1979     AddHistogramsToCanvas(block, gPHOSCanvas, gPHOSHistoCount);
1980    
1981  
1982   } else {
1983     
1984     cout <<"PHOS block not histo"<<endl;
1985
1986     if( !gPHOSElementList )
1987       gPHOSElementList = createPHOSElementList();
1988         
1989     if ( block->GetDataType().CompareTo("CALOCLUS") == 0 )
1990       iResult = processPHOSClusters( block );
1991       
1992     else if ( block->GetDataType().CompareTo("DIGITTYP") == 0 )
1993       iResult = processPHOSDigits( block);
1994     
1995     else if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) 
1996       iResult = processPHOSClusters( block );
1997   
1998   
1999     //Update the eve elements
2000     for(int im = 0; im < 5; im++)
2001       gPHOSBoxSet[im]->ElementChanged();
2002     
2003   }
2004   
2005   return iResult;
2006
2007
2008
2009 TEveElementList * createPHOSElementList() {
2010   
2011   TEveElementList * elementList  = new TEveElementList("PHOS Cells");
2012   
2013   gEve->AddElement(elementList);
2014   
2015   TVector3 center;
2016   Float_t angle;
2017   
2018   // -- Create boxsets
2019   for(int im = 0; im < 5; im++) {
2020     
2021     TEveRGBAPalette* pal = new TEveRGBAPalette(0,120);
2022     pal->SetLimits(-0.1, 1024);
2023     gPHOSBoxSet[im] = new TEveBoxSet(Form("Cells Module %d" , im));
2024     gPHOSBoxSet[im]->SetPalette(pal);
2025     gPHOSBoxSet[im]->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
2026     gPHOSBoxSet[im]->SetOwnIds(kTRUE);
2027     
2028     
2029     gPHOSGeom->GetModuleCenter(center, "CPV", im+1);
2030     angle = gPHOSGeom->GetPHOSAngle(im+1)*TMath::Pi()/180;
2031     
2032     gPHOSBoxSet[im]->RefitPlex();
2033     TEveTrans& t = gPHOSBoxSet[im]->RefMainTrans();
2034     t.SetupRotation(1, 2, angle );
2035     t.SetPos(center.X(), center.Y(), center.Z());
2036     
2037     elementList->AddElement(gPHOSBoxSet[im]);
2038   }
2039
2040   return elementList;
2041 }
2042
2043
2044 void processEMCALBlock(AliHLTHOMERBlockDesc * block) {  
2045
2046   Int_t iResult = 0;
2047   
2048   if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) { 
2049     
2050     if(!gEMCALCanvas) {
2051       gEMCALCanvas = CreateCanvas("EMCAL QA", "EMCAL QA");
2052       gEMCALCanvas->Divide(3, 2);
2053     }
2054     AddHistogramsToCanvas(block, gEMCALCanvas, gEMCALHistoCount);
2055    
2056  
2057   } else {
2058
2059     if( !gEMCALElementList ){
2060       gEMCALElementList = createEMCALElementList();
2061     }
2062
2063     if ( block->GetDataType().CompareTo("CALOCLUS") == 0 ) {
2064       iResult = processEMCALClusters( block );
2065       for(int sm = 0; sm < 12; sm++) {
2066         gEMCALBoxSet[sm]->ElementChanged();
2067       }
2068     }
2069   } 
2070 }
2071
2072 TEveElementList * createEMCALElementList() { 
2073   TEveElementList * elementList = new TEveElementList("EMCAL Cells");
2074   elementList->SetTitle("Tooltip");
2075   gEve->AddElement(elementList);
2076   
2077   gStyle->SetPalette(1, 0);
2078   TEveRGBAPalette* pal = new TEveRGBAPalette(0, 512);
2079   pal->SetLimits(0, 1024);
2080   
2081   
2082   for (Int_t sm=0; sm<12; ++sm) {
2083     
2084     TEveBoxSet* q = new TEveBoxSet(Form("SM %d", sm+1));
2085     q->SetOwnIds(kTRUE);
2086     
2087     q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
2088     q->RefMainTrans().SetFrom(*gEMCALNode->GetDaughter(sm)->GetMatrix());
2089     q->SetPalette(pal);
2090     
2091     gEve->AddElement(q, elementList);
2092     gEMCALBoxSet[sm] = q;
2093   }
2094
2095   return elementList;
2096 }
2097
2098 void processHLTBlock(AliHLTHOMERBlockDesc * block) {
2099
2100   if ( ! block->GetDataType().CompareTo("ALIESDV0") ) {
2101     if(!gTPCTrack){
2102       gTPCTrack = new TEveTrackList("ESD Tracks");
2103       gTPCTrack->SetMainColor(6);
2104       gEve->AddElement(gTPCTrack);
2105     }
2106     
2107     processEsdTracks(block, gTPCTrack);
2108     gTPCTrack->ElementChanged();
2109   } 
2110   
2111   else if ( ! block->GetDataType().CompareTo("ROOTTOBJ") ) {
2112     processROOTTOBJ( block, gHLTText );
2113   } 
2114
2115   else if ( ! block->GetDataType().CompareTo("HLTRDLST") ) {
2116     processHLTRDLST( block );
2117   } 
2118
2119   else if ( !block->GetDataType().CompareTo("ROOTHIST") ) {      
2120     
2121     processPrimVertexHistograms( block , gPrimVertexCanvas);
2122     gPrimVertexCanvas->Update();    
2123   }
2124
2125
2126
2127
2128 void processTPCBlock(AliHLTHOMERBlockDesc * block) {
2129
2130   cout <<"Processing tpc clusters"<<endl;
2131
2132   if ( ! block->GetDataType().CompareTo("CLUSTERS") ) {
2133     if(!gTPCClusters){    
2134       gTPCClusters = new TEvePointSet("TPC Clusters");
2135       //gTPCClusters->ApplyVizTag("TPC Clusters");
2136       gTPCClusters->SetMainColor(kRed);
2137       gTPCClusters->SetMarkerStyle((Style_t)kFullDotSmall);
2138       //gEve->AddElement(gTPCClusters);
2139     } 
2140     
2141     if(!gTPCColClusters){
2142       gTPCColClusters = new TEvePointSetArray("TPC Clusters Colorized");
2143       gTPCColClusters->SetMainColor(kRed);
2144       gTPCColClusters->SetMarkerStyle(4); // antialiased circle
2145       gTPCColClusters->SetMarkerSize(0.4);
2146       gTPCColClusters->InitBins("Cluster Charge", gTPCBins, 0., gTPCBins*20.);
2147       
2148       const Int_t nCol = TColor::GetNumberOfColors();
2149       
2150       for (Int_t ii = 0; ii < gTPCBins+1; ++ii)
2151         gTPCColClusters->GetBin(ii)->SetMainColor(TColor::GetColorPalette(ii * nCol / (gTPCBins+2)));
2152       
2153       gEve->AddElement(gTPCColClusters);
2154     } 
2155     
2156     processTPCClusters(block, gTPCClusters, gTPCColClusters);
2157     //gTPCClusters->ElementChanged();
2158     gTPCColClusters->ElementChanged();
2159   }
2160       
2161   else if ( ! block->GetDataType().CompareTo("HWCL_ALT") ) {
2162     if(!gTPCTestClusters){        
2163       
2164       gTPCTestClusters = new TEvePointSet("TPC Clusters Test");
2165       //ggTPCTestClusters->ApplyVizTag("TPC Clusters");
2166       gTPCTestClusters->SetMainColor(kBlue);
2167       gTPCTestClusters->SetMarkerStyle((Style_t)kFullDotSmall);
2168       gEve->AddElement(gTPCTestClusters);
2169     }
2170     
2171     processTPCClusters(block, gTPCTestClusters);
2172     gTPCTestClusters->ElementChanged();
2173   }
2174