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