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