]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/emcal_all.C
doxy: code cleanup: comments and clarifications
[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 #if !defined(__CINT__) || defined(__MAKECINT__)
25 #include <Riostream.h>
26 #include <TGeoManager.h>
27 #include <TGeoNode.h>
28 #include <TGeoMatrix.h>
29 #include <TMath.h>
30 #include <TString.h>
31 #include <TTree.h>
32 #include <TStyle.h>
33 #include <TEveManager.h>
34 #include <TEveElement.h>
35 #include <TEvePointSet.h>
36
37 #include <AliEMCAL.h>
38 #include <AliEMCALLoader.h>
39 #include <AliESDEvent.h>
40 #include <AliESDtrack.h>
41 #include <AliTrackPointArray.h>
42 #include <AliRunLoader.h>
43 #include <AliEveEventManager.h>
44 #include <AliEveMultiView.h>
45 #include <AliEveEMCALData.h>
46 #include <AliEveEMCALSModule.h>
47 #else
48 class AliEveEMCALData;
49 #endif
50
51 AliEveEMCALData     *emcal_data       = 0;
52
53 void emcal_all(const UInt_t evtNum = 0)/*, Bool_t digFile = 0, 
54                const UInt_t eventsToProcess = 5, TString dirName = "./", 
55                const TString esdTreeName = "esdTree", const char *  pattern = ".")*/
56 {
57
58   Int_t iLoader             = 1;
59   Int_t iESD                = 1;
60   Int_t iHits               = 1;
61   Int_t iDigits             = 1;
62   Int_t iClusters           = 1;
63
64   AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
65   // runloader check already in AssertRunLoader function 
66   AliESDEvent* esd = 0x0;
67   if(iESD) esd = AliEveEventManager::AssertESD();
68   // esd check already in AssertESD function 
69   AliEMCALLoader *emcl = dynamic_cast<AliEMCALLoader*> (rl->GetDetectorLoader("EMCAL"));
70   Int_t evtID = AliEveEventManager::GetMaster()->GetEventId();
71   if(evtID != (Int_t)evtNum) AliEveEventManager::GetMaster()->GotoEvent(evtNum);
72
73   TTree* ht = 0x0; 
74   TTree* dt = 0x0; 
75   TTree* rt = 0x0; 
76   if(iLoader)
77     {
78       //Load Hits
79       if(iHits) {
80         if(!rl->LoadHits("EMCAL"))
81           ht = rl->GetTreeH("EMCAL",false);
82         else {printf("Please make sure a have a EMCal.Hits.root file \n"); return;}
83       }
84       //Load Digits
85       if(iDigits) {
86         if(!rl->LoadDigits("EMCAL"))
87           dt = rl->GetTreeD("EMCAL",false);
88         else {printf("Please make sure a have a EMCal.Digits.root file \n"); return;}
89       }
90       //Load RecPoints
91       if(iClusters) {
92         if(!rl->LoadRecPoints("EMCAL"))
93           rt = rl->GetTreeR("EMCAL",false);
94         else {printf("Please make sure a have a EMCal.RecPoints.root file \n"); return;}
95       }
96     }
97
98   //  gGeoManager = gEve->GetDefaultGeometry();
99   AliEveEventManager::AssertGeometry();
100   TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("XEN1_1");
101   TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
102   emcal_data = new AliEveEMCALData(rl,node,m);
103   if(iESD) emcal_data->SetESD(esd);
104
105   // Get information from RunLoader
106   if(iLoader)
107     {
108       if(iHits)     emcal_data->LoadHits(ht); // Does not work with my aliroot version 
109       if(iDigits)   emcal_data->LoadDigits(dt);
110       if(iClusters) emcal_data->LoadRecPoints(rt);
111       
112       rl->GetEvent(evtNum);
113
114       if(iHits)     emcal_data->LoadHitsFromEMCALLoader(emcl);       
115       if(iDigits)   emcal_data->LoadDigitsFromEMCALLoader(emcl);     
116       if(iClusters) emcal_data->LoadRecPointsFromEMCALLoader(emcl); 
117     }
118
119   // Get information from ESDs
120   if(iESD)
121     {
122       rl->GetEvent(evtNum);
123       if(iDigits) emcal_data->LoadDigitsFromESD();
124       if(iClusters) emcal_data->LoadRecPointsFromESD();
125     }
126
127   gStyle->SetPalette(1, 0);
128
129   gEve->DisableRedraw();
130
131   TEveElementList* l = new TEveElementList("EMCAL");
132   l->SetTitle("Tooltip");
133   l->SetMainColor(Color_t(2));
134   gEve->AddElement(l);
135
136   for (Int_t sm=0; sm<12; sm++)
137     {
138       AliEveEMCALSModule* esm = new AliEveEMCALSModule(sm,Form("SM %d Element \n", sm),"test");
139       //      esm->SetSModuleID(sm);
140       esm->SetDataSource(emcal_data);
141       esm->UpdateQuads();
142       l->AddElement(esm);
143     }
144
145   gEve->Redraw3D(kTRUE);
146
147   gEve->EnableRedraw();
148
149
150 }