Belle II Software  release-05-01-25
TRGCDCDisplay.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : TRGCDCDisplay.cc
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A program to display TRGCDC components
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #ifdef TRGCDC_DISPLAY
15 
16 #define TRG_SHORT_NAMES
17 #define TRGCDC_SHORT_NAMES
18 
19 #include <iostream>
20 #include "trg/cdc/TRGCDC.h"
21 #include "trg/cdc/Wire.h"
22 #include "trg/cdc/Segment.h"
23 #include "framework/gearbox/Gearbox.h"
24 #include "trg/cdc/DisplayRphi.h"
25 #include "trg/cdc/DisplayHough.h"
26 namespace Belle2_TRGCDC {
27  Belle2::TRGCDCDisplayRphi* D = 0;
28 }
29 
30 using namespace std;
31 using namespace Belle2;
32 #ifdef TRGCDC_DISPLAY
33 using namespace Belle2_TRGCDC;
34 #endif
35 
36 #define DEBUG_LEVEL 1
37 #define PROGRAM_NAME "TRGCDCDisplay"
38 #define PROGRAM_VERSION "version 0.00"
39 #define ENV_PATH "BELLE2_LOCAL_DIR"
40 #define CONFIG "TRGCDCWireConfig_0_20101110_0836.dat"
41 
42 int
43 main(int , char**)
44 {
45 
46  cout << PROGRAM_NAME << " ... " << PROGRAM_VERSION << endl;
47 
48 #ifdef TRGCDC_DISPLAY
49  //...Gearbox...
50  const string path = getenv(ENV_PATH);
51  vector<std::string> m_backends;
52  string m_filename = path + "/data/geometry/Belle2.xml";
53  m_backends.push_back("file:");
54  Gearbox& gearbox = Gearbox::getInstance();
55  gearbox.setBackends(m_backends);
56  gearbox.open(m_filename);
57 
58  //...TRGCDC...
59  const string cname = path + "/data/trg/" + CONFIG;
60 // TRGCDC * cdc = TRGCDC::getTRGCDC(cname, false, 100, 100);
61  TRGCDC* cdc = TRGCDC::getTRGCDC(cname);
62 
63  //...Display...
64  D->clear();
65  D->show();
66 
67  //...For Iwasaki...
68  string inf = "1/8 of TS";
69  string stg = "";
70  string target = "none";
71  for (unsigned i = 0; i < cdc->nSegments(); i++) {
72  if (i % 8) continue;
73  D->area().append(cdc->segment(i));
74  }
75  for (unsigned i = 0; i < cdc->nWires(); i++) {
76  const TCWire& w = * cdc->wire(i);
77  if ((w.layerId() != 2) &&
78  (w.layerId() != 10) &&
79  (w.layerId() != 16) &&
80  (w.layerId() != 22) &&
81  (w.layerId() != 28) &&
82  (w.layerId() != 34) &&
83  (w.layerId() != 40) &&
84  (w.layerId() != 46) &&
85  (w.layerId() != 52)) continue;
86  if (i % 8) continue;
87  vector<const TCWire*> v;
88  v.push_back(cdc->wire(i));
89  D->area().append(v, Gdk::Color("red"));
90  }
91  D->stage(stg);
92  D->information(inf);
93  D->show();
94  D->run();
95 
96  //...Draw objects...
97  while (1) {
98 
99  cout << "Enter a target to display" << endl;
100  getline(cin, target);
101  if (target == "clear") {
102  D->clear();
103  inf = "";
104  cout << "targets cleared" << endl;
105  } else if (target.find("TS") != string::npos) {
106  bool found = false;
107  for (unsigned i = 0; i < cdc->nSegments(); i++) {
108  if (target == cdc->segment(i).name()) {
109  D->area().append(cdc->segment(i));
110  if (inf.size()) inf += ",";
111  inf += target;
112  D->stage(stg);
113  D->information(inf);
114  D->show();
115 // D->run();
116  found = true;
117  break;
118  }
119  }
120  if (! found)
121  cout << "!!! " << target << " not found" << endl;
122  } else if (target == "draw") {
123  D->run();
124  } else if (target == "quit") {
125  break;
126  } else {
127  cout << "!!! unknown target" << endl;
128  }
129  }
130 #endif
131 
132  //...Termination...
133  cout << PROGRAM_NAME << " ... terminated" << endl;
134 }
135 
136 #else
137 #include <iostream>
138 int
139 main()
140 {
141  std::cout << "Please turn on TRG*_DISPLAY flags in trg/SConscript to get "
142  << "a display" << std::endl;
143 }
144 #endif
main
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:77
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Gearbox
Singleton class responsible for loading detector parameters from an XML file.
Definition: Gearbox.h:44
Belle2::TRGCDC
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:70