20# include "TrkReco/TConformalFinder0.h"
21# include "TrkReco/TMDC.h"
22# include "TrkReco/TMDCWireHitMC.h"
23# include "TrkReco/TMLine.h"
24# include "TrkReco/TMLink.h"
25# include "TrkReco/TSegment.h"
26# include "TrkReco/TTrack.h"
27# include "TrkReco/TTrackHEP.h"
28# include "TrkReco/TWindow.h"
35bool TWindow::_skipAllWindow =
false;
37TWindow::TWindow(
const TWindow& a )
38 : _name(
"copy of " + a._name )
39 , _window( 600, 600, _name.
c_str() )
40 , _wireName( a._wireName )
41 , _coordinate( a._coordinate )
46 , _objects( a._objects )
47 , _colors( a._colors )
48 , _targetRun( a._targetRun )
49 , _targetEvent( a._targetEvent )
52 , _stereo( a._stereo )
54 , _segmentLink( a._segmentLink )
55 , _segmentProperty( a._segmentProperty )
58 , _nEvents( a._nEvents ) {
59 for (
unsigned i = 0; i < 4; i++ ) _zoomHistory[i] = a._zoomHistory[i];
60 _window.set_show_coordinates( _coordinate );
61 _window.buttons_per_line( 7 );
62 _closeButton = _window.button(
"next" );
63 _wireNameButton = _window.button(
"wire #" );
64 _axialButton = _window.button(
"axial" );
65 _stereoButton = _window.button(
"stereo" );
66 _coordinateButton = _window.button(
"coordinate" );
67 _zoomInButton = _window.button(
"zoom in" );
68 _zoomOutButton = _window.button(
"zoom out" );
69 _skipButton = _window.button(
"skip" );
70 _skipAllButton = _window.button(
"skip all" );
71 _szButton = _window.button(
"rphi/sz" );
72 _confButton = _window.button(
"conformal" );
73 _segmentLinkButton = _window.button(
"sgmt link" );
74 _segmentPropertyButton = _window.button(
"sgmt vec" );
75 _copyButton = _window.button(
"window cp" );
76 _window.init( _xmin, _xmax, _ymin );
79TWindow::TWindow(
const std::string& name )
81 , _window( 600, 600, name.
c_str() )
83 , _coordinate( false )
94 , _segmentLink( false )
95 , _segmentProperty( false )
98 _window.set_show_coordinates( _coordinate );
99 _window.buttons_per_line( 7 );
100 _closeButton = _window.button(
"next" );
101 _wireNameButton = _window.button(
"wire #" );
102 _axialButton = _window.button(
"axial" );
103 _stereoButton = _window.button(
"stereo" );
104 _coordinateButton = _window.button(
"coordinate" );
105 _zoomInButton = _window.button(
"zoom in" );
106 _zoomOutButton = _window.button(
"zoom out" );
107 _skipButton = _window.button(
"skip" );
108 _skipAllButton = _window.button(
"skip all" );
109 _szButton = _window.button(
"rphi/sz" );
110 _confButton = _window.button(
"conformal" );
111 _segmentLinkButton = _window.button(
"sgmt link" );
112 _segmentPropertyButton = _window.button(
"sgmt vec" );
113 _copyButton = _window.button(
"window cp" );
114 _window.init( _xmin, _xmax, _ymin );
115 _zoomHistory[0].push(
HepVector3D( _xmin, _xmax, _ymin ) );
117 _zoomHistory[2].push(
HepVector3D( _xmin, _xmax, _ymin ) );
118 _zoomHistory[3].push(
HepVector3D( -0.28, 0.28, -0.28 ) );
121TWindow::~TWindow() { clear(); }
123void TWindow::wait(
void ) {
125 if ( _skipAllWindow )
return;
126 if ( !target() )
return;
137 int b = _window.read_mouse( x0, y0 );
140 if ( b == _closeButton ) loop =
false;
141 else if ( b == _szButton )
143 if ( _mode != 0 ) _mode = 0;
144 else if ( _mode != 2 ) _mode = 2;
147 else if ( b == _confButton )
149 if ( _mode != 3 ) _mode = 3;
150 else if ( _mode != 1 ) _mode = 1;
153 else if ( b == _segmentLinkButton )
155 _segmentLink = !_segmentLink;
158 else if ( b == _segmentPropertyButton )
160 _segmentProperty = !_segmentProperty;
163 else if ( b == _skipButton )
168 else if ( b == _skipAllButton )
171 _skipAllWindow =
true;
173 else if ( b == _coordinateButton )
175 _coordinate = !_coordinate;
176 _window.set_show_coordinates( _coordinate );
179 else if ( b == _wireNameButton )
181 _wireName = !_wireName;
184 else if ( b == _axialButton )
189 else if ( b == _stereoButton )
194 else if ( b == _copyButton )
199 else if ( b == _zoomInButton ) { zoom =
true; }
200 else if ( b == _zoomOutButton )
202 if ( zoom )
continue;
203 if ( _zoomHistory[_mode].size() > 1 ) { _zoomHistory[_mode].pop(); }
206 _zoomHistory[_mode].pop();
210 _zoomHistory[_mode].push(
HepVector3D( _xmin, _xmax, _ymin ) );
215 else if ( b == MOUSE_BUTTON( 1 ) )
220 int bb = _window.read_mouse_rect( x0, y0, x, y );
221 double xx( x0 < x ? x0 : x );
222 double xxx( x0 < x ? x : x0 );
223 double yy( y0 < y ? y0 : y );
224 _zoomHistory[_mode].push(
HepVector3D( xx, xxx, yy ) );
232void TWindow::draw(
void ) {
233 if ( !target() )
return;
234 if ( !_display )
open();
239 _window.init( z.x(), z.y(), z.z() );
241 double xmin = _window.xmin();
242 double xmax = _window.xmax();
243 double ymin = _window.ymin();
244 double ymax = _window.ymax();
245 double x = xmin + ( xmax - xmin ) * .05;
246 double y = ymin + ( ymax - ymin ) * .03;
249 _yPositionStep = ( ymax - ymin ) * .03;
255 unsigned n = _objects.length();
256 for (
unsigned i = 0; i <
n; i++ )
263 drawSegment( (
const TSegment&)track, *_colors[i] );
264 else std::cout <<
"TWindow::draw !!! can't display" << std::endl;
268 _window.draw_text( _xPositionText, _yPositionText, _text.c_str() );
272void TWindow::drawBase(
const TTrackBase& base, leda_color c ) {
274 unsigned n = links.length();
275 for (
unsigned i = 0; i <
n; i++ )
277 if ( links[i]->wire() == NULL )
continue;
279 if ( links[i]->wire()->stereo() )
continue;
281 if ( links[i]->wire()->axial() )
continue;
289 _window.draw_point( x.x(), x.y(), c );
292 std::string
n = links[i]->wire()->name() +
":";
294 if ( links[i]->hit()->mc() )
295 n +=
"(" + std::to_string( links[i]->hit()->mc()->hep()->
id() ) +
")";
297 n += std::to_string( links[i]->leftRight() );
298 _window.draw_text( x.x(), x.y(),
n.c_str() );
303 else if ( _mode == 0 )
307 HepPoint3D x = links[i]->wire()->forwardPosition();
308 double radius = links[i]->hit()->drift();
309 _window.draw_circle( x.x(), x.y(), radius, c );
310 if ( _wireName ) _window.draw_text( x.x(), x.y(), wireName( *links[i] ).
c_str() );
314 else if ( _mode == 1 )
325 _window.draw_point( x.x(), x.y(), c );
328 std::string
n = links[i]->wire()->name();
329 _window.draw_text( x.x(), x.y(),
n.c_str() );
334 else if ( _mode == 3 )
339 _window.draw_point( x.x(), x.y(), c );
342 std::string
n = links[i]->wire()->name();
343 _window.draw_text( x.x(), x.y(),
n.c_str() );
349void TWindow::drawSegment(
const TSegment& base, leda_color c ) {
352 unsigned n = links.length();
355 for (
unsigned i = 0; i <
n; i++ )
358 if ( links[i]->wire()->stereo() )
return;
360 if ( links[i]->wire()->axial() )
return;
365 x = links[i]->position();
366 _window.draw_point( x.x(), x.y(), c );
370 links[i]->wire()->name() +
":" + std::to_string( links[i]->leftRight() );
371 _window.draw_text( x.x(), x.y(),
n.c_str() );
373 if ( i ) _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
378 else if ( _mode == 0 )
380 x = links[i]->wire()->forwardPosition();
381 double radius = links[i]->hit()->drift();
382 _window.draw_circle( x.x(), x.y(), radius, c );
384 _window.draw_text( x.x(), x.y(), (
const char*)wireName( *links[i] ).
c_str() );
385 if ( i ) _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
390 else if ( _mode == 1 )
401 _window.draw_point( x.x(), x.y(), c );
404 std::string
n = links[i]->wire()->name();
405 _window.draw_text( x.x(), x.y(),
n.c_str() );
407 if ( i ) _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
413 else if ( _mode == 3 )
424 _window.draw_point( x.x(), x.y(), c );
427 std::string
n = links[i]->wire()->name();
428 _window.draw_text( x.x(), x.y(),
n.c_str() );
430 if ( i ) _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
436 if ( _segmentProperty )
440 float in = links.first()->position().mag();
441 float out = links.last()->position().mag();
442 float length = out - in;
445 _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
451 if ( !_segmentLink )
return;
453 unsigned nLinks = innerLinks.length();
454 for (
unsigned i = 0; i < nLinks; i++ )
456 if ( i == 0 ) c = leda_blue;
466 else if ( _mode == 0 )
468 x = links[0]->wire()->forwardPosition();
469 y = innerTLinks.last()->wire()->forwardPosition();
470 _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
476 else if ( _mode == 1 )
482 list.append( (
TMDCWireHit*)innerTLinks.last()->hit() );
486 x = list2[0]->position();
487 y = list2[1]->position();
488 _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
494 else if ( _mode == 3 )
500 list.append( (
TMDCWireHit*)innerTLinks.last()->hit() );
504 x = list2[0]->position();
505 y = list2[1]->position();
506 _window.draw_segment( y.x(), y.y(), x.x(), x.y(), c );
513void TWindow::drawLine(
const TMLine& line, leda_color c ) {
518 double xmin = _window.xmin();
519 double xmax = _window.xmax();
520 double ymin = xmin * line.
a() + line.
b();
521 double ymax = xmax * line.
a() + line.
b();
522 _window.draw_segment( xmin, ymin, xmax, ymax, c );
525bool TWindow::target(
void )
const {
526 struct belle_event* ev = (
struct belle_event*)BsGetEnt( BELLE_EVENT, 1, BBS_No_Index );
527 if ( _targetRun == 0 && _targetEvent == 0 )
return true;
528 if ( ev->m_RunNo == _targetRun && ev->m_EvtNo == _targetEvent )
return true;
532void TWindow::target(
unsigned run,
unsigned farm,
unsigned event ) {
534 _targetEvent = ( farm << 28 ) + event;
537void TWindow::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++ )
547 if ( links[i]->wire()->stereo() )
continue;
549 if ( links[i]->wire()->axial() )
continue;
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(), x.y(), (
const char*)wireName( *links[i] ).
c_str() );
560 else if ( _mode == 2 )
564 t.szPosition( x, sz );
565 _window.draw_point( sz.x(), sz.y(), c );
569 links[i]->wire()->name() +
":" + std::to_string( links[i]->leftRight() );
570 _window.draw_text( sz.x(), sz.y(),
n.c_str() );
572 x = links[i]->positionOnWire();
574 t.szPosition( x, sz );
575 _window.draw_point( sz.x(), sz.y(), c );
579 links[i]->wire()->name() +
":" + std::to_string( links[i]->leftRight() );
580 _window.draw_text( sz.x(), sz.y(),
n.c_str() );
585 else if ( _mode == 1 )
596 _window.draw_point( x.x(), x.y(), c );
599 std::string
n = links[i]->wire()->name();
600 _window.draw_text( x.x(), x.y(),
n.c_str() );
606 else if ( _mode == 3 )
617 _window.draw_point( x.x(), x.y(), c );
620 std::string
n = links[i]->wire()->name();
621 _window.draw_text( x.x(), x.y(),
n.c_str() );
629 _window.draw_text( 0., 0., (
const char*)
"can't display a track" );
639 leda_point ip( hIp.
x( 0. ).x(), hIp.
x( 0. ).y() );
642 leda_point in( pIn.x(), pIn.y() );
643 leda_point out( pOut.x(), pOut.y() );
646 _window.draw_text( 0., 0., (
const char*)
"can't display a track" );
649 _window.draw_arc( ip, in, out, c );
650 _window.draw_text( pOut.x(), pOut.y(),
t.name().c_str() );
653 else if ( _mode == 2 )
658 double xmin = _window.xmin();
659 double xmax = _window.xmax();
660 double ymin = xmin * hIp.
tanl() *
t.charge() + hIp.
dz();
661 double ymax = xmax * hIp.
tanl() *
t.charge() + hIp.
dz();
662 _window.draw_segment( xmin, ymin, xmax, ymax, c );
666void TWindow::drawAxes(
void ) {
667 double xmin = _window.xmin();
668 double xmax = _window.xmax();
669 _window.draw_segment( xmin, 0., xmax, 0., leda_grey2 );
670 double ymin = _window.ymin();
671 double ymax = _window.ymax();
672 _window.draw_segment( 0., ymin, 0., ymax, leda_grey2 );
675void TWindow::drawCdc(
void ) {
681 _window.draw_circle( 0., 0., r );
683 _window.draw_circle( 0., 0., r );
685 _window.draw_circle( 0., 0., r );
689void TWindow::clear(
void ) {
692 _objects.removeAll();
695 HepAListDeleteAll( _colors );
696 HepAListDeleteAll( _selfObjects );
697 HepAListDeleteAll( _selfTLinks );
701void TWindow::append(
const AList<TMLink>& list, leda_color c ) {
703 _objects.append(
t );
704 _colors.append(
new leda_color( c ) );
705 _selfObjects.append(
t );
708std::string TWindow::wireName(
const TMLink& l )
const {
718void TWindow::oneShot(
const TTrackBase&
t, leda_color c ) {
721 unsigned id = _objects.length() - 1;
722 _objects.remove(
id );
723 leda_color* b = _colors[id];
724 _colors.remove(
id );
730 for (
unsigned i = 0; i <
t.length(); i++ )
733 for (
unsigned j = 0; j <
s.links().length(); j++ ) tmp.
append( *
s.links()[j] );
738 unsigned id = _objects.length() - 1;
739 _objects.remove(
id );
740 leda_color* b = _colors[id];
741 _colors.remove(
id );
746 unsigned n = list.length();
747 for (
unsigned i = 0; i <
n; i++ )
755 int err =
t.szPosition( *l0 );
756 err =
t.szPosition( *l1 );
757 err =
t.szPosition( *l2 );
763 _objects.append( b );
764 _colors.append(
new leda_color( c ) );
765 _selfTLinks.append( l0 );
766 _selfTLinks.append( l1 );
767 _selfTLinks.append( l2 );
768 _selfObjects.append( b );
773 unsigned n = list.length();
774 for (
unsigned i = 0; i <
n; i++ )
778 t.szPosition(
s, *l );
782 _objects.append( b );
783 _colors.append(
new leda_color( c ) );
784 _selfTLinks.append( l );
785 _selfObjects.append( b );
789void TWindow::draw(
const TPoint2D& p, leda_color c ) {
790 _window.draw_point( p.
x(), p.
y(), c );
793void TWindow::drawHeader(
void ) {
794 struct belle_event* h = (
struct belle_event*)BsGetEnt( BELLE_EVENT, 1, BBS_No_Index );
798 static const std::string sp =
" ";
799 std::string mc =
"mc:" + std::to_string( h->m_ExpMC );
800 std::string
exp =
"exp:" + std::to_string( h->m_ExpNo );
801 std::string run =
"run:" + std::to_string( h->m_RunNo );
802 std::string frm =
"frm:" + std::to_string( ( h->m_EvtNo >> 28 ) );
803 std::string evt =
"evt:" + std::to_string( ( h->m_EvtNo & 268435455 ) );
804 std::string dat =
"dat:" + std::string( ctime( (
const time_t*)&h->m_Time ) );
805 std::string fld =
"fld:" + dtostring( h->m_BField );
806 std::string ler =
"ler:" + dtostring( h->m_ELER );
807 std::string her =
"her:" + dtostring( h->m_EHER );
810 if ( calcdc_unpack_.unpack_truncate ) s0 +=
"truncated event";
811 std::string head0 =
exp + sp + run + sp + frm + sp + evt;
812 std::string head1 = dat;
813 std::string head2 = fld + sp + ler + sp + her;
815 double xmin = _window.xmin();
816 double xmax = _window.xmax();
817 double ymin = _window.ymin();
818 double ymax = _window.ymax();
819 double x0 = xmin + ( xmax - xmin ) * .7;
820 double x1 = xmin + ( xmax - xmin ) * .6;
821 double y0 = ymin + ( ymax - ymin ) * .92;
822 double y1 = ymin + ( ymax - ymin ) * .95;
823 double y2 = ymin + ( ymax - ymin ) * .98;
824 double y3 = ymin + ( ymax - ymin ) * -.90;
826 _window.draw_text( x0, y2, head2.c_str() );
827 _window.draw_text( x0, y1, head1.c_str() );
828 _window.draw_text( x0, y0, head0.c_str() );
830 _window.draw_text( x1, y3, s0.c_str() );
HepGeom::Vector3D< double > HepVector3D
HepGeom::Point3D< double > HepPoint3D
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 > &links)
TMLink * InnerMost(const AList< TMLink > &links)
returns the inner(outer)-most link.
int SortByWireId(const void *a, const void *b)
Sorter.
std::string TrackLayerUsage(const TTrack &)
std::string TrackKinematics(const TTrack &)
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
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)