]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/emcal_all.C
From Mikolaj. One more function for drawing ITS stand-alone tracks.
[u/mrichter/AliRoot.git] / EVE / alice-macros / emcal_all.C
1 //************************************************************************
2 // A macro to read and visualize EMCAL data
3 // The macro: 
4 // - can read hits, digits and clusters information from AliRunLoader:
5 //      emcal_data->LoadHits(ht); 
6 //      emcal_data->LoadDigits(dt);
7 //      emcal_data->LoadRecPoints(rt);
8 // - can read hits, digits and clusters information from AliEMCALLoader:
9 //      rl->GetEvent(evtNum);
10 //      emcal_data->LoadHitsFromEMCALLoader(emcl);       // Does not work
11 //      emcal_data->LoadDigitsFromEMCALLoader(emcl);     
12 //      emcal_data->LoadRecPointsFromEMCALLoader(emcl); 
13 // - can read hits, digits and clusters information from ESDs
14 //      emcal_data->LoadDigitsFromESD();
15 //      emcal_data->LoadClustersFromESD();
16 // - will read hits, digits and clusters information from raw
17 //   => To be implemented
18 //
19 //************************************************************************
20 //  Author: Magali Estienne (magali.estienne@cern.ch)
21 //  June 30 2008
22 //************************************************************************
23
24 #include <Riostream.h>
25 #include <TMath.h>
26
27
28 class AliEveEMCALData;
29 AliEveEMCALData     *emcal_data       = 0;
30
31 void emcal_all(const UInt_t evtNum = 0, Bool_t digFile = 0, 
32                const UInt_t eventsToProcess = 5, TString dirName = "./", 
33                const TString esdTreeName = "esdTree", const char *  pattern = ".")
34 {
35
36   Int_t iLoader             = 1;
37   Int_t iESD                = 1;
38   Int_t iAOD                = 0;
39   Int_t iHits               = 1;
40   Int_t iDigits             = 1;
41   Int_t iClusters           = 1;
42
43   AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
44   // runloader check already in AssertRunLoader function 
45   AliESDEvent* esd = 0x0;
46   if(iESD) esd = AliEveEventManager::AssertESD();
47   // esd check already in AssertESD function 
48   AliEMCALLoader *emcl = dynamic_cast<AliEMCALLoader*> (rl->GetDetectorLoader("EMCAL"));
49   Int_t evtID = AliEveEventManager::GetMaster()->GetEventId();
50   if(evtID != evtNum) AliEveEventManager::GetMaster()->GotoEvent(evtNum);
51
52   TTree* ht = 0x0; 
53   TTree* dt = 0x0; 
54   TTree* rt = 0x0; 
55   if(iLoader)
56     {
57       //Load Hits
58       if(iHits) {
59         if(!rl->LoadHits("EMCAL"))
60           ht = rl->GetTreeH("EMCAL",false);
61         else {printf("Please make sure a have a EMCal.Hits.root file \n"); return;}
62       }
63       //Load Digits
64       if(iDigits) {
65         if(!rl->LoadDigits("EMCAL"))
66           dt = rl->GetTreeD("EMCAL",false);
67         else {printf("Please make sure a have a EMCal.Digits.root file \n"); return;}
68       }
69       //Load RecPoints
70       if(iClusters) {
71         if(!rl->LoadRecPoints("EMCAL"))
72           rt = rl->GetTreeR("EMCAL",false);
73         else {printf("Please make sure a have a EMCal.RecPoints.root file \n"); return;}
74       }
75     }
76
77   gGeoManager = gEve->GetDefaultGeometry();
78   TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
79   TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
80   emcal_data = new AliEveEMCALData(rl,node,m);
81   if(iESD) emcal_data->SetESD(esd);
82
83   // Get information from RunLoader
84   if(iLoader)
85     {
86       if(iHits)     emcal_data->LoadHits(ht); // Does not work with my aliroot version 
87       if(iDigits)   emcal_data->LoadDigits(dt);
88       if(iClusters) emcal_data->LoadRecPoints(rt);
89       
90       rl->GetEvent(evtNum);
91
92       if(iHits)     emcal_data->LoadHitsFromEMCALLoader(emcl);       
93       if(iDigits)   emcal_data->LoadDigitsFromEMCALLoader(emcl);     
94       if(iClusters) emcal_data->LoadRecPointsFromEMCALLoader(emcl); 
95     }
96
97   // Get information from ESDs
98   if(iESD)
99     {
100       rl->GetEvent(evtNum);
101       if(iDigits) emcal_data->LoadDigitsFromESD();
102       if(iClusters) emcal_data->LoadRecPointsFromESD();
103     }
104
105   gStyle->SetPalette(1, 0);
106
107   gEve->DisableRedraw();
108
109   TEveElementList* l = new TEveElementList("EMCAL");
110   l->SetTitle("Tooltip");
111   l->SetMainColor(Color_t(2));
112   gEve->AddElement(l);
113
114   for (Int_t sm=0; sm<12; sm++)
115     {
116       AliEveEMCALSModule* esm = new AliEveEMCALSModule(sm,Form("SM %d Element \n", sm),"test");
117       //      esm->SetSModuleID(sm);
118       esm->SetDataSource(emcal_data);
119       esm->UpdateQuads();
120       l->AddElement(esm);
121     }
122
123   gEve->Redraw3D(kTRUE);
124
125   gEve->EnableRedraw();
126
127
128 }