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