Coverity
[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
d5180d24 105 Int_t run = 0;\r
8b669499 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
d5180d24 114 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1, AliMagF::k5kG));\r
8b669499 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
d5180d24 142 gEventManager->SetShowMuon(showMuon);\r
30e7579c 143 gEventManager->SetEveManager(gEve);\r
144 gEventManager->SetGeoManager(gGeoManager);\r
145 gEventManager->SetRPhiManager(gRPhiMgr);\r
146 gEventManager->SetRPhiEventScene(gRPhiEventScene);\r
147 gEventManager->SetRPhiViewer(gRPhiView);\r
148 gEventManager->SetRhoZManager(gRhoZMgr);\r
149 gEventManager->SetRhoZEventScene(gRhoZEventScene);\r
150 gEventManager->SetRhoZViewer(gRhoZView);\r
151 \r
152 //gEventManager->SetBarrelFlag(showBarrel);\r
153 //gEventManager->SetMuonFlag(showMuon);\r
154\r
155 // Int_t iResult = gHomerManager->Initialize();\r
156 // if (iResult) { \r
157 // printf("Error Initializing AliHLTHOMERManager, quitting");\r
158 // return; \r
159 // }\r
160 \r
161 // gEventManager->SetHomerManager(gHomerManager);\r
8b669499 162\r
163 // -- Add hM to EveTree\r
164 // ----------------------\r
30e7579c 165 //gEve->AddToListTree(gHomerManager, kTRUE);\r
166 gEve->AddToListTree(gEventManager, kTRUE);\r
8b669499 167\r
168 // -- Create SourceList\r
169 // ----------------------\r
30e7579c 170 // iResult = gHomerManager->CreateEveSourcesListLoop();\r
171 // if (iResult) {\r
172 // printf ("Couldn't find active services. Giving up. \n");\r
173 // return;\r
174 // } \r
175\r
176\r
177 // if ( showBarrel ) {\r
178 // gHomerManager->ConnectEVEtoHOMER("TPC" );\r
179 // } else if ( MUONMode ) {\r
180 // gHomerManager->ConnectEVEtoHOMER("MUON");\r
181 // } else if( TRDMode ) {\r
182 // gHomerManager->ConnectEVEtoHOMER("TRD"); \r
183 // } else {\r
184 // cout<<" No detectors selected, nothing will be displayed"<<endl;\r
185 // } \r
186 // THIS LINE DOES NOT WORK. PLEASE USE ANOTHER LINE!\r
187\r
8b669499 188\r
189 gGeoManager = fGeoManager;\r
190 \r
191\r
192}\r
193\r
194// -------------------------------------------------------------------------\r
b088c0a1 195Int_t initializeEveViewer( Bool_t showBarrel, Bool_t showMuon, TGeoManager * manager ) {\r
8b669499 196 \r
197 //=============================================================================\r
198 // Visualization database\r
199 //============================================================================\r
200\r
201 TEveUtil::AssertMacro("VizDB_scan.C");\r
202 \r
203 // alieve_vizdb();\r
204 \r
205\r
206\r
207 //==============================================================================\r
208 // -- Geometry, scenes, projections and viewers\r
209 //==============================================================================\r
210\r
211 TEveBrowser *browser = gEve->GetBrowser();\r
212 browser->ShowCloseTab(kFALSE);\r
213 \r
214 // -- Disable extra geometry\r
215 // ---------------------------\r
216 if (!showMuon)\r
217 gShowMUON = gShowMUONRPhi = gShowMUONRhoZ = kFALSE;\r
218 \r
219 // -- Load Geometry\r
220 // ------------------\r
221 TEveUtil::LoadMacro("geom_gentle_hlt.C");\r
222 gGeomGentle = geom_gentle_hlt();\r
223 gGeomGentleRPhi = geom_gentle_rphi(); gGeomGentleRPhi->IncDenyDestroy();\r
224 gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();\r
225 gGeomGentleTRD = geom_gentle_trd();\r
226\r
227 gGeoManager = fGeoManager;\r
228\r
229 gEMCALNode = gGeoManager->GetTopVolume()->FindNode("XEN1_1");\r
230\r
231 TEveGeoTopNode* emcal_re = new TEveGeoTopNode(gGeoManager, gEMCALNode);\r
b088c0a1 232 emcal_re->SetVisLevel(1);\r
233 // emcal_re->FirstChild()->Dump();\r
234\r
235 // for(Int_t i = 4; i < 11; i++) {\r
236 // emcal_re->FindChild(Form("SMOD_%d", i))->SetRnrState(kFALSE);\r
237 // }\r
238 // emcal_re->FindChild("SM10_1")->SetRnrState(kFALSE);\r
239 // emcal_re->FindChild("SM10_2")->SetRnrState(kFALSE);\r
240\r
241\r
242\r
8b669499 243 gEve->AddGlobalElement(emcal_re);\r
244 gEve->Redraw3D();\r
245\r
246 if (gShowMUON) \r
d5180d24 247 gGeomGentleMUON = geom_gentle_muon(kFALSE);\r
8b669499 248 \r
249 // -- Scenes\r
250 // -----------\r
251 gRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",\r
252 "Scene holding projected geometry for the RPhi view.");\r
253 gRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",\r
254 "Scene holding projected geometry for the RhoZ view.");\r
255 gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",\r
256 "Scene holding projected geometry for the RPhi view.");\r
257 gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",\r
258 "Scene holding projected geometry for the RhoZ view.");\r
259\r
260 // -- Projection managers\r
261 // ------------------------\r
262\r
263 gRPhiMgr = new TEveProjectionManager();\r
264 gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);\r
265 gEve->AddToListTree(gRPhiMgr, kFALSE);\r
266 {\r
267 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);\r
268 a->SetMainColor(kWhite);\r
269 a->SetTitle("R-Phi");\r
270 a->SetTitleSize(0.05);\r
271 a->SetTitleFont(102);\r
272 a->SetLabelSize(0.025);\r
273 a->SetLabelFont(102);\r
274 gRPhiGeomScene->AddElement(a);\r
275 }\r
276 gRPhiMgr->SetCurrentDepth(-10);\r
277 gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);\r
278 gRPhiMgr->SetCurrentDepth(0);\r
279 gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);\r
280 if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);\r
281\r
282 gRhoZMgr = new TEveProjectionManager();\r
283 gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);\r
284 gEve->AddToListTree(gRhoZMgr, kFALSE);\r
285 {\r
286 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);\r
287 a->SetMainColor(kWhite);\r
288 a->SetTitle("Rho-Z");\r
289 a->SetTitleSize(0.05);\r
290 a->SetTitleFont(102);\r
291 a->SetLabelSize(0.025);\r
292 a->SetLabelFont(102);\r
293 gRhoZGeomScene->AddElement(a);\r
294 }\r
295 gRhoZMgr->SetCurrentDepth(-10);\r
296 gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);\r
297 gRhoZMgr->SetCurrentDepth(0);\r
298 gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);\r
299 \r
300 if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);\r
301\r
302 // -- Viewers\r
303 // ------------\r
304\r
305 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());\r
306 TEveWindowPack *pack = slot->MakePack();\r
307 pack->SetElementName("Multi View");\r
308 pack->SetHorizontal();\r
309 pack->SetShowTitleBar(kFALSE);\r
310 pack->NewSlot()->MakeCurrent();\r
311 g3DView = gEve->SpawnNewViewer("3D View", "");\r
312 g3DView->AddScene(gEve->GetGlobalScene());\r
313 g3DView->AddScene(gEve->GetEventScene());\r
314\r
315\r
316 pack = pack->NewSlot()->MakePack();\r
317 pack->SetShowTitleBar(kFALSE);\r
318 pack->NewSlot()->MakeCurrent();\r
319 gRPhiView = gEve->SpawnNewViewer("RPhi View", "");\r
320 gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
321 gRPhiView->AddScene(gRPhiGeomScene);\r
322 gRPhiView->AddScene(gRPhiEventScene);\r
323\r
324 pack->NewSlot()->MakeCurrent();\r
325 gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");\r
326 gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
327 gRhoZView->AddScene(gRhoZGeomScene);\r
328 gRhoZView->AddScene(gRhoZEventScene);\r
329\r
330\r
331 \r
332 //Add HLT Text to windows\r
333 \r
334 TGLOverlayButton *ob1 = new TGLOverlayButton(g3DView->GetGLViewer(), "HLT", 0, 20, 110, 60);\r
335 ob1->SetAlphaValues(0.8, 0.8);\r
336 // cout << "color" << ob1->GetBackColor() << endl;\r
337 //ob1->SetBackColor(8421631);\r
338 //ob1->SetBackColor(10492431);\r
339 TGLOverlayButton *ob2 = new TGLOverlayButton(g3DView->GetGLViewer(), "ALICE", 0, 0, 110, 20);\r
340 ob2->SetAlphaValues(0.8, 0.8);\r
341 //ob2->SetBackColor(0.2);\r
342 TGLOverlayButton *ob3 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "HLT", 0, 20, 110, 60);\r
343 ob3->SetAlphaValues(0.8, 0.8);\r
344 TGLOverlayButton *ob4 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "ALICE", 0, 0, 110, 20);\r
345 ob4->SetAlphaValues(0.8, 0.8);\r
346\r
347\r
348 TGLOverlayButton *ne = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "Next Event", 110, 0, 210, 20);\r
349 ne->SetAlphaValues(0.0, 0.8);\r
350\r
351 // -- List of Viewers\r
352 // --------------------\r
353\r
354 TEveViewerList *viewerlist = new TEveViewerList();\r
355 viewerlist->AddElement(gEve->GetDefaultViewer());\r
356 \r
357 viewerlist->AddElement(g3DView);\r
358 viewerlist->AddElement(gRhoZView);\r
359 viewerlist->AddElement(gRPhiView);\r
360 viewerlist->SwitchColorSet();\r
361\r
362 //==============================================================================\r
363 // -- Macros / QA histograms\r
364 //==============================================================================\r
365\r
366 // -- Registration of per-event macros\r
367 // -------------------------------------\r
368\r
369 AliEveMacroExecutor *exec = new AliEveMacroExecutor();\r
370\r
371\r
372\r
373 gStyle->SetPalette(1, 0);\r
8b669499 374 gStyle->SetOptFit(1);\r
375\r
376\r
377 \r
378 return 0;\r
379}\r
380\r
8b669499 381//****************************************************************************\r
382void writeToFile(){\r
383\r
384 TList * bList = gHomerManager->GetBlockList();\r
385 if(bList){\r
386 TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", gHomerManager->GetEventID()), "RECREATE"); \r
387 bList->Write("blockList", TObject::kSingleKey);\r
388 file->Close();\r
389 }\r
390 \r
391 bList = gHomerManager->GetAsyncBlockList();\r
392 if(bList){\r
393 TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", gHomerManager->GetEventID()), "RECREATE"); \r
394 bList->Write("blockList", TObject::kSingleKey);\r
395 afile->Close();\r
396 }\r
397}\r
398\r
399\r
8b669499 400\r
401 \r