00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifdef TRKRECO_WINDOW
00014
00015 #include <time.h>
00016
00017
00018
00019 #include "CLHEP/String/Strings.h"
00020 #include "TrkReco/TMDC.h"
00021 #include "TrkReco/TWindow.h"
00022 #include "TrkReco/TMLink.h"
00023 #include "TrkReco/TTrack.h"
00024 #include "TrkReco/TMLine.h"
00025 #include "TrkReco/TSegment.h"
00026 #include "TrkReco/TMDCWireHitMC.h"
00027 #include "TrkReco/TTrackHEP.h"
00028 #include "TrkReco/TConformalFinder0.h"
00029
00030 extern struct {
00031 int unpack_truncate;
00032 int unpackAll;
00033 } calcdc_unpack_;
00034
00035 bool
00036 TWindow::_skipAllWindow = false;
00037
00038 TWindow::TWindow(const TWindow & a)
00039 : _name("copy of " + a._name),
00040 _window(600, 600, _name.c_str()),
00041 _wireName(a._wireName),
00042 _coordinate(a._coordinate),
00043 _xmin(a._xmin),
00044 _xmax(a._xmax),
00045 _ymin(a._ymin),
00046 _display(false),
00047 _objects(a._objects),
00048 _colors(a._colors),
00049 _targetRun(a._targetRun),
00050 _targetEvent(a._targetEvent),
00051 _mode(a._mode),
00052 _axial(a._axial),
00053 _stereo(a._stereo),
00054 _skip(false),
00055 _segmentLink(a._segmentLink),
00056 _segmentProperty(a._segmentProperty),
00057 _text(a._text),
00058 _canDelete(false),
00059 _nEvents(a._nEvents) {
00060 for (unsigned i = 0; i < 4; i++) _zoomHistory[i] = a._zoomHistory[i];
00061 _window.set_show_coordinates(_coordinate);
00062 _window.buttons_per_line(7);
00063 _closeButton = _window.button("next");
00064 _wireNameButton = _window.button("wire #");
00065 _axialButton = _window.button("axial");
00066 _stereoButton = _window.button("stereo");
00067 _coordinateButton = _window.button("coordinate");
00068 _zoomInButton = _window.button("zoom in");
00069 _zoomOutButton = _window.button("zoom out");
00070 _skipButton = _window.button("skip");
00071 _skipAllButton = _window.button("skip all");
00072 _szButton = _window.button("rphi/sz");
00073 _confButton = _window.button("conformal");
00074 _segmentLinkButton = _window.button("sgmt link");
00075 _segmentPropertyButton = _window.button("sgmt vec");
00076 _copyButton = _window.button("window cp");
00077 _window.init(_xmin, _xmax, _ymin);
00078 }
00079
00080 TWindow::TWindow(const std::string & name)
00081 : _name(name),
00082 _window(600, 600, name.c_str()),
00083 _wireName(false),
00084 _coordinate(false),
00085 _xmin(-100),
00086 _xmax(100),
00087 _ymin(-100),
00088 _display(false),
00089 _targetRun(0),
00090 _targetEvent(0),
00091 _mode(0),
00092 _axial(true),
00093 _stereo(false),
00094 _skip(false),
00095 _segmentLink(false),
00096 _segmentProperty(false),
00097 _canDelete(true),
00098 _nEvents(0) {
00099 _window.set_show_coordinates(_coordinate);
00100 _window.buttons_per_line(7);
00101 _closeButton = _window.button("next");
00102 _wireNameButton = _window.button("wire #");
00103 _axialButton = _window.button("axial");
00104 _stereoButton = _window.button("stereo");
00105 _coordinateButton = _window.button("coordinate");
00106 _zoomInButton = _window.button("zoom in");
00107 _zoomOutButton = _window.button("zoom out");
00108 _skipButton = _window.button("skip");
00109 _skipAllButton = _window.button("skip all");
00110 _szButton = _window.button("rphi/sz");
00111 _confButton = _window.button("conformal");
00112 _segmentLinkButton = _window.button("sgmt link");
00113 _segmentPropertyButton = _window.button("sgmt vec");
00114 _copyButton = _window.button("window cp");
00115 _window.init(_xmin, _xmax, _ymin);
00116 _zoomHistory[0].push(HepVector3D(_xmin, _xmax, _ymin));
00117 _zoomHistory[1].push(HepVector3D(0., 7., 0.));
00118 _zoomHistory[2].push(HepVector3D(_xmin, _xmax, _ymin));
00119 _zoomHistory[3].push(HepVector3D(-0.28, 0.28, -0.28));
00120 }
00121
00122 TWindow::~TWindow() {
00123 clear();
00124 }
00125
00126 void
00127 TWindow::wait(void) {
00128 if (_skip) return;
00129 if (_skipAllWindow) return;
00130 if (! target()) return;
00131 draw();
00132
00133 bool loop = true;
00134 bool zoom = false;
00135
00136 while (loop) {
00137
00138
00139 double x0, y0;
00140 int b = _window.read_mouse(x0, y0);
00141
00142
00143 if (b == _closeButton) loop = false;
00144 else if (b == _szButton) {
00145 if (_mode != 0) _mode = 0;
00146 else if (_mode != 2) _mode = 2;
00147 draw();
00148 }
00149 else if (b == _confButton) {
00150 if (_mode != 3) _mode = 3;
00151 else if (_mode != 1) _mode = 1;
00152 draw();
00153 }
00154 else if (b == _segmentLinkButton) {
00155 _segmentLink = ! _segmentLink;
00156 draw();
00157 }
00158 else if (b == _segmentPropertyButton) {
00159 _segmentProperty = ! _segmentProperty;
00160 draw();
00161 }
00162 else if (b == _skipButton) {
00163 loop = false;
00164 _skip = true;
00165 }
00166 else if (b == _skipAllButton) {
00167 loop = false;
00168 _skipAllWindow = true;
00169 }
00170 else if (b == _coordinateButton) {
00171 _coordinate = ! _coordinate;
00172 _window.set_show_coordinates(_coordinate);
00173 draw();
00174 }
00175 else if (b == _wireNameButton) {
00176 _wireName = ! _wireName;
00177 draw();
00178 }
00179 else if (b == _axialButton) {
00180 _axial = ! _axial;
00181 draw();
00182 }
00183 else if (b == _stereoButton) {
00184 _stereo = ! _stereo;
00185 draw();
00186 }
00187 else if (b == _copyButton) {
00188 TWindow tmp = * this;
00189 tmp.wait();
00190 }
00191 else if (b == _zoomInButton) {
00192 zoom = true;
00193 }
00194 else if (b == _zoomOutButton) {
00195 if (zoom) continue;
00196 if (_zoomHistory[_mode].size() > 1) {
00197 _zoomHistory[_mode].pop();
00198 }
00199 else {
00200 _zoomHistory[_mode].pop();
00201 _xmin *= 2.;
00202 _xmax *= 2.;
00203 _ymin *= 2.;
00204 _zoomHistory[_mode].push(HepVector3D(_xmin, _xmax, _ymin));
00205 }
00206 zoom = false;
00207 draw();
00208 }
00209 else if (b == MOUSE_BUTTON(1)) {
00210 if (zoom) {
00211 double x, y;
00212 int bb = _window.read_mouse_rect(x0, y0, x, y);
00213 double xx(x0 < x ? x0 : x);
00214 double xxx(x0 < x ? x : x0);
00215 double yy(y0 < y ? y0 : y);
00216 _zoomHistory[_mode].push(HepVector3D(xx, xxx, yy));
00217 draw();
00218 zoom = false;
00219 }
00220 }
00221 }
00222 }
00223
00224 void
00225 TWindow::draw(void) {
00226 if (! target()) return;
00227 if (! _display) open();
00228
00229 _window.clear();
00230 _nYLine = 0;
00231 HepVector3D z(_zoomHistory[_mode].top());
00232 _window.init(z.x(), z.y(), z.z());
00233
00234 double xmin = _window.xmin();
00235 double xmax = _window.xmax();
00236 double ymin = _window.ymin();
00237 double ymax = _window.ymax();
00238 double x = xmin + (xmax - xmin) * .05;
00239 double y = ymin + (ymax - ymin) * .03;
00240 _xPositionText = x;
00241 _yPositionText = y;
00242 _yPositionStep = (ymax - ymin) * .03;
00243
00244 drawCdc();
00245 drawAxes();
00246 drawHeader();
00247
00248 unsigned n = _objects.length();
00249 for (unsigned i = 0; i < n; i++) {
00250 const TTrackBase & track = * _objects[i];
00251 if (track.objectType() == Line)
00252 drawLine((const TMLine &) track, * _colors[i]);
00253 else if (track.objectType() == TrackBase)
00254 drawBase(track, * _colors[i]);
00255 else if (track.objectType() == Track)
00256 drawTrack((const TTrack &) track, * _colors[i]);
00257 else if (track.objectType() == Segment)
00258 drawSegment((const TSegment &) track, * _colors[i]);
00259 else
00260 std::cout << "TWindow::draw !!! can't display" << std::endl;
00261 }
00262
00263
00264 _window.draw_text(_xPositionText, _yPositionText, _text.c_str());
00265
00266 }
00267
00268 void
00269 TWindow::drawBase(const TTrackBase & base, leda_color c) {
00270 const AList<TMLink> & links = base.links();
00271 unsigned n = links.length();
00272 for (unsigned i = 0; i < n; i++) {
00273 if (links[i]->wire() == NULL) continue;
00274 if (! _stereo)
00275 if (links[i]->wire()->stereo())
00276 continue;
00277 if (! _axial)
00278 if (links[i]->wire()->axial())
00279 continue;
00280
00281
00282 if (_mode == 2) {
00283
00284
00285 HepPoint3D x = links[i]->position();
00286 _window.draw_point(x.x(), x.y(), c);
00287 if (_wireName) {
00288 std::string n = links[i]->wire()->name() + ":";
00289
00290 if (links[i]->hit()->mc())
00291 n += "("
00292 + itostring(links[i]->hit()->mc()->hep()->id()) + ")";
00293
00294 n += itostring(links[i]->leftRight());
00295 _window.draw_text(x.x(), x.y(), n.c_str());
00296 }
00297 }
00298
00299
00300 else if (_mode == 0) {
00301
00302
00303 HepPoint3D x = links[i]->wire()->forwardPosition();
00304 double radius = links[i]->hit()->drift();
00305 _window.draw_circle(x.x(), x.y(), radius, c);
00306 if (_wireName)
00307 _window.draw_text(x.x(),
00308 x.y(),
00309 wireName(* links[i]).c_str());
00310 }
00311
00312
00313 else if (_mode == 1) {
00314
00315
00316 AList<TMDCWireHit> list;
00317 list.append((TMDCWireHit *) links[i]->hit());
00318 AList<TMLink> list2;
00319 TConformalFinder0::conformalTransformationRphi(ORIGIN, list,list2);
00320
00321
00322 HepPoint3D x = list2[0]->position();
00323 _window.draw_point(x.x(), x.y(), c);
00324 if (_wireName) {
00325 std::string n = links[i]->wire()->name();
00326 _window.draw_text(x.x(), x.y(), n.c_str());
00327 }
00328 }
00329
00330
00331 else if (_mode == 3) {
00332
00333
00334 HepPoint3D x = links[i]->position();
00335 _window.draw_point(x.x(), x.y(), c);
00336 if (_wireName) {
00337 std::string n = links[i]->wire()->name();
00338 _window.draw_text(x.x(), x.y(), n.c_str());
00339 }
00340 }
00341 }
00342 }
00343
00344 void
00345 TWindow::drawSegment(const TSegment & base, leda_color c) {
00346 AList<TMLink> links = base.links();
00347 links.sort(SortByWireId);
00348 unsigned n = links.length();
00349 HepPoint3D x;
00350 HepPoint3D y;
00351 for (unsigned i = 0; i < n; i++) {
00352 if (! _stereo)
00353 if (links[i]->wire()->stereo())
00354 return;
00355 if (! _axial)
00356 if (links[i]->wire()->axial())
00357 return;
00358
00359
00360 if (_mode == 2) {
00361 x = links[i]->position();
00362 _window.draw_point(x.x(), x.y(), c);
00363 if (_wireName) {
00364 std::string n = links[i]->wire()->name() + ":"
00365 + itostring(links[i]->leftRight());
00366 _window.draw_text(x.x(), x.y(), n.c_str());
00367 }
00368 if (i)
00369 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00370 y = x;
00371 }
00372
00373
00374 else if (_mode == 0) {
00375 x = links[i]->wire()->forwardPosition();
00376 double radius = links[i]->hit()->drift();
00377 _window.draw_circle(x.x(), x.y(), radius, c);
00378 if (_wireName)
00379 _window.draw_text(x.x(),
00380 x.y(),
00381 (const char *) wireName(* links[i]).c_str());
00382 if (i)
00383 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00384 y = x;
00385 }
00386
00387
00388 else if (_mode == 1) {
00389
00390
00391 AList<TMDCWireHit> list;
00392 list.append((TMDCWireHit *) links[i]->hit());
00393 AList<TMLink> list2;
00394 TConformalFinder0::conformalTransformationRphi(ORIGIN, list,list2);
00395
00396
00397 HepPoint3D x = list2[0]->position();
00398 _window.draw_point(x.x(), x.y(), c);
00399 if (_wireName) {
00400 std::string n = links[i]->wire()->name();
00401 _window.draw_text(x.x(), x.y(), n.c_str());
00402 }
00403 if (i)
00404 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00405 y = x;
00406 delete list2[0];
00407 }
00408
00409
00410 else if (_mode == 3) {
00411
00412
00413 AList<TMDCWireHit> list;
00414 list.append((TMDCWireHit *) links[i]->hit());
00415 AList<TMLink> list2;
00416 TConformalFinder0::conformalTransformation(ORIGIN, list, list2);
00417
00418
00419 HepPoint3D x = list2[0]->position();
00420 _window.draw_point(x.x(), x.y(), c);
00421 if (_wireName) {
00422 std::string n = links[i]->wire()->name();
00423 _window.draw_text(x.x(), x.y(), n.c_str());
00424 }
00425 if (i)
00426 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00427 y = x;
00428 delete list2[0];
00429 }
00430 }
00431
00432 if (_segmentProperty) {
00433 if (_mode == 3) {
00434 float in = links.first()->position().mag();
00435 float out = links.last()->position().mag();
00436 float length = out - in;
00437 HepPoint3D x = base.position() - 0.5 * length * base.direction();
00438 HepPoint3D y = base.position() + 0.5 * length * base.direction();
00439 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00440 _window.draw_point(base.position().x(), base.position().y(), c);
00441 }
00442 }
00443
00444
00445 if (! _segmentLink) return;
00446 const AList<TSegment> & innerLinks = base.innerLinks();
00447 unsigned nLinks = innerLinks.length();
00448 for (unsigned i = 0; i < nLinks; i++) {
00449 if (i == 0) c = leda_blue;
00450 else c = leda_pink;
00451
00452 AList<TMLink> innerTLinks = innerLinks[i]->links();
00453 innerTLinks.sort(SortByWireId);
00454
00455
00456 if (_mode == 2) {
00457 }
00458
00459
00460 else if (_mode == 0) {
00461 x = links[0]->wire()->forwardPosition();
00462 y = innerTLinks.last()->wire()->forwardPosition();
00463 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00464
00465
00466 }
00467
00468
00469 else if (_mode == 1) {
00470
00471
00472 AList<TMDCWireHit> list;
00473 list.append((TMDCWireHit *) links[0]->hit());
00474 list.append((TMDCWireHit *) innerTLinks.last()->hit());
00475 AList<TMLink> list2;
00476 TConformalFinder0::conformalTransformation(ORIGIN, list, list2);
00477
00478
00479 x = list2[0]->position();
00480 y = list2[1]->position();
00481 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00482
00483
00484 }
00485
00486
00487 else if (_mode == 3) {
00488
00489
00490 AList<TMDCWireHit> list;
00491 list.append((TMDCWireHit *) links[0]->hit());
00492 list.append((TMDCWireHit *) innerTLinks.last()->hit());
00493 AList<TMLink> list2;
00494 TConformalFinder0::conformalTransformation(ORIGIN, list, list2);
00495
00496
00497 x = list2[0]->position();
00498 y = list2[1]->position();
00499 _window.draw_segment(y.x(), y.y(), x.x(), x.y(), c);
00500
00501
00502 }
00503 }
00504 }
00505
00506 void
00507 TWindow::drawLine(const TMLine & line, leda_color c) {
00508 drawAxes();
00509 drawBase((const TTrackBase &) line, c);
00510
00511
00512 double xmin = _window.xmin();
00513 double xmax = _window.xmax();
00514 double ymin = xmin * line.a() + line.b();
00515 double ymax = xmax * line.a() + line.b();
00516 _window.draw_segment(xmin, ymin, xmax, ymax, c);
00517 }
00518
00519 bool
00520 TWindow::target(void) const {
00521 struct belle_event * ev =
00522 (struct belle_event *) BsGetEnt(BELLE_EVENT, 1, BBS_No_Index);
00523 if (_targetRun == 0 && _targetEvent == 0)
00524 return true;
00525 if (ev->m_RunNo == _targetRun && ev->m_EvtNo == _targetEvent)
00526 return true;
00527 return false;
00528 }
00529
00530 void
00531 TWindow::target(unsigned run, unsigned farm, unsigned event) {
00532 _targetRun = run;
00533 _targetEvent = (farm << 28) + event;
00534 }
00535
00536 void
00537 TWindow::drawTrack(const TTrack & t, leda_color c) {
00538 std::string p = TrackKinematics(t.helix()) + " " + TrackLayerUsage(t);
00539 _window.draw_text(_xPositionText, _yPositionText, p.c_str(), c);
00540 _yPositionText += _yPositionStep;
00541
00542 const AList<TMLink> & links = t.links();
00543 unsigned n = links.length();
00544 for (unsigned i = 0; i < n; i++) {
00545 if (! _stereo)
00546 if (links[i]->wire()->stereo())
00547 continue;
00548 if (! _axial)
00549 if (links[i]->wire()->axial())
00550 continue;
00551
00552 if (_mode == 0) {
00553 HepPoint3D x = links[i]->wire()->forwardPosition();
00554 double radius = links[i]->hit()->drift();
00555 _window.draw_circle(x.x(), x.y(), radius, c);
00556 if (_wireName)
00557 _window.draw_text(x.x(),
00558 x.y(),
00559 (const char *) wireName(* links[i]).c_str());
00560 }
00561
00562 else if (_mode == 2) {
00563 HepPoint3D x = links[i]->positionOnTrack();
00564 HepPoint3D sz;
00565 t.szPosition(x, sz);
00566 _window.draw_point(sz.x(), sz.y(), c);
00567 if (_wireName) {
00568 std::string n = links[i]->wire()->name() + ":"
00569 + itostring(links[i]->leftRight());
00570 _window.draw_text(sz.x(), sz.y(), n.c_str());
00571 }
00572 x = links[i]->positionOnWire();
00573 sz;
00574 t.szPosition(x, sz);
00575 _window.draw_point(sz.x(), sz.y(), c);
00576 if (_wireName) {
00577 std::string n = links[i]->wire()->name() + ":"
00578 + itostring(links[i]->leftRight());
00579 _window.draw_text(sz.x(), sz.y(), n.c_str());
00580 }
00581 }
00582
00583
00584 else if (_mode == 1) {
00585
00586
00587 AList<TMDCWireHit> list;
00588 list.append((TMDCWireHit *) links[i]->hit());
00589 AList<TMLink> list2;
00590 TConformalFinder0::conformalTransformationRphi(ORIGIN, list,list2);
00591
00592
00593 HepPoint3D x = list2[0]->position();
00594 _window.draw_point(x.x(), x.y(), c);
00595 if (_wireName) {
00596 std::string n = links[i]->wire()->name();
00597 _window.draw_text(x.x(), x.y(), n.c_str());
00598 }
00599 delete list2[0];
00600 }
00601
00602
00603 else if (_mode == 3) {
00604
00605
00606 AList<TMDCWireHit> list;
00607 list.append((TMDCWireHit *) links[i]->hit());
00608 AList<TMLink> list2;
00609 TConformalFinder0::conformalTransformation(ORIGIN, list, list2);
00610
00611
00612 HepPoint3D x = list2[0]->position();
00613 _window.draw_point(x.x(), x.y(), c);
00614 if (_wireName) {
00615 std::string n = links[i]->wire()->name();
00616 _window.draw_text(x.x(), x.y(), n.c_str());
00617 }
00618 delete list2[0];
00619 }
00620 }
00621
00622 if (! n) {
00623 _window.draw_text(0., 0., (const char *) "can't display a track");
00624 return;
00625 }
00626
00627 if (_mode == 0) {
00628
00629
00630 Helix hIp = t.helix();
00631 hIp.pivot(ORIGIN);
00632 leda_point ip(hIp.x(0.).x(), hIp.x(0.).y());
00633 const HepPoint3D & pIn = InnerMost(t.cores())->positionOnTrack();
00634 const HepPoint3D & pOut = OuterMost(t.cores())->positionOnTrack();
00635 leda_point in(pIn.x(), pIn.y());
00636 leda_point out(pOut.x(), pOut.y());
00637 if (in == out) {
00638 _window.draw_text(0., 0., (const char *) "can't display a track");
00639 return;
00640 }
00641 _window.draw_arc(ip, in, out, c);
00642 _window.draw_text(pOut.x(), pOut.y(), t.name().c_str());
00643 }
00644
00645 else if (_mode == 2) {
00646 Helix hIp = t.helix();
00647 hIp.pivot(ORIGIN);
00648
00649 double xmin = _window.xmin();
00650 double xmax = _window.xmax();
00651 double ymin = xmin * hIp.tanl() * t.charge() + hIp.dz();
00652 double ymax = xmax * hIp.tanl() * t.charge() + hIp.dz();
00653 _window.draw_segment(xmin, ymin, xmax, ymax, c);
00654 }
00655 }
00656
00657 void
00658 TWindow::drawAxes(void) {
00659 double xmin = _window.xmin();
00660 double xmax = _window.xmax();
00661 _window.draw_segment(xmin, 0., xmax, 0., leda_grey2);
00662 double ymin = _window.ymin();
00663 double ymax = _window.ymax();
00664 _window.draw_segment(0., ymin, 0., ymax, leda_grey2);
00665 }
00666
00667 void
00668 TWindow::drawCdc(void) {
00669
00670
00671 if (_mode == 0) {
00672 double r = 8.4;
00673 _window.draw_circle(0., 0., r);
00674 r = 88.;
00675 _window.draw_circle(0., 0., r);
00676 r = 2.;
00677 _window.draw_circle(0., 0., r);
00678 }
00679 }
00680
00681 void
00682 TWindow::clear(void) {
00683 ++_nEvents;
00684
00685 _objects.removeAll();
00686 if (_canDelete) {
00687 HepAListDeleteAll(_colors);
00688 HepAListDeleteAll(_selfObjects);
00689 HepAListDeleteAll(_selfTLinks);
00690 }
00691 }
00692
00693 void
00694 TWindow::append(const AList<TMLink> & list, leda_color c) {
00695 TTrackBase * t = new TTrackBase(list);
00696 _objects.append(t);
00697 _colors.append(new leda_color(c));
00698 _selfObjects.append(t);
00699 }
00700
00701 std::string
00702 TWindow::wireName(const TMLink & l) const {
00703 unsigned state = l.hit()->state();
00704 std::string flag;
00705 if (state & WireHitFindingValid) flag += "o";
00706 if (state & WireHitFittingValid) flag += "+";
00707 if (state & WireHitInvalidForFit) flag += "x";
00708 if (l.hit()->mc())
00709 flag += "(" + itostring(l.hit()->mc()->hep()->id()) + ")";
00710 return l.wire()->name() + flag;
00711 }
00712
00713 void
00714 TWindow::oneShot(const TTrackBase & t, leda_color c) {
00715 append(t, c);
00716 wait();
00717 unsigned id = _objects.length() - 1;
00718 _objects.remove(id);
00719 leda_color * b = _colors[id];
00720 _colors.remove(id);
00721 delete b;
00722 }
00723
00724
00725 void
00726 TWindow::oneShot(const AList<TSegment> & t, leda_color c) {
00727 TTrackBase tmp;
00728 for (unsigned i = 0; i < t.length(); i++) {
00729 const TSegment & s = * t[i];
00730 for (unsigned j = 0; j < s.links().length(); j++)
00731 tmp.append(* s.links()[j]);
00732 }
00733
00734 append(tmp, c);
00735 wait();
00736 unsigned id = _objects.length() - 1;
00737 _objects.remove(id);
00738 leda_color * b = _colors[id];
00739 _colors.remove(id);
00740 delete b;
00741 }
00742
00743 void
00744 TWindow::appendSz(const TTrack & t, const AList<TMLink> & list, leda_color c) {
00745 unsigned n = list.length();
00746 for (unsigned i = 0; i < n; i++) {
00747 TMLink * l0 = new TMLink(* list[i]);
00748 TMLink * l1 = new TMLink(* list[i]);
00749 TMLink * l2 = new TMLink(* list[i]);
00750 l0->leftRight(WireHitLeft);
00751 l1->leftRight(WireHitRight);
00752 l2->leftRight(2);
00753 int err = t.szPosition(* l0);
00754 err = t.szPosition(* l1);
00755 err = t.szPosition(* l2);
00756 AList<TMLink> links;
00757 links.append(l0);
00758 links.append(l1);
00759 links.append(l2);
00760 TTrackBase * b = new TTrackBase(links);
00761 _objects.append(b);
00762 _colors.append(new leda_color(c));
00763 _selfTLinks.append(l0);
00764 _selfTLinks.append(l1);
00765 _selfTLinks.append(l2);
00766 _selfObjects.append(b);
00767 }
00768 }
00769
00770 void
00771 TWindow::appendSz(const TTrack & t,
00772 const AList<TSegment> & list,
00773 leda_color c) {
00774 unsigned n = list.length();
00775 for (unsigned i = 0; i < n; i++) {
00776 TSegment & s = * list[i];
00777 TMLink * l = new TMLink();
00778 t.szPosition(s, * l);
00779 AList<TMLink> links;
00780 links.append(l);
00781 TTrackBase * b = new TTrackBase(links);
00782 _objects.append(b);
00783 _colors.append(new leda_color(c));
00784 _selfTLinks.append(l);
00785 _selfObjects.append(b);
00786 }
00787 }
00788
00789 void
00790 TWindow::draw(const TPoint2D & p, leda_color c) {
00791 _window.draw_point(p.x(), p.y(), c);
00792 }
00793
00794 void
00795 TWindow::drawHeader(void) {
00796 struct belle_event * h = (struct belle_event *)
00797 BsGetEnt(BELLE_EVENT, 1, BBS_No_Index);
00798 if (! h) return;
00799
00800
00801 static const std::string sp = " ";
00802 std::string mc = "mc:" + itostring(h->m_ExpMC);
00803 std::string exp = "exp:" + itostring(h->m_ExpNo);
00804 std::string run = "run:" + itostring(h->m_RunNo);
00805 std::string frm = "frm:" + itostring((h->m_EvtNo >> 28));
00806 std::string evt = "evt:" + itostring((h->m_EvtNo & 268435455));
00807 std::string dat = "dat:" + std::string(ctime((const time_t *) & h->m_Time));
00808 std::string fld = "fld:" + dtostring(h->m_BField);
00809 std::string ler = "ler:" + dtostring(h->m_ELER);
00810 std::string her = "her:" + dtostring(h->m_EHER);
00811
00812 std::string s0 = "";
00813 if (calcdc_unpack_.unpack_truncate)
00814 s0 += "truncated event";
00815 std::string head0 = exp + sp + run + sp + frm + sp + evt;
00816 std::string head1 = dat;
00817 std::string head2 = fld + sp + ler + sp + her;
00818
00819 double xmin = _window.xmin();
00820 double xmax = _window.xmax();
00821 double ymin = _window.ymin();
00822 double ymax = _window.ymax();
00823 double x0 = xmin + (xmax - xmin) * .7;
00824 double x1 = xmin + (xmax - xmin) * .6;
00825 double y0 = ymin + (ymax - ymin) * .92;
00826 double y1 = ymin + (ymax - ymin) * .95;
00827 double y2 = ymin + (ymax - ymin) * .98;
00828 double y3 = ymin + (ymax - ymin) * -.90;
00829
00830 _window.draw_text(x0, y2, head2.c_str());
00831 _window.draw_text(x0, y1, head1.c_str());
00832 _window.draw_text(x0, y0, head0.c_str());
00833
00834
00835 _window.draw_text(x1, y3, s0.c_str());
00836 }
00837
00838 #endif //TRKRECO_WINDOW