EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairEventManagerEditor.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairEventManagerEditor.cxx
2 
3 #include "FairRootManager.h"
4 #include "FairEventManager.h"
5 #include "FairRunAna.h"
6 
7 #include "TGLabel.h"
8 #include "TGButton.h"
9 #include "TGNumberEntry.h"
10 #include "TGeoManager.h"
11 #include "TChain.h"
12 
13 #define MAXE 5000
14 
15 //______________________________________________________________________________
16 // FairEventManagerEditor
17 //
18 // Specialization of TGedEditor for proper update propagation to
19 // TEveManager.
20 
22 
23 
24 //______________________________________________________________________________
25 FairEventManagerEditor::FairEventManagerEditor(const TGWindow* p, Int_t width, Int_t height,
26  UInt_t options, Pixel_t back)
27  :TGedFrame(p, width, height, options | kVerticalFrame, back),
28  fObject(0),
29  fManager(FairEventManager::Instance()),
30  fCurrentEvent(0),
31  fCurrentPDG(0),
32  fVizPri(0),
33  fMinEnergy(0),
34  fMaxEnergy(0),
35  fEventTime(NULL)
36 {
37  Init();
38 }
39 
41 {
42 
44  TChain* chain =fRootManager->GetInChain();
45  Int_t Entries= chain->GetEntriesFast();
46 
47  MakeTitle("FairEventManager Editor");
48  TGVerticalFrame* fInfoFrame= CreateEditorTabSubFrame("Info");
49  TGCompositeFrame* title1 = new TGCompositeFrame(fInfoFrame, 250, 10,
50  kVerticalFrame | kLHintsExpandX |
51  kFixedWidth | kOwnBackground);
52 
53  TString Infile= "Input file : ";
54 // TFile* file =FairRunAna::Instance()->GetInputFile();
55  TFile* file =FairRootManager::Instance()->GetInChain()->GetFile();
56  Infile+=file->GetName();
57  TGLabel* TFName=new TGLabel(title1, Infile.Data());
58  title1->AddFrame(TFName);
59 
60  UInt_t RunId= FairRunAna::Instance()->getRunId();
61  TString run= "Run Id : ";
62  run += RunId;
63  TGLabel* TRunId=new TGLabel(title1, run.Data());
64  title1->AddFrame( TRunId);
65 
66  TString nevent= "No of events : ";
67  nevent +=Entries ;
68  TGLabel* TEvent=new TGLabel(title1, nevent.Data());
69  title1->AddFrame(TEvent);
70 
71  Int_t nodes= gGeoManager->GetNNodes();
72  TString NNodes= "No. of Nodes : ";
73  NNodes += nodes;
74  TGLabel* NoNode=new TGLabel(title1, NNodes.Data());
75  title1->AddFrame( NoNode);
76 
77  TGHorizontalFrame* f = new TGHorizontalFrame(title1);
78  TGLabel* l = new TGLabel(f, "Current Event:");
79  f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
80  fCurrentEvent = new TGNumberEntry(f, 0., 6, -1,
81  TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
82  TGNumberFormat::kNELLimitMinMax, 0, Entries);
83  f->AddFrame(fCurrentEvent, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
84  fCurrentEvent->Connect("ValueSet(Long_t)","FairEventManagerEditor", this, "SelectEvent()");
85  title1->AddFrame(f);
86 
87  TGHorizontalFrame* f2 = new TGHorizontalFrame(title1);
88  TGLabel* EventTimeLabel = new TGLabel(f2, "Event Time: ");
89  fEventTime = new TGLabel(f2,"");
90  f2->AddFrame(EventTimeLabel);
91  f2->AddFrame(fEventTime);
92  title1->AddFrame(f2);
93 
94  fVizPri = new TGCheckButton(title1, "Primary Only");
95  AddFrame(fVizPri, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
96  fVizPri->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "DoVizPri()");
97 
98  title1->AddFrame(fVizPri);
99 
100  TGHorizontalFrame* f1 = new TGHorizontalFrame(title1);
101  TGLabel* L1 = new TGLabel(f1, "Select PDG :");
102  f1->AddFrame(L1, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
103  fCurrentPDG = new TGNumberEntry(f1, 0., 12, -1,
104  TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber,
105  TGNumberFormat::kNELNoLimits, 0, 1);
106  f1->AddFrame(fCurrentPDG, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
107  fCurrentPDG->Connect("ValueSet(Long_t)","FairEventManagerEditor", this, "SelectPDG()");
108  title1->AddFrame(f1);
109 
110 
111  fMinEnergy = new TEveGValuator(title1, "Min Energy:", 90, 0);
112  fMinEnergy->SetNELength(5);
113  fMinEnergy->SetLabelWidth(80);
114  fMinEnergy->Build();
115  fMinEnergy->SetLimits(0, MAXE, 2501, TGNumberFormat::kNESRealOne);
116  fMinEnergy->SetToolTip("Minimum energy of displayed track.");
117  fMinEnergy->Connect("ValueSet(Double_t)", "FairEventManagerEditor",this, "MinEnergy()");
118  title1->AddFrame(fMinEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
119 
120 
121  fMaxEnergy = new TEveGValuator(title1, "Max Energy:", 90, 0);
122  fMaxEnergy->SetNELength(5);
123  fMaxEnergy->SetLabelWidth(80);
124  fMaxEnergy->Build();
125  fMaxEnergy->SetLimits(0, MAXE, 2501, TGNumberFormat::kNESRealOne);
126  fMaxEnergy->SetToolTip("Maximum energy of displayed track.");
127  fMaxEnergy->SetValue(MAXE);
128  fMaxEnergy->Connect("ValueSet(Double_t)", "FairEventManagerEditor",this, "MaxEnergy()");
129  title1->AddFrame(fMaxEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
130 
131  TGTextButton* fUpdate = new TGTextButton(title1, "Update");
132  title1->AddFrame(fUpdate, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
133  fUpdate->Connect("Clicked()", "FairEventManagerEditor", this, "SelectEvent()");
134 
135  fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
136 
138 }
139 
140 
141 //______________________________________________________________________________
143 {
144  fManager->SetMaxEnergy(fMaxEnergy->GetValue());
145 
146 }
147 //______________________________________________________________________________
149 {
150  fManager->SetMinEnergy(fMinEnergy->GetValue());
151 
152 }
153 
154 //______________________________________________________________________________
156 {
157  if (fVizPri->IsOn()) { fManager->SetPriOnly(kTRUE); }
158  else { fManager->SetPriOnly(kFALSE); }
159 }
160 //______________________________________________________________________________
162 {
163  fManager->SelectPDG(fCurrentPDG->GetIntNumber());
164 }
165 
166 //______________________________________________________________________________
168 {
169  fManager->GotoEvent(fCurrentEvent->GetIntNumber());
170 
171  TString time;
172 // time+=(FairRootManager::Instance()->GetEventTime());
173  time.Form("%.2f", FairRootManager::Instance()->GetEventTime());
174  time += " ns";
175  fEventTime->SetText(time.Data());
176 
178  fMinEnergy->SetValue(fManager->GetEvtMinEnergy());
180  fMaxEnergy->SetValue( fManager->GetEvtMaxEnergy());
181  Update();
182 
183 }
184 //______________________________________________________________________________
186 {
187  fObject = obj;
188 
189 }
190 //______________________________________________________________________________
191 
192 
193