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