19#include "CLHEP/String/Strings.h"
36TWindow::_skipAllWindow =
false;
38TWindow::TWindow(
const TWindow & a)
39: _name(
"copy of " + a._name),
40 _window(600, 600, _name.
c_str()),
41 _wireName(a._wireName),
42 _coordinate(a._coordinate),
49 _targetRun(a._targetRun),
50 _targetEvent(a._targetEvent),
55 _segmentLink(a._segmentLink),
56 _segmentProperty(a._segmentProperty),
59 _nEvents(a._nEvents) {
60 for (
unsigned i = 0; i < 4; i++) _zoomHistory[i] = a._zoomHistory[i];
61 _window.set_show_coordinates(_coordinate);
62 _window.buttons_per_line(7);
63 _closeButton = _window.button(
"next");
64 _wireNameButton = _window.button(
"wire #");
65 _axialButton = _window.button(
"axial");
66 _stereoButton = _window.button(
"stereo");
67 _coordinateButton = _window.button(
"coordinate");
68 _zoomInButton = _window.button(
"zoom in");
69 _zoomOutButton = _window.button(
"zoom out");
70 _skipButton = _window.button(
"skip");
71 _skipAllButton = _window.button(
"skip all");
72 _szButton = _window.button(
"rphi/sz");
73 _confButton = _window.button(
"conformal");
74 _segmentLinkButton = _window.button(
"sgmt link");
75 _segmentPropertyButton = _window.button(
"sgmt vec");
76 _copyButton = _window.button(
"window cp");
77 _window.init(_xmin, _xmax, _ymin);
80TWindow::TWindow(
const std::string & name)
82 _window(600, 600, name.
c_str()),
96 _segmentProperty(
false),
99 _window.set_show_coordinates(_coordinate);
100 _window.buttons_per_line(7);
101 _closeButton = _window.button(
"next");
102 _wireNameButton = _window.button(
"wire #");
103 _axialButton = _window.button(
"axial");
104 _stereoButton = _window.button(
"stereo");
105 _coordinateButton = _window.button(
"coordinate");
106 _zoomInButton = _window.button(
"zoom in");
107 _zoomOutButton = _window.button(
"zoom out");
108 _skipButton = _window.button(
"skip");
109 _skipAllButton = _window.button(
"skip all");
110 _szButton = _window.button(
"rphi/sz");
111 _confButton = _window.button(
"conformal");
112 _segmentLinkButton = _window.button(
"sgmt link");
113 _segmentPropertyButton = _window.button(
"sgmt vec");
114 _copyButton = _window.button(
"window cp");
115 _window.init(_xmin, _xmax, _ymin);
116 _zoomHistory[0].push(
HepVector3D(_xmin, _xmax, _ymin));
118 _zoomHistory[2].push(
HepVector3D(_xmin, _xmax, _ymin));
119 _zoomHistory[3].push(
HepVector3D(-0.28, 0.28, -0.28));
129 if (_skipAllWindow)
return;
130 if (! target())
return;
140 int b = _window.read_mouse(x0, y0);
143 if (
b == _closeButton) loop =
false;
144 else if (
b == _szButton) {
145 if (_mode != 0) _mode = 0;
146 else if (_mode != 2) _mode = 2;
149 else if (
b == _confButton) {
150 if (_mode != 3) _mode = 3;
151 else if (_mode != 1) _mode = 1;
154 else if (
b == _segmentLinkButton) {
155 _segmentLink = ! _segmentLink;
158 else if (
b == _segmentPropertyButton) {
159 _segmentProperty = ! _segmentProperty;
162 else if (
b == _skipButton) {
166 else if (
b == _skipAllButton) {
168 _skipAllWindow =
true;
170 else if (
b == _coordinateButton) {
171 _coordinate = ! _coordinate;
172 _window.set_show_coordinates(_coordinate);
175 else if (
b == _wireNameButton) {
176 _wireName = ! _wireName;
179 else if (
b == _axialButton) {
183 else if (
b == _stereoButton) {
187 else if (
b == _copyButton) {
188 TWindow tmp = *
this;
191 else if (
b == _zoomInButton) {
194 else if (
b == _zoomOutButton) {
196 if (_zoomHistory[_mode].size() > 1) {
197 _zoomHistory[_mode].pop();
200 _zoomHistory[_mode].pop();
204 _zoomHistory[_mode].push(
HepVector3D(_xmin, _xmax, _ymin));
209 else if (
b == MOUSE_BUTTON(1)) {
212 int bb = _window.read_mouse_rect(x0, y0, x,
y);
213 double xx(x0 < x ? x0 : x);
214 double xxx(x0 < x ? x : x0);
215 double yy(y0 <
y ? y0 :
y);
216 _zoomHistory[_mode].push(
HepVector3D(xx, xxx, yy));
226 if (! target())
return;
227 if (! _display)
open();
232 _window.init(z.x(), z.y(), z.z());
234 double xmin = _window.xmin();
235 double xmax = _window.xmax();
236 double ymin = _window.ymin();
237 double ymax = _window.ymax();
238 double x = xmin + (xmax - xmin) * .05;
239 double y = ymin + (ymax - ymin) * .03;
242 _yPositionStep = (ymax - ymin) * .03;
248 unsigned n = _objects.length();
249 for (
unsigned i = 0; i <
n; i++) {
252 drawLine((
const TMLine &) track, * _colors[i]);
254 drawBase(track, * _colors[i]);
256 drawTrack((
const TTrack &) track, * _colors[i]);
258 drawSegment((
const TSegment &) track, * _colors[i]);
260 std::cout <<
"TWindow::draw !!! can't display" << std::endl;
264 _window.draw_text(_xPositionText, _yPositionText, _text.c_str());
269TWindow::drawBase(
const TTrackBase & base, leda_color c) {
271 unsigned n = links.length();
272 for (
unsigned i = 0; i <
n; i++) {
273 if (links[i]->wire() ==
NULL)
continue;
275 if (links[i]->wire()->stereo())
278 if (links[i]->wire()->axial())
286 _window.draw_point(
x.x(),
x.y(), c);
288 std::string
n = links[i]->wire()->name() +
":";
290 if (links[i]->hit()->mc())
292 + itostring(links[i]->hit()->mc()->hep()->
id()) +
")";
294 n += itostring(links[i]->leftRight());
295 _window.draw_text(
x.x(),
x.y(),
n.c_str());
300 else if (_mode == 0) {
303 HepPoint3D x = links[i]->wire()->forwardPosition();
304 double radius = links[i]->hit()->drift();
305 _window.draw_circle(
x.x(),
x.y(), radius, c);
307 _window.draw_text(
x.x(),
309 wireName(* links[i]).
c_str());
313 else if (_mode == 1) {
323 _window.draw_point(
x.x(),
x.y(), c);
325 std::string
n = links[i]->wire()->name();
326 _window.draw_text(
x.x(),
x.y(),
n.c_str());
331 else if (_mode == 3) {
335 _window.draw_point(
x.x(),
x.y(), c);
337 std::string
n = links[i]->wire()->name();
338 _window.draw_text(
x.x(),
x.y(),
n.c_str());
345TWindow::drawSegment(
const TSegment & base, leda_color c) {
348 unsigned n = links.length();
351 for (
unsigned i = 0; i <
n; i++) {
353 if (links[i]->wire()->stereo())
356 if (links[i]->wire()->axial())
361 x = links[i]->position();
362 _window.draw_point(
x.x(),
x.y(), c);
364 std::string
n = links[i]->wire()->name() +
":"
365 + itostring(links[i]->leftRight());
366 _window.draw_text(
x.x(),
x.y(),
n.c_str());
369 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
374 else if (_mode == 0) {
375 x = links[i]->wire()->forwardPosition();
376 double radius = links[i]->hit()->drift();
377 _window.draw_circle(
x.x(),
x.y(), radius, c);
379 _window.draw_text(
x.x(),
381 (
const char *) wireName(* links[i]).
c_str());
383 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
388 else if (_mode == 1) {
398 _window.draw_point(
x.x(),
x.y(), c);
400 std::string
n = links[i]->wire()->name();
401 _window.draw_text(
x.x(),
x.y(),
n.c_str());
404 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
410 else if (_mode == 3) {
420 _window.draw_point(
x.x(),
x.y(), c);
422 std::string
n = links[i]->wire()->name();
423 _window.draw_text(
x.x(),
x.y(),
n.c_str());
426 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
432 if (_segmentProperty) {
434 float in = links.first()->position().mag();
435 float out = links.last()->position().mag();
436 float length = out - in;
439 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
445 if (! _segmentLink)
return;
447 unsigned nLinks = innerLinks.length();
448 for (
unsigned i = 0; i < nLinks; i++) {
449 if (i == 0) c = leda_blue;
460 else if (_mode == 0) {
461 x = links[0]->wire()->forwardPosition();
462 y = innerTLinks.last()->wire()->forwardPosition();
463 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
469 else if (_mode == 1) {
474 list.append((
TMDCWireHit *) innerTLinks.last()->hit());
479 x = list2[0]->position();
480 y = list2[1]->position();
481 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
487 else if (_mode == 3) {
492 list.append((
TMDCWireHit *) innerTLinks.last()->hit());
497 x = list2[0]->position();
498 y = list2[1]->position();
499 _window.draw_segment(
y.x(),
y.y(),
x.x(),
x.y(), c);
507TWindow::drawLine(
const TMLine & line, leda_color c) {
512 double xmin = _window.xmin();
513 double xmax = _window.xmax();
514 double ymin = xmin * line.
a() + line.
b();
515 double ymax = xmax * line.
a() + line.
b();
516 _window.draw_segment(xmin, ymin, xmax, ymax, c);
520TWindow::target(
void)
const {
521 struct belle_event * ev =
522 (
struct belle_event *) BsGetEnt(BELLE_EVENT, 1, BBS_No_Index);
523 if (_targetRun == 0 && _targetEvent == 0)
525 if (ev->m_RunNo == _targetRun && ev->m_EvtNo == _targetEvent)
531TWindow::target(
unsigned run,
unsigned farm,
unsigned event) {
533 _targetEvent = (farm << 28) + event;
537TWindow::drawTrack(
const TTrack &
t, leda_color c) {
539 _window.draw_text(_xPositionText, _yPositionText, p.c_str(), c);
540 _yPositionText += _yPositionStep;
543 unsigned n = links.length();
544 for (
unsigned i = 0; i <
n; i++) {
546 if (links[i]->wire()->stereo())
549 if (links[i]->wire()->axial())
553 HepPoint3D x = links[i]->wire()->forwardPosition();
554 double radius = links[i]->hit()->drift();
555 _window.draw_circle(
x.x(),
x.y(), radius, c);
557 _window.draw_text(
x.x(),
559 (
const char *) wireName(* links[i]).
c_str());
562 else if (_mode == 2) {
566 _window.draw_point(sz.x(), sz.y(), c);
568 std::string
n = links[i]->wire()->name() +
":"
569 + itostring(links[i]->leftRight());
570 _window.draw_text(sz.x(), sz.y(),
n.c_str());
572 x = links[i]->positionOnWire();
575 _window.draw_point(sz.x(), sz.y(), c);
577 std::string
n = links[i]->wire()->name() +
":"
578 + itostring(links[i]->leftRight());
579 _window.draw_text(sz.x(), sz.y(),
n.c_str());
584 else if (_mode == 1) {
594 _window.draw_point(
x.x(),
x.y(), c);
596 std::string
n = links[i]->wire()->name();
597 _window.draw_text(
x.x(),
x.y(),
n.c_str());
603 else if (_mode == 3) {
613 _window.draw_point(
x.x(),
x.y(), c);
615 std::string
n = links[i]->wire()->name();
616 _window.draw_text(
x.x(),
x.y(),
n.c_str());
623 _window.draw_text(0., 0., (
const char *)
"can't display a track");
632 leda_point ip(hIp.
x(0.).x(), hIp.
x(0.).y());
635 leda_point in(pIn.x(), pIn.y());
636 leda_point out(pOut.x(), pOut.y());
638 _window.draw_text(0., 0., (
const char *)
"can't display a track");
641 _window.draw_arc(ip, in, out, c);
642 _window.draw_text(pOut.x(), pOut.y(),
t.name().c_str());
645 else if (_mode == 2) {
649 double xmin = _window.xmin();
650 double xmax = _window.xmax();
651 double ymin = xmin * hIp.
tanl() *
t.charge() + hIp.
dz();
652 double ymax = xmax * hIp.
tanl() *
t.charge() + hIp.
dz();
653 _window.draw_segment(xmin, ymin, xmax, ymax, c);
658TWindow::drawAxes(
void) {
659 double xmin = _window.xmin();
660 double xmax = _window.xmax();
661 _window.draw_segment(xmin, 0., xmax, 0., leda_grey2);
662 double ymin = _window.ymin();
663 double ymax = _window.ymax();
664 _window.draw_segment(0., ymin, 0., ymax, leda_grey2);
668TWindow::drawCdc(
void) {
673 _window.draw_circle(0., 0., r);
675 _window.draw_circle(0., 0., r);
677 _window.draw_circle(0., 0., r);
682TWindow::clear(
void) {
685 _objects.removeAll();
687 HepAListDeleteAll(_colors);
688 HepAListDeleteAll(_selfObjects);
689 HepAListDeleteAll(_selfTLinks);
697 _colors.append(
new leda_color(c));
698 _selfObjects.append(
t);
702TWindow::wireName(
const TMLink & l)
const {
714TWindow::oneShot(
const TTrackBase &
t, leda_color c) {
717 unsigned id = _objects.length() - 1;
719 leda_color *
b = _colors[id];
728 for (
unsigned i = 0; i <
t.length(); i++) {
730 for (
unsigned j = 0; j <
s.links().length(); j++)
736 unsigned id = _objects.length() - 1;
738 leda_color *
b = _colors[id];
745 unsigned n = list.length();
746 for (
unsigned i = 0; i <
n; i++) {
753 int err =
t.szPosition(* l0);
754 err =
t.szPosition(* l1);
755 err =
t.szPosition(* l2);
762 _colors.append(
new leda_color(c));
763 _selfTLinks.append(l0);
764 _selfTLinks.append(l1);
765 _selfTLinks.append(l2);
766 _selfObjects.append(
b);
771TWindow::appendSz(
const TTrack &
t,
774 unsigned n = list.length();
775 for (
unsigned i = 0; i <
n; i++) {
778 t.szPosition(
s, * l);
783 _colors.append(
new leda_color(c));
784 _selfTLinks.append(l);
785 _selfObjects.append(
b);
790TWindow::draw(
const TPoint2D & p, leda_color c) {
791 _window.draw_point(p.
x(), p.
y(), c);
795TWindow::drawHeader(
void) {
796 struct belle_event * h = (
struct belle_event *)
797 BsGetEnt(BELLE_EVENT, 1, BBS_No_Index);
801 static const std::string sp =
" ";
802 std::string mc =
"mc:" + itostring(h->m_ExpMC);
803 std::string
exp =
"exp:" + itostring(h->m_ExpNo);
804 std::string run =
"run:" + itostring(h->m_RunNo);
805 std::string frm =
"frm:" + itostring((h->m_EvtNo >> 28));
806 std::string evt =
"evt:" + itostring((h->m_EvtNo & 268435455));
807 std::string dat =
"dat:" + std::string(ctime((
const time_t *) & h->m_Time));
808 std::string fld =
"fld:" + dtostring(h->m_BField);
809 std::string ler =
"ler:" + dtostring(h->m_ELER);
810 std::string her =
"her:" + dtostring(h->m_EHER);
813 if (calcdc_unpack_.unpack_truncate)
814 s0 +=
"truncated event";
815 std::string head0 =
exp + sp + run + sp + frm + sp + evt;
816 std::string head1 = dat;
817 std::string head2 = fld + sp + ler + sp + her;
819 double xmin = _window.xmin();
820 double xmax = _window.xmax();
821 double ymin = _window.ymin();
822 double ymax = _window.ymax();
823 double x0 = xmin + (xmax - xmin) * .7;
824 double x1 = xmin + (xmax - xmin) * .6;
825 double y0 = ymin + (ymax - ymin) * .92;
826 double y1 = ymin + (ymax - ymin) * .95;
827 double y2 = ymin + (ymax - ymin) * .98;
828 double y3 = ymin + (ymax - ymin) * -.90;
830 _window.draw_text(x0, y2, head2.c_str());
831 _window.draw_text(x0, y1, head1.c_str());
832 _window.draw_text(x0, y0, head0.c_str());
835 _window.draw_text(x1, y3, s0.c_str());
HepGeom::Vector3D< double > HepVector3D
m_outputFile open("YYYY/m_txt_dir/LumTau_XXXX.txt", ios_base::app)
EvtComplex exp(const EvtComplex &c)
const HepPoint3D ORIGIN
Constants.
#define WireHitFindingValid
#define WireHitFittingValid
#define WireHitInvalidForFit
TMLink * OuterMost(const AList< TMLink > &a)
int SortByWireId(const void *av, const void *bv)
Sorter.
TMLink * InnerMost(const AList< TMLink > &a)
returns the inner(outer)-most link.
std::string TrackLayerUsage(const TTrack &t)
std::string TrackKinematics(const Helix &h)
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
const HepPoint3D & pivot(void) const
returns pivot position.
const TTrackHEP *const hep(void) const
returns a pointer to a GEN_HEPEVT.
unsigned state(void) const
returns state.
const TMDCWireHitMC *const mc(void) const
returns a pointer to TMDCWireHitMC.
std::string name(void) const
returns name.
A class to represent a track in tracking.
double a(void) const
returns coefficient a.
double b(void) const
returns coefficient b.
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & positionOnTrack(void) const
returns the closest point on track to wire.
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
A class to represent a point in 2D.
A class to relate TMDCWireHit and TTrack objects.
const HepVector3D & direction(void) const
returns direction.
const HepPoint3D & position(void) const
returns position.
AList< TSegment > & innerLinks(void)
A virtual class for a track class in tracking.
void append(TMLink &)
appends a TMLink.
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
virtual unsigned objectType(void) const
returns object type.
unsigned id(void) const
returns an id started from 0.
A class to represent a track in tracking.
char * append(const char *str, EvtCyclic3::Index i)