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