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