From 37f14bbf5644a40356d2d8f6db27d85879cc0197 Mon Sep 17 00:00:00 2001 From: hristov Date: Mon, 16 Feb 2004 16:09:23 +0000 Subject: [PATCH] Adding new display code (M.Rousselet) --- DISPLAY/AliDisplay2.cxx | 2231 ++++++++++++++++++++++++++++++++++++++ DISPLAY/AliDisplay2.h | 649 +++++++++++ DISPLAY/DISPLAYLinkDef.h | 25 + DISPLAY/README | 22 + DISPLAY/display2.C | 61 ++ DISPLAY/libDISPLAY.pkg | 8 + 6 files changed, 2996 insertions(+) create mode 100644 DISPLAY/AliDisplay2.cxx create mode 100644 DISPLAY/AliDisplay2.h create mode 100644 DISPLAY/DISPLAYLinkDef.h create mode 100644 DISPLAY/README create mode 100644 DISPLAY/display2.C create mode 100644 DISPLAY/libDISPLAY.pkg diff --git a/DISPLAY/AliDisplay2.cxx b/DISPLAY/AliDisplay2.cxx new file mode 100644 index 00000000000..8b571a86ea3 --- /dev/null +++ b/DISPLAY/AliDisplay2.cxx @@ -0,0 +1,2231 @@ +/************************************************************************** + * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +#define do_mc + +//standard modules +#include +#include +#include + +//ROOT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//AliRoot Module +#include "AliModule.h" +#include "AliDetector.h" +#include "AliHeader.h" +#include "AliPoints.h" +#include "AliRun.h" +#include "AliStack.h" +#include "AliITSclusterV2.h" +#include "AliITSgeom.h" +#include "AliITSLoader.h" +#include "AliITS.h" +#include "AliTPCcluster.h" +#include "AliTPCLoader.h" +#include "AliTPC.h" +#include "AliClusters.h" +#include "AliTPCParam.h" +#include "AliMC.h" + +#ifdef ALI_HLT +//HLT Module +#include "AliL3Logging.h" +#include "AliL3Display.h" +#include "AliL3Transform.h" +#include "AliL3Track.h" +#include "AliL3TrackArray.h" +#include "AliL3SpacePointData.h" +#include "AliL3MemHandler.h" +#endif + +#include "AliDisplay2.h" + + AliDisplay2 *gAliDisplay2; + +//extern filetypes; +const char *filetypes[] = {"ROOT files","*.root","All files","*",0,0}; +const char *imgtypes[] = {"GIF files","*.gif",0,0}; + +ClassImp(AliModuleInfo); + +//_____________________________________________________________ +AliModuleInfo::AliModuleInfo(int n) +{ + fName = new char*[n]; + fId = new Int_t[n]; + fEnabled = new Bool_t[n]; + fNb = 0; +} + +//_____________________________________________________________ +AliModuleInfo::~AliModuleInfo(){ + delete [] fName; + delete [] fId; + delete [] fEnabled; +} + +//_____________________________________________________________ +void AliModuleInfo::Add(const char *name,Int_t i) +{ + fName[fNb]=new char[strlen(name)]; + strcpy(fName[fNb],name); + fId[fNb]=i; + fEnabled[fNb]=kTRUE; + fNb++; +} + +//_____________________________________________________________ +void AliModuleInfo::SetId(char *name,Int_t id) +{ + Int_t i=0; + while((strcmp(name,fName[i])!=0)&&(i!=fNb)) i++; + if(strcmp(name,fName[i])==0) fId[i]=id; +} + +//_____________________________________________________________ +char* AliModuleInfo::Name(Int_t id) +{ + Int_t i=0; + while((fId[i]!=id)&&(i!=fNb)) i++; + if(fId[i]==id) return fName[i]; + return 0; +} + +//_____________________________________________________________ +Int_t AliModuleInfo::Id(char *name) +{ + Int_t i=0; + while((strcmp(name,fName[i])!=0)&&(i!=fNb)) i++; + if(strcmp(name,fName[i])==0) return fId[i]; + return -1; +} + +//_____________________________________________________________ +Bool_t AliModuleInfo::IsEnabled(Int_t id) +{ + //return the current status of the detector + Int_t i=0; + while((fId[i]!=id)&&(i!=fNb)) i++; + if(fId[i]==id) return fEnabled[i]; + return kFALSE; +} + +//_____________________________________________________________ +void AliModuleInfo::Disable(Int_t id) +{ + //Disable the detector + Int_t i=0; + while((fId[i]!=id)&&(i!=fNb)) i++; + if(fId[i]==id) fEnabled[i]=kFALSE; +} + +//_____________________________________________________________ +void AliModuleInfo::Enable(Int_t id) +{ + //Enable the detector + Int_t i=0; + while((fId[i]!=id)&&(i!=fNb)) i++; + if(fId[i]==id) fEnabled[i]=kTRUE; +} + +//_____________________________________________________________ +void AliModuleInfo::Print() +{ + printf("\n***Modules***"); + printf("\nName\tId\tEnabled"); + for(Int_t i=0;iGetNbModules()]; + fName = new char*[gAliDisplay2->GetNbModules()]; + fNb=0; + for(Int_t i=0;iGetNbModules();i++){ + fPoints[i].SetMarkerSize(0.2); + fPoints[i].SetMarkerColor(2); + fPoints[i].SetMarkerStyle(1); + } +} + +//_____________________________________________________________ +AliDisplayClusters::~AliDisplayClusters() +{ + delete [] fPoints; +} + +//_____________________________________________________________ +Int_t AliDisplayClusters::GetNbClusters() +{ + Int_t r=0; + for(Int_t i=0;iGetModuleInfo()->IsEnabled(fName[i])) r+=fPoints[i].GetN(); + } + return r; +} + +//_____________________________________________________________ +void AliDisplayClusters::LoadClusters(char *name,Int_t nevent) +{ + if(strstr(name,"ITS")) LoadITSClusters(nevent); + if(strstr(name,"TPC")) LoadTPCClusters(nevent); +} + +//_____________________________________________________________ +void AliDisplayClusters::LoadITSClusters(Int_t nevent) +{ + fName[fNb]=new char[strlen("ITS")]; + strcpy(fName[fNb],"ITS"); + AliRunLoader *rl = AliRunLoader::Open("galice.root"); + if(!rl) { + cerr<<"Can't open galice.root"; + return; + } + AliITSLoader *itsl = (AliITSLoader*)rl->GetLoader("ITSLoader"); + AliITS *its = (AliITS*)gAlice->GetModule("ITS"); + + rl->GetEvent(nevent); + itsl->LoadRecPoints(); + TTree *cTree=itsl->TreeR(); + if(!cTree) + { + cerr<<"Error occured during ITS clusters load"; + return; + } + + AliITSgeom *geom=its->GetITSgeom(); + Int_t count = 0; + + TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000); + TBranch *branch=cTree->GetBranch("Clusters"); + branch->SetAddress(&clusters); + Int_t nentr=(Int_t)cTree->GetEntries(); + for (Int_t i=0; iGetEvent(i)) continue; + + Double_t rot[9]; + geom->GetRotMatrix(i,rot); + Int_t lay,lad,det; + geom->GetModuleId(i,lay,lad,det); + Float_t tx,ty,tz; + geom->GetTrans(lay,lad,det,tx,ty,tz); + + Double_t r=-tx*rot[1]+ty*rot[0]; + if (lay==1) r=-r; + Double_t phi=TMath::ATan2(rot[1],rot[0]); + if (lay==1) phi-=3.1415927; + Double_t cp=TMath::Cos(phi), sp=TMath::Sin(phi); + + Int_t ncl=clusters->GetEntriesFast(); + while (ncl--) { + AliITSclusterV2 *c=(AliITSclusterV2*)clusters->UncheckedAt(ncl); + Double_t g[3]; + g[0]= r*cp + c->GetY()*sp; // + g[1]=-r*sp + c->GetY()*cp; // + g[2]=c->GetZ(); + fPoints[fNb].SetPoint(count,g[0],g[1],g[2]); + count++; + } + } + fNb++; +} + +//_____________________________________________________________ +void AliDisplayClusters::LoadTPCClusters(Int_t nevent) +{ + + fName[fNb]=new char[strlen("TPC")]; + strcpy(fName[fNb],"TPC"); + TFile *file = TFile::Open("galice.root"); + AliTPCParam *dig=(AliTPCParam *)file->Get("75x40_100x60_150x60"); + if (!dig) {cerr<<"TPC parameters have not been found !\n";} + file->Close(); + + AliRunLoader *rl = AliRunLoader::Open("galice.root"); + if(!rl) { + cerr<<"Can't open galice.root"; + return; + } + AliTPCLoader *itsl = (AliTPCLoader*)rl->GetLoader("TPCLoader"); + if(!itsl){ + cerr<<"Can't find Loader"; + return; + } + + rl->GetEvent(nevent); + itsl->LoadRecPoints(); + TTree *cTree=itsl->TreeR(); + if(!cTree) + { + cerr<<"Error during TPC clusters load"; + return; + } + + Int_t count = 0; + Float_t noiseth = 10; + + AliClusters *clusters=new AliClusters(); + clusters->SetClass("AliTPCcluster"); + + cTree->SetBranchAddress("Segment",&clusters); + + Int_t nrows=Int_t(cTree->GetEntries()); + for (Int_t n=0; nGetEvent(n); + Int_t sec,row; + dig->AdjustSectorRow(clusters->GetID(),sec,row); + TClonesArray &clrow=*clusters->GetArray(); + Int_t ncl=clrow.GetEntriesFast(); + while (ncl--) { + AliTPCcluster *cl=(AliTPCcluster*)clrow[ncl]; + Double_t x=dig->GetPadRowRadii(sec,row), y=cl->GetY(), z=cl->GetZ(); + if (cl->GetQ()AdjustCosSin(sec,cs,sn); + tmp = x*cs-y*sn; y= x*sn+y*cs; x=tmp; + fPoints[fNb].SetPoint(count,x,y,z); + count++; + } + clrow.Clear(); + + } + delete cTree; + delete dig; + fNb++; + +} + +//_____________________________________________________________ +void AliDisplayClusters::Draw() +{ + for(Int_t i=0;iGetModuleInfo()->IsEnabled(fName[i])) fPoints[i].Draw(); + } +} + + +ClassImp(AliDisplayHLT); + +//_____________________________________________________________ +AliDisplayHLT::AliDisplayHLT() +{ + fPoints = new TPolyMarker3D[gAliDisplay2->GetNbModules()]; + fName = new char*[gAliDisplay2->GetNbModules()]; + fNb=0; + for(Int_t i=0;iGetNbModules();i++){ + fPoints[i].SetMarkerSize(0.2); + fPoints[i].SetMarkerColor(2); + fPoints[i].SetMarkerStyle(1); + } +} + +//_____________________________________________________________ +AliDisplayHLT::~AliDisplayHLT() +{ + delete [] fPoints; +} + +//_____________________________________________________________ +void AliDisplayHLT::LoadHLT(char *name,Int_t nevent) +{ + if(strstr(name,"TPC")) LoadHLTTPC(nevent); +} + +//_____________________________________________________________ +void AliDisplayHLT::LoadHLTTPC(Int_t nevent) +{ +#ifdef ALI_HLT + //load TPC Clusters from the raw data + //raw data must be in the directorie $ALICE_ROOT/raw + //First we read the data from files + //do_mc MUST BE DEFINED AND USED FOR RAW DATA GENERATION + + fName[fNb]=new char[strlen("TPC")]; + strcpy(fName[fNb],"TPC"); + Char_t fname[256]; + AliL3MemHandler *clusterfile[36][6]; + AliL3SpacePointData *fClusters[36][6]; + UInt_t fNcl[36][6]; + memset(fClusters,0,36*6*sizeof(AliL3SpacePointData*)); + // strcpy(path,gSystem->Getenv("ALICE_ROOT")); + //strcat(path,"/raw"); + //printf("\nRaw data path %s",path); + char path[128]; + strcpy(path,gAliDisplay2->GetRawDataPath()); + for(Int_t s=0; s<36; s++) + { + for(Int_t p=0; pSetBinaryInput(fname)) + { + LOG(AliL3Log::kError,"AliL3Evaluation::Setup","File Open") + <<"Inputfile "<Allocate(); + clusterfile[s][p]->Binary2Memory(fNcl[s][p],fClusters[s][p]); + clusterfile[s][p]->CloseBinaryInput(); + break; + } + } + + //Second step: we assign the clusters to the fPoints array + Int_t nbc=0; + for(Int_t s=0; s<36; s++){ + for(Int_t p=0;p<6;p++){ + AliL3SpacePointData *points = fClusters[s][p]; + if(!points) continue; + Float_t xyz[3]; + for(UInt_t i=0; iGetModuleInfo()->IsEnabled(fName[i])) fPoints[i].Draw(); + } +} + + +ClassImp(AliSliderFrame); + +//_____________________________________________________________ +AliSliderFrame::AliSliderFrame(const TGWindow *p, UInt_t w, UInt_t h) +{ + fMainFrame = new TGCompositeFrame(p, w, h, kVerticalFrame | kRaisedFrame); + fLayout = new TGLayoutHints( kLHintsBottom | kLHintsRight | kLHintsExpandX,5,5,2,2); + + //Momentum Slider + fMomentumFrame = new TGCompositeFrame(fMainFrame,0,0, kHorizontalFrame); + fMomentumLayout = new TGLayoutHints( kLHintsLeft | kLHintsTop | kLHintsExpandX ,5,5,2,2); + fMomentumSlider = new TGDoubleHSlider(fMomentumFrame, 400, kDoubleScaleBoth, kIdsMOMENTUM); + fMomentumSlider->Connect("PositionChanged()","AliSliderFrame",this,"DoSlider()"); + fMomentumSlider->Connect("PositionChanged()","AliSliderFrame",this,"DoPositionChanged(Int_t)"); + fMomentumSlider->Connect("Released()","AliSliderFrame",this,"DoReleased()"); + SetMomentumRange(0,2); + fMomentumSlider->SetPosition(0,2); + fMomentumLabel = new TGLabel(fMomentumFrame,"Momentum"); + + fMomentumMinValue = new TGNumberEntry(fMomentumFrame,GetMomentumMin(),7,kIdsMomentumMIN); + fMomentumMinValue->Connect("ValueChanged(Long_t)","AliSliderFrame",this,"DoField(Long_t)"); + fMomentumMinValue->GetNumberEntry()->Connect("ReturnPressed()","AliSliderFrame",this,"DoField(Long_t)"); + fMomentumMinValue->SetButtonToNum(kFALSE); + + fMomentumMaxValue = new TGNumberEntry(fMomentumFrame,GetMomentumMax(),7,kIdsMomentumMAX); + fMomentumMaxValue->Connect("ValueChanged(Long_t)","AliSliderFrame",this,"DoField(Long_t)"); + fMomentumMaxValue->GetNumberEntry()->Connect("ReturnPressed()","AliSliderFrame",this,"DoField(Long_t)"); + fMomentumMaxValue->SetButtonToNum(kFALSE); + + fMomentumFrame->AddFrame(fMomentumLabel,new TGLayoutHints( kLHintsLeft | kLHintsCenterY,5,5,2,2)); + fMomentumFrame->AddFrame(fMomentumMinValue,new TGLayoutHints( kLHintsLeft ,5,5,2,2)); + fMomentumFrame->AddFrame(fMomentumSlider,fMomentumLayout); + fMomentumFrame->AddFrame(fMomentumMaxValue,new TGLayoutHints( kLHintsRight,5,5,2,2)); + fMomentumFrame->Resize(700,100); + + + //Rapidity Slider + fRapidityFrame = new TGCompositeFrame(fMainFrame,0,0, kHorizontalFrame); + fRapidityLayout = new TGLayoutHints( kLHintsLeft | kLHintsTop | kLHintsExpandX,5,5,2,2); + fRapiditySlider = new TGDoubleHSlider(fRapidityFrame, 400, kDoubleScaleBoth, kIdsRAPIDITY); + fRapiditySlider->Connect("PositionChanged()","AliSliderFrame",this,"DoSlider()"); + fRapiditySlider->Connect("PositionChanged()","AliSliderFrame",this,"DoPositionChanged(Int_t)"); + fRapiditySlider->Connect("Released()","AliSliderFrame",this,"DoReleased()"); + SetRapidityRange(-1.5,1.5); + fRapiditySlider->SetPosition(-1.5,1.5); + fRapidityLabel = new TGLabel(fRapidityFrame,"Rapidity "); + fRapidityMinValue = new TGNumberEntry(fRapidityFrame,GetRapidityMin(),7,kIdsRapidityMIN); + fRapidityMinValue->Connect("ValueChanged(Long_t)","AliSliderFrame",this,"DoField(Long_t)"); + fRapidityMinValue->SetButtonToNum(kFALSE); + fRapidityMinValue->GetNumberEntry()->Connect("ReturnPressed()","AliSliderFrame",this,"DoField(Long_t)"); + + fRapidityMaxValue = new TGNumberEntry(fRapidityFrame,GetRapidityMax(),7,kIdsRapidityMAX); + fRapidityMaxValue->Connect("ValueChanged(Long_t)","AliSliderFrame",this,"DoField(Long_t)"); + fRapidityMaxValue->SetButtonToNum(kFALSE); + fRapidityMaxValue->GetNumberEntry()->Connect("ReturnPressed()","AliSliderFrame",this,"DoField(Long_t)"); + + fRapidityFrame->AddFrame(fRapidityLabel,new TGLayoutHints( kLHintsLeft | kLHintsCenterY,5,5,2,2)); + fRapidityFrame->AddFrame(fRapidityMinValue,new TGLayoutHints( kLHintsLeft ,5,5,2,2)); + fRapidityFrame->AddFrame(fRapiditySlider,fRapidityLayout); + fRapidityFrame->AddFrame(fRapidityMaxValue,new TGLayoutHints( kLHintsRight ,5,5,2,2)); + fRapidityFrame->Resize(700,100); + + fMainFrame->AddFrame(fMomentumFrame,fLayout); + fMainFrame->AddFrame(fRapidityFrame,fLayout); + fMainFrame->MapSubwindows(); + fMainFrame->MapWindow(); + fMainFrame->Resize(700,100); + LoadFromRC(); +} + +//_____________________________________________________________ +AliSliderFrame::~AliSliderFrame(void) +{ + delete fLayout; + delete fRapidityLayout; + delete fMomentumLayout; + delete fMomentumMinValue; + delete fMomentumMaxValue; + delete fMainFrame; + delete fRapidityFrame; + delete fMomentumFrame; + delete fMomentumSlider; + delete fRapiditySlider; + delete fMomentumLabel; + delete fRapidityLabel; + delete fRapidityMinValue; + delete fRapidityMaxValue; +} + +//_____________________________________________________________ +void AliSliderFrame::CloseWindow(void) +{ + delete this; +} + +//_____________________________________________________________ +void AliSliderFrame::DoSlider(Int_t /*pos*/) +{ + TGFrame *frame = (TGFrame *) gTQSender; + TGDoubleSlider * ds = (TGDoubleSlider *) frame; + int id = ds->WidgetId(); + char min[8]; + char max[8]; + switch(id){ + case kIdsMOMENTUM:{ + //sprintf(buf,"momentum min:%f max:%f",GetMomentumMin(),GetMomentumMax()); + //printf("\n%s",buf); + sprintf(min,"%.4f",GetMomentumMin()); + sprintf(max,"%.4f",GetMomentumMax()); + fMomentumMaxValue->SetText(max); + fMomentumMinValue->SetText(min); + } + break; + case kIdsRAPIDITY:{ + sprintf(min,"%.4f",GetRapidityMin()); + sprintf(max,"%.4f",GetRapidityMax()); + fRapidityMaxValue->SetText(max); + fRapidityMinValue->SetText(min); + } + break; + default:break; + } +} + +//_____________________________________________________________ +void AliSliderFrame::DoReleased(Int_t /*pos*/) +{ + TGFrame *frame = (TGFrame *) gTQSender; + TGDoubleSlider * ds = (TGDoubleSlider *) frame; + int id = ds->WidgetId(); + switch(id){ + case kIdsRAPIDITY: + case kIdsMOMENTUM: + gAliDisplay2->Update(kmCUTS); + break; + default: break; + } +} + +//_____________________________________________________________ +void AliSliderFrame::DoPositionChanged(Int_t /*pos*/) +{ + if(!gAliDisplay2->GetSliderUpdate()) return; + TGFrame *frame = (TGFrame *) gTQSender; + TGDoubleSlider * ds = (TGDoubleSlider *) frame; + int id = ds->WidgetId(); + switch(id){ + case kIdsRapidityMIN: + case kIdsRapidityMAX: + case kIdsMomentumMIN: + case kIdsMomentumMAX:{ + gAliDisplay2->Update(kmCUTS); + } + break; + default: break; + } +} + +//_____________________________________________________________ +void AliSliderFrame::DoField(Long_t pos) +{ + TGNumberEntry *ne = (TGNumberEntry *) gTQSender; + int id = ne->WidgetId(); + char max[8],min[8]; + Int_t sign=0; + Float_t step=gAliDisplay2->GetSliderStep(); + if((pos/10000)==0){//Up button pressed + sign = 1; + } + else sign = -1; + + switch(id){ + case kIdsMomentumMIN:{ + fMomentumMinValue->SetNumber(fMomentumMinValue->GetNumber()+step*sign); + sprintf(min,"%.4f",fMomentumMinValue->GetNumber()); + fMomentumMinValue->SetText(min); + } + break; + case kIdsMomentumMAX:{ + fMomentumMaxValue->SetNumber(fMomentumMaxValue->GetNumber()+step*sign); + sprintf(max,"%.4f",fMomentumMaxValue->GetNumber()); + fMomentumMaxValue->SetText(max); + } + break; + case kIdsRapidityMIN:{ + fRapidityMinValue->SetNumber(fRapidityMinValue->GetNumber()+step*sign); + sprintf(min,"%.4f",fRapidityMinValue->GetNumber()); + fRapidityMinValue->SetText(min); + } + break; + case kIdsRapidityMAX:{ + fRapidityMaxValue->SetNumber(fRapidityMaxValue->GetNumber()+step*sign); + sprintf(max,"%.4f",fRapidityMaxValue->GetNumber()); + fRapidityMaxValue->SetText(max); + } + break; + default:break; + } + + fMomentumSlider->SetPosition(fMomentumMinValue->GetNumber(),fMomentumMaxValue->GetNumber()); + fRapiditySlider->SetPosition(fRapidityMinValue->GetNumber(),fRapidityMaxValue->GetNumber()); +// gAliDisplay2->Draw(); + gAliDisplay2->Update(kmCUTS); +} + +//_____________________________________________________________ +void AliSliderFrame::SaveToRC() +{ + TEnv *rc=new TEnv(".alidisplayrc"); + rc->SetValue("AliDisplay.MomentumMin",GetMomentumMin()); + rc->SetValue("AliDisplay.MomentumMax",GetMomentumMax()); + rc->SetValue("AliDisplay.RapidityMin",GetRapidityMin()); + rc->SetValue("AliDisplay.RapidityMax",GetRapidityMax()); + rc->SaveLevel(kEnvLocal); + rc->Save(); +} + +//_____________________________________________________________ +void AliSliderFrame::LoadFromRC() +{ + TEnv *rc=new TEnv(".alidisplayrc"); + Float_t a,b; + a=rc->GetValue("AliDisplay.MomentumMin",0); + b=rc->GetValue("AliDisplay.MomentumMax",2); + fMomentumSlider->SetPosition(a,b); + a=rc->GetValue("AliDisplay.RapidityMin",-1.5); + b=rc->GetValue("AliDisplay.RapidityMax",1.5); + fRapiditySlider->SetPosition(a,b); +} + + +ClassImp(AliDetectorFrame); + +int AliDetectorFrame::fgBaseId = 1000; + +//_____________________________________________________________ +AliDetectorFrame::AliDetectorFrame(const TGWindow *p, Int_t w, Int_t h,UInt_t bgc) +{ + fMainFrame = new TGCompositeFrame(p,w,h,kVerticalFrame,bgc); + TGLayoutHints *layout = new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2); + TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop | kLHintsRight,2,2,2,2); + TGLayoutHints *layout3 = new TGLayoutHints(kLHintsTop | kLHintsExpandX,2,2,2,2); + fCheckButton = new TGCheckButton*[gAliDisplay2->GetNbModules()]; + fCheckedButton = new Bool_t[gAliDisplay2->GetNbModules()]; + fCheckButtonId = new Int_t[gAliDisplay2->GetNbModules()]; + TGCompositeFrame *dframe; + TGButton *button; + char text[32]; + AliModule *mod; + fCheckedMode = kFALSE; + for(Int_t i=0;iGetNbModules();i++){ + mod = dynamic_cast (gAliDisplay2->GetModules()->At(i)); + if(!mod) continue; + dframe = new TGCompositeFrame(fMainFrame,150,20,kHorizontalFrame); + fCheckButton[i] = new TGCheckButton(dframe,mod->GetName(),fgBaseId); + fCheckButtonId[i]=fgBaseId; + fCheckButton[i]->Connect("Clicked()","AliDetectorFrame",this,"DoCheckButton(Int_t)"); + fCheckedButton[i]=kTRUE; + dframe->AddFrame(fCheckButton[i],layout); + fCheckButton[i]->SetState(kButtonDown); + sprintf(text,"Specific %s view",mod->GetName()); + button = new TGTextButton(dframe,"Display",fgBaseId); + button->SetToolTipText(text); + button->Connect("Clicked()","AliDetectorFrame",this,"DoSpecific()"); + dframe->AddFrame(button,layout2); + fMainFrame->AddFrame(dframe,layout3); + gAliDisplay2->GetModuleInfo()->SetId((char*)mod->GetName(),fgBaseId); + fgBaseId++; + } + gAliDisplay2->GetModuleInfo()->Print(); + fButtonFrame = new TGCompositeFrame(fMainFrame,w,100,kHorizontalFrame,bgc); + fButtonAll = new TGTextButton(fButtonFrame,"All",kIdbSelectALL); + fButtonAll->Connect("Clicked()","AliDetectorFrame",this,"DoButton(Int_t)"); + fButtonFrame->AddFrame(fButtonAll,new TGLayoutHints(kLHintsBottom | kLHintsLeft,2,2,2,2)); + fButtonInvert = new TGTextButton(fButtonFrame,"Invert",kIdbSelectINVERT); + fButtonInvert->Connect("Clicked()","AliDetectorFrame",this,"DoButton(Int_t)"); + fButtonFrame->AddFrame(fButtonInvert,new TGLayoutHints(kLHintsBottom | kLHintsRight,2,2,2,2)); + fMainFrame->AddFrame(fButtonFrame,new TGLayoutHints(kLHintsBottom | kLHintsLeft|kLHintsExpandX,0,0,2,2)); + fCheckedMode = kTRUE; +} + +//_____________________________________________________________ +AliDetectorFrame::~AliDetectorFrame() +{ + for(Int_t i=0;iGetNbModules();i++){ + delete fCheckButton[i]; + } + delete fCheckButton; + delete fCheckedButton; + delete fCheckButtonId; + //delete [] fDetectorName; + delete fButtonFrame; + delete fMainFrame; + delete fButtonAll; + delete fButtonInvert; +} + +//_____________________________________________________________ +void AliDetectorFrame::DoButton(Int_t /*pos*/) +{ + TGFrame *frame = (TGFrame *) gTQSender; + TGButton *bu= (TGButton *) frame; + int id = bu->WidgetId(); + fCheckedMode = kFALSE; + AliModule *mo; + switch(id){ + case kIdbSelectALL:{ + for(Int_t i=0;iGetNbModules();i++){ + mo = dynamic_cast (gAliDisplay2->GetModules()->At(i)); + if(!mo) continue; + fCheckButton[i]->SetState(kButtonDown); + fCheckedButton[i]=kTRUE; + gAliDisplay2->EnableDetector(mo->GetName()); + } + } + break; + case kIdbSelectINVERT:{ + for(Int_t i=0;iGetNbModules();i++){ + mo = dynamic_cast (gAliDisplay2->GetModules()->At(i)); + if(!mo) continue; + if(fCheckedButton[i]==kTRUE) { + fCheckButton[i]->SetState(kButtonUp); + fCheckedButton[i]=kFALSE; + gAliDisplay2->DisableDetector(mo->GetName()); + } + else if(fCheckedButton[i]==kFALSE) { + fCheckButton[i]->SetState(kButtonDown); + fCheckedButton[i]=kTRUE; + gAliDisplay2->EnableDetector(mo->GetName()); + } + } + } + break; + default:break; + } + gAliDisplay2->Update(kmMODULES); + fCheckedMode = kTRUE; +} + +//_____________________________________________________________ +void AliDetectorFrame::DoCheckButton(Int_t /*pos*/) +{ + if(fCheckedMode == kFALSE) return; + TGFrame *frame = (TGFrame *) gTQSender; + TGCheckButton *bu= (TGCheckButton *) frame; + Int_t id = bu->WidgetId(); + AliModule *mo; + for(Int_t i=0;iGetNbModules();i++){ + mo = dynamic_cast (gAliDisplay2->GetModules()->At(i)); + if(!mo) continue; + if(id==fCheckButtonId[i]){ + if(fCheckedButton[i]==kTRUE) { + fCheckedButton[i]=kFALSE; + gAliDisplay2->DisableDetector(mo->GetName()); + } + else { + fCheckedButton[i]=kTRUE; + gAliDisplay2->EnableDetector(mo->GetName()); + } + } + } + gAliDisplay2->Update(kmMODULES); +} + +//_____________________________________________________________ +void AliDetectorFrame::DoSpecific() +{ + TGFrame *frame = (TGFrame *) gTQSender; + TGCheckButton *bu= (TGCheckButton *) frame; + Int_t id = bu->WidgetId(); + AliModule *mo; + for(Int_t i=0;iGetNbModules();i++){ + mo = dynamic_cast (gAliDisplay2->GetModules()->At(i)); + if(!mo) continue; + if(id==fCheckButtonId[i]){ + gAliDisplay2->DrawDetector(mo->GetName()); + } + } +} + + +ClassImp(AliShutterItem); + +//_____________________________________________________________ +AliShutterItem::AliShutterItem(TGShutter *s,char *text, UInt_t id) +{ + fShutterItem = new TGShutterItem(s, new TGHotString(text), id); + fMainFrame = (TGCompositeFrame *) fShutterItem->GetContainer(); + s->AddItem(fShutterItem); +} + +//_____________________________________________________________ +AliShutterItem::~AliShutterItem(void) +{ + delete fButton; + delete fShutterItem; + delete fMainFrame; +} + +//_____________________________________________________________ +void AliShutterItem::AddTextButton(char* text,char *tiptext, UInt_t idb) +{ + //Add a TGTextButton in the TGShutterItem. This button will execute the fonction + fButton = new TGTextButton(fMainFrame,new TGHotString(text),idb); + fButton->Resize(100,fButton->GetDefaultHeight()); + fButton->Connect("Clicked()","AliShutterItem",this,"DoButton(Int_t)"); + fButton->SetToolTipText(tiptext); + //fButton->Connect("Clicked()","AliDisplay2",gAliDisplay2,"DoViews(Int_t)"); + fMainFrame->AddFrame(fButton, new TGLayoutHints( kLHintsTop | kLHintsCenterX ,5,5,10,10)); +} + +//_____________________________________________________________ +void AliShutterItem::AddPictureButton(char* file, char *tiptext, UInt_t idb) +{ + //Add a TGPictureButton in the TGShutterItem. The icon file must be in DISPLAY/icons + TString filename=StrDup(gAliDisplay2->GetIconsPath()); + filename.Append(file); + TGPicture *picture = (TGPicture *) gClient->GetPicture(filename); + fButton = new TGPictureButton(fMainFrame,picture,idb); + fButton->SetToolTipText(tiptext); + fButton->Connect("Clicked()","AliShutterItem",this,"DoButton(Int_t)"); + fMainFrame->AddFrame(fButton, new TGLayoutHints( kLHintsTop | kLHintsCenterX ,5,5,10,10)); +} + +//_____________________________________________________________ +void AliShutterItem::AddCheckButton(char *text,Int_t idb) +{ + fButton = new TGCheckButton(fMainFrame,new TGHotString(text),idb); + fButton->Resize(100,fButton->GetDefaultHeight()); + fButton->Connect("Clicked()","AliShutterItem",this,"DoButton(Int_t)"); + fMainFrame->AddFrame(fButton, new TGLayoutHints( kLHintsTop | kLHintsLeft ,5,5,10,10)); +} + +//_____________________________________________________________ +void AliShutterItem::DoButton(Int_t /*pos*/){ + TGFrame *frame = (TGFrame *) gTQSender; + TGButton *bu= (TGButton *) frame; + int id = bu->WidgetId(); + switch(id){ + case kIdbNextEVENT:{ + gAliDisplay2->ShowNextEvent(1); + } + break; + case kIdbPrevEVENT:{ + gAliDisplay2->ShowNextEvent(-1); + } + break; + case kIdbCheckHITS:{ + if(gAliDisplay2->IsEnabled(kHits)) gAliDisplay2->Disable(kHits); + else gAliDisplay2->Enable(kHits); + } + break; + case kIdbCheckCLUSTERS:{ + if(gAliDisplay2->IsEnabled(kClusters)) gAliDisplay2->Disable(kClusters); + else gAliDisplay2->Enable(kClusters); + } + break; + case kIdbCheckHLT:{ + if(gAliDisplay2->IsEnabled(kHLT)) gAliDisplay2->Disable(kHLT); + else gAliDisplay2->Enable(kHLT); + } + break; + case kIdbCheckTRACKS:{ + if(gAliDisplay2->IsEnabled(kTracks)) gAliDisplay2->Disable(kTracks); + else gAliDisplay2->Enable(kTracks); + } + break; + case kIdbSIDEVIEW:{ + gAliDisplay2->DoView(kIdbSIDEVIEW); + } + break; + case kIdbFRONTVIEW:{ + gAliDisplay2->DoView(kIdbFRONTVIEW); + } + break; + case kIdbTOPVIEW:{ + gAliDisplay2->DoView(kIdbTOPVIEW); + } + break; + case kIdbALLVIEW:{ + gAliDisplay2->DoView(kIdbALLVIEW); + } + break; + default:break; + } +} + +ClassImp(AliShutterFrame); + +//_____________________________________________________________ +AliShutterFrame::AliShutterFrame(TGCompositeFrame *p, UInt_t /*w*/, UInt_t h){ + fShutter = new TGShutter(p,kSunkenFrame); + fLayout = new TGLayoutHints(kLHintsExpandY | kLHintsTop | kLHintsLeft); + fMainFrame = (TGCompositeFrame *) fShutter; + + //Event Shutter + AliShutterItem *item = new AliShutterItem(fShutter,"Event",kIdsEVENT); + + item->AddPictureButton("next.xpm","Show next event",kIdbNextEVENT); + item->AddPictureButton("prev.xpm","Show previous event",kIdbPrevEVENT); + + //View Shutter + item = new AliShutterItem(fShutter,"View",kIdsVIEW); + item->AddPictureButton("top.xpm","Top view",kIdbTOPVIEW); + item->AddPictureButton("side.xpm","Side view",kIdbSIDEVIEW); + item->AddPictureButton("front.xpm","Front view",kIdbFRONTVIEW); + item->AddPictureButton("four.xpm","Four views",kIdbALLVIEW); + + //Detector Shutter + item = new AliShutterItem(fShutter,"Detectors",kIdsDETECTORS); + TGCompositeFrame *frame = item->GetShutterItemFrame(); + fDetectorFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsLeft| kLHintsExpandX | kLHintsCenterX,5,5,5,5); + fDetectorFrame = new AliDetectorFrame(frame,200,200,item->GetShutterItem()->GetDefaultFrameBackground()); + frame->AddFrame(fDetectorFrame->GetDetectorFrame(),fDetectorFrameLayout); + + //Options Shutter + item = new AliShutterItem(fShutter,"Options",kIdsOPTIONS); + item->AddCheckButton("Display Hits",kIdbCheckHITS); + item->AddCheckButton("Display Clusters",kIdbCheckCLUSTERS); + item->AddCheckButton("Display HLT Clusters",kIdbCheckHLT); + // item->AddCheckButton("Display Tracks",kIdbCheckTRACKS); + + fMainFrame->Resize(150,h); +} + +//_____________________________________________________________ +AliShutterFrame::~AliShutterFrame(void) +{ + delete fLayout; + delete fShutter; + delete fMainFrame; + delete fDetectorFrame; + delete fDetectorFrameLayout; +} + + +ClassImp(AliDisplayFrame); + +//_____________________________________________________________ +AliDisplayFrame::AliDisplayFrame(const TGWindow *p, UInt_t w, UInt_t h) +{ + fClipMin=-20; + fClipMax=20; + fPreviousW=0; + fPreviousH=0; + fRange = 500; + fPolyMarkers = new TObjArray(1000); + + fMainFrame = new TGCompositeFrame(p,w,h); + fMainTab = new TGTab(fMainFrame, w, h); + TGCompositeFrame *fFrame1 = fMainTab->AddTab("Main View"); + fMainEmbeddedCanvas = new TRootEmbeddedCanvas("Main12",fFrame1,w,h,kFixedWidth); + fFrame1->AddFrame(fMainEmbeddedCanvas,new TGLayoutHints( kLHintsTop | kLHintsLeft|kLHintsExpandX| kLHintsExpandY, 0, 0, 0, 0)); + fMainCanvas = fMainEmbeddedCanvas->GetCanvas(); + fMainCanvas->SetFillColor(1); + fMainCanvas->SetBorderMode(0); + fMainCanvas->cd(); + fMainCanvas->SetFixedAspectRatio(); + fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliDisplayFrame",this,"ExecuteEvent(Int_t,Int_t,Int_t,TObject*)"); + //fView = new TView(1); + //DoView(kIdbFRONTVIEW); + + gAliDisplay2->SetCurrentView(kIdbFRONTVIEW); + + TGCompositeFrame *fFrame2 = fMainTab->AddTab("No detector"); + fSelectionEmbeddedCanvas = new TRootEmbeddedCanvas("Selection",fFrame2,w,h); + fSelectionCanvas = fSelectionEmbeddedCanvas->GetCanvas(); + fSelectionCanvas->SetFillColor(1); + fSelectionCanvas->SetBorderMode(0); + fSelectionCanvas->cd(); + fFrame2->AddFrame(fSelectionEmbeddedCanvas,new TGLayoutHints( kLHintsTop | kLHintsLeft|kLHintsExpandX| kLHintsExpandY, 0, 0, 0, 0)); + fMainFrame->AddFrame(fMainTab,new TGLayoutHints( kLHintsTop | kLHintsLeft|kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); + fAllViews = kFALSE; + fMainFrame->MapSubwindows(); + fMainFrame->MapWindow(); +} + +//_____________________________________________________________ +AliDisplayFrame::~AliDisplayFrame(void) +{ + delete fMainTab; + delete fSelectionEmbeddedCanvas; + delete fMainEmbeddedCanvas; + delete fFrame1; + delete fFrame2; + delete fMainCanvas; + delete fSelectionCanvas; + delete fPoints2; + delete fPoints; + delete fModules; + delete fMainFrame; + delete [] fActivePoints; + delete [] fClustersPos; +} + +//_____________________________________________________________ +void AliDisplayFrame::DoView(Int_t view) +{ + Int_t x,y; + char vname[16]; + y=fMainFrame->GetDefaultHeight(); + x=fMainFrame->GetDefaultWidth(); + gAliDisplay2->SetCurrentView(view); + switch(view){ + case kIdbALLVIEW:{ + fAllViews=kTRUE; + strcpy(vname,"All views"); + fMainCanvas->cd(); + gPad->Clear(); + fMainCanvas->SetFillColor(15); + fMainCanvas->Divide(2,2,0.005,0.005,1); + + fMainCanvas->cd(1); + Draw(30,30,0); + + gAliDisplay2->SetCurrentView(kIdbTOPVIEW); + fMainCanvas->cd(2); + Draw(90,-90,90); + + gAliDisplay2->SetCurrentView(kIdbSIDEVIEW); + fMainCanvas->cd(3); + Draw(90,0,-90); + + gAliDisplay2->SetCurrentView(kIdbFRONTVIEW); + fMainCanvas->cd(4); + Draw(0,-90,0); + + //fMainCanvas->cd(); + + } + break; + case kIdbTOPVIEW:{ + strcpy(vname,"Top view "); + fAllViews=kFALSE; + fMainCanvas->cd(); + gPad->SetFillColor(1); + gPad->Clear(); + gPad->Draw(); + Draw(90,-90,90); + } + break; + case kIdbSIDEVIEW:{ + strcpy(vname,"Side view"); + fAllViews=kFALSE; + fMainCanvas->cd(); + gPad->SetFillColor(1); + gPad->Clear(); + gPad->Draw(); + Draw(90,0,-90); + } + break; + case kIdbFRONTVIEW:{ + strcpy(vname,"Front view"); + fAllViews=kFALSE; + fMainCanvas->cd(); + gPad->SetFillColor(1); + gPad->Clear(); + gPad->Draw(); + + Draw(0,-90,0); + } + break; + default: break; + } + (fMainTab->GetTabTab(0))->SetText(new TGString(vname)); +} + +//_____________________________________________________________ +void AliDisplayFrame::DrawDetector(const char *name) +{ + (fMainTab->GetTabTab(1))->SetText(new TGString(name)); +} + +//_____________________________________________________________ +void AliDisplayFrame::EnableDetector(const char *name) +{ + AliModule *module = dynamic_cast(gAlice->Modules()->FindObject(name)); + if(!module) return; + gAliDisplay2->GetModuleInfo()->Enable((char*)name); + module->Enable(); +} + +//_____________________________________________________________ +void AliDisplayFrame::DisableDetector(const char *name) +{ + AliModule *module = dynamic_cast(gAlice->Modules()->FindObject(name)); + if(!module) return; + gAliDisplay2->GetModuleInfo()->Disable((char*)name); + module->Disable(); +} + +//_____________________________________________________________ +void AliDisplayFrame::Draw(Float_t theta, Float_t phi, Float_t psi) +{ + //clock_t t1,t2; + time_t t1,t2; + //t1 = clock(); + TStopwatch timer; + timer.Start(); + time(&t1); + gPad->SetCursor(kWatch); + gPad->SetEditable(kTRUE); + gPad->SetFillColor(1); + gPad->Clear(); + + Int_t iret; + + TView *view = new TView(1); + TGDimension dim=((TGCanvas*)fMainEmbeddedCanvas)->GetViewPort()->GetDefaultSize(); + Float_t aspectRatio = dim.fWidth/(Float_t) dim.fHeight; + //printf("Dimension %d %d",dim.fWidth,dim.fHeight); + if(gAliDisplay2->GetCurrentView()==kIdbFRONTVIEW){ + view->SetRange(-fRange*aspectRatio,-fRange,-fRange,fRange*aspectRatio,fRange,fRange); + } + if(gAliDisplay2->GetCurrentView()==kIdbTOPVIEW){ + view->SetRange(-fRange,-fRange,-fRange*aspectRatio,fRange,fRange,fRange*aspectRatio); + } + if(gAliDisplay2->GetCurrentView()==kIdbSIDEVIEW){ + view->SetRange(-fRange,-fRange,-fRange*aspectRatio,fRange,fRange,fRange*aspectRatio); + } + + gAlice->GetGeometry()->Draw("same"); + if(gAliDisplay2->IsEnabled(kHits)) DrawHits(); + if(gAliDisplay2->IsEnabled(kClusters)) fClusters->Draw(); + if(gAliDisplay2->IsEnabled(kHLT)) fHLT->Draw(); + + gAliDisplay2->AppendPad(); + view->SetView(phi,theta,psi,iret); + + view->ZoomView(gPad,gAliDisplay2->GetZoomFactor()); + //t2 = clock(); + time(&t2); + // printf("\nDrawn in....%f sec", ((double)t2-t1)/(10000*CLK_TCK)); + printf("\nDrawn in....%2lf sec", difftime(t2,t1)); + timer.Stop(); + timer.Print("m"); +} + +//_____________________________________________________________ +void AliDisplayFrame::DrawHits() +{ + AliPoints *p; + if(!fPoints2) return; + for(Int_t i=0;iGetEntries();i++){ + if(fActivePoints[i]){ + p=dynamic_cast(fPoints2->UncheckedAt(i)); + if(!p) continue; + p->Draw(); + } + } +} + +//_____________________________________________________________ +void AliDisplayFrame::LoadEnabledModules() +{ + clock_t t1,t2; + t1=clock(); + TIter next(gAlice->Modules()); + AliModule *module; + fModules = new TObjArray(0,32); + while((module = dynamic_cast (next()))){ + if(!module) continue; + if(!module->IsActive()) continue; + fModules->AddLast(module); + } + t2=clock(); + fNbModules = fModules->GetEntriesFast(); + // printf("\nModules loaded in.....%f sec", ((double)t2-t1)/(10000*CLK_TCK)); +} + +//_____________________________________________________________ +void AliDisplayFrame::LoadClusters(Int_t nevent) +{ + fClusters = new AliDisplayClusters(); + fClusters->LoadClusters("ITS TPC",nevent); +} + +//_____________________________________________________________ +void AliDisplayFrame::LoadHLTClusters(Int_t nevent) +{ + fHLT = new AliDisplayHLT(); + fHLT->LoadHLT("TPC",nevent); +} + +//_____________________________________________________________ +void AliDisplayFrame::LoadHits() +{ + clock_t t1,t2; + + t1=clock(); + fPoints2 = new TObjArray(0,1000); + AliModule *module; + TObjArray *points; + for(Int_t i=0;i(fModules->UncheckedAt(i)); + if(!module) continue; + points = module->Points(); + if(!points) { + continue; + } + for(Int_t j=0;jGetEntriesFast();j++){ + if(!points->UncheckedAt(j)) continue; + fPoints2->AddLast((points->UncheckedAt(j))); + } + } + fActivePoints = new Bool_t[fPoints2->GetEntries()]; + for(Int_t k=0;kGetEntriesFast();k++){ + fActivePoints[k]=kTRUE; + } + printf("\n nb hits %d",fPoints2->GetEntries()); + t2=clock(); + // printf("\nPoints loaded in....%f sec", ((double)t2-t1)/(10000*CLK_TCK)); +} + +//_____________________________________________________________ +void AliDisplayFrame::ApplyCuts() +{ + clock_t t1,t2; + t1=clock(); + + Float_t *pxyz; + Float_t r,theta,eta,cutmin,cutmax,etamin,etamax,pmom,smin,smax; + Int_t nbhits=0; + AliPoints *pm; + TParticle *particle; + + //Get momentum cut + smin = gAliDisplay2->GetMomentumMin(); + smax = gAliDisplay2->GetMomentumMax(); + cutmin = 2.0*smin; + if(smax<0.98) cutmax = 2.0*smax; + else cutmax = 100000; + + //Get rapidity cut + smax = gAliDisplay2->GetRapidityMax(); + smin = gAliDisplay2->GetRapidityMin(); + //etamin = 1.5*(2*smin-1); + //etamax = 1.5*(2*smax-1); + etamin = smin; + etamax = smax; + if(smin<-1.46) etamin = -1000; + if(smax>1.46) etamax = 1000; + + + if(!fPoints2) return; + for(Int_t i=0;iGetEntries();i++){ + pm = dynamic_cast(fPoints2->UncheckedAt(i)); + if(!pm) { + fActivePoints[i]=kFALSE; + continue; + } + particle = pm->GetParticle(); + if(!particle) { + fActivePoints[i]=kFALSE; + continue; + } + pmom = particle->P(); + if(pmom < cutmin) { + fActivePoints[i]=kFALSE; + continue; + } + if(pmom > cutmax) { + fActivePoints[i]=kFALSE; + continue; + } + pxyz = pm->GetP(); + r = TMath::Sqrt(pxyz[0]*pxyz[0]+pxyz[1]*pxyz[1]); + theta = TMath::ATan2(r,TMath::Abs(pxyz[2])); + if(theta) eta = -TMath::Log(TMath::Abs(TMath::Tan(0.5*theta))); + else eta = 1e10; + if(pxyz[2] < 0) eta = -eta; + if((eta < etamin) || (eta > etamax)) { + fActivePoints[i]=kFALSE; + continue; + } + fActivePoints[i]=kTRUE; + //pm->Draw(); + nbhits += pm->GetN(); + } + gAliDisplay2->SetNbHits(nbhits); + t2=clock(); + // printf("\nCuts applied in....%f sec", ((double)t2-t1)/(10000*CLK_TCK)); + gAliDisplay2->SetNbParticles(GetNbActivePoints()); +} + +//_____________________________________________________________ +Int_t AliDisplayFrame::GetNbActivePoints() +{ + Int_t ans=0; + for(Int_t i=0;iGetEntries();i++){ + if(fActivePoints[i]) ans++; + } + return ans; +} +//_____________________________________________________________ +void AliDisplayFrame::DrawX3d() +{ + TPad *pad = dynamic_cast(gPad); + pad->cd(); + TView *view = pad->GetView(); + if(!view) return; + pad->x3d(); +} + +//_____________________________________________________________ +void AliDisplayFrame::SavePadGIF(const char *file) +{ + if(!gPad){ + printf("\nThere is no active pad"); + return; + } + gPad->SaveAs(file); +} + +//_____________________________________________________________ +void AliDisplayFrame::DrawGL() +{ + TPad *pad = dynamic_cast(gPad); + pad->cd(); + TView *view = pad->GetView(); + if(!view) return; + pad->x3d("OPENGL"); +} + +//_____________________________________________________________ +void AliDisplayFrame::ExecuteEvent(Int_t event, Int_t px,Int_t py,TObject *) +{ + static Float_t x0,y0,x1,y1; + static Int_t pxold,pyold; + static Int_t px0,py0; + static Int_t linedrawn; + Float_t temp; + + + switch(event){ + case kMouseMotion:{ + + AliPoints *p=dynamic_cast (gPad->GetSelected()); + if(p){ + gAliDisplay2->SetStatusBar(p->GetName(),1); + gAliDisplay2->SetStatusBar(p->GetDetector()->GetName(),2); + } + } + break; + default:break; + } + + if((!gAliDisplay2->GetZoomMode())&&(gPad->GetView())){ + gPad->GetView()->ExecuteRotateView(event,px,py); + return; + } + + + + if(gAliDisplay2->GetZoomMode()==kTRUE){ + switch(event){ + + case kButton1Down:{ + gVirtualX->SetLineColor(-1); + gPad->TAttLine::Modify(); + x0 = gPad->AbsPixeltoX(px); + y0 = gPad->AbsPixeltoY(py); + px0 = px; + py0 = py; + pxold = px; + pyold = py; + linedrawn = 0; + } + break; + case kButton1Motion:{ + if(linedrawn) gVirtualX->DrawBox(px0,py0,pxold,pyold,TVirtualX::kHollow); + pxold = px; + pyold = py; + linedrawn = 1; + gVirtualX->DrawBox(px0,py0,pxold,pyold,TVirtualX::kHollow); + } + break; + + case kButton1Up:{ + gPad->GetCanvas()->FeedbackMode(kFALSE); + if(px == px0) break; + if(py == py0) break; + x1 = gPad->AbsPixeltoX(px); + y1 = gPad->AbsPixeltoY(py); + if(x1SetEditable(kTRUE); + //gPad->Range(x0,y0,x1,y1); + gPad->SetEditable(kFALSE); + //gPad->Range(0.5,0.5,1,1); + //gAliDisplay2->SetZoomFactor(1); + gPad->Modified(kTRUE); + gAliDisplay2->Draw(); + gAliDisplay2->SetZoomMode(kFALSE); + gPad->SetEditable(kTRUE); + } + break; + default: break; + } + } +} + +ClassImp(AliInfoFrame); + +//_____________________________________________________________ +AliInfoFrame::AliInfoFrame(TGCompositeFrame *p, UInt_t w, UInt_t h) +{ + fMainFrame = new TGCompositeFrame(p, w, h, kVerticalFrame); + + fTitleFrame = new TGCompositeFrame(fMainFrame,w,h,kRaisedFrame|kVerticalFrame); + AddLabel("ALICE",kLHintsTop | kLHintsCenterX); + AddLabel("Event Display",kLHintsTop | kLHintsCenterX); + + TString filename=StrDup(gAliDisplay2->GetIconsPath()); + filename.Append("Alice.xpm"); + TGPicture *alicelogo = (TGPicture *) gClient->GetPicture(filename); + TGIcon *alice = new TGIcon(fTitleFrame,alicelogo,50,50); + fTitleFrame->AddFrame(alice,new TGLayoutHints(kLHintsTop | kLHintsCenterX,0,0,0,0)); + + AddLabel("Powered by",kLHintsTop | kLHintsCenterX); + AddLabel("AliRoot",kLHintsTop | kLHintsCenterX); + fMainFrame->AddFrame(fTitleFrame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,0,0,0,3)); + + //Feedback + fFiguresFrame = new TGCompositeFrame(fMainFrame,w,h,kRaisedFrame|kVerticalFrame); + TGCompositeFrame *frame = new TGCompositeFrame(fFiguresFrame,w,100, kHorizontalFrame); + fNbEventLabel = new TGLabel(frame,""); + TGLabel * label = new TGLabel(frame,"Event number"); + fNbEventLabel->SetText(gAliDisplay2->GetEventNumber()); + frame->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft ,10,0,0,0)); + frame->AddFrame(fNbEventLabel,new TGLayoutHints(kLHintsTop | kLHintsRight,5,10,0,0)); + + fFiguresFrame->AddFrame(frame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,0,0,0,0)); + + frame = new TGCompositeFrame(fFiguresFrame,w,100, kHorizontalFrame); + label = new TGLabel(frame,"Nb Particles"); + fNbParticuleLabel = new TGLabel(frame,""); + fNbParticuleLabel->SetText(gAliDisplay2->GetNbParticles()); + frame->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft,10,0,0,0)); + frame->AddFrame(fNbParticuleLabel,new TGLayoutHints(kLHintsTop | kLHintsRight,5,10,0,0)); + + fFiguresFrame->AddFrame(frame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,0,0,0,0)); + + frame = new TGCompositeFrame(fFiguresFrame,w,100, kHorizontalFrame); + label = new TGLabel(frame,"Nb Hits"); + fNbHitsLabel = new TGLabel(frame,""); + fNbHitsLabel->SetText("--"); + frame->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft,10,0,0,0)); + frame->AddFrame(fNbHitsLabel,new TGLayoutHints(kLHintsTop | kLHintsRight ,5,10,0,0)); + frame->Layout(); + fFiguresFrame->AddFrame(frame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,0,0,0,0)); + + frame = new TGCompositeFrame(fFiguresFrame,w,100, kHorizontalFrame); + label = new TGLabel(frame,"Nb Clusters"); + fNbClustersLabel = new TGLabel(frame,""); + fNbClustersLabel->SetText("--"); + frame->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft,10,0,0,0)); + frame->AddFrame(fNbClustersLabel,new TGLayoutHints(kLHintsTop | kLHintsRight ,5,10,0,0)); + frame->Layout(); + fFiguresFrame->AddFrame(frame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,0,0,0,0)); + fMainFrame->AddFrame(fFiguresFrame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,0,0,2,0)); + + fMainFrame->Layout(); + fMainFrame->MapSubwindows(); + fMainFrame->MapWindow(); +}; + +//_____________________________________________________________ +AliInfoFrame::~AliInfoFrame(void){ + + delete fMainFrame; + delete fTitleFrame; + delete fFiguresFrame; + delete fNbParticuleLabel; + delete fNbEventLabel; + delete fNbHitsLabel; +} + +//_____________________________________________________________ +void AliInfoFrame::AddLabel(char *text, UInt_t options){ + TGLabel * label = new TGLabel(fTitleFrame,text); + fTitleFrame->AddFrame(label,new TGLayoutHints(options,0,0,0,0)); +} + +//_____________________________________________________________ +void AliInfoFrame::Update() +{ + fNbParticuleLabel->SetText(gAliDisplay2->GetNbParticles()); + fNbEventLabel->SetText(gAliDisplay2->GetEventNumber()); + if(gAliDisplay2->IsEnabled(kHits))fNbHitsLabel->SetText(gAliDisplay2->GetNbHits()); + else fNbHitsLabel->SetText("--"); + if(gAliDisplay2->IsEnabled(kClusters))fNbClustersLabel->SetText(gAliDisplay2->GetNbClusters()); + else fNbClustersLabel->SetText("--"); + fMainFrame->Layout(); +} + + +ClassImp(AliSettingFrame); + +//_____________________________________________________________ +AliSettingFrame::AliSettingFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h) + :TGTransientFrame(p,main,w,h) +{ + fMainFrame = new TGCompositeFrame((TGWindow *)((TGTransientFrame *)this),w,h,kVerticalFrame); + + fZoomStepFrame = new TGCompositeFrame(fMainFrame,w,50,kHorizontalFrame); + fZoomStepLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft |kLHintsExpandX,5,5,5,5); + fZoomStepEntry = new TGNumberEntryField(fZoomStepFrame,kIdtZoomSTEP,gAliDisplay2->GetZoomStep()); + fZoomStepEntry->Connect("ReturnPressed()","AliSettingFrame",this,"DoSettings(Int_t)"); + fZoomStepLabel = new TGLabel(fZoomStepFrame,"Zoom step"); + fZoomStepFrame->AddFrame(fZoomStepLabel,new TGLayoutHints(kLHintsTop | kLHintsLeft,0,0,0,0)); + fZoomStepFrame->AddFrame(fZoomStepEntry,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX ,5,5,0,0)); + fMainFrame->AddFrame(fZoomStepFrame,fZoomStepLayout); + + fSliderStepFrame = new TGCompositeFrame(fMainFrame,w,50,kHorizontalFrame); + fSliderStepLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft |kLHintsExpandX,5,5,5,5); + fSliderStepEntry = new TGNumberEntryField(fSliderStepFrame,kIdtSliderSTEP,gAliDisplay2->GetSliderStep()); + fSliderStepEntry->Connect("ReturnPressed()","AliSettingFrame",this,"DoSettings(Int_t)"); + fSliderStepLabel = new TGLabel(fSliderStepFrame,"Slider step"); + fSliderStepFrame->AddFrame(fSliderStepLabel,new TGLayoutHints(kLHintsTop | kLHintsLeft,0,0,0,0)); + fSliderStepFrame->AddFrame(fSliderStepEntry,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX ,5,5,0,0)); + fMainFrame->AddFrame(fSliderStepFrame,fSliderStepLayout); + + fSliderUpdateFrame = new TGCompositeFrame(fMainFrame,w,50,kHorizontalFrame); + fSliderUpdateLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft |kLHintsExpandX,5,5,5,5); + fSliderUpdateButton = new TGCheckButton(fSliderUpdateFrame,"Update display on slider move",kIdtSliderUPDATE); + fSliderUpdateButton->Connect("Clicked()","AliSettingFrame",this,"DoSettings(Int_t)"); + fIsLoading = kTRUE; + if(gAliDisplay2->GetSliderUpdate()) fSliderUpdateButton->SetState(kButtonDown); + else fSliderUpdateButton->SetState(kButtonUp); + fIsLoading = kFALSE; + + fSliderUpdateFrame->AddFrame(fSliderUpdateButton,new TGLayoutHints(kLHintsTop | kLHintsLeft,0,0,0,0)); + fMainFrame->AddFrame(fSliderUpdateFrame,fSliderUpdateLayout); + + AddFrame(fMainFrame,new TGLayoutHints(kLHintsTop | kLHintsLeft |kLHintsExpandX,0,0,0,0)); + fMainFrame->Layout(); + // position relative to the parent's window + Window_t wdum; + int ax, ay; + gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(), + (Int_t)(((TGFrame *) main)->GetWidth() - GetWidth()) >> 1, + (Int_t)(((TGFrame *) main)->GetHeight() - GetHeight()) >> 1, + ax, ay, wdum); + Move(ax, ay); + + SetWindowName("Setting frame"); + MapSubwindows(); + MapWindow(); + Layout(); +} + +//_____________________________________________________________ +AliSettingFrame::~AliSettingFrame() +{ + delete fZoomStepLayout; + delete fZoomStepEntry; + delete fZoomStepLabel; + delete fSliderStepLayout; + delete fSliderStepEntry; + delete fSliderStepLabel; + + delete fSliderUpdateLayout; + delete fSliderUpdateButton; + + delete fMainFrame; + delete fZoomStepFrame; + delete fSliderUpdateFrame; + delete fSliderStepLayout; +} + +//_____________________________________________________________ +void AliSettingFrame::DoSettings(Int_t /*pos*/) +{ + TGNumberEntryField *ne = (TGNumberEntryField *) gTQSender; + int id = ne->WidgetId(); + switch(id){ + case kIdtZoomSTEP:{ + gAliDisplay2->SetZoomStep(ne->GetNumber()); + } + break; + case kIdtSliderSTEP:{ + gAliDisplay2->SetSliderStep(ne->GetNumber()); + } + break; + case kIdtSliderUPDATE:{ + if(fIsLoading) return ; + if(gAliDisplay2->GetSliderUpdate()) gAliDisplay2->SetSliderUpdate(kFALSE); + else gAliDisplay2->SetSliderUpdate(kTRUE); + } + break; + default: break; + } +} + + +ClassImp(AliMenu); + +//_____________________________________________________________ +AliMenu::AliMenu(TGCompositeFrame *p, UInt_t w, UInt_t h, UInt_t options) +{ + fMenuBar = new TGMenuBar(p,w,h,options); + fToolBar = new TGToolBar(p,60,20,options); + + fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsLeft ,0,0,0,0); + fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft,0,4,0,0); + + fMenuFile = new TGPopupMenu(gClient->GetRoot()); + fMenuFile->AddEntry("Open",kIdmOPEN); + fMenuFile->AddEntry("Save as",kIdmSAVEAS); + fMenuFile->AddEntry("Close",kIdmCLOSE); + fMenuFile->AddSeparator(); + fMenuFile->AddEntry("Print",kIdmPRINT); + fMenuFile->AddEntry("Print setup",kIdmPRINTSETUP); + fMenuFile->AddSeparator(); + fMenuFile->AddEntry("Exit",kIdmEXIT); + fMenuFile->DisableEntry(kIdmSAVEAS); + fMenuFile->Associate(p); + fMenuBar->AddPopup("File",fMenuFile,fMenuBarItemLayout); + fMenuFile->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)"); + + fMenuOptions = new TGPopupMenu(gClient->GetRoot()); + fMenuOptions->AddEntry("Settings",kIdmSETTINGS); + fMenuOptions->AddEntry("Save settings",kIdmSAVESETTINGS); + fMenuOptions->Associate(p); + fMenuBar->AddPopup("Options",fMenuOptions,fMenuBarItemLayout); + fMenuOptions->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)"); + + fMenuView = new TGPopupMenu(gClient->GetRoot()); + fMenuView->AddEntry("X3d ",kIdmVIEWX3D); + fMenuView->AddEntry("OpenGL",kIdmVIEWGL); + fMenuView->Associate(p); + fMenuBar->AddPopup("View",fMenuView,fMenuBarItemLayout); + fMenuView->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)"); + + fMenuHelp = new TGPopupMenu(gClient->GetRoot()); + fMenuHelp->AddEntry("Help",kIdmHELP); + fMenuHelp->AddSeparator(); + fMenuHelp->AddEntry("About",kIdmABOUT); + fMenuHelp->Associate(p); + fMenuBar->AddPopup("Help",fMenuHelp,fMenuBarItemLayout); + fMenuHelp->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)"); + + p->AddFrame(fMenuBar,fMenuBarLayout); + fTBD = new ToolBarData_t; + + fToolBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX,0,0,0,0); + AddPictureButton("open.xpm","Open file",kIdmOPEN,5); + AddPictureButton("save.xpm","Save current pad as gif file",kIdmSAVEAS,0); + AddPictureButton("settings.xpm","Settings",kIdmSETTINGS,5); + AddPictureButton("help.xpm","Help",kIdmHELP,5); + AddPictureButton("quit.xpm","Exit AliDisplay",kIdmEXIT,5); + AddPictureButton("opengl.xpm","Open GL view",kIdmVIEWGL,5); + AddPictureButton("x3d.xpm","x3d view",kIdmVIEWX3D,0); + AddPictureButton("zoomplus16.xpm","Zoom in",kIdbZoomIN,5); + AddPictureButton("zoommoins16.xpm","Zoom out",kIdbZoomOUT,0); + AddPictureButton("zoomzone.xpm","Zoom on zone",kIdbZoomZONE,0); + p->AddFrame(fToolBar,fToolBarLayout); +} + +//_____________________________________________________________ +AliMenu::~AliMenu() +{ + delete fMenuBarLayout; + delete fMenuBarItemLayout; + delete fMenuFile; + delete fMenuOptions; + delete fMenuView; + delete fMenuHelp; + delete fToolBarLayout; + delete fToolBar; + delete fMenuBar; + delete fTBD; +} + +//_____________________________________________________________ +void AliMenu::DoMenu(Int_t id) +{ + switch(id){ + case kIdmOPEN:{ + TGFileInfo fi; + static TString dir("."); + fi.fFileTypes = filetypes; + fi.fIniDir = StrDup(dir.Data()); + new TGFileDialog(gClient->GetRoot(),gAliDisplay2->GetMainFrame(),kFDOpen,&fi); + if(!fi.fFilename) return; + } + break; + case kIdmEXIT:{ + gApplication->Terminate(0); + } + break; + case kIdmSAVEAS:{ + TGFileInfo fi; + static TString dir("."); + fi.fFileTypes = imgtypes; + fi.fIniDir = StrDup(dir.Data()); + new TGFileDialog(gClient->GetRoot(),gAliDisplay2->GetMainFrame(),kFDSave,&fi); + if(!fi.fFilename) return; + gAliDisplay2->SavePadGIF(fi.fFilename); + } + break; + case kIdmSETTINGS:{ + new AliSettingFrame((TGWindow *)gClient->GetRoot(),(TGWindow *)gAliDisplay2->GetMainFrame(),200,150); + } + break; + case kIdmHELP:{ + TRootHelpDialog *hd=new TRootHelpDialog((TGWindow *)gClient->GetRoot(),"Help",300,300); + hd->SetText(helpTxt); + hd->Popup(); + } + break; + + case kIdmSAVESETTINGS:{ + gAliDisplay2->DoSaveSettings(); + } + break; + case kIdmVIEWX3D:{ + gAliDisplay2->DrawX3d(); + } + break; + case kIdmVIEWGL:{ + gAliDisplay2->DrawGL(); + } + break; + case kIdbZoomIN:{ + gAliDisplay2->SetZoomFactor(gAliDisplay2->GetZoomFactor()*gAliDisplay2->GetZoomStep()); + gAliDisplay2->Draw(); + } + break; + case kIdbZoomZONE:{ + gAliDisplay2->SetZoomMode(kTRUE); + gAliDisplay2->SetEditable(kFALSE); + } + break; + case kIdbZoomOUT:{ + gAliDisplay2->SetZoomFactor(gAliDisplay2->GetZoomFactor()/gAliDisplay2->GetZoomStep()); + gAliDisplay2->Draw(); + } + break; + default:break; + } +} + +//_____________________________________________________________ +void AliMenu::DoToolBar(Int_t /*id*/) +{ + TGFrame *frame = (TGFrame *) gTQSender; + TGButton *bu = (TGButton *) frame; + DoMenu(bu->WidgetId()); +} + +//_____________________________________________________________ +void AliMenu::AddPictureButton(char *fname,char *tiptext,UInt_t id, UInt_t spacing) +{ + TString filename = StrDup(gAliDisplay2->GetIconsPath()); + filename.Append(fname); + + fTBD->fPixmap=filename.Data(); + fTBD->fTipText = tiptext; + fTBD->fId = id; + fTBD->fStayDown = kFALSE; + + fToolBar->AddButton(fToolBar,fTBD,spacing); + if(fTBD->fButton) + fTBD->fButton->Connect("Clicked()","AliMenu",this,"DoToolBar(Int_t)"); +} + +ClassImp(AliDisplay2); +//_____________________________________________________________ +AliDisplay2::AliDisplay2(const TGWindow *p, UInt_t w, UInt_t h) + :TObject() +{ + //gAlice->SetDisplay(this); + gAliDisplay2=this; + fSliderUpdate = kFALSE; + fZoomMode = kFALSE; + fZoomStep = 1.2; + fZoomFactor = 1.5; + fNbParticles = 0; + fEventNumber = 0; + fNbHits = 0; + fSliderStep = 0.01; + fClustersLoaded = kFALSE; + fHitsLoaded = kFALSE; + fHLTLoaded = kFALSE; + fTracksLoaded = kFALSE; + fMode =0; + FindModules(); + + fIconsPath = new char[32]; + strcpy(fIconsPath,gSystem->Getenv("ALICE_ROOT")); + strcat(fIconsPath,"/DISPLAY/icons/"); + LoadFromRC(); + fMainFrame = new TGMainFrame(p,w,h,kVerticalFrame); + fSubFrame = new TGCompositeFrame(fMainFrame,w,h,kHorizontalFrame); + fLeftFrame = new TGCompositeFrame(fSubFrame,150,h,kVerticalFrame|kFixedWidth); + fRightFrame = new TGCompositeFrame(fSubFrame,600,h,kVerticalFrame); + //fMainFrame->Connect("ProcessedEvent(Event_t*)", "AliDisplay2", this,"HandleMouseWheel(Event_t*)"); + fMainFrame->Connect("ProcessedEvent(Event_t*)", "AliDisplay2",this,"HandleResize(Event_t*)"); + //MenuBar + fMenu = new AliMenu(fMainFrame,1,1,kRaisedFrame|kHorizontalFrame); + + //Slider Frame + fSliderFrameLayout = new TGLayoutHints( kLHintsBottom| kLHintsRight| kLHintsExpandX | kLHintsCenterX, 2, 2, 2, 2); + fSliderFrame = new AliSliderFrame(fRightFrame,600,150); + fRightFrame->AddFrame(fSliderFrame->GetSliderFrame(),fSliderFrameLayout); + + //Info Frame + fInfoFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX ,0,0,0,0); + fInfoFrame = new AliInfoFrame(fLeftFrame,150,200); + fLeftFrame->AddFrame(fInfoFrame->GetInfoFrame(),fInfoFrameLayout); + + + //Shutter Frame + fShutterFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandY |kLHintsExpandX, 0, 0, 5, 0); + fShutterFrame = new AliShutterFrame(fLeftFrame,150,300); + fLeftFrame->AddFrame(fShutterFrame->GetShutterFrame(),fShutterFrameLayout); + + //Display Frame + fDisplayFrameLayout = new TGLayoutHints( kLHintsTop | kLHintsRight | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2); + fDisplayFrame = new AliDisplayFrame(fRightFrame, w-150,w-110); + fRightFrame->AddFrame(fDisplayFrame->GetDisplayFrame(),fDisplayFrameLayout); + fDisplayFrame->GetDisplayFrame()->Connect("ProcessedEvent(Event_t*)", "AliDisplay2", this,"HandleMouseWheel(Event_t*)"); + + + fLeftFrame->Layout(); + + fSubFrame->AddFrame(fLeftFrame, new TGLayoutHints( kLHintsBottom | kLHintsLeft | kLHintsExpandY, 5, 5, 2, 2)); + fSubFrame->AddFrame(fRightFrame, new TGLayoutHints( kLHintsBottom | kLHintsRight | kLHintsExpandX | kLHintsExpandY, 5, 5, 2, 2)); + + Int_t parts[] = {45,45,10}; + fStatusBar = new TGStatusBar(fMainFrame,50,10,kHorizontalFrame); + fStatusBar->SetParts(parts,3); + fStatusBar->SetText("AliDisplay v2.0",0); + fMainFrame->AddFrame(fStatusBar,new TGLayoutHints(kLHintsBottom | kLHintsExpandX,0,0,0,0)); + + fMainFrame->AddFrame(fSubFrame,new TGLayoutHints( kLHintsBottom | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 2, 2)); + fMainFrame->SetWindowName("Ali Display"); + + fMainFrame->MapSubwindows(); + fMainFrame->MapWindow(); + LoadSettings(); + + + fMainFrame->Resize(w-10,h); + fMainFrame->Resize(w,h); + fMainFrame->SetWMSizeHints(500,500,1280, 1200,1,1); +} + +//_____________________________________________________________ +AliDisplay2::~AliDisplay2(void) +{ + delete fModules; + delete [] fEnabledModules; + delete fModuleInfo; + + delete fSliderFrameLayout; + delete fSliderFrame; + delete fDisplayFrameLayout; + delete fDisplayFrame; + // delete fZoomFrameLayout; + // delete fZoomFrame; + delete fShutterFrameLayout; + delete fShutterFrame; + delete fInfoFrameLayout; + delete fInfoFrame; + delete fDetectorFrameLayout; + delete fDetectorFrame; + + delete fSubFrame; + delete fLeftFrame; + delete fRightFrame; + delete fMainFrame; + delete fAliDisplay2rc; + + delete fMenu; + delete fStatusBar; +} + +//_____________________________________________________________ +void AliDisplay2::CloseWindow(void) +{ + delete this; +} + +//_____________________________________________________________ +void AliDisplay2::LoadFromRC() +{ + TEnv *rc=new TEnv(".alidisplayrc"); + SetSliderUpdate(rc->GetValue("AliDisplay.SliderUpdate",kFALSE)); + SetZoomStep(rc->GetValue("AliDisplay.ZoomStep",1.2)); + SetSliderStep(rc->GetValue("AliDisplay.SliderStep",0.01)); + char c[128]; + fRawDataPath = new char[128]; + strcpy(c,gSystem->Getenv("ALICE_ROOT")); + sprintf(fRawDataPath,"%s%s",c,rc->GetValue("AliDisplay.RawDataPath","/raw")); + printf("\nRaw data path %s",fRawDataPath); +} + +//_____________________________________________________________ +void AliDisplay2::SaveToRC() +{ + TEnv *rc=new TEnv(".alidisplayrc"); + rc->SetValue("AliDisplay.SliderUpdate",GetSliderUpdate()); + rc->SetValue("AliDisplay.ZoomStep",GetZoomStep()); + rc->SetValue("AliDisplay.SliderStep",GetSliderStep()); + rc->SetValue("AliDisplay.RawDataPath","/raw"); + rc->SaveLevel(kEnvLocal); + rc->Save(); +} + +//_____________________________________________________________ +void AliDisplay2::DoSaveSettings(void) +{ + fSliderFrame->SaveToRC(); + SaveToRC(); +} + +//_____________________________________________________________ +void AliDisplay2::LoadSettings() +{ + LoadFromRC(); +} + +//_____________________________________________________________ +void AliDisplay2::Draw(Option_t */*options*/) +{ + fDisplayFrame->DoView(fCurrentView); +} + +//_____________________________________________________________ +void AliDisplay2::DrawX3d() +{ + fDisplayFrame->DrawX3d(); +} + +//_____________________________________________________________ +void AliDisplay2::DrawGL() +{ + fDisplayFrame->DrawGL(); +} + +//_____________________________________________________________ +void AliDisplay2::ShowNextEvent(Int_t delta) +{ + //Load the next event + clock_t t1,t2; + t1=clock(); + Int_t newEvent=0; + if(delta!=0){ + gAlice->Clear(); + //Int_t currentEvent = gAlice->GetHeader()->GetEvent(); + newEvent = fEventNumber + delta; + if( newEvent < 0) return; + gAlice->GetEvent(newEvent); + fEventNumber += delta; + // if(!gAlice->TreeH()) return; + } + if(IsEnabled(kHits)) LoadHits(); + if(IsEnabled(kClusters)) LoadClusters(newEvent); + if(IsEnabled(kHLT)) LoadHLTClusters(newEvent); + t2=clock(); + // printf("\nEvent loaded in....%f sec", ((double)t2-t1)/(10000*CLK_TCK)); + Update(kmMODULES); +} + +//_____________________________________________________________ +void AliDisplay2::FindModules() +{ + //Find the modules used for the simulation and assign these modules to the array fModules + fModules = new TObjArray; + TObjArray *modules = gAlice->Modules(); + AliModule *mod; + Int_t nbm = 0; + for(Int_t i=0;iGetEntriesFast();i++){ + mod = (AliModule *) modules->At(i); + if(!mod) continue; + const char *avoid = strstr("BODY MAG ABSO DIPO HALL FRAME SHIL PIPE",mod->GetName()); + if(avoid) continue; + fModules->AddLast(mod); + nbm++; + } + fEnabledModules = new Bool_t[nbm]; + fNbModules = nbm; + fModuleInfo = new AliModuleInfo(nbm); + for(Int_t j=0;jGetEntriesFast();j++){ + fModuleInfo->Add(fModules->At(j)->GetName(),j); + fEnabledModules[j]=kTRUE; + } +} + +//_____________________________________________________________ +void AliDisplay2::LoadHits() +{ + //Load the detected hits from each detector to memory + gAlice->ResetPoints(); + TIter next(gAlice->Modules()); + AliModule *module; + Int_t ntracks = gAlice->GetMCApp()->GetNtrack(); + while((module = (AliModule*)next())) + { + AliDetector* detector = dynamic_cast(module); + if(detector) detector->SetTreeAddress(); + } + next.Reset(); + for (Int_t track=0; trackResetHits(); + while((module = (AliModule*)next())) { + AliDetector* detector = dynamic_cast(module); + if(detector) + { + detector->TreeH()->GetEvent(track); + detector->LoadPoints(track); + } + } + next.Reset(); + } + fHitsLoaded = kTRUE; +} + +//_____________________________________________________________ +void AliDisplay2::LoadClusters(Int_t nevent) +{ + //clock_t t1,t2; + fDisplayFrame->LoadClusters(nevent); + fClustersLoaded = kTRUE; + // printf("\nClusters loaded in....%f sec", ((double)t2-t1)/(10000*CLK_TCK)); +} + +//_____________________________________________________________ +void AliDisplay2::LoadHLTClusters(Int_t nevent) +{ + fDisplayFrame->LoadHLTClusters(nevent); + fHLTLoaded = kTRUE; +} + +//_____________________________________________________________ +void AliDisplay2::Enable(Int_t m) +{ + if(m==kHits){ + if((fMode&kHits)==kHits) return; + fMode = kHits|fMode; + if(!fHitsLoaded) LoadHits(); + Update(kmPOINTS); + } + if(m==kClusters){ + if((fMode&kClusters)==kClusters) return; + fMode = kClusters|fMode; + if(!fClustersLoaded) LoadClusters(fEventNumber); + Update(); + } + if(m==kHLT){ + if((fMode&kHLT)==kHLT) return; + fMode = kHLT|fMode; + if(!fHLTLoaded) { + LoadHLTClusters(fEventNumber); + } + Update(); + } + if(m==kTracks){ + if((fMode&kTracks)==kTracks) return; + fMode = kTracks|fMode; + Update(); + } +}; + +//_____________________________________________________________ +void AliDisplay2::Disable(Int_t m) +{ + if(m==kHits){ + fMode = fMode|kHits; + fMode = fMode^kHits; + } + if(m==kClusters){ + fMode = fMode|kClusters; + fMode = fMode^kClusters; + } + if(m==kHLT){ + fMode = fMode|kHLT; + fMode = fMode^kHLT; + } + if(m==kTracks){ + fMode = fMode|kTracks; + fMode = fMode^kTracks; + } + Update(); +} + +//_____________________________________________________________ +Bool_t AliDisplay2::IsEnabled(Int_t m) +{ + if(m==kHits){ + if((fMode&kHits)==kHits) return kTRUE; + return kFALSE; + } + if(m==kClusters){ + if((fMode&kClusters)==kClusters) return kTRUE; + return kFALSE; + } + if(m==kHLT){ + if((fMode&kHLT)==kHLT) return kTRUE; + return kFALSE; + } + if(m==kTracks){ + if((fMode&kTracks)==kTracks) return kTRUE; + return kFALSE; + } + return kFALSE; +} + +//_____________________________________________________________ +void AliDisplay2::HandleMouseWheel(Event_t *event) +{ + if(event->fType != kButtonPress && event->fType != kButtonRelease) return; + + if(event->fCode == kButton4){ + fZoomFactor *= fZoomStep; + Draw(); + } + + if(event->fCode == kButton5){ + fZoomFactor /= fZoomStep; + Draw(); + } +} + +//_____________________________________________________________ +void AliDisplay2::HandleResize(Event_t *event) +{ + switch(event->fType){ + case kConfigureNotify:{ + Draw(); + } + break; + default:break; + } +} + +//_____________________________________________________________ +void AliDisplay2::Update(Int_t tag) +{ + if(tag==kmMODULES){ + LoadEnabledModules(); + if(((fMode)&kHits)==kHits){ + LoadEnabledHits(); + ApplyCuts(); + } + } + if(tag==kmCUTS){ + if(((fMode)&kHits)==kHits)ApplyCuts(); + } + if(tag==kmPOINTS){ + if(((fMode)&kHits)==kHits){ + LoadEnabledHits(); + ApplyCuts(); + } + } + Draw(); + fInfoFrame->Update(); +} + + diff --git a/DISPLAY/AliDisplay2.h b/DISPLAY/AliDisplay2.h new file mode 100644 index 00000000000..30cfa7df136 --- /dev/null +++ b/DISPLAY/AliDisplay2.h @@ -0,0 +1,649 @@ +/* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +///////////////////////////////////////////////////////////////////////// +// ALICE EVENT DISPLAY CLASS // +// Author: Mayeul ROUSSELET // +// e-mail: Mayeul.Rousselet@cern.ch // +// Last update:26/08/2003 // +///////////////////////////////////////////////////////////////////////// + +#ifndef AliDISPLAY2_H +#define AliDISPLAY2_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class TGButton; +class TGMenu; +class TGMenuBar; +class TGPopupMenu; +class TGPopupMenu; +class TGPopupMenu; +class TGTab; +class TGLayoutHints; +class TObjArray; +class TPolyMarker3D; +class TGNumberEntry; +class TGNumberEntryField; +class TGCheckButton; +class TGTextButton; +class TGShutter; +class TGShutterItem; +class TGWindow; +class TEnv; +class TGLabel; +class TCanvas; + +enum AliDisplay2Id { + kIdsVIEW, //id of the view shutter + kIdbSIDEVIEW, //id of sideview button + kIdbTOPVIEW, + kIdbFRONTVIEW, + kIdbALLVIEW, + + kIdsEVENT, + kIdbPrevEVENT, + kIdbNextEVENT, + + kIdbZoomIN, + kIdbZoomOUT, + kIdbZoomZONE, + + kIdiNBPARTICULES, + kIdiNBEVENTS, + + kIdsRAPIDITY, + kIdsMOMENTUM, + kIdsOPTIONS, + + kIdsMomentumMIN, + kIdsMomentumMAX, + kIdsRapidityMIN, + kIdsRapidityMAX, + + kIdbSelectALL, + kIdbSelectINVERT, + + kIdsDETECTORS, + kIdbCheckTPC, + kIdbCheckMUON, + kIdbCheckTOF, + kIdbCheckTRD, + kIdbCheckPHOS, + kIdbCheckVZERO, + kIdbCheckEMCAL, + kIdbCheckSTART, + kIdbCheckPMD, + kIdbCheckFMD, + kIdbCheckZDC, + kIdbCheckRICH, + kIdbCheckITS, + + kIdbCheckHITS, + kIdbCheckCLUSTERS, + kIdbCheckHLT, + kIdbCheckTRACKS, + + kIdmOPEN, + kIdmSAVEAS, + kIdmCLOSE, + kIdmPRINT, + kIdmPRINTSETUP, + kIdmEXIT, + kIdmSETTINGS, + kIdmSAVESETTINGS, + kIdmHELP, + kIdmABOUT, + kIdmVIEWX3D, + kIdmVIEWGL, + + kIdtZoomSTEP, + kIdtSliderSTEP, + kIdtSliderUPDATE, + + kmCUTS, //tag for the update fucntion + kmMODULES, + kmPOINTS +}; + +const char helpTxt[] = "\tAliDisplay v2.0\n\t\tHelp\n\n\nWelcome in the AliDisplay help.\nHere is a list of useful subjects which discribes\nthe main functionnalities of the software\n \nEvent:Use the arrows to get the next or previous event\nView:Each button corresponds to a different view\nDetectors:Select the module you want to see\nOptions:Select the view mode\nSliders:Use the rapidity (or eta) slider to cut the set of hits\n\tAnd the momentum slider to cut with respect to the momentum\n"; + + +//const char *filetypes[] = {"ROOT files","*.root","All files","*",0,0}; + + +//Constants to set the display mode +const Int_t kHits = BIT(0); +const Int_t kClusters = BIT(1); +const Int_t kHLT = BIT(2); +const Int_t kTracks = BIT(3); + +//***Class ModulesInfo***// +class AliModuleInfo{ + public: + AliModuleInfo(int n); + virtual ~AliModuleInfo(); + + void SetId(char* name,Int_t id); + void Add(const char * name,Int_t i); + Int_t Id(char *name); + char* Name(Int_t id); + Bool_t IsEnabled(Int_t id); + Bool_t IsEnabled(char *name){return IsEnabled(Id(name));}; + void Disable(Int_t id); + void Disable(char* name){Disable(Id(name));}; + void Enable(Int_t id); + void Enable(char *name){Enable(Id(name));}; + void Print(); + + private: + //The purposes of this class is to link each module to its Id + char **fName; + Int_t *fId; + Bool_t *fEnabled; + Int_t fNb; + + ClassDef(AliModuleInfo,0); +}; + +//***Class DisplayCluster***// + +class AliDisplayClusters{ + //This class is an interface to the clusters data + +public: + AliDisplayClusters(); + virtual ~AliDisplayClusters(); + + void LoadClusters(char * name,Int_t nevent); + void LoadITSClusters(Int_t nevent); + void LoadTPCClusters(Int_t nevent); + void Draw(); + Int_t GetNbClusters(); + +private: + TPolyMarker3D *fPoints; //fPoints[i]=set of cluster coordinates in detector i; + Int_t fNb; + char **fName; //fName[i]=name of the detector i + + RQ_OBJECT("AliDisplayClusters") + + ClassDef(AliDisplayClusters,0); +}; + +//***class AliDisplayHLT***// + +class AliDisplayHLT{ + //This classes is an interface to the HLT data + //For the moment only for TPC, for adding modules there is two choices: + //1) add the function LoadHLT[module](Int_t) and update the function LoadHLT + //2) or inherit your class from AliDisplayHLT and overload LoadHLT + + public: + + AliDisplayHLT(); + virtual ~AliDisplayHLT(); + + virtual void LoadHLT(char *name,Int_t e);//Load L3 datas whose belong to detector name and from the event e + virtual void LoadHLTTPC(Int_t nevent); + virtual void Draw(); + + private: + TPolyMarker3D *fPoints; //fPoints[i]=set of cluster coordinates in detector i; + Int_t fNb; + char **fName; //fName[i]=name of the detector i + + ClassDef(AliDisplayHLT,0); +}; + +//***Class AliSliderFrame***// +class AliSliderFrame{ + //This class implements the cuts manager + +public: + + AliSliderFrame(const TGWindow *p, UInt_t w, UInt_t h); + virtual ~AliSliderFrame(); + + //Setters + void SetMomentumRange(Float_t min, Float_t max){fMomentumSlider->SetRange(min,max);}; + void SetRapidityRange(Float_t min, Float_t max){fRapiditySlider->SetRange(min,max);}; + + Float_t GetMomentumMax(){return fMomentumSlider->GetMaxPosition();}; + Float_t GetMomentumMin(){return fMomentumSlider->GetMinPosition();}; + Float_t GetRapidityMax(){return fRapiditySlider->GetMaxPosition();}; + Float_t GetRapidityMin(){return fRapiditySlider->GetMinPosition();}; + TGCompositeFrame* GetSliderFrame(){return fMainFrame;}; + + //Slots + void CloseWindow(); + void DoSlider(Int_t pos=0); + void DoField(Long_t pos=0); + void DoReleased(Int_t pos=0); + void DoPositionChanged(Int_t pos=0); + + //I/O + void SaveToRC(); + void LoadFromRC(); + +private: + + TGCompositeFrame *fMainFrame; + TGCompositeFrame *fMomentumFrame; + TGCompositeFrame *fRapidityFrame; + TGLayoutHints *fLayout;//Layout of the frame + TGLayoutHints *fMomentumLayout; + TGLayoutHints *fRapidityLayout; + TGDoubleHSlider *fMomentumSlider; + TGDoubleHSlider *fRapiditySlider; + TGLabel *fMomentumLabel; + TGLabel *fRapidityLabel; + TGNumberEntry *fMomentumMaxValue; + TGNumberEntry *fMomentumMinValue; + TGNumberEntry *fRapidityMaxValue; + TGNumberEntry *fRapidityMinValue; + + RQ_OBJECT("AliSliderFrame") + + ClassDef(AliSliderFrame,0); +}; + +//***Class AliDetectorFrame***// +class AliDetectorFrame{ + //This classe implements the frame which contains the list of enabled detectors + //and allows the user to change the current status of the detector (enabled/disabled) + +public: + + AliDetectorFrame(const TGWindow *p, Int_t w, Int_t h,UInt_t bgc); + virtual ~AliDetectorFrame(); + + TGCompositeFrame* GetDetectorFrame(){return fMainFrame;}; + + //Slots + void DoButton(Int_t pos=0); + void DoCheckButton(Int_t pos=0); + void DoSpecific(); + +private: + + TGCompositeFrame *fMainFrame; + TGCompositeFrame *fButtonFrame; + TGCheckButton **fCheckButton; + TGTextButton *fButtonAll; + TGTextButton *fButtonInvert; + Bool_t *fCheckedButton; //fEnabledButton[i]=kTRUE if button checked + Int_t *fCheckButtonId; + Bool_t fCheckedMode; + static int fgBaseId; + + RQ_OBJECT("AliDetectorFrame") + + ClassDef(AliDetectorFrame,0); +}; + +//***Class AliShutterItem**// +class AliShutterItem{ + //This class implements the shutter item, ie the base element of a shutter and provides functions to add button... in the shutter +public: + + AliShutterItem(TGShutter *s,char *text,UInt_t id); + virtual ~AliShutterItem(); + + //Getters + TGShutterItem* GetShutterItem(){return fShutterItem;}; + TGCompositeFrame* GetShutterItemFrame(){return fMainFrame;}; + + //Fill functions + void AddTextButton(char *text,char *tiptext, UInt_t idb); + void AddPictureButton(char *file,char *tiptext,UInt_t idb); + void AddCheckButton(char *txt,Int_t idb); + + //Slot + void DoButton(Int_t pos=0); + +private: + + TGCompositeFrame *fMainFrame; + TGShutterItem *fShutterItem; + TGButton *fButton; + + RQ_OBJECT("AliShutterItem") + + ClassDef(AliShutterItem,0); +}; + + +//***Class AliShutterFrame***// +class AliShutterFrame{ + //This class implements the shutter frame +public: + + AliShutterFrame(TGCompositeFrame *p, UInt_t w, UInt_t h); + virtual ~AliShutterFrame(); + + TGCompositeFrame* GetShutterFrame(){return fMainFrame;}; + +private: + + TGCompositeFrame *fMainFrame; + TGLayoutHints *fLayout; + TGShutter *fShutter; + AliDetectorFrame *fDetectorFrame; + TGLayoutHints *fDetectorFrameLayout; + + RQ_OBJECT("AliShutterFrame") + + ClassDef(AliShutterFrame,0); +}; + +//***Class AliDisplayFrame***// +class AliDisplayFrame{ + //This class implements the display of the event + +public: + + AliDisplayFrame(const TGWindow *p, UInt_t w, UInt_t h); + virtual ~AliDisplayFrame(); + + //Getters + TGCompositeFrame* GetDisplayFrame(){return fMainFrame;}; + TCanvas* GetMainCanvas(){return fMainCanvas;}; + Int_t GetPreviousW(){return fPreviousW;}; + Int_t GetPreviousH(){return fPreviousH;}; + TGDimension GetFrameDimension(){return ((TGCanvas*)fMainEmbeddedCanvas)->GetViewPort()->GetDefaultSize();}; + Int_t GetNbActivePoints(); + Int_t GetNbClusters(){return fClusters->GetNbClusters();}; + + //Setters + void SetPreviousW(Int_t w){fPreviousW=w;}; + void SetPreviousH(Int_t h){fPreviousH=h;}; + void SetEditable(Bool_t b){gPad->SetEditable(b);}; + + void DoView(Int_t view); + void Draw(Float_t theta,Float_t phi,Float_t psi); + void DrawDetector(const char *name); + void DrawHits(); + void DrawX3d(); + void DrawGL(); + void LoadEnabledModules(); + void LoadClusters(Int_t nevent); + void LoadHLTClusters(Int_t nevent); + void LoadHits(); + void ApplyCuts(); + void EnableDetector(const char *name); + void DisableDetector(const char *name); + void ExecuteEvent(Int_t event, Int_t px,Int_t py,TObject *); + void SavePadGIF(const char *file); + +private: + + TGCompositeFrame *fMainFrame,*fFrame1,*fFrame2; + TGTab *fMainTab; + Bool_t fAllViews; + TRootEmbeddedCanvas *fMainEmbeddedCanvas;//embedded Canvas which contains the main view(s) + TRootEmbeddedCanvas *fSelectionEmbeddedCanvas; + TCanvas *fMainCanvas; + TCanvas *fSelectionCanvas; + Float_t fClipMin,fClipMax; + Int_t fPreviousW,fPreviousH; + Float_t fRange; + AliDisplayClusters *fClusters; + AliDisplayHLT *fHLT; + TObjArray *fPoints; + TObjArray *fPoints2; + TObjArray *fModules; + Int_t fNbModules; + Bool_t *fActivePoints; + TObjArray *fPolyMarkers;//Array for TPolyMarker3D + Float_t *fClustersPos; + Int_t fNbClusters; + + RQ_OBJECT("AliDisplayFrame") + + ClassDef(AliDisplayFrame,0); +}; + +//***Class AliInfoFrame***// +class AliInfoFrame{ + //This class implements the info frame where the number of particles... are displayed + +public: + + AliInfoFrame(TGCompositeFrame *p, UInt_t w, UInt_t h); + virtual ~AliInfoFrame(void); + + void AddLabel(char *text, UInt_t options); + TGCompositeFrame *GetInfoFrame(){return fMainFrame;}; + void Update(); + +private: + + TGCompositeFrame *fMainFrame,*fTitleFrame,*fFiguresFrame; + TGLabel *fNbParticuleLabel; + TGLabel *fNbEventLabel; + TGLabel *fNbHitsLabel; + TGLabel *fNbClustersLabel; + + RQ_OBJECT("AliInfoFrame") + + ClassDef(AliInfoFrame,0); +}; + + +//***Class AliSettingFrame***// +class AliSettingFrame:public TGTransientFrame{ + //This classe implement the setting frame where the different otption can be set + +public: + + AliSettingFrame(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h); + virtual ~AliSettingFrame(); + + //Slots + void DoSettings(Int_t id=0); + +private: + + TGCompositeFrame *fMainFrame; + TGCompositeFrame *fZoomStepFrame; + TGLayoutHints *fZoomStepLayout; + TGNumberEntryField *fZoomStepEntry; + TGLabel *fZoomStepLabel; + TGCompositeFrame *fSliderStepFrame; + TGLayoutHints *fSliderStepLayout; + TGNumberEntryField *fSliderStepEntry; + TGLabel *fSliderStepLabel; + TGCompositeFrame *fSliderUpdateFrame; + TGLayoutHints *fSliderUpdateLayout; + TGCheckButton *fSliderUpdateButton; + Bool_t fIsLoading;//Used when retrieving the state of the check button + + RQ_OBJECT("AliSettingFrame") + + ClassDef(AliSettingFrame,0); +}; + + +//***Class AliMenu***// +class AliMenu { + //This class implement both the menu and the toolbar + +public: + + AliMenu(TGCompositeFrame *p, UInt_t w, UInt_t h, UInt_t options); + virtual ~AliMenu(); + + void AddPictureButton(char *fname,char *tiptext,UInt_t id, UInt_t spacing);//add a picture button to the toolbar + //slots + void DoMenu(Int_t id=0); + void DoToolBar(Int_t id=0); + +private: + + TGMenuBar *fMenuBar; + TGToolBar *fToolBar; + TGLayoutHints *fMenuBarLayout; + TGLayoutHints *fMenuBarItemLayout; + TGPopupMenu *fMenuFile; + TGPopupMenu *fMenuOptions; + TGPopupMenu *fMenuHelp; + TGPopupMenu *fMenuView; + TGLayoutHints *fToolBarLayout; + ToolBarData_t *fTBD; + TGButton *fButton; + + RQ_OBJECT("AliMenu") + + ClassDef(AliMenu,0); +}; + +//***Class AliDisplay2***// +class AliDisplay2 : public TObject{ + //This classe is the main component of the new display. + //It aggregates all the subframes and manage the relationnships + //between the widgets and the internal representation + +public: + + AliDisplay2(const TGWindow *p, UInt_t w, UInt_t h); //Constructor, load all the widgets + virtual ~AliDisplay2(void); + + //Slots + void CloseWindow();// + void DoView(Int_t pos){fDisplayFrame->DoView(pos);};//change the current view + + void DoSaveSettings();//Save settings to the ressource file + void LoadSettings();//load the settings from the ressource file + + //Getter + Int_t GetCurrentView(void){return fCurrentView;};//return current view + TGMainFrame* GetMainFrame(){return fMainFrame;};// + Float_t GetZoomStep(){return fZoomStep;};// + Float_t GetZoomFactor(){return fZoomFactor;};// + Float_t GetRapidityMin(){return fSliderFrame->GetRapidityMin();};// + Float_t GetRapidityMax(){return fSliderFrame->GetRapidityMax();};// + Float_t GetMomentumMin(){return fSliderFrame->GetMomentumMin();};// + Float_t GetMomentumMax(){return fSliderFrame->GetMomentumMax();};// + Int_t GetNbParticles(){return fNbParticles;};// + Int_t GetEventNumber(){return fEventNumber;};// + Int_t GetNbHits(){return fNbHits;};// + Int_t GetNbClusters(){return fDisplayFrame->GetNbClusters();};// + Float_t GetSliderStep(){return fSliderStep;};// + Bool_t GetZoomMode(){return fZoomMode;};// + Int_t GetMode(){return fMode;};// + TObjArray* GetModules(){return fModules;};// + Bool_t* GetEnabledModules(){return fEnabledModules;};// + Int_t GetNbModules(){return fNbModules;};// + char* GetIconsPath(){return fIconsPath;};// + AliModuleInfo* GetModuleInfo(){return fModuleInfo;};// + Bool_t GetSliderUpdate(){return fSliderUpdate;};// + char* GetRawDataPath(){return fRawDataPath;}; + + //Setter + void SetSliderUpdate(Bool_t b){fSliderUpdate = b;};// + void SetMode(Int_t m){fMode=m;};// + void Enable(Int_t m);//Enable the given mode + Bool_t IsEnabled(Int_t m);//Return if the given mode is enabled + void Disable(Int_t m);//Disable the given mode + void SetZoomMode(Bool_t b=kTRUE){fZoomMode = b;};// + void SetCurrentView(Int_t id){fCurrentView = id;};// + void SetZoomStep(Float_t zs){fZoomStep=zs;};// + void SetZoomFactor(Float_t zf){fZoomFactor=zf;};// + void SetNbHits(Int_t hi){fNbHits = hi;};// + void SetNbParticles(Int_t nbp){fNbParticles = nbp;};// + void SetSliderStep(Float_t st){fSliderStep = st;};// + void SetEditable(Bool_t b){fDisplayFrame->SetEditable(b);};// + void SetStatusBar(const char *s,Int_t p){fStatusBar->SetText(s,p);};//Change text in the p part of the status bar + void SetRawDataPath(char *path){fRawDataPath=new char[strlen(path)];strcpy(fRawDataPath,path);}; + + void SavePadGIF(const char* file){fDisplayFrame->SavePadGIF(file);};//save current pad to gif file + void Draw(Option_t *options=0);//draw + void DrawDetector(const char *name){fDisplayFrame->DrawDetector(name);};//draw detector specific view (not implemented) + void DrawX3d();//Draw current pad in x3d view + void DrawGL();//Draw current pad in OpenGL view + void ShowNextEvent(Int_t delta);//Load and display the current+delta event, if it exists + void LoadClusters(Int_t nevent);//Load the clusters of the event + void LoadHits();//Load the hits + void LoadHLTClusters(Int_t nevent);//Load the hlt clusters + void LoadEnabledModules(){fDisplayFrame->LoadEnabledModules();};//Load enabled modules + void LoadEnabledHits(){fDisplayFrame->LoadHits();};//Load enabled hits + void ApplyCuts(){fDisplayFrame->ApplyCuts();}//Apply cuts from the slider frame + void EnableDetector(const char *name){fDisplayFrame->EnableDetector(name);};//Enable detector "name" + void DisableDetector(const char *name){fDisplayFrame->DisableDetector(name);};//Disable detector "name" + void Update(Int_t tag=-1);//Update the view, if loading only the modified data from the previous changes, the integer tag indicates the kind of modification + void HandleMouseWheel(Event_t *event);//Handle mouve event, not working yet + void HandleResize(Event_t *event);//Handle resize event + void FindModules();//Find the modules used for the simulation + + //I/O + void LoadFromRC(); + void SaveToRC(); + +private: + + Float_t fZoomStep;//Step of the zoom, ie the factor by which the zoom factor will be multiplied(divided) when pressing the zoom in (out) button + Float_t fZoomFactor;//Zoom factor, ie 1=no zoom, >1 zoom in & <1 zoom out + Bool_t fZoomMode;//kTrue if zoom on zone is enabled + Int_t fCurrentView;//Current view, see the enum for value + Int_t fNbParticles;//Current number of displayed particles + Int_t fEventNumber;//Number of event + Int_t fNbHits;//Number of displayed hits + Float_t fSliderStep;//Step of the slider + Int_t fMode;//Display mode : each bit is associated to a mode : Hits=BIT(0), clusters=BIT(1)... + Int_t fNbModules;//Total number of modules + TObjArray *fModules;//Array of modules + Bool_t *fEnabledModules;//Array of bool for coding the enabled modules + char *fIconsPath;//Icon Path (by default $ALICE_ROOT/DISPLAY/icons/) + char *fRawDataPath;//Raw data path + Bool_t fHitsLoaded,fClustersLoaded,fHLTLoaded,fTracksLoaded;//Implement if the type of datas was loaded, to avoid uneeded load + Bool_t fSliderUpdate;//True if display frame update on slider move, for fast machine only (desactivated by default) + AliModuleInfo *fModuleInfo;//Pointer to the class which map module name and internal module ID, necessary because of the dynamic load of the available modules + + TEnv *fAliDisplay2rc;//ressources file (.alidisplay.rc) + + TGMainFrame *fMainFrame;//Main frame + TGCompositeFrame *fLeftFrame;//frame used for the layout + TGCompositeFrame *fRightFrame;//frame used for the layout + TGCompositeFrame *fSubFrame;//frame used for the layout + + //Slider Frame + TGLayoutHints *fSliderFrameLayout; + AliSliderFrame *fSliderFrame;//Frame which contains the rapidity and momentum sliders + + //Shutter Frame + TGLayoutHints *fShutterFrameLayout; + AliShutterFrame *fShutterFrame; + + //Display Frame + TGLayoutHints *fDisplayFrameLayout; + AliDisplayFrame *fDisplayFrame; + + //Info Frame + TGLayoutHints *fInfoFrameLayout; + AliInfoFrame *fInfoFrame; + + //Detector Option Frame + TGLayoutHints *fDetectorFrameLayout; + AliDetectorFrame *fDetectorFrame; + + //MenuBar + AliMenu *fMenu; + + //Status bar + TGStatusBar *fStatusBar; + + RQ_OBJECT("AliDisplay2") + + ClassDef(AliDisplay2,0); +}; + +#endif + diff --git a/DISPLAY/DISPLAYLinkDef.h b/DISPLAY/DISPLAYLinkDef.h new file mode 100644 index 00000000000..639780ec2b9 --- /dev/null +++ b/DISPLAY/DISPLAYLinkDef.h @@ -0,0 +1,25 @@ +#ifdef __CINT__ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + + + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +// Standard AliDisplay2 classes +#pragma link C++ class AliModuleInfo; +#pragma link C++ class AliDisplayClusters; +#pragma link C++ class AliDisplayHLT; +#pragma link C++ class AliSliderFrame; +#pragma link C++ class AliDetectorFrame; +#pragma link C++ class AliShutterItem; +#pragma link C++ class AliShutterFrame; +#pragma link C++ class AliDisplayFrame; +#pragma link C++ class AliInfoFrame; +#pragma link C++ class AliSettingFrame; +#pragma link C++ class AliMenu; +#pragma link C++ class AliDisplay2; + +#endif diff --git a/DISPLAY/README b/DISPLAY/README new file mode 100644 index 00000000000..f00e74c0f2e --- /dev/null +++ b/DISPLAY/README @@ -0,0 +1,22 @@ +1) Extract files and move the DISPLAY directory to $ALICE_ROOT + +2) Move the .alidisplayrc to $ALICE_ROOT + +3) Move the macro display2.C to $ALICE_ROOT/macros/ + +4) In the AliRoot Makefile ($ALICE_ROOT/Makefile), add DISPLAY at the end of the +ALIROOTMODULES + +5) In the include path, add the following lines: + + CXXFLAGS += -I$(HLT)/src + CXXFLAGS += -I$(ALICE_ROOT)/TPC + CXXFLAGS += -I$(ALICE_ROOT)/CONTAINERS + + CINTFLAGS += -I$(HLT)/src + CINTFLAGS += -I$(ALICE_ROOT)/TPC + CINTFLAGS += -I$(ALICE_ROOT)/CONTAINERS + + DEPINC += -I$(HLT)/src + DEPINC += -I$(ALICE_ROOT)/TPC + DEPINC += -I$(ALICE_ROOT)/CONTAINERS diff --git a/DISPLAY/display2.C b/DISPLAY/display2.C new file mode 100644 index 00000000000..b7482901ee3 --- /dev/null +++ b/DISPLAY/display2.C @@ -0,0 +1,61 @@ +// This macro displays the hits belonging to a track for selected detectors +// Input: in the tracks contains the interesting tracks +// ntracks is the number of interesing tracks +// The default values correspond to "Show everything" +// Note: For the moment it works only with HIJING events, the PYTHIA is +// still not supported +//#include + +void display2 (const char *filename="galice.root",Int_t nevent=0, Int_t * tracks=0, Int_t ntracks=0) { +// Dynamically link some shared libs + if (gClassTable->GetID("AliRun") < 0) { + gROOT->LoadMacro("loadlibs.C"); + loadlibs(); + } else { + delete gAlice->GetRunLoader(); + delete gAlice; + gAlice = 0; + } + //gROOT->LoadMacro("AliDisplay2.C"); + gSystem->Load("libAliL3Src"); + gSystem->Load("libDISPLAY"); +// Connect the Root Galice file containing Geometry, Kine and Hits + + AliRunLoader *rl = 0x0; + TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); + if(file){ + cout<<"galice.root is already open \n"; + } + rl = AliRunLoader::Open(filename,"DISPLAYED EVENT"); + + if (rl == 0x0) + { + cerr<<"Error : can not get Run Loader. Exiting"<LoadgAlice(); + + gAlice = rl->GetAliRun(); + if (!gAlice) { + cerr<<"AliTPCHits2Digits.C : AliRun object not found on file\n"; + return; + } + +// Create Event Display object + AliDisplay2 *edisplay = new AliDisplay2(gClient->GetRoot(), 900, 700); +// if (ntracks>0) edisplay->SetTracksToDisplay(tracks, ntracks); + +// Display the requested event +// gAlice->GetEvent(nevent); + rl->GetEvent(nevent); + rl->LoadKinematics(); + rl->LoadHeader(); + rl->LoadHits(); + // edisplay->FindModules(); + edisplay->ShowNextEvent(0); +} + + + diff --git a/DISPLAY/libDISPLAY.pkg b/DISPLAY/libDISPLAY.pkg new file mode 100644 index 00000000000..f7bda8a1bbe --- /dev/null +++ b/DISPLAY/libDISPLAY.pkg @@ -0,0 +1,8 @@ +SRCS = AliDisplay2.cxx + + +HDRS:= $(SRCS:.cxx=.h) + +DHDR=DISPLAYLinkDef.h + +EINCLUDE:= ITS TPC CONTAINERS -- 2.43.5