def test__validated_mc_track(self): """Test the mc track validator for various scenarios""" self.load_selector() self.sel.data_type = 'MC' track = Mock() track.etaMC = 0 # dont care about eta here # only pos charge, no TPC border treatment! self.sel.only_charge = 3; self.sel.exclude_tpc_border = False track.qMC=3; track.ptMC = 2; track.phiMC = 0.12 - pi/18 self.assertTrue(self.sel._validate_mc_track(track)) track.qMC=-3 self.assertFalse(self.sel._validate_mc_track(track)) # only pos charge, with TPC border exclusion self.sel.only_charge = 3; self.sel.exclude_tpc_border = True track.qMC=3; track.ptMC = 2; track.phiMC = 0.12 - pi/18 self.assertFalse(self.sel._validate_mc_track(track)) track.qMC = 3; track.phiMC = 0.3 - pi/18 self.assertTrue(self.sel._validate_mc_track(track)) # exclude TPC borders, include both charges self.sel.only_charge = None; self.sel.exclude_tpc_border = True track.qMC = 3; track.ptMC = 2; track.phiMC = 0.12 - pi/18 self.assertFalse(self.sel._validate_mc_track(track)) track.qMC = -3; track.phiMC = 0.05 - pi/18 self.assertTrue(self.sel._validate_mc_track(track))
def test_is_track_at_tpc_border_for_MC(self): self.load_selector() self.sel.data_type = 'MC' track = Mock() track.qMC=3; track.ptMC = 2; track.phiMC = 0.12 - pi/18 self.assertTrue(self.sel.is_track_at_tpc_border(track)) track.qMC = -3; track.phiMC=.23 - pi/18 self.assertTrue(self.sel.is_track_at_tpc_border(track)) track.qMC = 3; track.phiMC = 0.3 - pi/18 self.assertFalse(self.sel.is_track_at_tpc_border(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