-Fixed bug in offline buffer that deleted event object.
[u/mrichter/AliRoot.git] / EVE / hlt-macros / off.C
CommitLineData
30e7579c 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
32#include "AliEveHLTEventManagerOffline.h"\r
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
77// -----------------------------------------------------------------\r
78// -- Members --\r
79// -----------------------------------------------------------------\r
80\r
81// -- Timer for automatic event loop\r
82TTimer eventTimer;\r
83TTimer eventTimerFast;\r
84\r
85// -- HOMERManager\r
86AliEveHLTEventManagerOffline* geventManager = 0;\r
87\r
88// -- Geometry Manager \r
89TGeoManager* gGeoManager = 0;\r
90AliPHOSGeometry* gPHOSGeom = 0;\r
91\r
92// -- Cluster members\r
93TEvePointSet* gSPDClusters = 0;\r
94TEvePointSet* gSSDClusters = 0;\r
95TEvePointSet* gSDDClusters = 0;\r
96TEvePointSet* gTRDClusters = 0;\r
97TEvePointSetArray* gTRDColClusters = 0;\r
98TEvePointSet* gTPCClusters = 0;\r
99TEvePointSet* gTPCTestClusters = 0;\r
100TEvePointSetArray* gTPCColClusters = 0;\r
101TEveBoxSet* gPHOSBoxSet[5] = {0, 0, 0, 0, 0}; \r
102TEveBoxSet* gEMCALBoxSet[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\r
103TEvePointSet* gMUONClusters = 0;\r
104TEveStraightLineSet* gMUONTracks = 0;\r
105\r
106// -- Text output members\r
107TEveText* gHLTText = 0;\r
108\r
109// -- Tracks members\r
110TEveTrackList* gTPCTrack = 0;\r
111\r
112// -- Canvas for histograms\r
113TCanvas* gTRDCanvas = 0;\r
114TCanvas* gTPCCanvas = 0;\r
115TCanvas* gTPCClustCanvas = 0;\r
116TCanvas* gTRDCalibCanvas = 0;\r
117TCanvas* gTRDEORCanvas = 0;\r
118TCanvas* gPrimVertexCanvas = 0;\r
119TCanvas* gSPDVertexCanvas = 0;\r
120TCanvas* gITSCanvas = 0;\r
121TCanvas* gSSDCanvas0 = 0;\r
122TCanvas* gSSDCanvas1 = 0;\r
123TCanvas* gV0Canvas = 0;\r
124TCanvas* gPHOSCanvas = NULL;\r
125TCanvas* gEMCALCanvas = 0;\r
126\r
127// -- vertex --\r
128Int_t gSPDVertexHistoCount = 0;\r
129\r
130\r
131\r
132// -- TRD --\r
133Int_t gTRDHistoCount = 0;\r
134Int_t gTRDEvents = 0;\r
135Int_t gTRDBins = 12;\r
136\r
137// -- TPC --\r
138Int_t gTPCBins = 15;\r
139TH1F* gTPCCharge = 0;\r
140TH1F* gTPCQMax = 0;\r
141TH1F* gTPCQMaxOverCharge = 0;\r
142\r
143TH1F* gTPCPt = 0; // KK\r
144TH1F* gTPCEta = 0; \r
145TH1F* gTPCPsi = 0; \r
146TH1F* gTPCnClusters = 0; \r
147TH1F* gTPCMult = 0;\r
148\r
149// -- PHOS --\r
150TEveElementList* gPHOSElementList = 0;\r
151Int_t gPHOSHistoCount =0;\r
152// -- EMCAL\r
153TEveElementList* gEMCALElementList = 0;\r
154TGeoNode* gEMCALNode = 0;\r
155Int_t gEMCALHistoCount =0;\r
156\r
157// --- Flag if eventloop is running\r
158Bool_t gEventLoopStarted = kFALSE;\r
159\r
160\r
161\r
162//Container for gGeoManager till it is broken\r
163TGeoManager *fGeoManager = 0;\r
164// -----------------------------------------------------------------\r
165// -- Methods --\r
166// -----------------------------------------------------------------\r
167\r
168Int_t initializeEveViewer( Bool_t showBarrel, Bool_t showMuon );\r
169\r
170void writeToFile();\r
171\r
172\r
173// #################################################################\r
174// #################################################################\r
175// #################################################################\r
176\r
177// -----------------------------------------------------------------\r
178void off ( Bool_t showBarrel = kTRUE, Bool_t showMuon = kFALSE ) {\r
179\r
180 // -- Loading Geometry\r
181 // ---------------------\r
182 Int_t run = 67179;\r
183 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");\r
184 AliCDBManager::Instance()->SetRun(run);\r
185 AliGeomManager::LoadGeometry();\r
186 // The default in the simulation is the following line\r
187 // TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", -1., -1, AliMagF::k5kG));\r
188 // However for the current setting of +ve L3 and +ve Dipole magnetic field\r
189 // the following setting creates the field close to real field with currect polarity\r
190 if(showMuon)\r
191 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", 1., 1, AliMagF::k5kG));\r
192\r
193 // Get the pointer to gGeoManager before it's broken (bug in alieve)\r
194 fGeoManager = gGeoManager;\r
195\r
196 // -- Initialize pointsets and add macros\r
197 // ----------------------------------------\r
198 //TEveUtil::LoadMacro("hlt_alieve_init.C");\r
199 //hlt_alieve_init(".", -1);\r
200\r
201 // -- Initialize Eve\r
202 // -------------------\r
203 initializeEveViewer( showBarrel, showMuon );\r
204\r
205 // -- Reset gGeoManager to the original pointer\r
206 // ----------------------------------------------\r
207\r
208 // -- Finalize Eve\r
209 // -----------------\r
210 gSystem->ProcessEvents();\r
211 gEve->Redraw3D(kTRUE);\r
212\r
213 // -- Create new hM object\r
214 // -------------------------\r
215 \r
216 gEventManager = new AliEveHLTEventManagerOffline("/home/slindal/alice/data/PbPb/AliESDs.root");\r
239fdf4e 217\r
30e7579c 218 gEventManager->SetEveManager(gEve);\r
219 gEventManager->SetGeoManager(gGeoManager);\r
220 gEventManager->SetRPhiManager(gRPhiMgr);\r
221 gEventManager->SetRPhiEventScene(gRPhiEventScene);\r
222 gEventManager->SetRPhiViewer(gRPhiView);\r
223 gEventManager->SetRhoZManager(gRhoZMgr);\r
224 gEventManager->SetRhoZEventScene(gRhoZEventScene);\r
225 gEventManager->SetRhoZViewer(gRhoZView);\r
226 //gEventManager->SetBarrelFlag(showBarrel);\r
227 //gEventManager->SetMuonFlag(showMuon);\r
228\r
229\r
230 // -- Add hM to EveTree\r
231 // ----------------------\r
232 gEve->AddToListTree(gEventManager, kTRUE);\r
233\r
234 // -- Create SourceList\r
235 // ----------------------\r
236\r
237\r
238\r
239 gGeoManager = fGeoManager;\r
240 \r
241\r
242}\r
243\r
244// -------------------------------------------------------------------------\r
245Int_t initializeEveViewer( Bool_t showBarrel, Bool_t showMuon ) {\r
246 \r
247 //=============================================================================\r
248 // Visualization database\r
249 //============================================================================\r
250\r
251 TEveUtil::AssertMacro("VizDB_scan.C");\r
252 \r
253 // alieve_vizdb();\r
254 \r
255\r
256\r
257 //==============================================================================\r
258 // -- Geometry, scenes, projections and viewers\r
259 //==============================================================================\r
260\r
261 TEveBrowser *browser = gEve->GetBrowser();\r
262 browser->ShowCloseTab(kFALSE);\r
263 \r
264 // -- Disable extra geometry\r
265 // ---------------------------\r
266 if (!showMuon)\r
267 gShowMUON = gShowMUONRPhi = gShowMUONRhoZ = kFALSE;\r
268 \r
269 // -- Load Geometry\r
270 // ------------------\r
271 TEveUtil::LoadMacro("geom_gentle_hlt.C");\r
272 gGeomGentle = geom_gentle_hlt();\r
273 gGeomGentleRPhi = geom_gentle_rphi(); gGeomGentleRPhi->IncDenyDestroy();\r
274 gGeomGentleRhoZ = geom_gentle_rhoz(); gGeomGentleRhoZ->IncDenyDestroy();\r
275 gGeomGentleTRD = geom_gentle_trd();\r
276\r
277 gGeoManager = fGeoManager;\r
278\r
279 gEMCALNode = gGeoManager->GetTopVolume()->FindNode("XEN1_1");\r
280\r
281 TEveGeoTopNode* emcal_re = new TEveGeoTopNode(gGeoManager, gEMCALNode);\r
282 gEve->AddGlobalElement(emcal_re);\r
283 gEve->Redraw3D();\r
284\r
285 if (gShowMUON) \r
286 gGeomGentleMUON = geom_gentle_muon(kFALSE);\r
287 \r
288 // -- Scenes\r
289 // -----------\r
290 gRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry",\r
291 "Scene holding projected geometry for the RPhi view.");\r
292 gRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry",\r
293 "Scene holding projected geometry for the RhoZ view.");\r
294 gRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data",\r
295 "Scene holding projected geometry for the RPhi view.");\r
296 gRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data",\r
297 "Scene holding projected geometry for the RhoZ view.");\r
298\r
299 // -- Projection managers\r
300 // ------------------------\r
301\r
302 gRPhiMgr = new TEveProjectionManager();\r
303 gRPhiMgr->SetProjection(TEveProjection::kPT_RPhi);\r
304 gEve->AddToListTree(gRPhiMgr, kFALSE);\r
305 {\r
306 TEveProjectionAxes* a = new TEveProjectionAxes(gRPhiMgr);\r
307 a->SetMainColor(kWhite);\r
308 a->SetTitle("R-Phi");\r
309 a->SetTitleSize(0.05);\r
310 a->SetTitleFont(102);\r
311 a->SetLabelSize(0.025);\r
312 a->SetLabelFont(102);\r
313 gRPhiGeomScene->AddElement(a);\r
314 }\r
315 gRPhiMgr->SetCurrentDepth(-10);\r
316 gRPhiMgr->ImportElements(gGeomGentleRPhi, gRPhiGeomScene);\r
317 gRPhiMgr->SetCurrentDepth(0);\r
318 gRPhiMgr->ImportElements(gGeomGentleTRD, gRPhiGeomScene);\r
319 if (gShowMUONRPhi) gRPhiMgr->ImportElements(gGeomGentleMUON, gRPhiGeomScene);\r
320\r
321 gRhoZMgr = new TEveProjectionManager();\r
322 gRhoZMgr->SetProjection(TEveProjection::kPT_RhoZ);\r
323 gEve->AddToListTree(gRhoZMgr, kFALSE);\r
324 {\r
325 TEveProjectionAxes* a = new TEveProjectionAxes(gRhoZMgr);\r
326 a->SetMainColor(kWhite);\r
327 a->SetTitle("Rho-Z");\r
328 a->SetTitleSize(0.05);\r
329 a->SetTitleFont(102);\r
330 a->SetLabelSize(0.025);\r
331 a->SetLabelFont(102);\r
332 gRhoZGeomScene->AddElement(a);\r
333 }\r
334 gRhoZMgr->SetCurrentDepth(-10);\r
335 gRhoZMgr->ImportElements(gGeomGentleRhoZ, gRhoZGeomScene);\r
336 gRhoZMgr->SetCurrentDepth(0);\r
337 gRhoZMgr->ImportElements(gGeomGentleTRD, gRhoZGeomScene);\r
338 \r
339 if (gShowMUONRhoZ) gRhoZMgr->ImportElements(gGeomGentleMUON, gRhoZGeomScene);\r
340\r
341 // -- Viewers\r
342 // ------------\r
343\r
344 TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());\r
345 TEveWindowPack *pack = slot->MakePack();\r
346 pack->SetElementName("Multi View");\r
347 pack->SetHorizontal();\r
348 pack->SetShowTitleBar(kFALSE);\r
349 pack->NewSlot()->MakeCurrent();\r
350 g3DView = gEve->SpawnNewViewer("3D View", "");\r
351 g3DView->AddScene(gEve->GetGlobalScene());\r
352 g3DView->AddScene(gEve->GetEventScene());\r
353\r
354\r
355 pack = pack->NewSlot()->MakePack();\r
356 pack->SetShowTitleBar(kFALSE);\r
357 pack->NewSlot()->MakeCurrent();\r
358 gRPhiView = gEve->SpawnNewViewer("RPhi View", "");\r
359 gRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
360 gRPhiView->AddScene(gRPhiGeomScene);\r
361 gRPhiView->AddScene(gRPhiEventScene);\r
362\r
363 pack->NewSlot()->MakeCurrent();\r
364 gRhoZView = gEve->SpawnNewViewer("RhoZ View", "");\r
365 gRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);\r
366 gRhoZView->AddScene(gRhoZGeomScene);\r
367 gRhoZView->AddScene(gRhoZEventScene);\r
368\r
369\r
370 \r
371 //Add HLT Text to windows\r
372 \r
373 TGLOverlayButton *ob1 = new TGLOverlayButton(g3DView->GetGLViewer(), "HLT", 0, 20, 110, 60);\r
374 ob1->SetAlphaValues(0.8, 0.8);\r
375 // cout << "color" << ob1->GetBackColor() << endl;\r
376 //ob1->SetBackColor(8421631);\r
377 //ob1->SetBackColor(10492431);\r
378 TGLOverlayButton *ob2 = new TGLOverlayButton(g3DView->GetGLViewer(), "ALICE", 0, 0, 110, 20);\r
379 ob2->SetAlphaValues(0.8, 0.8);\r
380 //ob2->SetBackColor(0.2);\r
381 TGLOverlayButton *ob3 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "HLT", 0, 20, 110, 60);\r
382 ob3->SetAlphaValues(0.8, 0.8);\r
383 TGLOverlayButton *ob4 = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "ALICE", 0, 0, 110, 20);\r
384 ob4->SetAlphaValues(0.8, 0.8);\r
385\r
386\r
387 TGLOverlayButton *ne = new TGLOverlayButton(gEve->GetDefaultGLViewer(), "Next Event", 110, 0, 210, 20);\r
388 ne->SetAlphaValues(0.0, 0.8);\r
389\r
390 // -- List of Viewers\r
391 // --------------------\r
392\r
393 TEveViewerList *viewerlist = new TEveViewerList();\r
394 viewerlist->AddElement(gEve->GetDefaultViewer());\r
395 \r
396 viewerlist->AddElement(g3DView);\r
397 viewerlist->AddElement(gRhoZView);\r
398 viewerlist->AddElement(gRPhiView);\r
399 viewerlist->SwitchColorSet();\r
400\r
401 //==============================================================================\r
402 // -- Macros / QA histograms\r
403 //==============================================================================\r
404\r
405 // -- Registration of per-event macros\r
406 // -------------------------------------\r
407\r
408 AliEveMacroExecutor *exec = new AliEveMacroExecutor();\r
409\r
410\r
411\r
412 gStyle->SetPalette(1, 0);\r
413\r
414 gStyle->SetOptFit(1);\r
415\r
416\r
417 \r
418 return 0;\r
419}\r
420\r
421\r
422\r
423\r
424\r
425\r
426 \r