ATLAS Offline Software
trackplotter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // To run it do: make trackplotter; trackplotter
6 
7 #include "trackplotter.h"
8 
9 #include "TROOT.h"
10 #include "TApplication.h"
11 #include "TGTableLayout.h"
12 #include "TGFrame.h"
13 #include "TList.h"
14 #include "TGWindow.h"
15 #include "TRootEmbeddedCanvas.h"
16 #include "TEllipse.h"
17 #include "TBox.h"
18 #include "TArrow.h"
19 #include "TPolyLine.h"
20 #include "TGButton.h"
21 #include "TCanvas.h"
22 #include "TRandom.h"
23 #include "TGDoubleSlider.h"
24 #include "TGaxis.h"
25 #include "TColor.h"
26 #include "Riostream.h"
27 
28 #include "TEnv.h"
29 
30 #include "PlotValNtuple.h"
31 
32 Viewer::Viewer(const TGWindow *win, PlotValNtuple* ntuplePlotter) : TGMainFrame(win,800,800),
33  //m_trackNtuple(trackNtuple),
34  //m_rioNtuple(rioNtuple),
35  m_ntuplePlotter(ntuplePlotter),
36  //m_entryNumber(0),
37  m_singleTrackMode(true),
38  m_equalScaling(false),
39  m_showDAFinfo(false) {
40  const UInt_t max_size = 800;
41 
42  // Memory management isn't the best in this class, but make a half
43  // hearted attempts not to gush too much....
44  fCleanup = new TList;
45 
46  TGCompositeFrame *table = new TGCompositeFrame(this,350,350,kSunkenFrame);
47  fCleanup->Add(table);
48 
49  TGTableLayout* tlo = new TGTableLayout(table, 10, 6);
50  //TGTableLayout* tlo = new TGTableLayout(table, 9, 6);
51  table->SetLayoutManager(tlo);
52  TGLayoutHints* loh = new TGLayoutHints(kLHintsTop|kLHintsLeft|
53  kLHintsExpandX|kLHintsExpandY);
54  AddFrame(table,loh);
55 
56  TGTableLayoutHints* tloh;
57 
58  // The Canvas
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);
65  table->AddFrame(fMainEmbeddedCanvas,tloh);
66 
67  fCanvas = fMainEmbeddedCanvas->GetCanvas();
68 
69  // The sliders
70  fHSlider = new TGDoubleHSlider(table,max_size,kDoubleScaleBoth,100,
71  kHorizontalFrame,GetDefaultFrameBackground(),
72  kFALSE, kTRUE);
73 
74  tloh = new TGTableLayoutHints(2,5,0,1,
75  kLHintsExpandX|kLHintsShrinkX|kLHintsFillX);
76  table->AddFrame(fHSlider,tloh);
77  fHSlider->Connect("PositionChanged()","Viewer",this,"DoSlider()");
78 
79  fVSlider = new TGDoubleVSlider(table,max_size,kDoubleScaleBoth,200,
80  kVerticalFrame,GetDefaultFrameBackground(),
81  kTRUE,kTRUE);
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);
87  table->AddFrame(fVSlider,tloh);
88  fVSlider->Connect("PositionChanged()","Viewer",this,"DoSlider()");
89 
90  // The scales
92  new TRootEmbeddedCanvas("H Scale",table,max_size,50);
93  tloh = new TGTableLayoutHints(2,5,1,2,
94  kLHintsExpandX|kLHintsShrinkX|kLHintsFillX);
95  table->AddFrame(fHScaleCanvas,tloh);
96  fHScaleCanvas->GetCanvas()->cd();
97 
98  fHScaleCanvas->GetCanvas()->Range(0,0,1,1);
99  fHScale = new TGaxis(0.0,0.5, 1.0,0.5, 0.0,100.0, 510, "-");
100  fHScale->SetLabelSize(0.4);
101  fHScale->SetName("X Scale");
102  fHScale->Draw();
103  fHScaleCanvas->GetCanvas()->SetEditable(kFALSE);
104 
105  fVScaleCanvas =
106  new TRootEmbeddedCanvas("V Scale",table,50,max_size);
107  tloh = new TGTableLayoutHints(1,2,2,6,
108  kLHintsExpandY|kLHintsShrinkY|kLHintsFillY);
109  table->AddFrame(fVScaleCanvas,tloh);
110  fVScaleCanvas->GetCanvas()->cd();
111 
112  fVScaleCanvas->GetCanvas()->Range(0,0,1,1);
113  fVScale = new TGaxis(0.5,0.0, 0.50001,1.0, 0.0,100.0, 510, "-");
114  fVScale->SetLabelSize(0.4);
115  fVScale->SetName("Y Scale");
116  fVScale->Draw();
117  fVScaleCanvas->GetCanvas()->SetEditable(kFALSE);
118 
119  // Call this after scales/sliders are setup
120  SetRange(-1100,-1100,1100,1100);
121 
122  // The shape buttons
123  const char* shape_button_name[] = {
124  "Barrel", "EndCap", "", "", "Zoom Out", "Zoom In", "Close"
125  };
126  UInt_t ind;
127  for (ind = 0; ind < 7; ++ind) {
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()");
137  }
138 
139  const char* ctrl_button_name[2][3] = {{"Prev", "Next", ""},
140  { "Create EPS File" , "Create PNG File", "Reset View" }};
141  // { "W" , "C", "E" },
142  // { "SW", "S", "SE" }
143 
144  UInt_t indx, indy;
145  for (indx = 0; indx < 3; ++indx) {
146  for (indy = 0; indy < 2; ++indy) {
147 
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()");
158  }
159  }
160  //--------- radio buttons for mode
161 
162  //TGLayoutHints *fL3, *fL4;
163  //TGRadioButton *fR[2];
164  TGGroupFrame *fG2 = new TGGroupFrame(table, new TGString("DisplayMode"),kVerticalFrame|kRaisedFrame);
165 
166  TGLayoutHints* fL4 = new TGLayoutHints(kLHintsTop | kLHintsLeft,
167  0, 0, 5, 0);
168 // fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft |
169 // kLHintsExpandX | kLHintsExpandY,
170 // 2, 2, 2, 2);
171 
172  fRadioSingleTrackMode[0] = new TGRadioButton(fG2, new TGHotString("single track mode"), 21);
173  fRadioSingleTrackMode[1] = new TGRadioButton(fG2, new TGHotString("event mode"), 22);
174 
175  for (int i = 0; i < 2; ++i) {
176  fG2->AddFrame(fRadioSingleTrackMode[i], fL4);
177  //fR[i]->Associate(this);
178  fRadioSingleTrackMode[i]->Connect("Clicked()","Viewer",this,"DoRadioButton()");
179  }
180 
181  fRadioSingleTrackMode[0]->SetState(kButtonDown);
182  TGTableLayoutHints* RadioFrameLayoutHint = new TGTableLayoutHints(3,4, 9, 10,
183  kLHintsExpandX|kLHintsExpandY |
184  kLHintsShrinkX|kLHintsShrinkY |
185  kLHintsFillX|kLHintsFillY);
186  //table->AddFrame(fG2, new TGLayoutHints(kLHintsLeft | kLHintsTop,0,1,5,5));*/
187  table->AddFrame(fG2, RadioFrameLayoutHint);
188 
189  //--------- check buttons for whatever (options)
190  TGGroupFrame *fCheckGroup = new TGGroupFrame(table, new TGString("Options"),kVerticalFrame|kRaisedFrame);
191 
192  TGLayoutHints* CheckButtonsLayoutHint = new TGLayoutHints(kLHintsTop | kLHintsLeft,
193  0, 0, 5, 0);
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);
198 
199  fCheckGroup->AddFrame(checkEqualScaling, CheckButtonsLayoutHint);
200  checkEqualScaling->Connect("Clicked()","Viewer",this,"DoCheckButton()");
201  fCheckGroup->AddFrame(checkAssgnProbs, CheckButtonsLayoutHint);
202  checkAssgnProbs->Connect("Clicked()","Viewer",this,"DoCheckButton()");
203 
204  TGTableLayoutHints* CheckFrameLayoutHint = new TGTableLayoutHints(4,5, 9, 10,
205  kLHintsExpandX|kLHintsExpandY |
206  kLHintsShrinkX|kLHintsShrinkY |
207  kLHintsFillX|kLHintsFillY);
208  table->AddFrame(fCheckGroup, CheckFrameLayoutHint);
209 
210  table->Layout();
211 
212  // exit on close window
213  Connect("CloseWindow()","TApplication",gApplication,"Terminate(=0)");
214 
215  MapSubwindows();
216  Layout();
217  MapWindow();
218 
219 /* // get the ntuple now
220  char *filename = new char[80];
221  filename = "TrkValidation.root";
222  TFile *f = new TFile(filename);
223  if (!f) {
224  std::cout << "ERROR: could not find " << filename << std::endl;
225  //return 1;
226  } else {
227  f->cd("TrkValidation.root:/FitterValidation");
228  //}
229  TTree *tree = (TTree*)gDirectory->Get("OutputTrack");
230  if (!tree) {
231  std::cout << "ERROR: could not get the tree." << std::endl;
232  //return 1;
233  } else {
234  //int numberOfEntries = tree->GetEntriesFast();
235  // get the ntuple with the track data
236  m_trackNtuple = new TrackDataNtupleTree(tree);*/
237  //m_ntuplePlotter = new PlotValNtuple();
238 /* }
239  }*/
240 
241 }
242 
244  fCanvas->Clear();
245  delete fCanvas;
246  fCleanup->Delete();
247  delete fCleanup;
248  //delete m_trackNtuple;
249  //delete m_ntuplePlotter;
250 }
251 
253  TGButton* button = (TGButton*)gTQSender;
254  UInt_t id = button->WidgetId();
255 
256  double xmin, ymin, xmax, ymax;
257  double xdiff, ydiff;
258  fCanvas->GetRange(xmin,ymin,xmax,ymax);
259  xdiff = xmax - xmin;
260  ydiff = ymax - ymin;
261 
262  fCanvas->cd();
263  //fprintf(stdout, "Button ID: %d \n", int(id));
264  switch (id) {
265  case 0: // Barrel view
266  if (m_ntuplePlotter) {
268  fCanvas->Clear();
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.);
273 
274  if (!m_singleTrackMode) {
275  std::vector<TObject*>* rioObjects = m_ntuplePlotter->getRIOGraphics();
276  std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
277  //std::cout << "Got " << rioObjects.size() << " graphic objects for RIOs "<< std::endl;
278  for( ; rioit!=rioObjects->end();++rioit) {
279  (*rioit)->Draw();
280  }
281  }
282  std::vector<TObject*>* trackObjects = m_ntuplePlotter->getTrackGraphics();
283  std::vector<TObject*>::const_iterator oit = trackObjects->begin();
284  for( ; oit!=trackObjects->end();++oit) {
285  (*oit)->Draw();
286  }
287  if (m_showDAFinfo){
288  std::vector<TObject*>* compRotObjects = m_ntuplePlotter->getCompetingROTsGraphics();
289  oit = compRotObjects->begin();
290  for( ; oit!=compRotObjects->end();++oit) {
291  (*oit)->Draw();
292  }
293  }
294 
295  fCanvas->Modified();
296  fCanvas->Update();
297  }
298  break;
299  case 1: // Endcap view
300  if (m_ntuplePlotter) {
302  fCanvas->Clear();
303  fVSlider->SetRange(-3500., 3500.);
304  fHSlider->SetRange(-2700., 2700.);
305  SetRange(-2700., -3500., 2700., 3500.);
306 
307  if (!m_singleTrackMode) {
308  std::vector<TObject*>* rioObjects = m_ntuplePlotter->getRIOGraphics();
309  std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
310  //std::cout << "Got " << rioObjects.size() << " graphic objects for RIOs "<< std::endl;
311  for( ; rioit!=rioObjects->end();++rioit) {
312  (*rioit)->Draw();
313  }
314  }
315  std::vector<TObject*>* trackObjects = m_ntuplePlotter->getTrackGraphics();
316  std::vector<TObject*>::const_iterator oit = trackObjects->begin();
317  for( ; oit!=trackObjects->end();++oit) {
318  (*oit)->Draw();
319  }
320  if (m_showDAFinfo){
321  std::vector<TObject*>* compRotObjects = m_ntuplePlotter->getCompetingROTsGraphics();
322  oit = compRotObjects->begin();
323  for( ; oit!=compRotObjects->end();++oit) {
324  (*oit)->Draw();
325  }
326  }
327 
328  fCanvas->Modified();
329  fCanvas->Update();
330  }
331  break;
332  case 4: // Zoom out
333  SetRange(xmin-xdiff*.1, ymin-ydiff*.1, xmax+xdiff*.1, ymax+ydiff*.1);
334  break;
335  case 5: // Zoom in
336  SetRange(xmin+xdiff*.1, ymin+ydiff*.1, xmax-xdiff*.1, ymax-ydiff*.1);
337  break;
338  case 6:
339  gApplication->Terminate(0);
340  break;
341  case 11: // prev
342  if (m_ntuplePlotter) {
343  fCanvas->Clear();
344 
345  if (m_singleTrackMode) {
346  int eventNumber, trackNumber, InterationNumber;
348  } else {
349  int eventNumber;
351  }
352  if (!m_singleTrackMode) {
353  std::vector<TObject*>* rioObjects = m_ntuplePlotter->getRIOGraphics();
354  std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
355  //std::cout << "Got " << rioObjects.size() << " graphic objects for RIOs "<< std::endl;
356  for( ; rioit!=rioObjects->end();++rioit) {
357  (*rioit)->Draw();
358  }
359  }
360  std::vector<TObject*>* trackObjects = m_ntuplePlotter->getTrackGraphics();
361  std::vector<TObject*>::const_iterator oit = trackObjects->begin();
362  for( ; oit!=trackObjects->end();++oit) {
363  (*oit)->Draw();
364  }
365  if (m_showDAFinfo){
366  std::vector<TObject*>* compRotObjects = m_ntuplePlotter->getCompetingROTsGraphics();
367  oit = compRotObjects->begin();
368  for( ; oit!=compRotObjects->end();++oit) {
369  (*oit)->Draw();
370  }
371  }
372 
373  fCanvas->Modified();
374  fCanvas->Update();
375  }
376  //fprintf(stdout, "entry %d \n", int(m_entryNumber));
377  break;
378  case 12: // next
379  if (m_ntuplePlotter) {
380  fCanvas->Clear();
381 
382  if (m_singleTrackMode) {
383  int eventNumber, trackNumber, InterationNumber;
385  } else {
386  int eventNumber;
388  }
389  if (!m_singleTrackMode) {
390  std::vector<TObject*>* rioObjects = m_ntuplePlotter->getRIOGraphics();
391  std::vector<TObject*>::const_iterator rioit = rioObjects->begin();
392  //std::cout << "Got " << rioObjects.size() << " graphic objects for RIOs "<< std::endl;
393  for( ; rioit!=rioObjects->end();++rioit) {
394  (*rioit)->Draw();
395  }
396  }
397  std::vector<TObject*>* trackObjects = m_ntuplePlotter->getTrackGraphics();
398  std::vector<TObject*>::const_iterator oit = trackObjects->begin();
399  for( ; oit!=trackObjects->end();++oit) {
400  (*oit)->Draw();
401  }
402  if (m_showDAFinfo){
403  std::vector<TObject*>* compRotObjects = m_ntuplePlotter->getCompetingROTsGraphics();
404  oit = compRotObjects->begin();
405  for( ; oit!=compRotObjects->end();++oit) {
406  (*oit)->Draw();
407  }
408  }
409 
410  fCanvas->Modified();
411  fCanvas->Update();
412  }
413  //fprintf(stdout, "entry %d \n", int(m_entryNumber));
414  break;
415  case 21: // create EPS
416  {
417  //if(fCanvas)
418  char epsFileName[50]="BarrelTrack.eps";
419  //sprintf(epsFileName,"BarrelTrack%d.eps",int(m_entryNumber));
420  fCanvas->Print( epsFileName,"eps");
421  //}
422  break;}
423  case 22: // create PNG
424  {//if(fCanvas)
425  char pngFileName[50]="BarrelTrack.png";
426  //sprintf(pngFileName,"BarrelTrack%d.png",int(m_entryNumber));
427  fCanvas->Print( pngFileName,"png");
428  //}
429  break;}
430  case 23: // reset view
431  SetRange(-1100., -1100., 1100., 1100.);
432  break;
433 // case 33: // se
434 // SetRange(xmin+xdiff*.1, ymin-ydiff*.1, xmax+xdiff*.1, ymax-ydiff*.1);
435 // break;
436 // case 32: // e
437 // SetRange(xmin+xdiff*.1, ymin, xmax+xdiff*.1, ymax);
438 // break;
439 // case 31: // ne
440 // SetRange(xmin+xdiff*.1, ymin+ydiff*.1, xmax+xdiff*.1, ymax+ydiff*.1);
441 // break;
442 // case 21: // n
443 // SetRange(xmin, ymin+ydiff*.1, xmax, ymax+ydiff*.1);
444 // break;
445 // case 22: // c
446 // SetRange(50.0-xdiff/2,50-ydiff/2,50+xdiff/2,50+ydiff/2);
447 // break;
448  } // end switch(id)
449 }
450 
452  TGButton* button = (TGButton*)gTQSender;
453  UInt_t id = button->WidgetId();
454 
455 
456  fCanvas->cd();
457  fprintf(stdout, "RadioButton ID: %d \n", int(id));
458  switch (id) {
459  case 21: // single track mode
460  m_singleTrackMode = true;
461  fRadioSingleTrackMode[0]->SetState(kButtonDown);
462  fRadioSingleTrackMode[1]->SetState(kButtonUp);
463  break;
464  case 22: // event mode
465  m_singleTrackMode = false;
466  fRadioSingleTrackMode[0]->SetState(kButtonUp);
467  fRadioSingleTrackMode[1]->SetState(kButtonDown);
468  break;
469  }
470 }
471 
473  TGButton* button = (TGButton*)gTQSender;
474  TGCheckButton* checkButton = dynamic_cast<TGCheckButton*> (button);
475  if (!checkButton){
476  fprintf(stderr, "did not get the button\n");
477  return;
478  }
479  UInt_t id = button->WidgetId();
480 
481  fCanvas->cd();
482  //fprintf(stdout, "CheckButton ID: %d \n", int(id));
483  switch (id) {
484  case 21: // equal scaling
485  if (checkButton->IsOn()){
486  //fprintf(stdout, "CheckButton ID %d is on\n", int(id));
487  m_equalScaling = true;
488  // force rescaling:
489  double xmin, ymin, xmax, ymax;
490  fCanvas->GetRange(xmin,ymin,xmax,ymax);
491  //SetRange(xmin, ymin, xmax, ymax);
492  } else {
493  m_equalScaling = false;
494  }
495  break;
496  case 22: // draw assignment probabilities for DAF tracks
497  if (checkButton->IsOn()){
498  m_showDAFinfo = true;
499  std::vector<TObject*>* compRotObjects = m_ntuplePlotter->getCompetingROTsGraphics();
500  std::vector<TObject*>::const_iterator oit = compRotObjects->begin();
501  for( ; oit!=compRotObjects->end();++oit) {
502  (*oit)->Draw();
503  }
504  fCanvas->Modified();
505  fCanvas->Update();
506  } else {
507  m_showDAFinfo = false;
508  }
509  break;
510  }
511 }
512 
514  float xmin, ymin, xmax, ymax;
515  fHSlider->GetPosition(xmin,xmax);
516  fVSlider->GetPosition(ymin,ymax);
517  //std::cout << "Slider: X=(" << xmin<< "," << xmax<< "), Y=(" << ymin<< "," << ymax << ")"<< std::endl;
518 /* float xmin2 = xmin-2000.;
519  float ymin2 = ymin-2000.;
520  float xmax2 = xmax-2000.;
521  float ymax2 = ymax-2000.;*/
522  SetRange(xmin,ymin,xmax,ymax, kFALSE);
523 }
524 
525 void Viewer::SetRange(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax,
526  Bool_t move_slider) {
527 
528  if (m_equalScaling) {
529  //fprintf(stdout, "before scaling: x: [%f,%f] y: [%f, %f]\n", xmin, xmax, ymin, ymax );
530  double ratio = double(fMainEmbeddedCanvas->GetWidth())/double(fMainEmbeddedCanvas->GetHeight());
531  xmax = xmin + (ymax - ymin)*ratio;
532  //fprintf(stdout, "width: %d, height: %d, ratio: %f\n", fMainEmbeddedCanvas->GetWidth(), fMainEmbeddedCanvas->GetHeight(), ratio);
533  //fprintf(stdout, "after scaling: x: [%f,%f] y: [%f, %f]\n", xmin, xmax, ymin, ymax );
534  }
535  fCanvas->Range(xmin,ymin,xmax,ymax);
536 
537  //cerr << "x=[" << xmin << " - " << xmax << "], "
538  // << "y=[" << ymin << " - " << ymax << "]\n";
539 
540  fHScale->SetWmin(xmin);
541  fHScale->SetWmax(xmax);
542  fVScale->SetWmin(ymin);
543  fVScale->SetWmax(ymax);
544 
545  // Set position of slider - don't if DoSlider called SetRange
546  //if (move_slider) {
547 /* float xmin2 = xmin+2000.;
548  float ymin2 = ymin+2000.;
549  float xmax2 = xmax+2000.;
550  float ymax2 = ymax+2000.;*/
551  //xmin+=2000.; ymin+=2000.; xmax+=2000., ymax+=2000.;
552  fHSlider->SetPosition(xmin,xmax);
553  fVSlider->SetPosition(ymin,ymax);
554  //}
555 
556  fCanvas->Modified();
557  fHScaleCanvas->GetCanvas()->Modified();
558  fVScaleCanvas->GetCanvas()->Modified();
559  fCanvas->Update();
560  fHScaleCanvas->GetCanvas()->Update();
561  fVScaleCanvas->GetCanvas()->Update();
562  fClient->ForceRedraw(); //prevent GUI from being starved of redraws
563 
564 }
565 
566 
567 //---- Main program ------------------------------------------------------------
568 
569 int main(int argc, char **argv) {
570 // TApplication theApp("App", &argc, argv);
571 
572  if (gROOT->IsBatch()) {
573  fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]);
574  return 1;
575  }
576  // -----------------------------------
577  // Read the current TrackPlotter setup
578 
579  // get the TEnv object
580  TEnv* trackPlotterSetup = new TEnv("trackplotter.conf");
581  // get the ntuple filename
582  //char *filename = new char[80];
583  const char* filename = trackPlotterSetup->GetValue("TrackingNtupleFileName","TrkValidation.root");
584  // track ntuple directory and tree name
585  //char *trackNtupleDir = new char[80];
586  const char* trackNtupleDir = trackPlotterSetup->GetValue("TrackingNtupleDirectory","Validation");
587  //char *trackNtupleTree = new char[80];
588  const char* trackNtupleTree = trackPlotterSetup->GetValue("TrackingNtupleTree","Tracks");
589 
590  // use DAF data?
591  bool doDAFdata = false;
592  doDAFdata = trackPlotterSetup->GetValue("PlotDAFdata",0);
593 
594  // use RIO data?
595  bool doRIOdata = true;
596  doRIOdata = trackPlotterSetup->GetValue("PlotPrepRawData", 1);
597  //std::cout << "use RIO: -" << trackPlotterSetup->GetValue("PlotPrepRawData", "True") <<"-" << std::endl;
598  // rio ntuple directory and tree name
599  //char *rioNtupleDir = new char[80];
600  const char* rioNtupleDir = trackPlotterSetup->GetValue("PrepRawDataNtupleDirectory","Validation");
601  //char *trackNtupleTree = new char[80];
602  const char* rioNtupleTree = trackPlotterSetup->GetValue("PrepRawDataNtupleTree","TRT_RIOs");
603 
604 // trackPlotterSetup->SetValue("TrackingNtupleFileName", filename);
605 // trackPlotterSetup->SetValue("TrackingNtupleDirectory", trackNtupleDir);
606 // trackPlotterSetup->SetValue("TrackingNtupleTree", trackNtupleTree);
607 // trackPlotterSetup->SetValue("PlotDAFdata", doDAFdata);
608 // trackPlotterSetup->SetValue("PlotPrepRawData", doRIOdata);
609 // trackPlotterSetup->SetValue("PrepRawDataNtupleDirectory", rioNtupleDir);
610 // trackPlotterSetup->SetValue("PrepRawDataNtupleTree", rioNtupleTree);
611 // trackPlotterSetup->Save();
612  trackPlotterSetup->Print();
613 
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,"");
620 
621 // int trackNumber = 0;
622  if ( argc >= 2 ){ // argc should be 2 for correct execution
623  //delete[] filename;
624  filename = argv[1];
625  }else {
626  // We print argv[0] assuming it is the program name
627  std::cout<<"usage: "<< argv[0] <<" <filename>"<< std::endl;
628  //filename = "TrkValidation.root";
629 // trackNumber = atoi(argv[2]);
630  }
631  //if ( argc >= 3 ){
632  // doDAFdata = bool(argv[2]);
633  //}
634  std::cout<<"Using file "<<filename << (doRIOdata ? " including PrepRawData" : "") << (doDAFdata ? " with DAF information" : "") << std::endl;
635 
636  TApplication theApp("App", &argc, argv);
637  TFile *f = new TFile(filename);
638  if (!f) {
639  std::cout << "ERROR: could not find " << filename << std::endl;
640  return 1;
641  }
642 
643  char rootFileName[100];
644  sprintf(rootFileName,"%s:/%s",filename, trackNtupleDir);
645  //std::cout<<"cd: "<<rootFileName << std::endl;
646  f->cd(rootFileName);
647 
648  TTree *tree = (TTree*)gDirectory->Get(trackNtupleTree);
649  if (!tree) {
650  std::cout << "ERROR: could not get the tree: " << filename << ":/" << trackNtupleDir << "/" << trackNtupleTree << std::endl;
651  return 1;
652  }
653  //delete filename;
654  // get the ntuple with the track data
655  TrackDataNtupleTree* trackNtuple = new TrackDataNtupleTree(tree, doDAFdata);
656 
657  //std::cout<<"got TrackDataNtupleTree"<< std::endl;
658  // get the RIOs
659 
660  sprintf(rootFileName,"%s:/%s",filename, rioNtupleDir);
661  //f->cd("TrkValidation.root:/FitterValidation");
662  //std::cout<<"cd: "<<rootFileName << std::endl;
663  f->cd(rootFileName);
664 
665  TTree *RIOtree = 0;
666  TrkValidationNtupleRIOs* rioNtuple = 0;
667  if (doRIOdata) {
668  RIOtree = (TTree*)gDirectory->Get(rioNtupleTree);
669  if (!RIOtree) {
670  std::cout << "ERROR: could not get the tree: " << filename << ":/" << rioNtupleDir << "/" << rioNtupleTree << std::endl;
671  return 1;
672  }
673  // get the ntuple with the rio data
674  rioNtuple = new TrkValidationNtupleRIOs(RIOtree);
675  }
676  //delete filename;
677 
678  PlotValNtuple theNtuplePlotter( *trackNtuple, rioNtuple);
679 
680  Viewer viewer(gClient->GetRoot(), &theNtuplePlotter);
681 
682  theApp.Run();
683 
684  delete color_301; delete color_302;
685  delete color_303; delete color_306;
686  delete color_310; delete color_311;
687  delete trackNtuple;
688  delete rioNtuple;
689  return 0;
690 }
PlotValNtuple::setNextTrack
void setNextTrack(int &eventNumber, int &trackNumber, int &InterationNumber)
Definition: PlotValNtuple.cxx:23
Viewer::fHSlider
TGDoubleSlider * fHSlider
Definition: trackplotter.h:38
Viewer
Definition: trackplotter.h:23
ymin
double ymin
Definition: listroot.cxx:63
main
int main(int argc, char **argv)
Definition: trackplotter.cxx:569
Viewer::DoRadioButton
void DoRadioButton()
Definition: trackplotter.cxx:451
tree
TChain * tree
Definition: tile_monitor.h:30
Viewer::DoSlider
void DoSlider()
Definition: trackplotter.cxx:513
get_generator_info.stdout
stdout
Definition: get_generator_info.py:40
Viewer::fRadioSingleTrackMode
TGRadioButton * fRadioSingleTrackMode[2]
Definition: trackplotter.h:40
PlotValNtuple::setPrevEvent
void setPrevEvent(int &eventNumber)
Definition: PlotValNtuple.cxx:130
TrkValidationNtupleRIOs
Definition: TrkValidationNtupleRIOs.h:26
Viewer::m_singleTrackMode
bool m_singleTrackMode
Definition: trackplotter.h:30
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
trackplotter.h
Viewer::m_ntuplePlotter
PlotValNtuple * m_ntuplePlotter
Definition: trackplotter.h:28
Viewer::Viewer
Viewer(const TGWindow *win, PlotValNtuple *ntuplePlotter)
Definition: trackplotter.cxx:32
PlotValNtuple
Definition: PlotValNtuple.h:28
Viewer::fVScaleCanvas
TRootEmbeddedCanvas * fVScaleCanvas
Definition: trackplotter.h:36
PlotValNtuple::getTrackGraphics
std::vector< TObject * > * getTrackGraphics()
Definition: PlotValNtuple.h:60
PlotValNtuple::setNextEvent
void setNextEvent(int &eventNumber)
Definition: PlotValNtuple.cxx:92
BarrelXY
@ BarrelXY
Definition: PlotValNtuple.h:24
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
xmin
double xmin
Definition: listroot.cxx:60
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
Viewer::fCanvas
TCanvas * fCanvas
Definition: trackplotter.h:34
PlotValNtuple.h
Viewer::DoCheckButton
void DoCheckButton()
Definition: trackplotter.cxx:472
Viewer::fCleanup
TList * fCleanup
Definition: trackplotter.h:33
TrackDataNtupleTree
this class inherites from the automatically created TrkValidationNtupleOutputTrack to have independen...
Definition: TrackDataNtupleTree.h:16
hist_file_dump.f
f
Definition: hist_file_dump.py:135
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Viewer::DoButton
void DoButton()
Definition: trackplotter.cxx:252
Viewer::fHScaleCanvas
TRootEmbeddedCanvas * fHScaleCanvas
Definition: trackplotter.h:36
Viewer::fMainEmbeddedCanvas
TRootEmbeddedCanvas * fMainEmbeddedCanvas
Definition: trackplotter.h:35
python.ext.table_printer.table
list table
Definition: table_printer.py:81
Viewer::m_equalScaling
bool m_equalScaling
Definition: trackplotter.h:31
Viewer::fVSlider
TGDoubleSlider * fVSlider
Definition: trackplotter.h:39
PlotValNtuple::getRIOGraphics
std::vector< TObject * > * getRIOGraphics()
Definition: PlotValNtuple.h:71
python.compareTCTs.ratio
ratio
Definition: compareTCTs.py:295
StateLessPT_NewConfig.Layout
Layout
Definition: StateLessPT_NewConfig.py:159
Viewer::m_showDAFinfo
bool m_showDAFinfo
Definition: trackplotter.h:32
PlotValNtuple::setMode
void setMode(DisplayMode mode)
Definition: PlotValNtuple.h:41
TRT::Track::trackNumber
@ trackNumber
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:75
Viewer::fHScale
TGaxis * fHScale
Definition: trackplotter.h:37
xmax
double xmax
Definition: listroot.cxx:61
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
Viewer::SetRange
void SetRange(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Bool_t move_slider=kTRUE)
Definition: trackplotter.cxx:525
Viewer::~Viewer
virtual ~Viewer()
Definition: trackplotter.cxx:243
python.AppMgr.theApp
theApp
Definition: AppMgr.py:771
PlotValNtuple::getCompetingROTsGraphics
std::vector< TObject * > * getCompetingROTsGraphics()
Definition: PlotValNtuple.h:93
Viewer::fVScale
TGaxis * fVScale
Definition: trackplotter.h:37
EndCapPhiZ
@ EndCapPhiZ
Definition: PlotValNtuple.h:24
PlotValNtuple::setPrevTrack
void setPrevTrack(int &eventNumber, int &trackNumber, int &InterationNumber)
Definition: PlotValNtuple.cxx:58
checkFileSG.ind
list ind
Definition: checkFileSG.py:118
ymax
double ymax
Definition: listroot.cxx:64