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