def selectOnPhotonPhotonDeltaR(photons): for photon1 in photons: photons = filter(lambda photon2: photon1.DeltaR(photon2) > minPhotonPhotonDeltaR or photon2.Pt() > photon1.Pt() # Remove Lower P Photon or photon1 == photon2, # Do Not Remove itself photons) # Currently Double Counts histogramBuilder.fillDeltaRHistograms(photons, photons, 'PhotonPhoton_DeltaR_PostPhotonPhotonDeltaRCut') return photons
def lheTruePhotonSelection(): inRootFileLoc = inRootFileDir + inRootFileName inRootFile = TFile(inRootFileLoc, "READ") # Set Histograms analysis_tree = inRootFile.Get(treeLoc) print "Tree ", analysis_tree num_entries = analysis_tree.GetEntries() print "Number of Entries: ", num_entries # # Loop Over Entries # for entry in xrange(num_entries): if entry%10000 == 0: print entry analysis_tree.GetEntry(entry) # print analysis_tree.__dict__ # Select Event, should be only one per entry. # Assign Particles # Will be filled with TLorentz Vector, for now. lhe_photons = [] lhe_electrons = [] lhe_muons = [] lhe_nu_es = [] lhe_nu_ms = [] lhe_ws = [] mc_photons = [] mc_electrons = [] mc_muons = [] mc_nu_es = [] mc_nu_ms = [] mc_ws = [] lhe_candidate_photons = [] lhe_candidate_electrons = [] lhe_candidate_muons = [] lhe_candidate_nu_es = [] lhe_candidate_nu_ms = [] lhe_candidate_ws = [] mc_candidate_photons = [] mc_candidate_electrons = [] mc_candidate_muons = [] mc_candidate_nu_es = [] mc_candidate_nu_ms = [] mc_candidate_ws = [] prompt_photons = [] # # Particle Identification # particleIdentification.assignParticles(analysis_tree, mc_photons, mc_electrons, mc_muons, mc_nu_es, mc_nu_ms, mc_ws) particleIdentification.assignLHEParticles(analysis_tree, lhe_photons, lhe_electrons, lhe_muons, lhe_nu_es, lhe_nu_ms, lhe_ws) # histogramBuilder.fillNumParticleHistograms(mc_photons, 'MCPhotonMultiplicity_PreCuts') # histogramBuilder.fillNumParticleHistograms(lhe_photons, 'LHEPhotonMultiplicity_PreCuts') passCandidateCuts(lhe_candidate_photons, lhe_candidate_electrons, lhe_candidate_muons, lhe_photons, lhe_electrons, lhe_muons) if not passCandidateCuts(mc_candidate_photons, mc_candidate_electrons, mc_candidate_muons, mc_photons, mc_electrons, mc_muons): continue # Select True Photons based on Parentage promptPhotons = filter(lambda photon: (photon.McParentage() & non_prompt_mask) != non_prompt_mask, mc_candidate_photons) #print "Num True Photons: ", len(promptPhotons) # photons_PtLT5 = filter(lambda photon: photon.Pt() < 5, photons) # Electron Channel if len(mc_candidate_electrons) == 1: #histogramBuilder.fillNumParticleHistograms(mc_candidate_photons, 'MCPhotonMultiplicity_ElectronChannel_MCPtdRCuts') histogramBuilder.fillNumParticleHistograms(lhe_candidate_photons, 'LHEPhotonMultiplicity_ElectronChannel_MCPtdRCuts') histogramBuilder.fillNumParticleHistograms(promptPhotons, 'PromptPhotonMultiplicity_ElectronChannel_MCPtdRCuts') if len(promptPhotons) > 1: print "More than One Prompt Photon - Electron Channel" histogramBuilder.fillDeltaRHistograms(promptPhotons, lhe_photons, "dRPromptLHEPhotons_PromptPhotonnGT1_ElectronChannel_MCPtdRCuts") new_photons = makeNewPhotons(lhe_photons,promptPhotons) histogramBuilder.fillParentHistograms(new_photons, "MomPID_NewPhoton_ElectronChannel") # histogramBuilder.fillStandardHistograms(new_photons, mc_electrons, mc_muons, "NewPhotons_ElectronChannel_MCPtdRCuts") histogramBuilder.fillVertexSeparationHistograms(new_photons,mc_electrons, "vertexSeparation_NewPhotonvMC_ElectronChannel") displacement= TVector3() for new_photon in new_photons: for mc_electron in mc_electrons: displacement = new_photon.Vertex()-mc_electron.Vertex() print "Separation ", displacement.Mag() # Muon Channel if len(mc_candidate_muons) == 1: #histogramBuilder.fillNumParticleHistograms(mc_candidate_photons, 'MCPhotonMultiplicity_MuonChannel_MCPtdRCuts') histogramBuilder.fillNumParticleHistograms(lhe_candidate_photons, 'LHEPhotonMultiplicity_MuonChannel_MCPtdRCuts') histogramBuilder.fillNumParticleHistograms(promptPhotons, 'PromptPhotonMultiplicity_MuonChannel_MCPtdRCuts') if len(promptPhotons) > 1: print "More than One True Photon --Muon Channel" histogramBuilder.fillDeltaRHistograms(promptPhotons, lhe_photons, 'dR_PromptLHEPhotons_PromptPhotonGT1_MuonChannel_MCPtdRCuts') new_photons = makeNewPhotons(lhe_photons, promptPhotons) histogramBuilder.fillParentHistograms(new_photons, "MomPID_NewPhotons_MuonChannel") # histogramBuilder.fillStandardHistograms(new_photons, mc_electrons, mc_muons, 'PromptPhotonGT1_MuonChannel_MCPtdRCuts') displacement= TVector3() for new_photon in new_photons: for mc_muon in mc_muons: displacement = new_photon.Vertex()-mc_muon.Vertex() print "Separation ", displacement.Mag() # Candidate Cuts on the LHE Events # if passCandidateCuts(lhe_candidate_photons, lhe_candidate_electrons, lhe_candidate_muons, # lhe_photons, lhe_electrons, lhe_muons): # histogramBuilder.fillStandardHistograms(lhe_candidate_photons, lhe_candidate_electrons, lhe_candidate_muons, "LHEPtdRCuts") #photons_Boson = filter(lambda photon: (photon.McParentage() & boson_parent_mask) == boson_parent_mask, photons) outRootFile = TFile(outRootFileName, 'RECREATE') outRootFile.cd() #Iterate Over All Histograms for key, Histogram in histogramBuilder.Histograms.iteritems(): Histogram.Write() inRootFile.Close() outRootFile.Close()
def selectOnPhotonMuonDeltaR(photons, muons): for muon in muons: photons = filter(lambda photon: photon.DeltaR(muon) > minPhotonMuonDeltaR, photons) histogramBuilder.fillDeltaRHistograms(photons, muons, 'PhotonMuon_DeltaR_PostPhotonMuonDeltaRCut') return photons
def MakeDeltaRHistograms(prefix, particles1, particles2, particleType1, particleType2): prefix+="_"+particleType1 +"_"+ particleType2 for particle1 in particles1: for particle2 in particles2: if particle1 != particle2: histogramBuilder.fillDeltaRHistograms(prefix, particle1.DeltaR(particle2))