Merge branch 'multipleThreads'
[u/mrichter/AliRoot.git] / EVE / hlt-macros / od.C
CommitLineData
8b669499 1//-*- Mode: C++ -*-\r
2\r
3// ** USED macros :\r
4// ***************************************************\r
5// - hlt_alieve_init.C\r
6// - VizDB_scan.C\r
7// - geom_gentle_hlt.C\r
8// - geom_gentle_muon.C\r
9// ***************************************************\r
10\r
11#if !defined(__CINT__) || defined(__MAKECINT__)\r
12\r
13//****************** ROOT ******************************************\r
14#include "TRandom.h"\r
15#include "TVirtualPad.h"\r
16#include "TGLViewer.h"\r
17#include "TThread.h"\r
18#include "TGFileBrowser.h"\r
19#include "TStyle.h"\r
20#include "TList.h"\r
21#include "TDirectory.h"\r
22#include "TFile.h"\r
23#include "TH2.h"\r
24#include "TCanvas.h"\r
25#include "TColor.h"\r
26#include "TVector3.h"\r
27\r
28//****************** ROOT/EVE **************************************\r
29#include "TEveManager.h"\r
30\r
31#include "AliEveHOMERManager.h"\r
30e7579c 32#include "AliEveHLTEventManager.h"\r
8b669499 33#include "geom_gentle_hlt.C"\r
34\r
35//***************************************************************\r
36#include "HLT/rec/AliHLTReconstructor.h"\r
37\r
38\r
39\r
40#endif\r
41\r
42\r
43\r
44// -----------------------------------------------------------------\r
45// -- Geometry / Scenes --\r
46// -----------------------------------------------------------------\r
47\r
48TEveGeoShape *gGeomGentle = 0;\r
49TEveGeoShape *gGeomGentleRPhi = 0;\r
50TEveGeoShape *gGeomGentleRhoZ = 0;\r
51TEveGeoShape *gGeomGentleTRD = 0;\r
52TEveGeoShape *gGeomGentleMUON = 0;\r
53\r
54TEveScene *gRPhiGeomScene = 0;\r
55TEveScene *gRhoZGeomScene = 0;\r
56TEveScene *gRPhiEventScene = 0;\r
57TEveScene *gRhoZEventScene = 0;\r
58\r
59TEveProjectionManager *gRPhiMgr = 0;\r
60TEveProjectionManager *gRhoZMgr = 0;\r
61\r
62TEveViewer *g3DView = 0;\r
63TEveViewer *gRPhiView = 0;\r
64TEveViewer *gRhoZView = 0;\r
65\r
66// -----------------------------------------------------------------\r
67// -- Geometry / Scenes Parameters --\r
68// -----------------------------------------------------------------\r
69\r
70// -- Parameters to show different geometries\r
71Bool_t gShowMUON = kTRUE;\r
72Bool_t gShowMUONRPhi = kFALSE;\r
73Bool_t gShowMUONRhoZ = kTRUE;\r
74Bool_t gShowTRD = kFALSE;\r
75\r
76\r
8b669499 77// -- HOMERManager\r
78AliEveHOMERManager* gHomerManager = 0;\r
30e7579c 79AliEveHLTEventManager* geventManager = 0;\r
8b669499 80\r
81// -- Geometry Manager \r
82TGeoManager* gGeoManager = 0;\r
8b669499 83\r
84\r
85//Container for gGeoManager till it is broken\r
86TGeoManager *fGeoManager = 0;\r
87// -----------------------------------------------------------------\r
88// -- Methods --\r
89// -----------------------------------------------------------------\r
90\r
91Int_t initializeEveViewer( Bool_t showBarrel, Bool_t showMuon );\r
92\r
93void writeToFile();\r
94\r
95\r
96// #################################################################\r
97// #################################################################\r
98// #################################################################\r
99\r
100// -----------------------------------------------------------------\r
b277b277 101void od ( Bool_t showBarrel = kTRUE, Bool_t showMuon = kFALSE ) {\r
8b669499 102\r
103 // -- Loading Geometry\r
104 // ---------------------\r
105 Int_t run = 67179;\r
106 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");\r
107 AliCDBManager::Instance()->SetRun(run);\r
108 AliGeomManager::LoadGeometry();\r
109 // The default in the simulation is the following line\r
110 // TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1, AliMagF::k5kG));\r
111 // However for the current setting of +ve L3 and +ve Dipole magnetic field\r
112 // the following setting creates the field close to real field with currect polarity\r
113 if(showMuon)\r
114 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 1., 1, AliMagF::k5kG));\r
115\r
8b669499 116 // Get the pointer to gGeoManager before it's broken (bug in alieve)\r
117 fGeoManager = gGeoManager;\r
118\r
119 // -- Initialize pointsets and add macros\r
120 // ----------------------------------------\r
121 //TEveUtil::LoadMacro("hlt_alieve_init.C");\r
122 //hlt_alieve_init(".", -1);\r
123\r
124 // -- Initialize Eve\r
125 // -------------------\r
30e7579c 126 cout << "Initializing the EVE viewer"<<endl;\r
8b669499 127 initializeEveViewer( showBarrel, showMuon );\r
128\r
129 // -- Reset gGeoManager to the original pointer\r
130 // ----------------------------------------------\r
131\r
132 // -- Finalize Eve\r
133 // -----------------\r
134 gSystem->ProcessEvents();\r
135 gEve->Redraw3D(kTRUE);\r
136\r
137 // -- Create new hM object\r
138 // -------------------------\r
30e7579c 139\r
140 cout << "Creating the Event Manager"<<endl;\r
141 gEventManager = new AliEveHLTEventManagerHomer();\r
142 gEventManager->SetEveManager(gEve);\r
143 gEventManager->SetGeoManager(gGeoManager);\r
144 gEventManager->SetRPhiManager(gRPhiMgr);\r
145 gEventManager->SetRPhiEventScene(gRPhiEventScene);\r
146 gEventManager->SetRPhiViewer(gRPhiView);\r
147 gEventManager->SetRhoZManager(gRhoZMgr);\r
148 gEventManager->SetRhoZEventScene(gRhoZEventScene);\r
149 gEventManager->SetRhoZViewer(gRhoZView);\r
150 \r
151 //gEventManager->SetBarrelFlag(showBarrel);\r
152 //gEventManager->SetMuonFlag(showMuon);\r
153\r
154 // Int_t iResult = gHomerManager->Initialize();\r
155 // if (iResult) { \r
156 // printf("Error Initializing AliHLTHOMERManager, quitting");\r
157 // return; \r
158 // }\r
159 \r
160 // gEventManager->SetHomerManager(gHomerManager);\r
8b669499 161\r
162 // -- Add hM to EveTree\r
163 // ----------------------\r
30e7579c 164 //gEve->AddToListTree(gHomerManager, kTRUE);\r
165 gEve->AddToListTree(gEventManager, kTRUE);\r
8b669499 166\r
167 // -- Create SourceList\r
168 // ----------------------\r
30e7579c 169 // iResult = gHomerManager->CreateEveSourcesListLoop();\r
170 // if (iResult) {\r
171 // printf ("Couldn't find active services. Giving up. \n");\r
172 // return;\r
173 // } \r
174\r
175\r
176 // if ( showBarrel ) {\r
177 // gHomerManager->ConnectEVEtoHOMER("TPC" );\r
178 // } else if ( MUONMode ) {\r
179 // gHomerManager->ConnectEVEtoHOMER("MUON");\r
180 // } else if( TRDMode ) {\r
181 // gHomerManager->ConnectEVEtoHOMER("TRD"); \r
182 // } else {\r
183 // cout<<" No detectors selected, nothing will be displayed"<<endl;\r
184 // } \r
185 // THIS LINE DOES NOT WORK. PLEASE USE ANOTHER LINE!\r
186\r
8b669499 187\r
188 gGeoManager = fGeoManager;\r
189 \r
190\r
191}\r
192\r
193// -------------------------------------------------------------------------\r
194Int_t initializeEveViewer( Bool_t showBarrel, Bool_t showMuon ) {\r
195 \r
196 //=============================================================================\r
197 // Visualization database\r
198 //============================================================================\r
199\r
200 TEveUtil::AssertMacro("VizDB_scan.C");\r
201 \r
202 // alieve_vizdb();\r
203 \r
204\r
205\r
206 //==============================================================================\r
207 // -- Geometry, scenes, projections and viewers\r
208 //==============================================================================\r
209\r
210 TEveBrowser *browser = gEve->GetBrowser();\r
211 browser->ShowCloseTab(kFALSE);\r
212 \r
213 // -- Disable extra geometry\r
214 // ---------------------------\r
215 if (!showMuon)\r
216 gShowMUON = gShowMUONRPhi = gShowMUONRhoZ = kFALSE;\r
217 \r
218 // -- Load Geometry\r
219 // ------------------\r
220 TEveUtil::LoadMacro("geom_gentle_hlt.C");\r
221 gGeomGentle = geom_gentle_hlt();\r
222 gGeomGentleRPhi = geom_gentle_rphi(); gGeomGentleRPhi->IncDenyDestroy();\r
223 gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();\r
224 gGeomGentleTRD = geom_gentle_trd();\r
225\r
226 gGeoManager = fGeoManager;\r
227\r
228 gEMCALNode = gGeoManager->GetTopVolume()->FindNode("XEN1_1");\r
229\r
230 TEveGeoTopNode* emcal_re = new TEveGeoTopNode(gGeoManager, gEMCALNode);\r
231 gEve->AddGlobalElement(emcal_re);\r
232 gEve->Redraw3D();\r
233\r
234 if (gShowMUON) \r
235 gGeomGentleMUON = geom_gentle_muon(kFALSE);\r
236 \r
237 // -- Scenes\r
238 // -----------\r
239 gRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",\r
240 "Scene holding projected geometry for the RPhi view.");\r
241 gRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",\r
242 "Scene holding projected geometry for the RhoZ view.");\r
243 gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",\r
244 "Scene holding projected geometry for the RPhi view.");\r
245 gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",\r
246 "Scene holding projected geometry for the RhoZ view.");\r
247\r
248 // -- Projection managers\r
249 // ------------------------\r
250\r
251 gRPhiMgr = new TEveProjectionManager();\r
252 gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);\r
253 gEve->AddToListTree(gRPhiMgr, kFALSE);\r
254 {\r
255 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);\r
256 a->SetMainColor(kWhite);\r
257 a->SetTitle("R-Phi");\r
258 a->SetTitleSize(0.05);\r
259 a->SetTitleFont(102);\r
260 a->SetLabelSize(0.025);\r
261 a->SetLabelFont(102);\r
262 gRPhiGeomScene->AddElement(a);\r
263 }\r
264 gRPhiMgr->SetCurrentDepth(-10);\r
265 gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);\r
266 gRPhiMgr->SetCurrentDepth(0);\r
267 gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);\r
268 if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);\r
269\r
270 gRhoZMgr = new TEveProjectionManager();\r
271 gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);\r
272 gEve->AddToListTree(gRhoZMgr, kFALSE);\r
273 {\r
274 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);\r
275 a->SetMainColor(kWhite);\r
276 a->SetTitle("Rho-Z");\r
277 a->SetTitleSize(0.05);\r
278 a->SetTitleFont(102);\r
279 a->SetLabelSize(0.025);\r
280 a->SetLabelFont(102);\r
281 gRhoZGeomScene->AddElement(a);\r
282 }\r
283 gRhoZMgr->SetCurrentDepth(-10);\r
284 gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);\r
285 gRhoZMgr->SetCurrentDepth(0);\r
286 gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);\r
287 \r
288 if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);\r
289\r
290 // -- Viewers\r
291 // ------------\r
292\r
293 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());\r
294 TEveWindowPack *pack = slot->MakePack();\r
295 pack->SetElementName("Multi View");\r
296 pack->SetHorizontal();\r
297 pack->SetShowTitleBar(kFALSE);\r
298 pack->NewSlot()->MakeCurrent();\r
299 g3DView = gEve->SpawnNewViewer("3D View", "");\r
300 g3DView->AddScene(gEve->GetGlobalScene());\r
301 g3DView->AddScene(gEve->GetEventScene());\r
302\r
303\r
304 pack = pack->NewSlot()->MakePack();\r
305 pack->SetShowTitleBar(kFALSE);\r
306 pack->NewSlot()->MakeCurrent();\r
307 gRPhiView = gEve->SpawnNewViewer("RPhi View", "");\r
308 gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
309 gRPhiView->AddScene(gRPhiGeomScene);\r
310 gRPhiView->AddScene(gRPhiEventScene);\r
311\r
312 pack->NewSlot()->MakeCurrent();\r
313 gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");\r
314 gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
315 gRhoZView->AddScene(gRhoZGeomScene);\r
316 gRhoZView->AddScene(gRhoZEventScene);\r
317\r
318\r
319 \r
320 //Add HLT Text to windows\r
321 \r
322 TGLOverlayButton *ob1 = new TGLOverlayButton(g3DView->GetGLViewer(), "HLT", 0, 20, 110, 60);\r
323 ob1->SetAlphaValues(0.8, 0.8);\r
324 // cout << "color" << ob1->GetBackColor() << endl;\r
325 //ob1->SetBackColor(8421631);\r
326 //ob1->SetBackColor(10492431);\r
327 TGLOverlayButton *ob2 = new TGLOverlayButton(g3DView->GetGLViewer(), "ALICE", 0, 0, 110, 20);\r
328 ob2->SetAlphaValues(0.8, 0.8);\r
329 //ob2->SetBackColor(0.2);\r
330 TGLOverlayButton *ob3 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "HLT", 0, 20, 110, 60);\r
331 ob3->SetAlphaValues(0.8, 0.8);\r
332 TGLOverlayButton *ob4 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "ALICE", 0, 0, 110, 20);\r
333 ob4->SetAlphaValues(0.8, 0.8);\r
334\r
335\r
336 TGLOverlayButton *ne = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "Next Event", 110, 0, 210, 20);\r
337 ne->SetAlphaValues(0.0, 0.8);\r
338\r
339 // -- List of Viewers\r
340 // --------------------\r
341\r
342 TEveViewerList *viewerlist = new TEveViewerList();\r
343 viewerlist->AddElement(gEve->GetDefaultViewer());\r
344 \r
345 viewerlist->AddElement(g3DView);\r
346 viewerlist->AddElement(gRhoZView);\r
347 viewerlist->AddElement(gRPhiView);\r
348 viewerlist->SwitchColorSet();\r
349\r
350 //==============================================================================\r
351 // -- Macros / QA histograms\r
352 //==============================================================================\r
353\r
354 // -- Registration of per-event macros\r
355 // -------------------------------------\r
356\r
357 AliEveMacroExecutor *exec = new AliEveMacroExecutor();\r
358\r
359\r
360\r
361 gStyle->SetPalette(1, 0);\r
8b669499 362 gStyle->SetOptFit(1);\r
363\r
364\r
365 \r
366 return 0;\r
367}\r
368\r
8b669499 369//****************************************************************************\r
370void writeToFile(){\r
371\r
372 TList * bList = gHomerManager->GetBlockList();\r
373 if(bList){\r
374 TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", gHomerManager->GetEventID()), "RECREATE"); \r
375 bList->Write("blockList", TObject::kSingleKey);\r
376 file->Close();\r
377 }\r
378 \r
379 bList = gHomerManager->GetAsyncBlockList();\r
380 if(bList){\r
381 TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", gHomerManager->GetEventID()), "RECREATE"); \r
382 bList->Write("blockList", TObject::kSingleKey);\r
383 afile->Close();\r
384 }\r
385}\r
386\r
387\r
8b669499 388\r
389 \r