def __init__(self, *args, **kwargs): '''Defines a gTower''' """ initialize it by passing in kwargs that contain all information """ if len(args) == 2 and isinstance(args[0], pow.__class__): super(self.__class__, self).__init__(args[0](*args[1])) else: newVector = bool(len(kwargs) == 6) # require that exactly one of the sets of arguments are valid length if not newVector: raise ValueError( 'invalid number of keyword arguments supplied') TLorentzVector.__init__(self) validKeys = ('et', 'etamin', 'etamax', 'phimin', 'phimax', 'num_cells') kwargs = dict((k.lower(), v) for k, v in kwargs.iteritems()) if all(k in kwargs for k in validKeys): # set the center of the tower to the geometric center self.SetPtEtaPhiM(kwargs['et'], (kwargs['etamax'] + kwargs['etamin']) / 2.0, (kwargs['phimax'] + kwargs['phimin']) / 2.0, 0.0) else: raise ValueError( 'Missing specific keys to make new vector, {}'.format( validKeys)) self._etamax = kwargs['etamax'] self._etamin = kwargs['etamin'] self._phimax = kwargs['phimax'] self._phimin = kwargs['phimin'] self._num_cells = np.int(kwargs['num_cells'])
def __init__(self, *args, **kwargs): '''Defines a gTower''' """ initialize it by passing in kwargs that contain all information """ if len(args) == 2 and isinstance(args[0], pow.__class__): super(self.__class__, self).__init__(args[0](*args[1])) else: newVector = bool(len(kwargs) == 6) # require that exactly one of the sets of arguments are valid length if not newVector: raise ValueError('invalid number of keyword arguments supplied') TLorentzVector.__init__(self) validKeys = ('et', 'etamin', 'etamax', 'phimin', 'phimax', 'num_cells') kwargs = dict((k.lower(), v) for k, v in kwargs.iteritems()) if all(k in kwargs for k in validKeys): # set the center of the tower to the geometric center self.SetPtEtaPhiM(kwargs['et'], (kwargs['etamax'] + kwargs['etamin'])/2.0, (kwargs['phimax'] + kwargs['phimin'])/2.0, 0.0) else: raise ValueError('Missing specific keys to make new vector, {}'.format(validKeys)) self._etamax = kwargs['etamax'] self._etamin = kwargs['etamin'] self._phimax = kwargs['phimax'] self._phimin = kwargs['phimin'] self._num_cells = np.int(kwargs['num_cells'])
def __init__(self, x, y, z, t, tau21, C2_beta1, D2_beta1, BTag_rfj_BTagMax, subjetE_ratio, subjet_DeltaPhi): TLorentzVector.__init__(self, x, y, z, t) self.tau21 = tau21 self.C2_beta1 = C2_beta1 self.D2_beta1 = D2_beta1 self.BTag_rfj_BTagMax = BTag_rfj_BTagMax self.subjetE_ratio = subjetE_ratio self.subjet_DeltaPhi = subjet_DeltaPhi
def __init__(self,name="<Py4Vector Object>"): """ Initialize the TLorentzVector (to inherit its properties). @param name Set the name of the object, if given (useful for printing). """ TLorentzVector.__init__(self) # Inheriting from TLorentzVector if name == "<Py4Vector Object>": self.name = name+" {0}".format( id(self) ) # unique name based on object's id else: self.name = name return
def __init__(self, _index = 0, _px = None, _py = None, _pz = None, _E = None, _pt = None, _eta = None, _phi = None, _m = None): TLorentzVector.__init__( self ) self.index = _index if _pt != None and _eta != None and _phi != None and _m != None: self.SetPtEtaPhiM( _pt, _eta, _phi, _m ) elif _pt != None and _eta != None and _phi != None and _E != None : self.SetPtEtaPhiE( _pt, _eta, _phi, _E ) elif _px != None and _py != None and _pz != None and _E != None : self.SetPxPyPzE( _px, _py, _pz, _E )
def __init__(self, *arg, **kwargs): '''Defines an offline jet''' """ energy : jet energy, E momentum_transverse: magnitude of momentum transverse to beam, mag(p)*sin(theta) mass : invariant mass of jet pseudo-rapidity coordinates - eta : -ln( tan[theta/2] ) - phi : polar angle in the transverse plane -- theta is angle between particle momentum and the beam axis -- see more: http://en.wikipedia.org/wiki/Pseudorapidity radius : radius of jet (eta-phi coordinates) initialize it by Jet(TLorentzVector) or Jet({'Pt': #, 'm': #, 'eta': #, 'phi': #, ...}) """ copyVector = bool(len(arg) == 1) newVector = bool(len(kwargs) >= 4) # require that exactly one of the sets of arguments are valid length if not(copyVector ^ newVector): raise ValueError('invalid number of arguments supplied') if copyVector: if isinstance(arg[0], TLorentzVector): TLorentzVector.__init__(self, arg[0]) else: raise TypeError('expected a TLorentzVector') else: TLorentzVector.__init__(self) validKeys = ('pt','eta','phi','m') kwargs = dict((k.lower(), v) for k,v in kwargs.iteritems()) if all(k in kwargs for k in validKeys): self.SetPtEtaPhiM(*(kwargs[k] for k in validKeys)) else: raise ValueError('Missing specific keys to make new vector, {}'.format(validKeys)) # remember that the names are lowercased to make it consistent self._radius = np.float(kwargs.get('radius', 1.0)) self._nsj = np.int(kwargs.get('nsj', 0)) self._tau = np.array(kwargs.get('tau', [None,None,None])) self._split = np.array(kwargs.get('split', [None,None,None])) self._subjetsPt = np.array(kwargs.get('subjetspt', [None]))
def test03CopyContructor( self ): """Test copy constructor""" t1 = TLorentzVector( 1., 2., 3., -4. ) t2 = TLorentzVector( 0., 0., 0., 0. ) t3 = TLorentzVector( t1 ) t4 = TLorentzVector(0, 0, 0, 0) t4.__init__(TLorentzVector(0, 1, 2, 3)) # the following should work exactly as above, but no longer does on some version of ROOT 6 t5 = TLorentzVector(0, 0, 0, 0) TLorentzVector.__init__(t5, TLorentzVector(0, 1, 2, 3)) self.assertEqual( t1, t3 ) self.assertNotEqual( t1, t2 ) #self.assertNotEqual( t4, t5 ) for i in range(4): self.assertEqual( t1[i], t3[i] ) self.assertEqual( t4[i], t5[i] )
def test06CopyContructor(self): """Test copy constructor""" t1 = TLorentzVector(1., 2., 3., -4.) t2 = TLorentzVector(0., 0., 0., 0.) t3 = TLorentzVector(t1) t4 = TLorentzVector(0, 0, 0, 0) t4.__init__(TLorentzVector(0, 1, 2, 3)) # the following should work exactly as above, but no longer does on some version of ROOT 6 t5 = TLorentzVector(0, 0, 0, 0) TLorentzVector.__init__(t5, TLorentzVector(0, 1, 2, 3)) self.assertEqual(t1, t3) self.assertNotEqual(t1, t2) #self.assertNotEqual( t4, t5 ) for i in range(4): self.assertEqual(t1[i], t3[i]) self.assertEqual(t4[i], t5[i])
def __init__(self, *args, **kwargs): '''Defines a trigger jet''' """ vector : a TLorentzVector() defined from ROOT that contains information about the Jet's 4-vector area : jet area based on sum of gTower areas that made jet radius : radius of jet (eta-phi coordinates) towers_around : contains the top 3 gTowers seed : contains the seed used for this jet initialize it by passing in a TLorentzVector() object plus kwargs that contain area, radius, and towers_around """ if len(args) == 2 and isinstance(args[0], pow.__class__): super(self.__class__, self).__init__(args[0](*args[1])) else: copyVector = bool(len(args) == 1) newVector = bool(len(kwargs) == 4) # require that exactly one of the sets of arguments are valid length if not (copyVector and newVector): raise ValueError('invalid number of arguments supplied') if isinstance(args[0], TLorentzVector): TLorentzVector.__init__(self, args[0]) else: raise TypeError('expected a TLorentzVector') # TLorentzVector.__init__(self) validKeys = ('area', 'radius', 'towers', 'seed') kwargs = dict((k.lower(), v) for k, v in kwargs.iteritems()) if all(k in kwargs for k in validKeys): self._area = np.float(kwargs['area']) self._radius = np.float(kwargs['radius']) self._towers = np.array(kwargs['towers']) self._seed = kwargs['seed'] else: raise ValueError( 'Missing specific keys to make tJet object, {}'.format( validKeys))
def test07CopyContructor(self): """Test copy constructor""" t1 = TLorentzVector(1., 2., 3., -4.) t2 = TLorentzVector(0., 0., 0., 0.) t3 = TLorentzVector(t1) self.assertEqual(t1, t3) self.assertNotEqual(t1, t2) for i in range(4): self.assertEqual(t1[i], t3[i]) if self.exp_pyroot: # Test copy constructor with null pointer t4 = MakeNullPointer(TLorentzVector) t4.__init__(TLorentzVector(0, 1, 2, 3)) t5 = MakeNullPointer(TLorentzVector) TLorentzVector.__init__(t5, TLorentzVector(0, 1, 2, 3)) # Test __assign__ if the object already exists t6 = TLorentzVector(0, 0, 0, 0) t6.__assign__(TLorentzVector(0, 1, 2, 3)) t7 = TLorentzVector(0, 0, 0, 0) TLorentzVector.__assign__(t7, TLorentzVector(0, 1, 2, 3)) for i in range(4): self.assertEqual(t4[i], t5[i]) self.assertEqual(t6[i], t7[i]) else: t4 = TLorentzVector(0, 0, 0, 0) t4.__init__(TLorentzVector(0, 1, 2, 3)) # the following should work exactly as above, but no longer does on some version of ROOT 6 t5 = TLorentzVector(0, 0, 0, 0) TLorentzVector.__init__(t5, TLorentzVector(0, 1, 2, 3)) for i in range(4): self.assertEqual(t4[i], t5[i])
def __init__(self, *args, **kwargs): '''Defines a trigger jet''' """ vector : a TLorentzVector() defined from ROOT that contains information about the Jet's 4-vector area : jet area based on sum of gTower areas that made jet radius : radius of jet (eta-phi coordinates) towers_around : contains the top 3 gTowers seed : contains the seed used for this jet initialize it by passing in a TLorentzVector() object plus kwargs that contain area, radius, and towers_around """ if len(args) == 2 and isinstance(args[0], pow.__class__): super(self.__class__, self).__init__(args[0](*args[1])) else: copyVector = bool(len(args) == 1) newVector = bool(len(kwargs) == 4) # require that exactly one of the sets of arguments are valid length if not(copyVector and newVector): raise ValueError('invalid number of arguments supplied') if isinstance(args[0], TLorentzVector): TLorentzVector.__init__(self, args[0]) else: raise TypeError('expected a TLorentzVector') # TLorentzVector.__init__(self) validKeys = ('area', 'radius', 'towers', 'seed') kwargs = dict((k.lower(), v) for k, v in kwargs.iteritems()) if all(k in kwargs for k in validKeys): self._area = np.float(kwargs['area']) self._radius = np.float(kwargs['radius']) self._towers = np.array(kwargs['towers']) self._seed = kwargs['seed'] else: raise ValueError('Missing specific keys to make tJet object, {}'.format(validKeys))