Merge branch 'multipleThreads' into newdevel
[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
b088c0a1 127 initializeEveViewer( showBarrel, showMuon, fGeoManager );\r
8b669499 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
b088c0a1 194Int_t initializeEveViewer( Bool_t showBarrel, Bool_t showMuon, TGeoManager * manager ) {\r
8b669499 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
b088c0a1 231 emcal_re->SetVisLevel(1);\r
232 // emcal_re->FirstChild()->Dump();\r
233\r
234 // for(Int_t i = 4; i < 11; i++) {\r
235 // emcal_re->FindChild(Form("SMOD_%d", i))->SetRnrState(kFALSE);\r
236 // }\r
237 // emcal_re->FindChild("SM10_1")->SetRnrState(kFALSE);\r
238 // emcal_re->FindChild("SM10_2")->SetRnrState(kFALSE);\r
239\r
240\r
241\r
8b669499 242 gEve->AddGlobalElement(emcal_re);\r
243 gEve->Redraw3D();\r
244\r
245 if (gShowMUON) \r
b088c0a1 246 gGeomGentleMUON = geom->geom_gentle_muon(kFALSE);\r
8b669499 247 \r
248 // -- Scenes\r
249 // -----------\r
250 gRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",\r
251 "Scene holding projected geometry for the RPhi view.");\r
252 gRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",\r
253 "Scene holding projected geometry for the RhoZ view.");\r
254 gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",\r
255 "Scene holding projected geometry for the RPhi view.");\r
256 gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",\r
257 "Scene holding projected geometry for the RhoZ view.");\r
258\r
259 // -- Projection managers\r
260 // ------------------------\r
261\r
262 gRPhiMgr = new TEveProjectionManager();\r
263 gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);\r
264 gEve->AddToListTree(gRPhiMgr, kFALSE);\r
265 {\r
266 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);\r
267 a->SetMainColor(kWhite);\r
268 a->SetTitle("R-Phi");\r
269 a->SetTitleSize(0.05);\r
270 a->SetTitleFont(102);\r
271 a->SetLabelSize(0.025);\r
272 a->SetLabelFont(102);\r
273 gRPhiGeomScene->AddElement(a);\r
274 }\r
275 gRPhiMgr->SetCurrentDepth(-10);\r
276 gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);\r
277 gRPhiMgr->SetCurrentDepth(0);\r
278 gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);\r
279 if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);\r
280\r
281 gRhoZMgr = new TEveProjectionManager();\r
282 gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);\r
283 gEve->AddToListTree(gRhoZMgr, kFALSE);\r
284 {\r
285 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);\r
286 a->SetMainColor(kWhite);\r
287 a->SetTitle("Rho-Z");\r
288 a->SetTitleSize(0.05);\r
289 a->SetTitleFont(102);\r
290 a->SetLabelSize(0.025);\r
291 a->SetLabelFont(102);\r
292 gRhoZGeomScene->AddElement(a);\r
293 }\r
294 gRhoZMgr->SetCurrentDepth(-10);\r
295 gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);\r
296 gRhoZMgr->SetCurrentDepth(0);\r
297 gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);\r
298 \r
299 if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);\r
300\r
301 // -- Viewers\r
302 // ------------\r
303\r
304 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());\r
305 TEveWindowPack *pack = slot->MakePack();\r
306 pack->SetElementName("Multi View");\r
307 pack->SetHorizontal();\r
308 pack->SetShowTitleBar(kFALSE);\r
309 pack->NewSlot()->MakeCurrent();\r
310 g3DView = gEve->SpawnNewViewer("3D View", "");\r
311 g3DView->AddScene(gEve->GetGlobalScene());\r
312 g3DView->AddScene(gEve->GetEventScene());\r
313\r
314\r
315 pack = pack->NewSlot()->MakePack();\r
316 pack->SetShowTitleBar(kFALSE);\r
317 pack->NewSlot()->MakeCurrent();\r
318 gRPhiView = gEve->SpawnNewViewer("RPhi View", "");\r
319 gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
320 gRPhiView->AddScene(gRPhiGeomScene);\r
321 gRPhiView->AddScene(gRPhiEventScene);\r
322\r
323 pack->NewSlot()->MakeCurrent();\r
324 gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");\r
325 gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
326 gRhoZView->AddScene(gRhoZGeomScene);\r
327 gRhoZView->AddScene(gRhoZEventScene);\r
328\r
329\r
330 \r
331 //Add HLT Text to windows\r
332 \r
333 TGLOverlayButton *ob1 = new TGLOverlayButton(g3DView->GetGLViewer(), "HLT", 0, 20, 110, 60);\r
334 ob1->SetAlphaValues(0.8, 0.8);\r
335 // cout << "color" << ob1->GetBackColor() << endl;\r
336 //ob1->SetBackColor(8421631);\r
337 //ob1->SetBackColor(10492431);\r
338 TGLOverlayButton *ob2 = new TGLOverlayButton(g3DView->GetGLViewer(), "ALICE", 0, 0, 110, 20);\r
339 ob2->SetAlphaValues(0.8, 0.8);\r
340 //ob2->SetBackColor(0.2);\r
341 TGLOverlayButton *ob3 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "HLT", 0, 20, 110, 60);\r
342 ob3->SetAlphaValues(0.8, 0.8);\r
343 TGLOverlayButton *ob4 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "ALICE", 0, 0, 110, 20);\r
344 ob4->SetAlphaValues(0.8, 0.8);\r
345\r
346\r
347 TGLOverlayButton *ne = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "Next Event", 110, 0, 210, 20);\r
348 ne->SetAlphaValues(0.0, 0.8);\r
349\r
350 // -- List of Viewers\r
351 // --------------------\r
352\r
353 TEveViewerList *viewerlist = new TEveViewerList();\r
354 viewerlist->AddElement(gEve->GetDefaultViewer());\r
355 \r
356 viewerlist->AddElement(g3DView);\r
357 viewerlist->AddElement(gRhoZView);\r
358 viewerlist->AddElement(gRPhiView);\r
359 viewerlist->SwitchColorSet();\r
360\r
361 //==============================================================================\r
362 // -- Macros / QA histograms\r
363 //==============================================================================\r
364\r
365 // -- Registration of per-event macros\r
366 // -------------------------------------\r
367\r
368 AliEveMacroExecutor *exec = new AliEveMacroExecutor();\r
369\r
370\r
371\r
372 gStyle->SetPalette(1, 0);\r
8b669499 373 gStyle->SetOptFit(1);\r
374\r
375\r
376 \r
377 return 0;\r
378}\r
379\r
8b669499 380//****************************************************************************\r
381void writeToFile(){\r
382\r
383 TList * bList = gHomerManager->GetBlockList();\r
384 if(bList){\r
385 TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", gHomerManager->GetEventID()), "RECREATE"); \r
386 bList->Write("blockList", TObject::kSingleKey);\r
387 file->Close();\r
388 }\r
389 \r
390 bList = gHomerManager->GetAsyncBlockList();\r
391 if(bList){\r
392 TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", gHomerManager->GetEventID()), "RECREATE"); \r
393 bList->Write("blockList", TObject::kSingleKey);\r
394 afile->Close();\r
395 }\r
396}\r
397\r
398\r
8b669499 399\r
400 \r