ROOT logo
//************************************************************************
// A macro to read and visualize EMCAL data
// The macro: 
// - can read hits, digits and clusters information from AliRunLoader:
//      emcal_data->LoadHits(ht); 
//      emcal_data->LoadDigits(dt);
//      emcal_data->LoadRecPoints(rt);
// - can read hits, digits and clusters information from AliEMCALLoader:
//      rl->GetEvent(evtNum);
//      emcal_data->LoadHitsFromEMCALLoader(emcl);       // Does not work
//      emcal_data->LoadDigitsFromEMCALLoader(emcl);     
//      emcal_data->LoadRecPointsFromEMCALLoader(emcl); 
// - can read hits, digits and clusters information from ESDs
//      emcal_data->LoadDigitsFromESD();
//      emcal_data->LoadClustersFromESD();
// - will read hits, digits and clusters information from raw
//   => To be implemented
//
//************************************************************************
//  Author: Magali Estienne (magali.estienne@cern.ch)
//  June 30 2008
//************************************************************************

#if !defined(__CINT__) || defined(__MAKECINT__)
#include <Riostream.h>
#include <TGeoManager.h>
#include <TGeoNode.h>
#include <TGeoMatrix.h>
#include <TMath.h>
#include <TString.h>
#include <TTree.h>
#include <TStyle.h>
#include <TEveManager.h>
#include <TEveElement.h>
#include <TEvePointSet.h>

#include <AliEMCAL.h>
#include <AliEMCALLoader.h>
#include <AliESDEvent.h>
#include <AliESDtrack.h>
#include <AliTrackPointArray.h>
#include <AliRunLoader.h>
#include <AliEveEventManager.h>
#include <AliEveMultiView.h>
#include <AliEveEMCALData.h>
#include <AliEveEMCALSModule.h>
#else
class AliEveEMCALData;
#endif

AliEveEMCALData     *emcal_data       = 0;

