def test_is_track_at_tpc_border_for_recon(self): self.load_selector() self.sel.data_type = 'reconstructed' track = Mock() track.q=3; track.pt = 2; track.phi = 0.12 - pi/18 self.assertTrue(self.sel.is_track_at_tpc_border(track)) track.q = -3; track.phi=.23 - pi/18 self.assertTrue(self.sel.is_track_at_tpc_border(track)) track.q = 3; track.phi = 0.3 - pi/18 self.assertFalse(self.sel.is_track_at_tpc_border(track))
def test__validated_recon_track(self): """Test the recon track validator for various scenarios""" self.load_selector() self.sel.data_type = 'reconstructed' track = Mock() track.eta = 0 # dont care about eta here track.filter = 1; self.sel.track_filter = 1 track.primary = 1; track.dcaxy = 0; track.dcaz = 0 # only pos charge, no TPC border treatment! self.sel.only_charge = 3; self.sel.exclude_tpc_border = False track.q=3; track.pt = 2; track.phi = 0.12 - pi/18 self.assertTrue(self.sel._validate_recon_track(track)) track.q=-3 self.assertFalse(self.sel._validate_recon_track(track)) # only pos charge, with TPC border exclusion self.sel.only_charge = 3; self.sel.exclude_tpc_border = True track.q=3; track.pt = 2; track.phi = 0.12 - pi/18 self.assertFalse(self.sel._validate_recon_track(track)) track.q = 3; track.phi = 0.3 - pi/18 self.assertTrue(self.sel._validate_recon_track(track)) # exclude TPC borders, include both charges self.sel.only_charge = None; self.sel.exclude_tpc_border = True track.q= 3; track.pt = 2; track.phi = 0.12 - pi/18 self.assertFalse(self.sel._validate_recon_track(track)) track.q = -3; track.phi = 0.05 - pi/18 self.assertTrue(self.sel._validate_recon_track(track))
def load_hard_event(self, option='valid'): """fChain needs extra care, calling function needs to be decorated with @patch.object(MyPySelector, 'fChain', Mock())""" e = self.sel.fChain.event e.trig = 1; e.vtxstatus = 1; e.zvtxMC=0; e.ptmaxMC = 1 + self.pt_threshold e.cent = 50; e.zvtx=0; e.ptmax = 1 + self.pt_threshold; t = Mock() t.qMC=3; t.ptMC = 1.5; t.phiMC = 0.12 - pi/18; t.etaMC = 0.0 t.q=3; t.pt = 1.5; t.phi = 0.12 - pi/18; t.eta = 0; t.filter=1; t.primary=1; t.dcaxy=0.0; t.dcaz = 0.0 self.sel.get_tracks_generator = Mock(return_value=[t,]) if option == 'valid': return None if option == 'bad threshold': e.ptmaxMC = e.ptmax = self.pt_threshold * .5 return None