]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/esd_zdc.C
Modified macros to be compilable by ACLiC
[u/mrichter/AliRoot.git] / EVE / alice-macros / esd_zdc.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TGeoManager.h>
3 #include <TGeoShape.h>
4 #include <TGeoMatrix.h>
5 #include <TStyle.h>
6 #include <TEveRGBAPalette.h>
7 #include <TEveGeoShape.h>
8 #include <TEveStraightLineSet.h>
9 #include <TEveManager.h>
10 #include <TEveElement.h>
11
12 #include <STEER/ESD/AliESDEvent.h>
13 #include <STEER/ESD/AliESDZDC.h>
14 #include <EVE/EveBase/AliEveEventManager.h>
15 #endif
16
17 TEveRGBAPalette *g_zdc_palette = 0;
18 Float_t          g_zdc_scale   = 0.1;
19 Float_t          g_zdc_dist    = 11695;
20 Float_t          g_zdc_cross   = 20;
21
22 TEveGeoShape* zdc_make_shape(const Text_t* name, const Text_t* title_base,
23                              Double_t signal,    const Text_t* path)
24 {
25   if ( ! gGeoManager->cd(path))
26   {
27     Warning("zdc_make_shape", "Module name=%s, path='%s' not found.\n", name, path);
28     return 0;
29   }
30
31   UChar_t rgb[3];
32   g_zdc_palette->ColorFromValue(TMath::Nint(signal), rgb, kFALSE);
33
34   TGeoShape *gs = (TGeoShape*) gGeoManager->GetCurrentVolume()->GetShape()->Clone();
35
36   TEveGeoShape *s = new TEveGeoShape(name, Form("%s %s, E=%.3f", title_base, name, signal));
37   s->SetPickable(kTRUE);
38   s->SetMainColorRGB(rgb[0], rgb[1], rgb[2]);
39   s->SetShape(gs);
40   s->RefMainTrans().SetFrom(*gGeoManager->GetCurrentMatrix());
41
42   // Scale z-dictance by 0.1
43   Double_t* t = s->RefMainTrans().ArrT();
44   t[2] *= g_zdc_scale;
45
46   return s;
47 }
48
49 TEveStraightLineSet*
50 zdc_make_cross(const Text_t* name, const Text_t* title_base,
51                Float_t x, Float_t y, Float_t z, Float_t dx, Float_t dy, Float_t dz)
52 {
53   TEveStraightLineSet* ls = new TEveStraightLineSet(name, Form("%s, x=%.3f, y=%.3f", title_base, x, y));
54   ls->SetMainColor(kYellow);
55   ls->SetLineWidth(2);
56   ls->RefMainTrans().SetPos(x, y, z);
57   ls->AddLine(dx, 0,  0, -dx, 0,  0);
58   ls->AddLine(0,  dy, 0,  0, -dy, 0);
59   ls->AddLine(0,  0,  dz, 0,  0, -dz);
60
61   return ls;
62 }
63
64 // ???? There are 5 towers in ESD, 4 in geom.
65 // Not sure about assignment A/C <-> 1/2
66
67 void esd_zdc() 
68 {
69   AliEveEventManager::AssertGeometry();
70
71   AliESDZDC *esd = AliEveEventManager::AssertESD()->GetESDZDC();
72
73   if (g_zdc_palette == 0)
74   {
75     // Map values from 0, 50 on a spectrum palette.
76     g_zdc_palette = new TEveRGBAPalette(0, 50, kTRUE, kFALSE);
77     g_zdc_palette->IncRefCount();
78     gStyle->SetPalette(1, 0);
79     g_zdc_palette->SetupColorArray();
80   }
81
82   TEveElementList* l = new TEveElementList("ZDC Data", "");
83   gEve->AddElement(l);
84
85   TEveElementList *c  = 0;
86   const Double_t  *te = 0;
87   const Text_t    *tb = 0;
88
89   // ZNC geometry ------------------------------------
90   tb = "ZNC";
91   c = new TEveElementList(tb);
92   l->AddElement(c);
93
94   te = esd->GetZN1TowerEnergy();
95
96   c->AddElement(zdc_make_shape("Tower 1", tb, te[1],
97                                "ALIC_1/ZDCC_1/ZNEU_1/ZNTX_1/ZN1_1"));
98
99   c->AddElement(zdc_make_shape("Tower 2", tb, te[2],
100                                "ALIC_1/ZDCC_1/ZNEU_1/ZNTX_1/ZN1_2"));
101
102   c->AddElement(zdc_make_shape("Tower 3", tb, te[3],
103                                "ALIC_1/ZDCC_1/ZNEU_1/ZNTX_2/ZN1_1"));
104
105   c->AddElement(zdc_make_shape("Tower 4", tb, te[4],
106                                "ALIC_1/ZDCC_1/ZNEU_1/ZNTX_2/ZN1_2"));
107
108   // ZNA geometry
109   tb = "ZNA";
110   c = new TEveElementList(tb);
111   l->AddElement(c);
112
113   te = esd->GetZN2TowerEnergy();
114
115   c->AddElement(zdc_make_shape("Tower 1", tb, te[1],
116                                "ALIC_1/ZDCA_1/ZNEU_2/ZNTX_1/ZN1_1"));
117
118   c->AddElement(zdc_make_shape("Tower 2", tb, te[2],
119                                "ALIC_1/ZDCA_1/ZNEU_2/ZNTX_1/ZN1_2"));
120
121   c->AddElement(zdc_make_shape("Tower 3", tb, te[3],
122                                "ALIC_1/ZDCA_1/ZNEU_2/ZNTX_2/ZN1_1"));
123
124   c->AddElement(zdc_make_shape("Tower 4", tb, te[4],
125                                "ALIC_1/ZDCA_1/ZNEU_2/ZNTX_2/ZN1_2"));
126
127
128   // ZPC geometry ------------------------------------
129   tb = "ZPC";
130   c = new TEveElementList(tb);
131   l->AddElement(c);
132
133   te = esd->GetZP1TowerEnergy();
134
135   c->AddElement(zdc_make_shape("Tower 1", tb, te[1],
136                                "ALIC_1/ZDCC_1/ZPRO_1/ZPTX_1/ZP1_1"));
137
138   c->AddElement(zdc_make_shape("Tower 2", tb, te[2],
139                                "ALIC_1/ZDCC_1/ZPRO_1/ZPTX_2/ZP1_1"));
140
141   c->AddElement(zdc_make_shape("Tower 3", tb, te[3],
142                                "ALIC_1/ZDCC_1/ZPRO_1/ZPTX_3/ZP1_1"));
143
144   c->AddElement(zdc_make_shape("Tower 4", tb, te[4],
145                                "ALIC_1/ZDCC_1/ZPRO_1/ZPTX_4/ZP1_1"));
146
147   // ZPA geometry
148   tb = "ZPA";
149   c = new TEveElementList(tb);
150   l->AddElement(c);
151
152   te = esd->GetZP2TowerEnergy();
153
154   c->AddElement(zdc_make_shape("Tower 1", tb, te[1],
155                                "ALIC_1/ZDCA_1/ZPRO_2/ZPTX_1/ZP1_1"));
156
157   c->AddElement(zdc_make_shape("Tower 2", tb, te[2],
158                                "ALIC_1/ZDCA_1/ZPRO_2/ZPTX_2/ZP1_1"));
159
160   c->AddElement(zdc_make_shape("Tower 3", tb, te[3],
161                                "ALIC_1/ZDCA_1/ZPRO_2/ZPTX_3/ZP1_1"));
162
163   c->AddElement(zdc_make_shape("Tower 4", tb, te[4],
164                                "ALIC_1/ZDCA_1/ZPRO_2/ZPTX_4/ZP1_1"));
165
166
167   // Centroids
168   /*
169   TEveStraightLineSet *ls = 0;
170
171   const Double32_t *cNA = esd->GetZNACentroid();
172   ls = zdc_make_cross("ZNA Centroid", "ZNA",
173                       cNA[0], cNA[1],  g_zdc_dist * g_zdc_scale,
174                       g_zdc_cross, g_zdc_cross, g_zdc_cross);
175   l->AddElement(ls);
176
177   const Double32_t *cNC = esd->GetZNCCentroid();
178   ls = zdc_make_cross("ZNA Centroid", "ZNA",
179                       cNC[0], cNC[1], -g_zdc_dist * g_zdc_scale,
180                       g_zdc_cross, g_zdc_cross, g_zdc_cross);
181   l->AddElement(ls);
182   */
183
184   // End - refresh screen
185   gEve->Redraw3D();
186 }