]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/hlt-macros/onlineDisplay.C
Changes from Svein Lindal
[u/mrichter/AliRoot.git] / EVE / hlt-macros / onlineDisplay.C
index 1c9ff85ecf44b3443e2a80852d72c3b0501dff7b..1c8bbe50bafeec064d64435a414dbced9b77e8e5 100644 (file)
 #include "TEveBoxSet.h"
 #include "TEveTrans.h"
 #include "TEveRGBAPalette.h"
-
+#include "TLine.h"
+#include "TEveStraightLineSet.h"
+#include "TGeoNode.h"
+#include "TGeoManager.h"
+#include "TGLOverlayButton.h"
 //****************** AliRoot ***************************************
 #include "AliESDEvent.h"
 #include "AliCDBManager.h"
 #include "AliHLTTriggerDecision.h"
 #include "AliHLTGlobalTriggerDecision.h"
 #include "AliHLTTPCCATrackParam.h"
-#include "AliHLTCaloClusterDataStruct.h"
-#include "AliHLTCaloClusterReader.h"
+
 
 //****************** AliRoot/MUON **********************************
 #include "AliMUONCalibrationData.h"
 #include "AliMUONVCalibParam.h"
 #include "AliMUONGeometryTransformer.h"
 #include "AliMUONGeometryDetElement.h"
+#include "AliMUONConstants.h"
 
 #include "AliMpCDB.h"
 #include "AliMpDDLStore.h"
 //****************** AliRoot/TRD ***********************************
 #include "AliHLTTRDCluster.h"
 #include "AliTRDcluster.h"
+#include "AliTRDCalibraVdriftLinearFit.h"
 
-//#####################AliRoot PHOS ##################################3
-#include "AliPHOSGeometry.h"
 
+
+
+//#################### AliRoot EMCAL ###################################3
+#include "AliHLTCaloClusterDataStruct.h"
+#include "AliHLTCaloClusterReader.h"
+
+#include "HLT/CALO/AliHLTCaloChannelDataHeaderStruct.h"
+#include "HLT/CALO/AliHLTCaloChannelDataStruct.h"
+
+
+//#####################AliRoot PHOS ##################################
+#include "AliPHOSGeometry.h"
+#include "HLT/PHOS/AliHLTPHOSDigitDataStruct.h"
+#include  "AliHLTPHOSChannelDataHeaderStruct.h"
+#include  "AliHLTPHOSChannelDataStruct.h"
 //****************** Macros ****************************************
 #include "hlt_structs.C"
 #include "hlt_alieve_init.C"
 #include "geom_gentle_hlt.C"
 #include "alice-macros/esd_tracks.C"
+#include "hlt_esd_tracks.C"
+//#include "alieve_vizdb.C"
 
 #endif
 
@@ -123,6 +143,21 @@ class AliHLTHOMERBlockDesc;
 
 class TEveViewer;
 
+// 
+class caloCell :  public TObject 
+{
+
+public :
+
+  AliHLTPHOSChannelDataStruct phosStruct;
+
+private :
+  ClassDef(caloCell, 1);
+
+};
+
+
+
 // -----------------------------------------------------------------
 // --                       Geometry / Scenes                     --
 // -----------------------------------------------------------------
@@ -181,7 +216,9 @@ TEvePointSetArray*                        gTRDColClusters    = 0;
 TEvePointSet*                             gTPCClusters       = 0;
 TEvePointSetArray*                        gTPCColClusters    = 0;
 TEveBoxSet*                               gPHOSBoxSet[5]     = {0, 0, 0, 0, 0}; 
+TEveBoxSet*                               gEMCALBoxSet[13]   = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 TEvePointSet*                             gMUONClusters      = 0;
+TEveStraightLineSet*                      gMUONTracks        = 0;
 
 // -- Text output members
 TEveText*                                 gHLTText           = 0;
@@ -192,6 +229,12 @@ TEveTrackList*                            gTPCTrack          = 0;
 // -- Canvas for histograms
 TCanvas*                                  gTRDCanvas         = 0;
 TCanvas*                                  gTPCCanvas         = 0;
+TCanvas*                               gTRDCalibCanvas=0;
+TCanvas *                                              gTRDEORCanvas=0;
+TCanvas *                                 gVertexCanvas = 0;
+
+// -- vertex ----
+Int_t                                      gVertexHistoCount = 0;
 
 // -- TRD --
 Int_t                                     gTRDHistoCount     = 0;
@@ -207,9 +250,16 @@ TH1F*                                     gTPCQMaxOverCharge = 0;
 // -- PHOS --
 TEveElementList*                          gPHOSElementList   = 0;
 
+// -- EMCAL
+TEveElementList*                          gEMCALElementList  = 0;
+TGeoNode                                  *gEMCALNode = 0;
+
 // --- Flag if eventloop is running
 Bool_t                                    gEventLoopStarted = kFALSE;
 
+
+//Container for gGeoManager till it is broken
+TGeoManager *fGeoManager = 0;
 // -----------------------------------------------------------------
 // --                          Methods                            --
 // -----------------------------------------------------------------
@@ -222,6 +272,8 @@ Int_t processEvent();
 
 Int_t processPHOSClusters( AliHLTHOMERBlockDesc* block);
 
+Int_t processEMCALClusters( AliHLTHOMERBlockDesc* block);
+
 Int_t processEsdTracks( AliHLTHOMERBlockDesc* block, TEveTrackList* cont );
 
 Int_t processHLTRDLST( AliHLTHOMERBlockDesc* block );
