40
40
px = 0.0, py = 0.0, pz = 0.0, station = 0, \
41
41
time = 0.0, mass = 105.6583715, p_value = 1.0, pid = 13, \
43
scifi_track_point = None, virtual_track_point = None ) :
43
scifi_track_point = None, virtual_track_point = None, \
44
global_track_point = None ) :
45
46
Initialise the object. this can be done in three ways:
46
47
1. Specify all components by hand
47
48
2. Build from a sci-fr trackpoint
48
49
3. Build from a virtual trackpoint
50
if scifi_track_point is None and virtual_track_point is None :
51
if scifi_track_point is None and virtual_track_point is None and global_track_point is None :
389
404
for key, val in __hit_get_variables.iteritems() :
390
405
__hit_get_keys.append( key )
408
################################################################################
411
class AnalysisSpacePoint() :
413
A simple, unified class that holds the essential information, when copied
414
from MAUS data types, during various analyses.
416
Some syntax was borrowed from XBoa for simplicity and because I like the
419
def __init__( self, x = 0.0, y = 0.0, z = 0.0, station = 0, \
420
time = 0.0, weight = 1.0, tof = None, scifi = None ) :
422
Initialise the object. this can be done in three ways:
423
1. Specify all components by hand
424
2. Build from a sci-fr trackpoint
425
3. Build from a virtual trackpoint
427
if tof is None and scifi is None :
432
self.__station = station
433
self.__weight = weight
435
elif scifi is not None and tof is None :
436
self.__x = scifi.pos().x()
437
self.__y = scifi.pos().y()
438
self.__z = scifi.pos().z()
440
self.__station = tools.calculate_plane_id(scifi.tracker(), \
442
self.__weight = weight
444
elif scifi is None and tof is not None :
445
self.__x = tof.GetGlobalPosX()
446
self.__y = tof.GetGlobalPosY()
447
self.__z = tof.GetGlobalPosZ()
448
self.__time = tof.GetTime()
449
self.__station = tof.GetStation()
450
self.__weight = weight
454
raise ValueError( 'Please supply precisely one of "virtual_track_point"'+\
455
' or "scifi_track_point", or specify all values explicitly.' )
458
def __str__( self ) :
460
Return a string of the parameters.
461
Mostly useful for debuging.
463
return '(' + str( self.__x ) + ',' +\
464
str( self.__y ) + ',' +\
465
str( self.__z ) + '):[' +\
466
str( self.__time ) +\
467
str( self.__station ) + ']'
470
def __repr__( self ) :
472
Return a string of the parameters.
473
Mostly useful for debuging.
475
return '(' + str( self.__x ) + ',' +\
476
str( self.__y ) + ',' +\
477
str( self.__z ) + '):[' +\
478
str( self.__time ) +\
479
str( self.__station ) + ']'
483
def set_x( self, val ) :
489
def set_y( self, val ) :
495
def set_z( self, val ) :
501
def set_time( self, val ) :
507
def set_station( self, station ) :
511
self.__station = station
513
def set_weight( self, w ) :
515
Set the statistical weight of the hit
538
def get_time( self ) :
546
Get the position radius
548
return math.sqrt( self.__x**2 + self.__y**2 )
550
def get_phi( self ) :
552
Get the Phi angle (Position)
554
return math.atan2( self.__y, self.__x )
556
def get_station( self ) :
560
return self.__station
563
def get_weight( self ) :
565
Return the statistical weight of the hit
570
def get( self, string ) :
572
Return the value of the variable described in the string
574
if not string in AnalysisSpacePoint.__hit_get_keys :
577
return AnalysisSpacePoint.__hit_get_variables[ string ]( self )
580
def get_as_vector( self ) :
582
Returns the 6D phase-space vector corresponding to the particle.
585
return [self.__time, self.__x, self.__y, self.__z]
588
def get_variable_list() :
590
Return the list of variables that the user can request
592
return AnalysisSpacePoint.__hit_get_keys
593
get_variable_list = staticmethod( get_variable_list )
598
__hit_get_variables = { 'x':get_x, 'y':get_y, 'z':get_z,
599
't':get_time, 'r':get_r, 'station':get_station }
601
for key, val in __hit_get_variables.iteritems() :
602
__hit_get_keys.append( key )