1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 /////////////////////////////////////////////////////////////////////////
16 // ALICE EVENT DISPLAY CLASS //
17 // Author: Mayeul ROUSSELET //
18 // e-mail: Mayeul.Rousselet@cern.ch //
19 // Last update:26/08/2003 //
20 /////////////////////////////////////////////////////////////////////////
33 #include <TObjArray.h>
40 #include "AliModule.h"
41 #include "AliDetector.h"
45 #include "AliModuleInfo.h"
46 #include "AliSliderFrame.h"
47 #include "AliShutterFrame.h"
48 #include "AliDisplayFrame.h"
49 #include "AliInfoFrame.h"
50 #include "AliDetectorFrame.h"
53 #include "AliDisplay2.h"
56 AliDisplay2 *gAliDisplay2;
60 //_____________________________________________________________
61 AliDisplay2::AliDisplay2(const TGWindow *p, UInt_t w, UInt_t h)
65 //gAlice->SetDisplay(this);
67 fSliderUpdate = kFALSE;
75 fClustersLoaded = kFALSE;
78 fTracksLoaded = kFALSE;
82 fIconsPath = new char[256];
83 strcpy(fIconsPath,gSystem->Getenv("ALICE_ROOT"));
84 strcat(fIconsPath,"/DISPLAY/icons/");
86 fMainFrame = new TGMainFrame(p,w,h,kVerticalFrame);
87 fSubFrame = new TGCompositeFrame(fMainFrame,w,h,kHorizontalFrame);
88 fLeftFrame = new TGCompositeFrame(fSubFrame,150,h,kVerticalFrame|kFixedWidth);
89 fRightFrame = new TGCompositeFrame(fSubFrame,600,h,kVerticalFrame);
90 //fMainFrame->Connect("ProcessedEvent(Event_t*)", "AliDisplay2", this,"HandleMouseWheel(Event_t*)");
91 fMainFrame->Connect("ProcessedEvent(Event_t*)", "AliDisplay2",this,"HandleResize(Event_t*)");
93 fMenu = new AliMenu(fMainFrame,1,1,kRaisedFrame|kHorizontalFrame);
96 fSliderFrameLayout = new TGLayoutHints( kLHintsBottom| kLHintsRight| kLHintsExpandX | kLHintsCenterX, 2, 2, 2, 2);
97 fSliderFrame = new AliSliderFrame(fRightFrame,600,150);
98 fRightFrame->AddFrame(fSliderFrame->GetSliderFrame(),fSliderFrameLayout);
101 fInfoFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX ,0,0,0,0);
102 fInfoFrame = new AliInfoFrame(fLeftFrame,150,200);
103 fLeftFrame->AddFrame(fInfoFrame->GetInfoFrame(),fInfoFrameLayout);
107 fShutterFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandY |kLHintsExpandX, 0, 0, 5, 0);
108 fShutterFrame = new AliShutterFrame(fLeftFrame,150,300);
109 fLeftFrame->AddFrame(fShutterFrame->GetShutterFrame(),fShutterFrameLayout);
112 fDisplayFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsRight | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2);
113 fDisplayFrame = new AliDisplayFrame(fRightFrame, w-150,w-110);
114 fRightFrame->AddFrame(fDisplayFrame->GetDisplayFrame(),fDisplayFrameLayout);
115 fDisplayFrame->GetDisplayFrame()->Connect("ProcessedEvent(Event_t*)", "AliDisplay2", this,"HandleMouseWheel(Event_t*)");
118 fLeftFrame->Layout();
120 fSubFrame->AddFrame(fLeftFrame, new TGLayoutHints( kLHintsBottom | kLHintsLeft | kLHintsExpandY, 5, 5, 2, 2));
121 fSubFrame->AddFrame(fRightFrame, new TGLayoutHints( kLHintsBottom | kLHintsRight | kLHintsExpandX | kLHintsExpandY, 5, 5, 2, 2));
123 Int_t parts[] = {45,45,10};
124 fStatusBar = new TGStatusBar(fMainFrame,50,10,kHorizontalFrame);
125 fStatusBar->SetParts(parts,3);
126 fStatusBar->SetText("AliDisplay v2.0",0);
127 fMainFrame->AddFrame(fStatusBar,new TGLayoutHints(kLHintsBottom | kLHintsExpandX,0,0,0,0));
129 fMainFrame->AddFrame(fSubFrame,new TGLayoutHints( kLHintsBottom | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 2, 2));
130 fMainFrame->SetWindowName("Ali Display");
132 fMainFrame->MapSubwindows();
133 fMainFrame->MapWindow();
137 fMainFrame->Resize(w-10,h);
138 fMainFrame->Resize(w,h);
139 fMainFrame->SetWMSizeHints(500,500,1280, 1200,1,1);
142 //_____________________________________________________________
143 AliDisplay2::~AliDisplay2(void)
147 delete [] fEnabledModules;
150 delete fSliderFrameLayout;
152 delete fDisplayFrameLayout;
153 delete fDisplayFrame;
154 // delete fZoomFrameLayout;
155 // delete fZoomFrame;
156 delete fShutterFrameLayout;
157 delete fShutterFrame;
158 delete fInfoFrameLayout;
160 delete fDetectorFrameLayout;
161 delete fDetectorFrame;
167 delete fAliDisplay2rc;
173 //_____________________________________________________________
174 void AliDisplay2::CloseWindow(void)
176 // Deletes the current display
180 //_____________________________________________________________
181 void AliDisplay2::LoadFromRC()
183 // Load the environment settings from .alidisplayrc file
184 TEnv *rc=new TEnv(".alidisplayrc");
185 SetSliderUpdate(rc->GetValue("AliDisplay.SliderUpdate",kFALSE));
186 SetZoomStep(rc->GetValue("AliDisplay.ZoomStep",1.2));
187 SetSliderStep(rc->GetValue("AliDisplay.SliderStep",0.01));
189 fRawDataPath = new char[128];
190 strcpy(c,gSystem->Getenv("ALICE_ROOT"));
191 sprintf(fRawDataPath,"%s%s",c,rc->GetValue("AliDisplay.RawDataPath","/raw"));
192 printf("\nRaw data path %s",fRawDataPath);
195 //_____________________________________________________________
196 void AliDisplay2::SaveToRC() const
198 // Saves the environment settings in .alidisplayrc file
199 TEnv *rc=new TEnv(".alidisplayrc");
200 rc->SetValue("AliDisplay.SliderUpdate",GetSliderUpdate());
201 rc->SetValue("AliDisplay.ZoomStep",GetZoomStep());
202 rc->SetValue("AliDisplay.SliderStep",GetSliderStep());
203 rc->SetValue("AliDisplay.RawDataPath","/raw");
204 rc->SaveLevel(kEnvLocal);
208 //_____________________________________________________________
209 void AliDisplay2::DoSaveSettings(void)
211 // Saves the environment settings for the slider frame and display
212 fSliderFrame->SaveToRC();
216 //_____________________________________________________________
217 void AliDisplay2::LoadSettings()
223 //_____________________________________________________________
224 void AliDisplay2::Draw(Option_t */*options*/)
226 // Draws display frame
227 fDisplayFrame->DoView(fCurrentView);
230 //_____________________________________________________________
231 void AliDisplay2::DrawX3d()
233 // Draws display frame using X3d
234 fDisplayFrame->DrawX3d();
237 //_____________________________________________________________
238 void AliDisplay2::DrawGL()
240 // Draws display frame using GL
241 fDisplayFrame->DrawGL();
244 //_____________________________________________________________
245 void AliDisplay2::ShowNextEvent(Int_t delta)
247 //Load the next event
253 newEvent = fEventNumber + delta;
254 if( newEvent < 0) return;
255 gAlice->GetEvent(newEvent);
256 fEventNumber += delta;
257 // if(!gAlice->TreeH()) return;
259 if(IsEnabled(kHits)) LoadHits();
260 if(IsEnabled(kClusters)) LoadClusters(newEvent);
261 if(IsEnabled(kHLT)) LoadHLTClusters(newEvent);
263 // printf("\nEvent loaded in....%f sec", ((double)t2-t1)/(10000*CLK_TCK));
267 //_____________________________________________________________
268 void AliDisplay2::FindModules()
270 // Find the modules used for the simulation and assign
271 // these modules to the array fModules
272 fModules = new TObjArray;
273 TObjArray *modules = gAlice->Modules();
276 for(Int_t i=0;i<modules->GetEntriesFast();i++){
277 mod = (AliModule *) modules->At(i);
279 const char *avoid = strstr("BODY MAG ABSO DIPO HALL FRAME SHIL PIPE",mod->GetName());
281 fModules->AddLast(mod);
284 fEnabledModules = new Bool_t[nbm];
286 fModuleInfo = new AliModuleInfo(nbm);
287 for(Int_t j=0;j<fModules->GetEntriesFast();j++){
288 fModuleInfo->Add(fModules->At(j)->GetName(),j);
289 fEnabledModules[j]=kTRUE;
293 //_____________________________________________________________
294 void AliDisplay2::LoadHits()
296 //Load the detected hits from each detector to memory
297 gAlice->ResetPoints();
298 TIter next(gAlice->Modules());
300 Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
301 while((module = (AliModule*)next()))
303 AliDetector* detector = dynamic_cast<AliDetector*>(module);
304 if(detector) detector->SetTreeAddress();
307 for (Int_t track=0; track<ntracks;track++) {
309 while((module = (AliModule*)next())) {
310 AliDetector* detector = dynamic_cast<AliDetector*>(module);
313 detector->TreeH()->GetEvent(track);
314 detector->LoadPoints(track);
322 //_____________________________________________________________
323 void AliDisplay2::LoadClusters(Int_t nevent)
326 fDisplayFrame->LoadClusters(nevent);
327 fClustersLoaded = kTRUE;
328 // printf("\nClusters loaded in....%f sec", ((double)t2-t1)/(10000*CLK_TCK));
331 //_____________________________________________________________
332 void AliDisplay2::LoadHLTClusters(Int_t nevent)
334 // Loads HLT clusters
335 fDisplayFrame->LoadHLTClusters(nevent);
339 //_____________________________________________________________
340 void AliDisplay2::Enable(Int_t m)
342 // Enables the given mode m
344 if((fMode&kHits)==kHits) return;
346 if(!fHitsLoaded) LoadHits();
350 if((fMode&kClusters)==kClusters) return;
351 fMode = kClusters|fMode;
352 if(!fClustersLoaded) LoadClusters(fEventNumber);
356 if((fMode&kHLT)==kHLT) return;
359 LoadHLTClusters(fEventNumber);
364 if((fMode&kTracks)==kTracks) return;
365 fMode = kTracks|fMode;
370 //_____________________________________________________________
371 void AliDisplay2::Disable(Int_t m)
373 // Disables the given mode m
379 fMode = fMode|kClusters;
380 fMode = fMode^kClusters;
387 fMode = fMode|kTracks;
388 fMode = fMode^kTracks;
393 //_____________________________________________________________
394 Bool_t AliDisplay2::IsEnabled(Int_t m) const
396 // Checks if the mode m is enabled
398 if((fMode&kHits)==kHits) return kTRUE;
402 if((fMode&kClusters)==kClusters) return kTRUE;
406 if((fMode&kHLT)==kHLT) return kTRUE;
410 if((fMode&kTracks)==kTracks) return kTRUE;
416 //_____________________________________________________________
417 void AliDisplay2::HandleMouseWheel(Event_t *event)
419 //Handle mouve event, not working yet
420 if(event->fType != kButtonPress && event->fType != kButtonRelease) return;
422 if(event->fCode == kButton4){
423 fZoomFactor *= fZoomStep;
427 if(event->fCode == kButton5){
428 fZoomFactor /= fZoomStep;
433 //_____________________________________________________________
434 void AliDisplay2::HandleResize(Event_t *event)
436 // Handle resize event
437 switch(event->fType){
438 case kConfigureNotify:{
446 //_____________________________________________________________
447 void AliDisplay2::Update(Int_t tag)
449 // Update the view, if loading only the modified data from the previous
450 // changes, the integer tag indicates the kind of modification
452 LoadEnabledModules();
453 if(((fMode)&kHits)==kHits){
459 if(((fMode)&kHits)==kHits)ApplyCuts();
462 if(((fMode)&kHits)==kHits){
468 fInfoFrame->Update();