@@ -234,12 +286,21 @@ Int_t processTRDClusters( AliHLTHOMERBlockDesc * block, TEvePointSet *cont, TEve
 
 Int_t processTRDHistograms (AliHLTHOMERBlockDesc * block, TCanvas * canvas );
 
+Int_t processVertexHistograms  (AliHLTHOMERBlockDesc * block, TCanvas * canvas );
+
+Int_t processTRDCalibHistograms(AliHLTHOMERBlockDesc *block, TCanvas *canvas);
+
 Int_t processMUONClusters( AliHLTHOMERBlockDesc* block);
 
+Int_t processMUONTracks( AliHLTHOMERBlockDesc* block);
+
 Int_t processITSClusters(AliHLTHOMERBlockDesc* block, TEvePointSet* cont);
 
 Int_t processITSHist(AliHLTHOMERBlockDesc* block);
 
+void writeToFile();
+
+
 // #################################################################
 // #################################################################
 // #################################################################
@@ -255,12 +316,12 @@ void onlineDisplay(Bool_t TPCMode = kTRUE, Bool_t MUONMode = kFALSE, Bool_t TRDM
   AliGeomManager::LoadGeometry();
 
   // Get the pointer to gGeoManager before it's broken (bug in alieve)
-  TGeoManager *gm = gGeoManager;
+  fGeoManager = gGeoManager;
 
   // -- Create new hM object
   // -------------------------
   gHomerManager = new AliEveHOMERManager();
-  gHomerManager->SetRetryCount(50,5);
+  gHomerManager->SetRetryCount(1000,15);
 
   Int_t iResult = gHomerManager->Initialize();
   if (iResult) { 
@@ -291,7 +352,7 @@ void onlineDisplay(Bool_t TPCMode = kTRUE, Bool_t MUONMode = kFALSE, Bool_t TRDM
 
   // -- Reset gGeoManager to the original pointer
   // ----------------------------------------------
-  gGeoManager = gm;
+  gGeoManager = fGeoManager;
   gPHOSGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
 
   // -- Finalize Eve
@@ -310,11 +371,22 @@ void onlineDisplay(Bool_t TPCMode = kTRUE, Bool_t MUONMode = kFALSE, Bool_t TRDM
   }    
 
   g_esd_tracks_true_field = kFALSE;
+
 }
 
 // -------------------------------------------------------------------------
 Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
   
+  //=============================================================================
+  // Visualization database
+  //============================================================================
+
+  TEveUtil::AssertMacro("VizDB_scan.C");
+  
+  //  alieve_vizdb();
+  
+
+
   //==============================================================================
   // -- Geometry, scenes, projections and viewers
   //==============================================================================
@@ -335,6 +407,14 @@ Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
   gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();
   gGeomGentleTRD  = geom_gentle_trd();
 
+  gGeoManager = fGeoManager;
+
+  gEMCALNode = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
+
+  TEveGeoTopNode* emcal_re = new TEveGeoTopNode(gGeoManager, gEMCALNode);
+  gEve->AddGlobalElement(emcal_re);
+  gEve->Redraw3D();
+
   if (gShowMUON) 
     gGeomGentleMUON = geom_gentle_muon(kFALSE);
   
@@ -403,6 +483,9 @@ Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
   g3DView->AddScene(gEve->GetGlobalScene());
   g3DView->AddScene(gEve->GetEventScene());
 
+
+
   pack = pack->NewSlot()->MakePack();
   pack->SetShowTitleBar(kFALSE);
   pack->NewSlot()->MakeCurrent();
@@ -417,6 +500,24 @@ Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
   gRhoZView->AddScene(gRhoZGeomScene);
   gRhoZView->AddScene(gRhoZEventScene);
 
+
+   
+  //Add HLT Text to windows
+  TGLOverlayButton *ob1 = new TGLOverlayButton(g3DView->GetGLViewer(),  "HLT", 0, 20, 110, 60);
+  ob1->SetAlphaValues(0.8, 0.8);
+  cout << "color" << ob1->GetBackColor() << endl;
+  //ob1->SetBackColor(8421631);
+  ob1->SetBackColor(10492431);
+  TGLOverlayButton *ob2 = new TGLOverlayButton(g3DView->GetGLViewer(),  "ALICE", 0, 0, 110, 20);
+  ob2->SetAlphaValues(0.8, 0.8);
+  ob1->SetBackColor(0.2);
+  TGLOverlayButton *ob3 = new TGLOverlayButton(gEve->GetDefaultGLViewer(),  "HLT", 0, 20, 110, 60);
+  ob3->SetAlphaValues(0.8, 0.8);
+  TGLOverlayButton *ob4 = new TGLOverlayButton(gEve->GetDefaultGLViewer(),  "ALICE", 0, 0, 110, 20);
+  ob4->SetAlphaValues(0.8, 0.8);
+
+
   // -- List of Viewers
   // --------------------
 
@@ -505,6 +606,18 @@ Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
     gTRDCanvas = new TCanvas("canvasTRD","canvasTRD", 600, 400);
     gTRDCanvas->Divide(3,2);
     slot->StopEmbedding("TRD histograms");
+    
+    slot=TEveWindow::CreateWindowInTab(browser->GetTabRight());
+    slot->StartEmbedding();
+    gTRDCalibCanvas=new TCanvas("CalibCanvasTRD","CalibCanvasTRD",600,400);
+    gTRDCalibCanvas->Divide(2,2);
+    slot->StopEmbedding("TRD Calibration Histograms");
+
+     slot=TEveWindow::CreateWindowInTab(browser->GetTabRight());
+    slot->StartEmbedding();
+    gTRDEORCanvas=new TCanvas("CalibEORTRD","CalibCEORTRD",600,400);
+    gTRDEORCanvas->Divide(3,2);
+    slot->StopEmbedding("TRD EOR Histograms");
   }
   else if(TPCMode){
     slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
@@ -517,6 +630,16 @@ Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
     slot->StopEmbedding("TPC histograms");
   }
 
+  
+  slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
+  slot->StartEmbedding();
+  
+  gVertexCanvas = new TCanvas("canvasVertex","canvasVertex", 600, 400);
+  slot->StopEmbedding("Vertex Histograms");
+
+
+
+
   //==============================================================================
   // -- Additional GUI components
   //==============================================================================
@@ -528,15 +651,27 @@ Int_t initializeEveViewer( Bool_t TPCMode, Bool_t MUONMode, Bool_t TRDMode) {
                                 "are placed here when the main-frame is closed.");
   gEve->GetWindowManager()->SetDefaultContainer(storeTab);
   
+  
+
   return 0;
 }
 
 // -----------------------------------------------------------------
 void nextEvent() {
 
-  if ( gHomerManager->NextEvent() )
-    return;
-  
+  if ( gHomerManager->NextEvent() ) {
+    if (gEventLoopStarted) {
+      cout << "HomerManager failed getting next event, trying to reconnect" << endl;
+
+      gHomerManager->DisconnectHOMER();
+      gHomerManager->ConnectEVEtoHOMER();
+      nextEvent();
+   
+    } else {
+      return;
+    }
+  }
+
   processEvent();
 }
 
@@ -552,10 +687,26 @@ Int_t processEvent() {
   // -- Reset
   //==============================================================================
 
+
+
+
   if ( gTRDCanvas ) {
     gTRDCanvas->Clear();
     gTRDCanvas->Divide(3,2);
   }
+  if(gTRDCalibCanvas){
+       gTRDCalibCanvas->Clear();
+       gTRDCalibCanvas->Divide(2,2);
+ }
+  if(gTRDEORCanvas){
+       gTRDEORCanvas->Clear();
+       gTRDEORCanvas->Divide(3,2);
+ }
+
+  if(gVertexCanvas) {
+    gVertexCanvas->Clear();
+    gVertexCanvas->Divide(2,2);
+  }
 
   if ( gTPCTrack )     gTPCTrack->DestroyElements();
 
@@ -565,11 +716,21 @@ Int_t processEvent() {
   if ( gTPCClusters )  gTPCClusters->Reset();
   if ( gTRDClusters )  gTRDClusters->Reset();
   if ( gMUONClusters ) gMUONClusters->Reset();
+  if ( gMUONTracks ){
+    gMUONTracks->Destroy();
+    gMUONTracks = 0x0;
+  }
 
   if ( gPHOSBoxSet[1] )
     for(int im = 0; im < 5; im++)
       gPHOSBoxSet[im]->Reset();   
 
+  if ( gEMCALElementList)
+    for(int i = 0; i < 12; i++) {
+      gEMCALBoxSet[i]->Reset();
+    }
+  
+
   if ( gTPCColClusters )
     for (Int_t ii = 0; ii <= gTPCBins+1; ++ii) 
       gTPCColClusters->GetBin(ii)->Reset();
@@ -579,17 +740,21 @@ Int_t processEvent() {
       gTRDColClusters->GetBin(ii)->Reset();
 
   gTRDHistoCount = 0;
+  gVertexHistoCount = 0;
+  
 
   //==============================================================================
   // -- Process Blocks
   //==============================================================================
 
   if ( gHomerManager->GetBlockList() == NULL) {
-    printf ("No BlockList ... ");
+    printf ("onlineDisplay:   No BlockList ... ");
+       cout << endl;
     return -1;
   }
   if (gHomerManager->GetBlockList()->IsEmpty() ) {
-    printf ("No Blocks in list ... ");
+    printf ("onlineDisplay:    No Blocks in list ... ");
+       cout<<endl;
     return -2;
   }
 
@@ -600,7 +765,7 @@ Int_t processEvent() {
   // ------------------------------------------
   while ((block = (AliHLTHOMERBlockDesc*)next())) {
         
-#if DEBUG
+#if 1 //DEBUG
     printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
     printf( "Detector           : %s\n", block->GetDetector().Data() );
     printf( "Datatype           : %s\n", block->GetDataType().Data() );
@@ -649,8 +814,9 @@ Int_t processEvent() {
       
       // -- Process TPC Clusters
       if ( ! block->GetDataType().CompareTo("CLUSTERS") ) {
-       if(!gTPCClusters){
+       if(!gTPCClusters){        
          gTPCClusters = new TEvePointSet("TPC Clusters");
+         //gTPCClusters->ApplyVizTag("TPC Clusters");
          gTPCClusters->SetMainColor(kRed);
          gTPCClusters->SetMarkerStyle((Style_t)kFullDotSmall);
          gEve->AddElement(gTPCClusters);
@@ -664,6 +830,7 @@ Int_t processEvent() {
          gTPCColClusters->InitBins("Cluster Charge", gTPCBins, 0., gTPCBins*20.);
 
          const Int_t nCol = TColor::GetNumberOfColors();
+         
          for (Int_t ii = 0; ii < gTPCBins+1; ++ii)
            gTPCColClusters->GetBin(ii)->SetMainColor(TColor::GetColorPalette(ii * nCol / (gTPCBins+2)));
          
@@ -716,8 +883,17 @@ Int_t processEvent() {
       else if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
        iResult = processTRDHistograms( block, gTRDCanvas );     
        if ( gTRDCanvas) gTRDCanvas->Update();
+     }
+     
+       else if(block->GetDataType().CompareTo("CALIBRAH")==0){
+       iResult=processTRDCalibHistograms(block,gTRDCalibCanvas);
+       if(gTRDCalibCanvas)gTRDCalibCanvas->Update();
+      }
+  
+      else if(block->GetDataType().CompareTo("CALIBEOR")==0){
+       iResult=processTRDCalibHistograms(block,gTRDEORCanvas);
+       if(gTRDEORCanvas)gTRDEORCanvas->Update();
       }
-
     } // else if ( ! block->GetDetector().CompareTo("TRD") ) {
     
     // ++ MUON BLOCK
@@ -737,6 +913,19 @@ Int_t processEvent() {
        processMUONClusters( block );
        gMUONClusters->ElementChanged();
        
+      }else if(block->GetDataType().CompareTo("MANTRACK") == 0){
+       
+       if ( !gMUONTracks ) {
+         gMUONTracks = new TEveStraightLineSet("MUON Tracks");
+         gMUONTracks->SetMainColor(kRed);
+         gMUONTracks->SetLineWidth(3);
+         gEve->AddElement(gMUONTracks);
+       }
+
+       processMUONTracks( block );
+       gMUONTracks->ElementChanged();
+
+
       } 
     } // else if ( ! block->GetDetector().CompareTo("MUON") && gShowMUON ) {
 
@@ -754,6 +943,13 @@ Int_t processEvent() {
        
        processITSClusters( block , gSPDClusters);
        gSPDClusters->ElementChanged();
+      
+      } else if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
+
+       // -- Process Vertex Histos
+         cout << "processvertexhistorgrams"<<endl;
+         processVertexHistograms( block , gVertexCanvas);
+         gVertexCanvas->Update();
       } 
     } // else if ( ! block->GetDetector().CompareTo("ISPD") ){
 
@@ -804,7 +1000,8 @@ Int_t processEvent() {
     else if ( ! block->GetDetector().CompareTo("PHOS") ) {
 
       // -- Process Digits
-      if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
+      //if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) { 
+      if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
        
        if( !gPHOSElementList ){
          gPHOSElementList = new TEveElementList("PHOS Cells");
@@ -816,12 +1013,14 @@ Int_t processEvent() {
          // -- Create boxsets
          for(int im = 0; im < 5; im++) {
          
-           TEveRGBAPalette* pal = new TEveRGBAPalette(40,120);
+           TEveRGBAPalette* pal = new TEveRGBAPalette(0,120);
+           pal->SetLimits(-0.1, 1024);
            gPHOSBoxSet[im] = new TEveBoxSet(Form("Cells Module %d" , im));
            gPHOSBoxSet[im]->SetPalette(pal);
            gPHOSBoxSet[im]->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
            gPHOSBoxSet[im]->SetOwnIds(kTRUE);
            
+
            gPHOSGeom->GetModuleCenter(center, "CPV", im+1);
            angle = gPHOSGeom->GetPHOSAngle(im+1)*TMath::Pi()/180;
          
@@ -843,15 +1042,191 @@ Int_t processEvent() {
 
     } // else if ( ! block->GetDetector().CompareTo("PHOS") ){
 
+    else if ( ! block->GetDetector().CompareTo("EMCAL") ){
+      if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
+       
+       cout << "EMCAL, setting up digits display"<<endl;
+       
+       if( !gEMCALElementList ){
+         
+         
+         gEMCALElementList = new TEveElementList("EMCAL Cells");
+         gEMCALElementList->SetTitle("Tooltip");
+         gEve->AddElement(gEMCALElementList);
+         
+         
+         gStyle->SetPalette(1, 0);
+         TEveRGBAPalette* pal = new TEveRGBAPalette(0, 512);
+         pal->SetLimits(0, 1024);
+         
+         
+         for (Int_t sm=0; sm<12; ++sm) {
+             
+           TEveBoxSet* q = new TEveBoxSet(Form("SM %d", sm+1));
+           q->SetOwnIds(kTRUE);
+           
+           q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
+           q->RefMainTrans().SetFrom(*gEMCALNode->GetDaughter(sm)->GetMatrix());
+           q->SetPalette(pal);
+           
+           gEve->AddElement(q, gEMCALElementList);
+           gEMCALBoxSet[sm] = q;
+         }
+       }
+       
+       
+       cout << "Processing emcal digits" << endl;
+       iResult = processEMCALClusters( block );
+       
+       for(int sm = 0; sm < 12; sm++) {
+         gEMCALBoxSet[sm]->ElementChanged();
+       }
+       
+       
+      }
+      
+    } // "EMCAL" blocks end
+
     // ---------------------------------------------------------
   } // while ((block = (AliHLTHOMERBlockDesc*)next())) {
 
+
+  //============================================================================
+  //   Reading out the histograms
+  //===========================================================================
+  TIter anext(gHomerManager->GetAsyncBlockList());
+  cout << gHomerManager->GetAsyncBlockList()->GetSize() << endl;
+  cout << "Asynced it"<<endl;
+  while ( (block = (AliHLTHOMERBlockDesc*)anext()) ) {
+
+#if 1 //DEBUG
+    printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
+    printf( "Detector           : %s\n", block->GetDetector().Data() );
+    printf( "Datatype           : %s\n", block->GetDataType().Data() );
+    if (block->IsTObject() )
+      printf( "Is TObject of class: %s\n", block->GetClassName().Data() );
+    printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
+#endif
+
+
+
+    // ++ ISPD BLOCK
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    if ( ! block->GetDetector().CompareTo("ISPD") ){
+      if ( block->GetDataType().CompareTo("ROOTHIST") == 0 ) {
+      
+       // -- Process Vertex Histos
+       cout << "processvertexhistorgrams"<<endl;
+       processVertexHistograms( block , gVertexCanvas);
+       gVertexCanvas->Update();
+      } 
+    }
+  
+
+    // ++ PHOS BLOCK
+    // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    else if ( ! block->GetDetector().CompareTo("PHOS") ) {
+
+      // -- Process Digits
+      //if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) { 
+      if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
+       
+       if( !gPHOSElementList ){
+         gPHOSElementList = new TEveElementList("PHOS Cells");
+         gEve->AddElement(gPHOSElementList);
+         
+         TVector3 center;
+         Float_t angle;
+         
+         // -- Create boxsets
+         for(int im = 0; im < 5; im++) {
+         
+           TEveRGBAPalette* pal = new TEveRGBAPalette(0,120);
+           pal->SetLimits(-0.1, 1024);
+           gPHOSBoxSet[im] = new TEveBoxSet(Form("Cells Module %d" , im));
+           gPHOSBoxSet[im]->SetPalette(pal);
+           gPHOSBoxSet[im]->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
+           gPHOSBoxSet[im]->SetOwnIds(kTRUE);
+           
+
+           gPHOSGeom->GetModuleCenter(center, "CPV", im+1);
+           angle = gPHOSGeom->GetPHOSAngle(im+1)*TMath::Pi()/180;
+         
+           gPHOSBoxSet[im]->RefitPlex();
+           TEveTrans& t = gPHOSBoxSet[im]->RefMainTrans();
+           t.SetupRotation(1, 2, angle );
+           t.SetPos(center.X(), center.Y(), center.Z());
+           
+           gPHOSElementList->AddElement(gPHOSBoxSet[im]);
+         }
+       } // for(int im = 0; im < 5; im++) {
+       
+       iResult = processPHOSClusters( block );
+       
+       for(int im = 0; im < 5; im++)
+         gPHOSBoxSet[im]->ElementChanged();
+
+      } // if ( block->GetDataType().CompareTo("DIGITTYP") == 0 ) {
+
+    } // else if ( ! block->GetDetector().CompareTo("PHOS") ){
+
+    else if ( ! block->GetDetector().CompareTo("EMCA") ){
+      if ( block->GetDataType().CompareTo("CHANNELT") == 0 ) {
+       
+       cout << "EMCAL, setting up digits display"<<endl;
+       
+       if( !gEMCALElementList ){
+         
+         
+         gEMCALElementList = new TEveElementList("EMCAL Cells");
+         gEMCALElementList->SetTitle("Tooltip");
+         gEve->AddElement(gEMCALElementList);
+         
+         
+         gStyle->SetPalette(1, 0);
+         TEveRGBAPalette* pal = new TEveRGBAPalette(0, 512);
+         pal->SetLimits(0, 1024);
+         
+         
+         for (Int_t sm=0; sm<12; ++sm) {
+             
+           TEveBoxSet* q = new TEveBoxSet(Form("SM %d", sm+1));
+           q->SetOwnIds(kTRUE);
+           
+           q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64);
+           q->RefMainTrans().SetFrom(*gEMCALNode->GetDaughter(sm)->GetMatrix());
+           q->SetPalette(pal);
+           
+           gEve->AddElement(q, gEMCALElementList);
+           gEMCALBoxSet[sm] = q;
+         }
+       }
+       
+       
+       cout << "Processing emcal digits" << endl;
+       iResult = processEMCALClusters( block );
+       
+       for(int sm = 0; sm < 12; sm++) {
+         gEMCALBoxSet[sm]->ElementChanged();
+       }
+       
+       
+      }
+      
+    } // "EMCAL" blocks end
+
+
+
+
+  }
+
   //==============================================================================
   // -- Update Objects
   //==============================================================================
 
   // -- TPC Histograms
   if ( gTPCCanvas && gTPCCharge && gTPCQMax) {
+
     gTPCCanvas->Clear();    
     gTPCCanvas->Divide(1,3);
 
@@ -878,6 +1253,12 @@ Int_t processEvent() {
     for(int im = 0; im < 5; im++)
       gPHOSBoxSet[im]->ResetBBox();      
 
+  if ( gEMCALElementList )
+    for(int sm = 0; sm < 12; sm++) 
+      gEMCALBoxSet[sm]->ResetBBox();
+    
+  
+
   //==============================================================================
   // -- Set EventID in Window Title  
   // -- Update Objects
@@ -953,15 +1334,19 @@ Int_t processROOTTOBJ(AliHLTHOMERBlockDesc* block, TEveText* /*et*/) {
 // -----------------------------------------------------------------
 Int_t processEsdTracks( AliHLTHOMERBlockDesc* block, TEveTrackList* cont ) {
 
+  cout << "Adding tracks" << endl;
+
   AliESDEvent* esd = (AliESDEvent *) (block->GetTObject());
   esd->GetStdContent();
 
   esd_track_propagator_setup(cont->GetPropagator(),0.1*esd->GetMagneticField(), 520);
 
-  printf( "Number of ESD Tracks : %d \n", esd->GetNumberOfTracks());
+  //  printf( "Number of ESD Tracks : %d \n", esd->GetNumberOfTracks());
 
   for (Int_t iter = 0; iter < esd->GetNumberOfTracks(); ++iter) {
-    AliEveTrack* track = dynamic_cast<AliEveTrack*>(esd_make_track(esd->GetTrack(iter), cont));
+    cout << "track" << endl;
+    //AliEveTrack* track = dynamic_cast<AliEveTrack*>(esd_make_track(esd->GetTrack(iter), cont));
+    AliEveTrack* track = dynamic_cast<AliEveTrack*>(hlt_esd_make_track(esd->GetTrack(iter), cont));
     cont->AddElement(track);
   }
   
@@ -971,49 +1356,119 @@ Int_t processEsdTracks( AliHLTHOMERBlockDesc* block, TEveTrackList* cont ) {
   return 0;
 }
 
-
 // -----------------------------------------------------------------
-// Int_t processPHOSClusters(AliHLTHOMERBlockDesc* block) {
+Int_t processPHOSClusters(AliHLTHOMERBlockDesc* block) {
 
-//    AliHLTCaloClusterHeaderStruct *hd = reinterpret_cast<AliHLTCaloClusterHeaderStruct*> (block->GetData());
-//    AliHLTCaloClusterReader * cReader = new AliHLTCaloClusterReader();
-//    cReader->SetMemory(hd);
-   
-//    AliHLTCaloClusterDataStruct* cd = 0;
+  
+  
+  cout << "PHOS PHOS"<<endl;
+  
+  AliHLTPHOSChannelDataHeaderStruct *chh = reinterpret_cast<AliHLTPHOSChannelDataHeaderStruct*> (block->GetData());
+  
+
+  AliHLTPHOSChannelDataStruct *chd = reinterpret_cast<AliHLTPHOSChannelDataStruct*>(chh+1);
+
+  for(UInt_t i = 0; i < chh->fNChannels; i++, chd++) {
+    
+    Int_t gain = (chd->fChannelID >> 12)&0x1;    
+    Int_t module = (chd->fChannelID >> 13)&0x1f;
+    module = 4 -module;
    
-//    while( (cd = cReader->NextCluster()) ){
 
-//      cout << cd->fEnergy << endl;
-     
-//      Float_t e = cd->fEnergy;
-//      Float_t x = cd->fGlobalPos[0];
-//      Float_t y = cd->fGlobalPos[1];
-//      Float_t z = cd->fGlobalPos[2];
+    if(gain == 0)
+      
+      {
+       Float_t x = (static_cast<Float_t>(chd->fChannelID&0x3f) - 32)* 2.2;
+       Float_t z = (static_cast<Float_t>((chd->fChannelID >> 6)&0x3f) - 28) * 2.2;
+       //      gPHOSBoxSet[ds->fModule]->AddBox(ds->fLocX, 0, ds->fLocZ, 2.2, ds->fEnergy*20, 2.2);
+       gPHOSBoxSet[module]->AddBox(x, 0, z, 2.2, chd->fEnergy/15, 2.2);
+       gPHOSBoxSet[module]->DigitValue(static_cast<Int_t>(chd->fEnergy));
+       
+       caloCell *cs = new caloCell();
+       cs->phosStruct = *chd;
+       gPHOSBoxSet[module]->DigitId(cs);
+      }
 
-     
-//      gPHOSBoxSet->AddBox(x, y, z, 2.2, e*10, 2.2);
-     
-//    }
+
+
+  }
+
+  return 0;
+}
+
+// // -----------------------------------------------------------------
+// Int_t processPHOSClusters(AliHLTHOMERBlockDesc* block) {
+
+//   AliHLTPHOSDigitHeaderStruct *dh = reinterpret_cast<AliHLTPHOSDigitHeaderStruct*> (block->GetData());
+//   //UInt_t nClusters = block->GetSize()/sizeof(AliHLTPHOSDigitDataStruct);
+    
+//     UInt_t nDigits = dh->fNDigits;
+
+//     AliHLTPHOSDigitDataStruct *ds = reinterpret_cast<AliHLTPHOSDigitDataStruct*>(reinterpret_cast<UChar_t*>(dh)+sizeof(AliHLTPHOSDigitHeaderStruct));
+
+//   for(UInt_t i = 0; i < nDigits; i++, ds++) {
+//     gPHOSBoxSet[ds->fModule]->AddBox(ds->fLocX, 0, ds->fLocZ, 2.2, ds->fEnergy*20, 2.2);
+//     gPHOSBoxSet[ds->fModule]->DigitValue(static_cast<Int_t>(ds->fEnergy*100));
+//   }
 
 //   return 0;
 // }
 
 
 
+
+
+
+
+
+
 // -----------------------------------------------------------------
-Int_t processPHOSClusters(AliHLTHOMERBlockDesc* block) {
+Int_t processEMCALClusters(AliHLTHOMERBlockDesc* block) {
 
-  AliHLTPHOSDigitDataStruct *ds = reinterpret_cast<AliHLTPHOSDigitDataStruct*> (block->GetData());
-    UInt_t nClusters = block->GetSize()/sizeof(AliHLTPHOSDigitDataStruct);
+  AliHLTCaloChannelDataHeaderStruct *dhs = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*> (block->GetData());
+  Short_t nC = dhs->fNChannels;
+  AliHLTUInt8_t *ui = reinterpret_cast<AliHLTUInt8_t*>(dhs) + sizeof(AliHLTCaloChannelDataHeaderStruct);
+  AliHLTCaloChannelDataStruct *ds = reinterpret_cast<AliHLTCaloChannelDataStruct*>(ui);
+  
+  UShort_t fX =0;
+  UShort_t fZ =0;
+  UShort_t fGain =0;
+  UShort_t fModuleId =0;
+  
 
-  for(UInt_t i = 0; i < nClusters; i++, ds++) {
-    gPHOSBoxSet[ds->fModule]->AddBox(ds->fX, 0, ds->fZ, 2.2, ds->fEnergy*20, 2.2);
-    gPHOSBoxSet[ds->fModule]->DigitValue(static_cast<Int_t>(ds->fEnergy*100));
-  }
 
+  for(Short_t s = 0; s < nC; s++ ) {
+  
+
+
+    //    cout << nC << " "<< s << endl;
+    //cout << ds->fEnergy << " " << ds->fChannelID<<endl;
+    
+
+    
+    fX = ds->fChannelID&0x3f;
+    fZ = (ds->fChannelID >> 6)&0x3f;
+    fGain = (ds->fChannelID >> 12)&0x1;
+    fModuleId  = (ds->fChannelID >> 13)&0x1f;
+    
+    //    cout << fX << " " << fZ << " " << fGain << " " << fModuleId <<endl;
+   
+    if ( ( fModuleId > -1 && fModuleId < 12 ) ) {
+      gEMCALBoxSet[fModuleId]->AddBox(10, fX*6-12*6, fZ*6-24*6, ds->fEnergy/4, 6, 6);
+      gEMCALBoxSet[fModuleId]->DigitValue(static_cast<Int_t>(ds->fEnergy));
+    } 
+    ds++;
+  
+}
+  
+
+    
   return 0;
 }
 
+
+
+
 // -----------------------------------------------------------------
 Int_t processITSClusters(AliHLTHOMERBlockDesc* block, TEvePointSet* cont) {
 
@@ -1120,10 +1575,10 @@ Int_t processMUONClusters(AliHLTHOMERBlockDesc* block) {
       const AliHLTMUONRecHitStruct* hit = &trigrec->fHit[0];
       for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
        {
-         cout << setw(10) << left << ch + 11 << setw(0);
-         cout << setw(13) << left << hit->fX << setw(0);
-         cout << setw(13) << left << hit->fY << setw(0);
-         cout << hit->fZ << setw(0) << endl;
+//       cout << setw(10) << left << ch + 11 << setw(0);
+//       cout << setw(13) << left << hit->fX << setw(0);
+//       cout << setw(13) << left << hit->fY << setw(0);
+//       cout << hit->fZ << setw(0) << endl;
          if(hit->fX!=0.0 && hit->fY!=0.0 && hit->fZ!=0.0)
            gMUONClusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
          hit++;
@@ -1135,6 +1590,59 @@ Int_t processMUONClusters(AliHLTHOMERBlockDesc* block) {
   return iResult;
 }
 
+// -----------------------------------------------------------------
+Int_t processMUONTracks(AliHLTHOMERBlockDesc* block) {
+  
+  Int_t iResult = 0;
+  
+  unsigned long size = block->GetSize();
+  Int_t * buffer = (Int_t *)block->GetData();
+  AliHLTMUONRecHitStruct hit1,hit2;
+  hit1.fX = hit1.fY = hit1.fZ = hit2.fX = hit2.fY = hit2.fZ = 0;
+  Int_t ch1=0, ch2=0;
+  Float_t x0=0.0,y0=0.0,z0=0.0;
+  Float_t x3=0.0,y3=0.0,z3=0.0;
+  if(block->GetDataType().CompareTo("MANTRACK") == 0){  
+    AliHLTMUONMansoTracksBlockReader mantrackblock(buffer, size);
+    const AliHLTMUONMansoTrackStruct* mtrack = mantrackblock.GetArray();
+    for(AliHLTUInt32_t ientry = 0; ientry < mantrackblock.Nentries(); ientry++){
+      const AliHLTMUONRecHitStruct* hit = &mtrack->fHit[0];
+      for(AliHLTUInt32_t ch = 0; ch < 4; ch++){
+       // cout << setw(10) << left << ch + 7 << setw(0);
+       // cout << setw(13) << left << hit->fX << setw(0);
+       // cout << setw(13) << left << hit->fY << setw(0);
+       // cout << hit->fZ << setw(0) << endl;
+       if(hit->fZ != 0.0){
+         if(ch==0 || ch==1){
+           hit1 = *hit; ch1 = ch+6;
+         }else{
+           hit2 = *hit; ch2 = ch+6;
+         }
+       }
+       hit++;
+      }// trig chamber loop
+      // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch1,hit1.fX,hit1.fY,hit1.fZ);
+      // printf("ch : %d, (X,Y,Z) : (%f,%f,%f)\n",ch2,hit2.fX,hit2.fY,hit2.fZ);
+      // meminfo();
+      z3 = AliMUONConstants::DefaultChamberZ(ch2+4);
+      y3 =  hit1.fY - (hit1.fZ-z3)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ;
+      x3 =  hit1.fX - (hit1.fZ-z3)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ;
+
+      z0 = AliMUONConstants::DefaultChamberZ(ch1);
+      y0 =  hit1.fY - (hit1.fZ-z0)*(hit1.fY - hit2.fY)/(hit1.fZ - hit2.fZ) ;
+      x0 =  hit1.fX - (hit1.fZ-z0)*(hit1.fX - hit2.fX)/(hit1.fZ - hit2.fZ) ;
+      
+
+      gMUONTracks->AddLine(x0,y0,z0,x3,y3,z3);
+      mtrack++;
+    }
+    cout<<"NofManso Tracks : "<<mantrackblock.Nentries()<<endl;
+  }
+  
+  return iResult;
+
+}
+
  
 // -----------------------------------------------------------------
 Int_t processTRDClusters(AliHLTHOMERBlockDesc* block, TEvePointSet *cont, TEvePointSetArray *contCol) {
@@ -1210,8 +1718,106 @@ Int_t processTRDHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
   return iResult;
 }
 
+
+// -----------------------------------------------------------------
+Int_t processVertexHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
+
+  Int_t iResult = 0;
+  cout << gVertexHistoCount<<endl;
+
+  if ( ! block->GetClassName().CompareTo("TH1F")) {
+    cout << "TH1F"<<endl;
+    TH1F* histo = reinterpret_cast<TH1F*>(block->GetTObject());
+    ++gVertexHistoCount;
+  
+    canvas->cd(gVertexHistoCount);
+    histo->Draw();
+//     pad->SetGridy();
+//     pad->SetGridx();
+
+  }  else if ( ! block->GetClassName().CompareTo("TH2F")) {
+    cout << "TH2F"<<endl;
+    TH2F *hista = reinterpret_cast<TH2F*>(block->GetTObject());
+    if (hista) {
+      
+      ++gVertexHistoCount;
+  
+      canvas->cd(gVertexHistoCount);
+      hista->Draw();
+    }
+  }
+  canvas->cd();
+
+  cout << "done with histos"<< endl;
+  return iResult;
+
+
+}
+
+//*-------------------------------------------------------------------------------------- 
+Int_t processTRDCalibHistograms(AliHLTHOMERBlockDesc* block, TCanvas * canvas) {
+  Int_t iResult = 0;
+
+  TObjArray *HistArray=(TObjArray*)block->GetTObject();
+  Int_t nCalibHistos=HistArray->GetEntriesFast();
+  for(Int_t CalibHistoCount=0;CalibHistoCount<nCalibHistos;CalibHistoCount++){
+    canvas->cd(CalibHistoCount+1);
+    
+    if(HistArray->At(CalibHistoCount)->InheritsFrom("TH2S")){
+        TH2S *histCalib=(TH2S*)(HistArray->At(CalibHistoCount));
+        histCalib->Draw("colz");
+       }
+     else if(HistArray->At(CalibHistoCount)->InheritsFrom("TH2")){
+      //TH2D *histCalib=dynamic_cast<TH2D*>(HistArray->At(CalibHistoCount));
+      TH2D *histCalib=(TH2D*)(HistArray->At(CalibHistoCount));
+      histCalib->Draw("lego2");
+    }
+    else if(HistArray->At(CalibHistoCount)->InheritsFrom("TH1")){
+      //TH1D *histCalib=dynamic_cast<TH1D*>(HistArray->At(CalibHistoCount));
+      TH1D *histCalib=(TH1D*)(HistArray->At(CalibHistoCount));
+      histCalib->Draw();
+    }
+    else if(HistArray->At(CalibHistoCount)->InheritsFrom("AliTRDCalibraVdriftLinearFit")){
+      //TH2S *histCalib = ((dynamic_cast<AliTRDCalibraVdriftLinearFit*>(HistArray->At(CalibHistoCount)))->GetLinearFitterHisto(10,kTRUE));
+      TH2S *histCalib =(TH2S*)(((AliTRDCalibraVdriftLinearFit*)HistArray->At(CalibHistoCount))->GetLinearFitterHisto(10,kTRUE));
+
+      histCalib->Draw();
+    }
+    
+   
+  }
+ return iResult;
+}
 //****************************************************************************
 
+void writeToFile(){
+
+    cout << "balle " << endl;
+  
+  TList * bList = gHomerManager->GetBlockList();
+  TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", gHomerManager->GetEventID()), "RECREATE"); 
+  bList->Write("blockList", TObject::kSingleKey);
+  file->Close();
+  
+  bList = gHomerManager->GetAsyncBlockList();
+  TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", gHomerManager->GetEventID()), "RECREATE"); 
+  bList->Write("blockList", TObject::kSingleKey);
+  afile->Close();
+
+
+//   TIter next(bList);
+  
+//   AliHLTHOMERBlockDesc* block = 0;
+  
+//   // -- Iterate over blocks in the block list
+//   // ------------------------------------------
+//   while ((block = (AliHLTHOMERBlockDesc*)next())) {
+//     cout << "balle " << endl;
+//   }
+  
+}
+
+
 // -----------------------------------------------------------------
 void loopEvent() {
   eventTimer.SetCommand("nextEvent()");
@@ -1242,9 +1848,10 @@ void EventLoopFast() {
   if ( gEventLoopStarted ) {
     loopEventFast();
     gEventLoopStarted = kTRUE;
-  }
-  else {
+  
+  } else {  
     stopLoopEventFast();
     gEventLoopStarted = kFALSE;
+  
   }
 }