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