void emcal_all(const UInt_t evtNum = 0)/*, Bool_t digFile = 0, 
	       const UInt_t eventsToProcess = 5, TString dirName = "./", 
	       const TString esdTreeName = "esdTree", const char *  pattern = ".")*/
{

  Int_t iLoader             = 1;
  Int_t iESD                = 1;
  Int_t iHits               = 1;
  Int_t iDigits             = 1;
  Int_t iClusters           = 1;

  AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
  // runloader check already in AssertRunLoader function 
  AliESDEvent* esd = 0x0;
  if(iESD) esd = AliEveEventManager::AssertESD();
  // esd check already in AssertESD function 
  AliEMCALLoader *emcl = dynamic_cast<AliEMCALLoader*> (rl->GetDetectorLoader("EMCAL"));
  Int_t evtID = AliEveEventManager::GetMaster()->GetEventId();
  if(evtID != (Int_t)evtNum) AliEveEventManager::GetMaster()->GotoEvent(evtNum);

  TTree* ht = 0x0; 
  TTree* dt = 0x0; 
  TTree* rt = 0x0; 
  if(iLoader)
    {
      //Load Hits
      if(iHits) {
	if(!rl->LoadHits("EMCAL"))
	  ht = rl->GetTreeH("EMCAL",false);
	else {printf("Please make sure a have a EMCal.Hits.root file \n"); return;}
      }
      //Load Digits
      if(iDigits) {
	if(!rl->LoadDigits("EMCAL"))
	  dt = rl->GetTreeD("EMCAL",false);
	else {printf("Please make sure a have a EMCal.Digits.root file \n"); return;}
      }
      //Load RecPoints
      if(iClusters) {
	if(!rl->LoadRecPoints("EMCAL"))
	  rt = rl->GetTreeR("EMCAL",false);
	else {printf("Please make sure a have a EMCal.RecPoints.root file \n"); return;}
      }
    }

  //  gGeoManager = gEve->GetDefaultGeometry();
  AliEveEventManager::AssertGeometry();
  TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
  TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
  emcal_data = new AliEveEMCALData(rl,node,m);
  if(iESD) emcal_data->SetESD(esd);

  // Get information from RunLoader
  if(iLoader)
    {
      if(iHits)     emcal_data->LoadHits(ht); // Does not work with my aliroot version 
      if(iDigits)   emcal_data->LoadDigits(dt);
      if(iClusters) emcal_data->LoadRecPoints(rt);
      
      rl->GetEvent(evtNum);

      if(iHits)     emcal_data->LoadHitsFromEMCALLoader(emcl);       
      if(iDigits)   emcal_data->LoadDigitsFromEMCALLoader(emcl);     
      if(iClusters) emcal_data->LoadRecPointsFromEMCALLoader(emcl); 
    }

  // Get information from ESDs
  if(iESD)
    {
      rl->GetEvent(evtNum);
      if(iDigits) emcal_data->LoadDigitsFromESD();
      if(iClusters) emcal_data->LoadRecPointsFromESD();
    }

  gStyle->SetPalette(1, 0);

  gEve->DisableRedraw();

  TEveElementList* l = new TEveElementList("EMCAL");
  l->SetTitle("Tooltip");
  l->SetMainColor(Color_t(2));
  gEve->AddElement(l);

  for (Int_t sm=0; sm<12; sm++)
    {
      AliEveEMCALSModule* esm = new AliEveEMCALSModule(sm,Form("SM %d Element \n", sm),"test");
      //      esm->SetSModuleID(sm);
      esm->SetDataSource(emcal_data);
      esm->UpdateQuads();
      l->AddElement(esm);
    }

  gEve->Redraw3D(kTRUE);

  gEve->EnableRedraw();


}
 emcal_all.C:1
 emcal_all.C:2
 emcal_all.C:3
 emcal_all.C:4
 emcal_all.C:5
 emcal_all.C:6
 emcal_all.C:7
 emcal_all.C:8
 emcal_all.C:9
 emcal_all.C:10
 emcal_all.C:11
 emcal_all.C:12
 emcal_all.C:13
 emcal_all.C:14
 emcal_all.C:15
 emcal_all.C:16
 emcal_all.C:17
 emcal_all.C:18
 emcal_all.C:19
 emcal_all.C:20
 emcal_all.C:21
 emcal_all.C:22
 emcal_all.C:23
 emcal_all.C:24
 emcal_all.C:25
 emcal_all.C:26
 emcal_all.C:27
 emcal_all.C:28
 emcal_all.C:29
 emcal_all.C:30
 emcal_all.C:31
 emcal_all.C:32
 emcal_all.C:33
 emcal_all.C:34
 emcal_all.C:35
 emcal_all.C:36
 emcal_all.C:37
 emcal_all.C:38
 emcal_all.C:39
 emcal_all.C:40
 emcal_all.C:41
 emcal_all.C:42
 emcal_all.C:43
 emcal_all.C:44
 emcal_all.C:45
 emcal_all.C:46
 emcal_all.C:47
 emcal_all.C:48
 emcal_all.C:49
 emcal_all.C:50
 emcal_all.C:51
 emcal_all.C:52
 emcal_all.C:53
 emcal_all.C:54
 emcal_all.C:55
 emcal_all.C:56
 emcal_all.C:57
 emcal_all.C:58
 emcal_all.C:59
 emcal_all.C:60
 emcal_all.C:61
 emcal_all.C:62
 emcal_all.C:63
 emcal_all.C:64
 emcal_all.C:65
 emcal_all.C:66
 emcal_all.C:67
 emcal_all.C:68
 emcal_all.C:69
 emcal_all.C:70
 emcal_all.C:71
 emcal_all.C:72
 emcal_all.C:73
 emcal_all.C:74
 emcal_all.C:75
 emcal_all.C:76
 emcal_all.C:77
 emcal_all.C:78
 emcal_all.C:79
 emcal_all.C:80
 emcal_all.C:81
 emcal_all.C:82
 emcal_all.C:83
 emcal_all.C:84
 emcal_all.C:85
 emcal_all.C:86
 emcal_all.C:87
 emcal_all.C:88
 emcal_all.C:89
 emcal_all.C:90
 emcal_all.C:91
 emcal_all.C:92
 emcal_all.C:93
 emcal_all.C:94
 emcal_all.C:95
 emcal_all.C:96
 emcal_all.C:97
 emcal_all.C:98
 emcal_all.C:99
 emcal_all.C:100
 emcal_all.C:101
 emcal_all.C:102
 emcal_all.C:103
 emcal_all.C:104
 emcal_all.C:105
 emcal_all.C:106
 emcal_all.C:107
 emcal_all.C:108
 emcal_all.C:109
 emcal_all.C:110
 emcal_all.C:111
 emcal_all.C:112
 emcal_all.C:113
 emcal_all.C:114
 emcal_all.C:115
 emcal_all.C:116
 emcal_all.C:117
 emcal_all.C:118
 emcal_all.C:119
 emcal_all.C:120
 emcal_all.C:121
 emcal_all.C:122
 emcal_all.C:123
 emcal_all.C:124
 emcal_all.C:125
 emcal_all.C:126
 emcal_all.C:127
 emcal_all.C:128
 emcal_all.C:129
 emcal_all.C:130
 emcal_all.C:131
 emcal_all.C:132
 emcal_all.C:133
 emcal_all.C:134
 emcal_all.C:135
 emcal_all.C:136
 emcal_all.C:137
 emcal_all.C:138
 emcal_all.C:139
 emcal_all.C:140
 emcal_all.C:141
 emcal_all.C:142
 emcal_all.C:143
 emcal_all.C:144
 emcal_all.C:145
 emcal_all.C:146
 emcal_all.C:147
 emcal_all.C:148
 emcal_all.C:149
 emcal_all.C:150
 emcal_all.C:151