10 #include "TApplication.h"
11 #include "TGTableLayout.h"
15 #include "TRootEmbeddedCanvas.h"
19 #include "TPolyLine.h"
23 #include "TGDoubleSlider.h"
26 #include "Riostream.h"
35 m_ntuplePlotter(ntuplePlotter),
37 m_singleTrackMode(true),
38 m_equalScaling(false),
39 m_showDAFinfo(false) {
40 const UInt_t max_size = 800;
46 TGCompositeFrame *
table =
new TGCompositeFrame(
this,350,350,kSunkenFrame);
49 TGTableLayout* tlo =
new TGTableLayout(
table, 10, 6);
51 table->SetLayoutManager(tlo);
52 TGLayoutHints* loh =
new TGLayoutHints(kLHintsTop|kLHintsLeft|
53 kLHintsExpandX|kLHintsExpandY);
56 TGTableLayoutHints* tloh;
60 new TRootEmbeddedCanvas(
"Shapes",
table,max_size,max_size);
61 tloh =
new TGTableLayoutHints(2,5,2,6,
62 kLHintsExpandX|kLHintsExpandY |
63 kLHintsShrinkX|kLHintsShrinkY |
64 kLHintsFillX|kLHintsFillY);
70 fHSlider =
new TGDoubleHSlider(
table,max_size,kDoubleScaleBoth,100,
71 kHorizontalFrame,GetDefaultFrameBackground(),
74 tloh =
new TGTableLayoutHints(2,5,0,1,
75 kLHintsExpandX|kLHintsShrinkX|kLHintsFillX);
77 fHSlider->Connect(
"PositionChanged()",
"Viewer",
this,
"DoSlider()");
79 fVSlider =
new TGDoubleVSlider(
table,max_size,kDoubleScaleBoth,200,
80 kVerticalFrame,GetDefaultFrameBackground(),
82 Float_t RangeMin=-1100.; Float_t RangeMax=1100.;
83 fVSlider->SetRange(RangeMin, RangeMax);
84 fHSlider->SetRange(RangeMin, RangeMax);
85 tloh =
new TGTableLayoutHints(0,1,2,6,
86 kLHintsExpandY|kLHintsShrinkY|kLHintsFillY);
88 fVSlider->Connect(
"PositionChanged()",
"Viewer",
this,
"DoSlider()");
92 new TRootEmbeddedCanvas(
"H Scale",
table,max_size,50);
93 tloh =
new TGTableLayoutHints(2,5,1,2,
94 kLHintsExpandX|kLHintsShrinkX|kLHintsFillX);
99 fHScale =
new TGaxis(0.0,0.5, 1.0,0.5, 0.0,100.0, 510,
"-");
106 new TRootEmbeddedCanvas(
"V Scale",
table,50,max_size);
107 tloh =
new TGTableLayoutHints(1,2,2,6,
108 kLHintsExpandY|kLHintsShrinkY|kLHintsFillY);
113 fVScale =
new TGaxis(0.5,0.0, 0.50001,1.0, 0.0,100.0, 510,
"-");
123 const char* shape_button_name[] = {
124 "Barrel",
"EndCap",
"",
"",
"Zoom Out",
"Zoom In",
"Close"
128 TGTextButton* button =
129 new TGTextButton(
table,shape_button_name[
ind],
ind);
130 tloh =
new TGTableLayoutHints(5,6,
ind+2,
ind+1+2,
131 kLHintsExpandX|kLHintsExpandY |
132 kLHintsShrinkX|kLHintsShrinkY |
133 kLHintsFillX|kLHintsFillY);
134 table->AddFrame(button,tloh);
135 button->Resize(100,button->GetDefaultHeight());
136 button->Connect(
"Clicked()",
"Viewer",
this,
"DoButton()");
139 const char* ctrl_button_name[2][3] = {{
"Prev",
"Next",
""},
140 {
"Create EPS File" ,
"Create PNG File",
"Reset View" }};
145 for (indx = 0; indx < 3; ++indx) {
146 for (indy = 0; indy < 2; ++indy) {
148 TGTextButton* button =
new TGTextButton(
table,
149 ctrl_button_name[indy][indx],
150 (indy+1)*10 + indx +1);
151 tloh =
new TGTableLayoutHints(indx+2,indx+1+2, 6+indy,6+indy+1,
152 kLHintsExpandX|kLHintsExpandY |
153 kLHintsShrinkX|kLHintsShrinkY |
154 kLHintsFillX|kLHintsFillY);
155 table->AddFrame(button,tloh);
156 button->Resize(100,button->GetDefaultHeight());
157 button->Connect(
"Clicked()",
"Viewer",
this,
"DoButton()");
164 TGGroupFrame *fG2 =
new TGGroupFrame(
table,
new TGString(
"DisplayMode"),kVerticalFrame|kRaisedFrame);
166 TGLayoutHints* fL4 =
new TGLayoutHints(kLHintsTop | kLHintsLeft,
175 for (
int i = 0;
i < 2; ++
i) {
182 TGTableLayoutHints* RadioFrameLayoutHint =
new TGTableLayoutHints(3,4, 9, 10,
183 kLHintsExpandX|kLHintsExpandY |
184 kLHintsShrinkX|kLHintsShrinkY |
185 kLHintsFillX|kLHintsFillY);
187 table->AddFrame(fG2, RadioFrameLayoutHint);
190 TGGroupFrame *fCheckGroup =
new TGGroupFrame(
table,
new TGString(
"Options"),kVerticalFrame|kRaisedFrame);
192 TGLayoutHints* CheckButtonsLayoutHint =
new TGLayoutHints(kLHintsTop | kLHintsLeft,
194 TGCheckButton* checkEqualScaling =
new TGCheckButton(fCheckGroup,
new TGHotString(
"equal scaling along axis"), 21);
195 checkEqualScaling->SetState(kButtonUp);
196 TGCheckButton* checkAssgnProbs =
new TGCheckButton(fCheckGroup,
new TGHotString(
"show assgn probs for DAF tracks"), 22);
197 checkAssgnProbs->SetState(kButtonUp);
199 fCheckGroup->AddFrame(checkEqualScaling, CheckButtonsLayoutHint);
200 checkEqualScaling->Connect(
"Clicked()",
"Viewer",
this,
"DoCheckButton()");
201 fCheckGroup->AddFrame(checkAssgnProbs, CheckButtonsLayoutHint);
202 checkAssgnProbs->Connect(
"Clicked()",
"Viewer",
this,
"DoCheckButton()");
204 TGTableLayoutHints* CheckFrameLayoutHint =
new TGTableLayoutHints(4,5, 9, 10,
205 kLHintsExpandX|kLHintsExpandY |
206 kLHintsShrinkX|kLHintsShrinkY |
207 kLHintsFillX|kLHintsFillY);
208 table->AddFrame(fCheckGroup, CheckFrameLayoutHint);
213 Connect(
"CloseWindow()",
"TApplication",gApplication,
"Terminate(=0)");
253 TGButton* button = (TGButton*)gTQSender;
254 UInt_t
id = button->WidgetId();
269 Float_t RangeMin=-1100.; Float_t RangeMax=1100.;
270 fVSlider->SetRange(RangeMin, RangeMax);
271 fHSlider->SetRange(RangeMin, RangeMax);
272 SetRange(-1100., -1100., 1100., 1100.);
276 std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
278 for( ; rioit!=rioObjects->end();++rioit) {
283 std::vector<TObject*>::const_iterator oit = trackObjects->begin();
284 for( ; oit!=trackObjects->end();++oit) {
289 oit = compRotObjects->begin();
290 for( ; oit!=compRotObjects->end();++oit) {
305 SetRange(-2700., -3500., 2700., 3500.);
309 std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
311 for( ; rioit!=rioObjects->end();++rioit) {
316 std::vector<TObject*>::const_iterator oit = trackObjects->begin();
317 for( ; oit!=trackObjects->end();++oit) {
322 oit = compRotObjects->begin();
323 for( ; oit!=compRotObjects->end();++oit) {
339 gApplication->Terminate(0);
354 std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
356 for( ; rioit!=rioObjects->end();++rioit) {
361 std::vector<TObject*>::const_iterator oit = trackObjects->begin();
362 for( ; oit!=trackObjects->end();++oit) {
367 oit = compRotObjects->begin();
368 for( ; oit!=compRotObjects->end();++oit) {
391 std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
393 for( ; rioit!=rioObjects->end();++rioit) {
398 std::vector<TObject*>::const_iterator oit = trackObjects->begin();
399 for( ; oit!=trackObjects->end();++oit) {
404 oit = compRotObjects->begin();
405 for( ; oit!=compRotObjects->end();++oit) {
418 char epsFileName[50]=
"BarrelTrack.eps";
420 fCanvas->Print( epsFileName,
"eps");
425 char pngFileName[50]=
"BarrelTrack.png";
427 fCanvas->Print( pngFileName,
"png");
431 SetRange(-1100., -1100., 1100., 1100.);
452 TGButton* button = (TGButton*)gTQSender;
453 UInt_t
id = button->WidgetId();
457 fprintf(
stdout,
"RadioButton ID: %d \n",
int(
id));
473 TGButton* button = (TGButton*)gTQSender;
474 TGCheckButton* checkButton =
dynamic_cast<TGCheckButton*
> (button);
476 fprintf(
stderr,
"did not get the button\n");
479 UInt_t
id = button->WidgetId();
485 if (checkButton->IsOn()){
497 if (checkButton->IsOn()){
500 std::vector<TObject*>::const_iterator oit = compRotObjects->begin();
501 for( ; oit!=compRotObjects->end();++oit) {
526 Bool_t move_slider) {
562 fClient->ForceRedraw();
572 if (gROOT->IsBatch()) {
573 fprintf(
stderr,
"%s: cannot run in batch mode\n",
argv[0]);
580 TEnv* trackPlotterSetup =
new TEnv(
"trackplotter.conf");
583 const char*
filename = trackPlotterSetup->GetValue(
"TrackingNtupleFileName",
"TrkValidation.root");
586 const char* trackNtupleDir = trackPlotterSetup->GetValue(
"TrackingNtupleDirectory",
"Validation");
588 const char* trackNtupleTree = trackPlotterSetup->GetValue(
"TrackingNtupleTree",
"Tracks");
591 bool doDAFdata =
false;
592 doDAFdata = trackPlotterSetup->GetValue(
"PlotDAFdata",0);
595 bool doRIOdata =
true;
596 doRIOdata = trackPlotterSetup->GetValue(
"PlotPrepRawData", 1);
600 const char* rioNtupleDir = trackPlotterSetup->GetValue(
"PrepRawDataNtupleDirectory",
"Validation");
602 const char* rioNtupleTree = trackPlotterSetup->GetValue(
"PrepRawDataNtupleTree",
"TRT_RIOs");
612 trackPlotterSetup->Print();
614 TColor *color_301 =
new TColor(301,0.7,0.0,0.0,
"");
615 TColor *color_302 =
new TColor(302,0.0,0.7,0.0,
"");
616 TColor *color_303 =
new TColor(303,0.0,0.0,0.7,
"");
617 TColor *color_306 =
new TColor(306,0.7,0.0,0.7,
"");
618 TColor *color_310 =
new TColor(310,0.8,0.8,0.8,
"");
619 TColor *color_311 =
new TColor(311,0.55,0.0,0.0,
"");
627 std::cout<<
"usage: "<<
argv[0] <<
" <filename>"<< std::endl;
634 std::cout<<
"Using file "<<
filename << (doRIOdata ?
" including PrepRawData" :
"") << (doDAFdata ?
" with DAF information" :
"") << std::endl;
639 std::cout <<
"ERROR: could not find " <<
filename << std::endl;
643 char rootFileName[100];
644 sprintf(rootFileName,
"%s:/%s",
filename, trackNtupleDir);
650 std::cout <<
"ERROR: could not get the tree: " <<
filename <<
":/" << trackNtupleDir <<
"/" << trackNtupleTree << std::endl;
660 sprintf(rootFileName,
"%s:/%s",
filename, rioNtupleDir);
668 RIOtree = (TTree*)
gDirectory->Get(rioNtupleTree);
670 std::cout <<
"ERROR: could not get the tree: " <<
filename <<
":/" << rioNtupleDir <<
"/" << rioNtupleTree << std::endl;
680 Viewer viewer(gClient->GetRoot(), &theNtuplePlotter);
684 delete color_301;
delete color_302;
685 delete color_303;
delete color_306;
686 delete color_310;
delete color_311;