Example #1
0
    def PlotFakes(self,
                  event,
                  reconstructed=1,
                  fake_filter=None,
                  end_filter=None,
                  last_filter=None,
                  particle_end_filter=None):
        iterative = 1

        fakes = analysis.FindFakes(event)
        if iterative:
            # Plot fakes one by one
            for fake in fakes:
                # Check for filter
                if fake_filter:
                    info = analysis.FakeInfo(fake)
                    if info.fake_class not in fake_filter:
                        continue

                self.Reset()
                self.Plot3DHelixes([fake], 2)
                self.Plot3DHits(fake, 2)
                #self.PlotVertex3D(vertex,2)
                fake_info = analysis.FakeInfo(fake)
                analysis.PrintTrackInfo(fake, None, 0, fake_info)
                if fake_info.matches:
                    for match in fake_info.matches:
                        continue  #self.PlotTrackingFail(match)
                        #self.PlotPoint3D(fake_info.end_loc, 2)

                        # Find real particle tracks which include fake tracks hits
                icol = 0
                particle_inds = []
                particles = []
                reco_inds = []
                recos = []
                for hit in fake.hits():
                    if hit.isValid() and hit.nMatchedTrackingParticles() >= 0:
                        for info in hit.matchedTrackingParticleInfos():
                            particle = info.trackingParticle()
                            if particle.index() not in particle_inds:
                                particle_inds.append(particle.index())
                                particles.append(particle)
                            if reconstructed and particle.nMatchedTracks() > 0:
                                for info in particle.matchedTrackInfos():
                                    track = info.track()
                                    if track.index() not in reco_inds:
                                        reco_inds.append(track.index())
                                        recos.append(track)

                    # Find reconstructed tracks included in fakes hits
                    if hit.isValid() and reconstructed and hit.ntracks() > 0:
                        for track in hit.tracks():
                            #track = info.track()
                            if (track.index() not in reco_inds
                                ) and track.index() != fake.index():
                                reco_inds.append(track.index())
                                recos.append(track)

    # Plot the particles and reconstructed tracks
                icol = 0
                self.ParticleTest(particles, draw=False)
                for particle in particles:
                    self.Plot3DHelix(particle, self.colors_G[icol], 1)
                    self.plots_3D[-1].SetLineStyle(5)
                    self.Plot3DHits(particle, self.colors_G[icol], 1)
                    self.PlotVertex3D(particle.parentVertex(),
                                      self.colors_G[icol])
                    # EXPERIMENTAL LINE:
                    #self.PlotTrack3D(particle, self.colors_G[icol])

                    for decay in particle.decayVertices():
                        self.PlotVertex3D(decay, 5)
                    analysis.PrintTrackInfo(particle, fake)
                    icol += 1
                icol = 0
                for track in recos:
                    self.Plot3DHelix(track, self.colors_B[icol], 2)
                    self.Plot3DHits(track, self.colors_B[icol], 2)
                    #self.PlotVertex3D(vertex,self.colors_B[icol])
                    analysis.PrintTrackInfo(track, fake)
                    icol += 1

                if hit.isValid() and hit.z() >= 0:
                    self.PlotDetectorRange("p", 4)
                elif hit.isValid() and hit.z() < 0:
                    self.PlotDetectorRange("n", 4)
                else:
                    self.PlotDetectorRange("b", 4)

                print("****************************\n")
                self.Draw()
            return
Example #2
0
    def PlotFakes(self, event, reconstructed = 1, fake_filter = None, end_filter = None, last_filter = None, particle_end_filter = None):
	'''
        This is the main function to plot fakes in 3D with related TrackingParticles and tracks.
	Fake track is drawn as red, TrackingParticles as green and reconstructed tracks as blue.
	The detector scheme is also drawn with black circles.
	The decay vertices (yellow) and reconstructed collision vertices (colour of the track) are also drawn.
	Alongside with the fake plotting, the track and particle informations are printed.

	Set reconstructed to false for not drawing other reconstructed tracks related to a fake,
	use filters (lists of class indexes or detector layer strings) to filter out everything else from plotting.
	'''
	iterative = 1 # simple edits for not needing to refactorise code	

        fakes = analysis.FindFakes(event)
	if iterative:
            # Plot fakes one by one
	    for fake in fakes:
		fake_info = analysis.FakeInfo(fake)
                # Check for filter
		if fake_filter and fake_info.fake_class not in fake_filter:
			continue
	        if last_filter or particle_end_filter:
		    found_flag = False
		    for match in fake_info.matches:
			if (not end_filter or match.end_class in end_filter) and (not last_filter or last_filter in match.last_str) and (not particle_end_filter or particle_end_filter in match.particle_end_str):
			    found_flag = True
	            if not found_flag:
			continue 

		self.Reset()
		self.Plot3DHelixes([fake],2)
		self.Plot3DHits(fake, 2)
		#self.PlotVertex3D(vertex,2)
		analysis.PrintTrackInfo(fake, None, 0, fake_info)
                if fake_info.matches:
		    for match in fake_info.matches:
			self.PlotTrackingFail(match)
			#self.PlotPoint3D(fake_info.end_loc, 2)

                # Find real particle tracks which include fake tracks hits
		icol = 0
		particle_inds = []
		particles = []
		reco_inds = []
		recos = []
		for hit in fake.hits():
		    if hit.isValidHit() and hit.nSimHits() >= 0:
			for simHit in hit.simHits():
			    particle = simHit.trackingParticle()
			    if particle.index() not in particle_inds:
				particle_inds.append(particle.index())
				particles.append(particle)
			    if reconstructed and particle.nMatchedTracks() > 0:
				for info in particle.matchedTrackInfos():
				    track = info.track()
				    if track.index() not in reco_inds:
					reco_inds.append(track.index())
					recos.append(track)


		    # Find reconstructed tracks included in fakes hits 
		    if hit.isValidHit() and reconstructed and hit.ntracks() > 0:
			for track in hit.tracks():
			    #track = info.track()
			    if (track.index() not in reco_inds) and track.index() != fake.index():
				reco_inds.append(track.index())
				recos.append(track)
 
                # Plot the particles and reconstructed tracks
		icol =  0
		self.ParticleTest(particles, draw=False)
                for particle in particles:
		    self.Plot3DHelix(particle, self.colors_G[icol], 1)
		    self.plots_3D[-1].SetLineStyle(5)
		    self.Plot3DHits(particle, self.colors_G[icol], 1) 
		    self.PlotVertex3D(particle.parentVertex(),self.colors_G[icol])
                    # EXPERIMENTAL LINE:
                    #self.PlotTrack3D(particle, self.colors_G[icol])

		    for decay in particle.decayVertices():
			self.PlotVertex3D(decay, 5)
		    analysis.PrintTrackInfo(particle, fake)
		    icol += 1
		icol = 0
		for track in recos:
		    self.Plot3DHelix(track,self.colors_B[icol],2)
		    self.Plot3DHits(track,self.colors_B[icol],2)
		    #self.PlotVertex3D(vertex,self.colors_B[icol])
		    analysis.PrintTrackInfo(track, fake)
		    icol += 1
		    
		if hit.isValidHit() and hit.z() >= 0: self.PlotDetectorRange("p",4)
		elif hit.isValidHit() and hit.z() < 0: self.PlotDetectorRange("n",4)
		else: self.PlotDetectorRange("b",4)

                print("****************************\n")
	        self.Draw()
            return