# for 1000 events 621.6023199558258 Filename: process_csv.py Line # Mem usage Increment Occurrences Line Contents ============================================================= 16 172.2 MiB 172.2 MiB 1 @profile 17 def main(): 18 19 832.5 MiB 0.0 MiB 540452 def pt_cond1(tree,branch,index,i,pt1,pt2): #"index" is index of the tau of concern, i is the index of the tau pair 20 ''' This returns True or False for a particular hltpt tau if it can be paired up 21 with the second tau and pass the pt cut''' 22 # Check if both the taus are above pt2 and check if atleast one of them is above pt2 23 832.5 MiB 0.5 MiB 540451 condition1 = getattr(tree,branch)[index].Pt()>pt2 24 832.5 MiB 0.0 MiB 540451 condition1 &= getattr(tree,branch)[i].Pt()>pt2 25 832.5 MiB 0.0 MiB 540451 condition1 &= (getattr(tree,branch)[index].Pt()>pt1 or getattr(tree,branch)[i].Pt()>pt1) 26 832.5 MiB 0.0 MiB 540451 if i!=index and condition1: 27 832.5 MiB 0.0 MiB 340954 return True 28 832.5 MiB 0.0 MiB 199497 return False 29 30 832.5 MiB 0.0 MiB 340955 def Online_mRNN_cond(tree,index,i, no_RNN = 440, m_RNN=280 ): 31 '''This returns True or False for a particlular hltpt tau if it can be paired up 32 with the second tau and pass the medium RNN cut''' 33 # For tau[index] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 34 832.5 MiB 153.9 MiB 340954 RNN1_cond = (tree.TrigTRM_TauIDm[index]) and (tree.TrigTRM_Taus[index].Pt() < m_RNN) 35 832.5 MiB 146.2 MiB 340954 RNN1_cond |= (tree.TrigTRM_TauIDl[index]) and (tree.TrigTRM_Taus[index].Pt() > m_RNN) and (tree.TrigTRM_Taus[index].Pt() < no_RNN) 36 832.5 MiB 0.0 MiB 340954 RNN1_cond |= tree.TrigTRM_Taus[index].Pt() > no_RNN 37 # For tau[i] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 38 832.5 MiB 146.9 MiB 340954 RNN2_cond = (tree.TrigTRM_TauIDm[i]) and (tree.TrigTRM_Taus[i].Pt() < m_RNN) 39 832.5 MiB 141.9 MiB 340954 RNN2_cond |= (tree.TrigTRM_TauIDl[i]) and (tree.TrigTRM_Taus[i].Pt() > m_RNN) and (tree.TrigTRM_Taus[i].Pt() < no_RNN) 40 832.5 MiB 0.0 MiB 340954 RNN2_cond |= tree.TrigTRM_Taus[i].Pt() > no_RNN 41 832.5 MiB 0.0 MiB 340954 if RNN1_cond and RNN2_cond: 42 830.1 MiB 0.0 MiB 12364 return True 43 else: 44 832.5 MiB 0.0 MiB 328590 return False 45 46 830.1 MiB 0.0 MiB 12365 def Online_DR_cond(tree,index,i,min_DR = 0.3, max_DR = 3): 47 '''This returns True or False for a particlular tau if it can be paired up 48 with the second tau and pass the hltpt Delta R cut''' 49 #Delta R should be greater than 0.3 and less than 3 50 830.1 MiB 0.0 MiB 12364 hltptDR_cond = tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) > min_DR 51 830.1 MiB 0.0 MiB 12364 hltptDR_cond &= tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) < max_DR 52 830.1 MiB 0.0 MiB 12364 if hltptDR_cond: 53 509.7 MiB 0.0 MiB 19 return True 54 else: 55 830.1 MiB 0.0 MiB 12345 return False 56 57 58 832.5 MiB 0.0 MiB 60692 def Online_hltpt_cond(tree,tau_i,pt1=35,pt2=25, no_RNN = 440, m_RNN =280, min_DR =0.3,max_DR =3): 59 '''This returns True if the hltpt trigger condition is satisfied for tau_i''' 60 832.5 MiB 0.0 MiB 60691 if len(tree.TrigTRM_Taus)>=2: 61 832.5 MiB 0.0 MiB 60691 ptflag = 0 62 832.5 MiB 0.0 MiB 60691 RNN_flag = 0 63 #Checking if tau_i has a pair that satidsfies the hltpt condition by looping over all taus 64 832.5 MiB 0.0 MiB 601123 for i in range(len(tree.TrigTRM_Taus)): 65 #Checking the pt condtion for tau_i and tau[i] 66 832.5 MiB 0.0 MiB 540451 if pt_cond1(tree,"TrigTRM_Taus",tau_i,i,pt1,pt2): 67 832.5 MiB 0.0 MiB 340954 if ptflag ==0: 68 832.5 MiB 0.0 MiB 44848 ptflag =1 69 #Checking the medium RNN condition for tau_i and tau[i] 70 832.5 MiB 0.0 MiB 340954 if Online_mRNN_cond(tree,tau_i,i,no_RNN,m_RNN): 71 830.1 MiB 0.0 MiB 12364 if RNN_flag == 0: 72 830.1 MiB 0.0 MiB 3963 RNN_flag =1 73 #Checking the DeltaR condtion for tau_i and tau[i] 74 830.1 MiB 0.0 MiB 12364 if Online_DR_cond(tree,tau_i,i,min_DR,max_DR): 75 509.7 MiB 0.0 MiB 19 return True 76 832.5 MiB 0.0 MiB 60672 return False 77 79 80 81 172.2 MiB 0.0 MiB 1 histFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.root" 82 186.1 MiB 13.9 MiB 1 File = ROOT.TFile.Open(histFileRoot,"READ") 83 195.3 MiB 9.2 MiB 1 tree = File.Get("analysis") 84 85 195.3 MiB 0.0 MiB 1 weightFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.EBweights.root" 86 195.3 MiB 0.0 MiB 1 WeightFile = ROOT.TFile.Open(weightFileRoot,"READ") 87 195.3 MiB 0.0 MiB 1 weight_tree = WeightFile.Get('trig') 88 89 195.6 MiB 0.3 MiB 1 pt1 = np.linspace(20,45,6) 90 195.6 MiB 0.0 MiB 1 pt2 = np.linspace(15,40,6) 92 195.6 MiB 0.0 MiB 1 RNN = 440 93 195.6 MiB 0.0 MiB 1 m_RNN =280 95 195.6 MiB 0.0 MiB 1 DR = 0.3 96 195.6 MiB 0.0 MiB 1 max_DR = 3 97 195.6 MiB 0.0 MiB 1 t = 2860 99 195.4 MiB 0.0 MiB 1 N_events = 1000 98 195.6 MiB 0.0 MiB 1 rate_column = np.zeros(26) 102 195.6 MiB 0.0 MiB 1 with open('HLTpt_rates.csv', 'w', newline='') as csvfile: 103 195.6 MiB 0.0 MiB 1 csvwriter = csv.writer(csvfile) 104 195.6 MiB 0.0 MiB 1 csvwriter.writerow(['pt1','pt2','eff_HLTpt']) 105 832.5 MiB 0.0 MiB 1001 for event in range(N_events): 106 832.5 MiB 44.2 MiB 1000 tree.GetEntry(event) 107 832.5 MiB 0.3 MiB 1000 weight_tree.GetEntry(event) 108 832.5 MiB 0.0 MiB 1000 pass_events = np.array([]) # No of events that passed each trigger 109 832.5 MiB 0.0 MiB 7000 for pti in pt1: 110 832.5 MiB 0.0 MiB 42000 for ptj in pt2: 111 832.5 MiB 0.0 MiB 36000 if pti >= ptj: 112 832.5 MiB 0.0 MiB 26000 hltptevent_flag = 0 113 832.5 MiB 2.9 MiB 26000 if len(tree.TrigTRM_Taus)>=2: 114 832.5 MiB 0.0 MiB 69862 for i in range(len(tree.TrigTRM_Taus)): 115 832.5 MiB 0.0 MiB 60840 if hltptevent_flag == 0 and Online_hltpt_cond(tree,i,pti,ptj,no_RNN = 440, m_RNN =280, min_DR =0.3,max_DR =3): 116 509.7 MiB 0.0 MiB 19 pass_events = np.append(pass_events,weight_tree.EBweight) 117 509.7 MiB 0.0 MiB 19 hltptevent_flag = 1 118 832.5 MiB 0.0 MiB 26000 if hltptevent_flag == 0: 119 832.5 MiB 0.0 MiB 25981 pass_events = np.append(pass_events,0) 121 832.5 MiB 0.0 MiB 1000 rate_column +=pass_events 122 123 832.5 MiB 0.0 MiB 1 index = 0 124 832.5 MiB 0.0 MiB 7 for pti in pt1: 125 832.5 MiB 0.0 MiB 42 for ptj in pt2: 126 832.5 MiB 0.0 MiB 36 if pti >= ptj: 127 832.5 MiB 0.0 MiB 26 csvwriter.writerow([pti,ptj,rate_column[index]/t]) 128 832.5 MiB 0.0 MiB 26 index+=1 130 832.5 MiB 0.0 MiB 1 csvfile.close() ########################################################################################################## For 100 events 32.241984605789185 Filename: process_csv.py Line # Mem usage Increment Occurrences Line Contents ============================================================= 16 172.2 MiB 172.2 MiB 1 @profile 17 def main(): 18 19 228.1 MiB 0.0 MiB 29953 def pt_cond1(tree,branch,index,i,pt1,pt2): #"index" is index of the tau of concern, i is the index of the tau pair 20 ''' This returns True or False for a particular hltpt tau if it can be paired up 21 with the second tau and pass the pt cut''' 22 # Check if both the taus are above pt2 and check if atleast one of them is above pt2 23 228.1 MiB 0.5 MiB 29952 condition1 = getattr(tree,branch)[index].Pt()>pt2 24 228.1 MiB 0.0 MiB 29952 condition1 &= getattr(tree,branch)[i].Pt()>pt2 25 228.1 MiB 0.0 MiB 29952 condition1 &= (getattr(tree,branch)[index].Pt()>pt1 or getattr(tree,branch)[i].Pt()>pt1) 26 228.1 MiB 0.0 MiB 29952 if i!=index and condition1: 27 228.1 MiB 0.0 MiB 15606 return True 28 228.1 MiB 0.0 MiB 14346 return False 29 30 228.1 MiB 0.0 MiB 15607 def Online_mRNN_cond(tree,index,i, no_RNN = 440, m_RNN=280 ): 31 '''This returns True or False for a particlular hltpt tau if it can be paired up 32 with the second tau and pass the medium RNN cut''' 33 # For tau[index] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 34 228.1 MiB 6.8 MiB 15606 RNN1_cond = (tree.TrigTRM_TauIDm[index]) and (tree.TrigTRM_Taus[index].Pt() < m_RNN) 35 228.1 MiB 7.4 MiB 15606 RNN1_cond |= (tree.TrigTRM_TauIDl[index]) and (tree.TrigTRM_Taus[index].Pt() > m_RNN) and (tree.TrigTRM_Taus[index].Pt() < no_RNN) 36 228.1 MiB 0.0 MiB 15606 RNN1_cond |= tree.TrigTRM_Taus[index].Pt() > no_RNN 37 # For tau[i] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 38 228.1 MiB 6.9 MiB 15606 RNN2_cond = (tree.TrigTRM_TauIDm[i]) and (tree.TrigTRM_Taus[i].Pt() < m_RNN) 39 228.1 MiB 6.5 MiB 15606 RNN2_cond |= (tree.TrigTRM_TauIDl[i]) and (tree.TrigTRM_Taus[i].Pt() > m_RNN) and (tree.TrigTRM_Taus[i].Pt() < no_RNN) 40 228.1 MiB 0.0 MiB 15606 RNN2_cond |= tree.TrigTRM_Taus[i].Pt() > no_RNN 41 228.1 MiB 0.0 MiB 15606 if RNN1_cond and RNN2_cond: 42 227.1 MiB 0.0 MiB 684 return True 43 else: 44 228.1 MiB 0.0 MiB 14922 return False 45 46 227.1 MiB 0.0 MiB 685 def Online_DR_cond(tree,index,i,min_DR = 0.3, max_DR = 3): 47 '''This returns True or False for a particlular tau if it can be paired up 48 with the second tau and pass the hltpt Delta R cut''' 49 #Delta R should be greater than 0.3 and less than 3 50 227.1 MiB 0.3 MiB 684 hltptDR_cond = tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) > min_DR 51 227.1 MiB 0.0 MiB 684 hltptDR_cond &= tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) < max_DR 52 227.1 MiB 0.0 MiB 684 if hltptDR_cond: 53 return True 54 else: 55 227.1 MiB 0.0 MiB 684 return False 56 57 58 228.1 MiB 0.0 MiB 4057 def Online_hltpt_cond(tree,tau_i,pt1=35,pt2=25, no_RNN = 440, m_RNN =280, min_DR =0.3,max_DR =3): 59 '''This returns True if the hltpt trigger condition is satisfied for tau_i''' 60 228.1 MiB 0.0 MiB 4056 if len(tree.TrigTRM_Taus)>=2: 61 228.1 MiB 0.0 MiB 4056 ptflag = 0 62 228.1 MiB 0.0 MiB 4056 RNN_flag = 0 63 #Checking if tau_i has a pair that satidsfies the hltpt condition by looping over all taus 64 228.1 MiB 0.0 MiB 34008 for i in range(len(tree.TrigTRM_Taus)): 65 #Checking the pt condtion for tau_i and tau[i] 66 228.1 MiB 0.0 MiB 29952 if pt_cond1(tree,"TrigTRM_Taus",tau_i,i,pt1,pt2): 67 228.1 MiB 0.0 MiB 15606 if ptflag ==0: 68 228.1 MiB 0.0 MiB 2546 ptflag =1 69 #Checking the medium RNN condition for tau_i and tau[i] 70 228.1 MiB 0.0 MiB 15606 if Online_mRNN_cond(tree,tau_i,i,no_RNN,m_RNN): 71 227.1 MiB 0.0 MiB 684 if RNN_flag == 0: 72 227.1 MiB 0.0 MiB 236 RNN_flag =1 73 #Checking the DeltaR condtion for tau_i and tau[i] 74 227.1 MiB 0.0 MiB 684 if Online_DR_cond(tree,tau_i,i,min_DR,max_DR): 75 return True 76 228.1 MiB 0.0 MiB 4056 return False 77 79 80 81 172.2 MiB 0.0 MiB 1 histFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.root" 82 186.1 MiB 13.9 MiB 1 File = ROOT.TFile.Open(histFileRoot,"READ") 83 195.4 MiB 9.3 MiB 1 tree = File.Get("analysis") 84 85 195.4 MiB 0.0 MiB 1 weightFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.EBweights.root" 86 195.4 MiB 0.0 MiB 1 WeightFile = ROOT.TFile.Open(weightFileRoot,"READ") 87 195.4 MiB 0.0 MiB 1 weight_tree = WeightFile.Get('trig') 88 89 195.4 MiB 0.0 MiB 1 pt1 = np.linspace(20,45,6) 90 195.4 MiB 0.0 MiB 1 pt2 = np.linspace(15,40,6) 92 195.4 MiB 0.0 MiB 1 RNN = 440 93 195.4 MiB 0.0 MiB 1 m_RNN =280 95 195.4 MiB 0.0 MiB 1 DR = 0.3 96 195.4 MiB 0.0 MiB 1 max_DR = 3 97 195.4 MiB 0.0 MiB 1 t = 2860 98 195.4 MiB 0.0 MiB 1 rate_column = np.zeros(26) 99 195.4 MiB 0.0 MiB 1 N_events = 100 102 195.4 MiB 0.0 MiB 1 with open('HLTpt_rates.csv', 'w', newline='') as csvfile: 103 195.4 MiB 0.0 MiB 1 csvwriter = csv.writer(csvfile) 104 195.4 MiB 0.0 MiB 1 csvwriter.writerow(['pt1','pt2','eff_HLTpt']) 105 228.1 MiB 0.0 MiB 101 for event in range(N_events): 106 228.1 MiB 1.5 MiB 100 tree.GetEntry(event) 107 228.1 MiB 0.0 MiB 100 weight_tree.GetEntry(event) 108 228.1 MiB 0.0 MiB 100 pass_events = np.array([]) 109 228.1 MiB 0.0 MiB 700 for pti in pt1: 110 228.1 MiB 0.0 MiB 4200 for ptj in pt2: 111 228.1 MiB 0.0 MiB 3600 if pti >= ptj: 112 228.1 MiB 0.0 MiB 2600 hltptevent_flag = 0 113 228.1 MiB 2.9 MiB 2600 if len(tree.TrigTRM_Taus)>=2: 114 228.1 MiB 0.0 MiB 4706 for i in range(len(tree.TrigTRM_Taus)): 115 228.1 MiB 0.0 MiB 4056 if hltptevent_flag == 0 and Online_hltpt_cond(tree,i,pti,ptj,no_RNN = 440, m_RNN =280, min_DR =0.3,max_DR =3): 116 pass_events = np.append(pass_events,weight_tree.EBweight) 117 hltptevent_flag = 1 118 228.1 MiB 0.0 MiB 2600 if hltptevent_flag == 0: 119 228.1 MiB 0.0 MiB 2600 pass_events = np.append(pass_events,0) 121 228.1 MiB 0.0 MiB 100 rate_column +=pass_events 122 123 228.1 MiB 0.0 MiB 1 index = 0 124 228.1 MiB 0.0 MiB 7 for pti in pt1: 125 228.1 MiB 0.0 MiB 42 for ptj in pt2: 126 228.1 MiB 0.0 MiB 36 if pti >= ptj: 127 228.1 MiB 0.0 MiB 26 csvwriter.writerow([pti,ptj,rate_column[index]/t]) 128 228.1 MiB 0.0 MiB 26 index+=1 129 130 228.1 MiB 0.0 MiB 1 csvfile.close() ########################################################################################################## For 10 events 2.2671191692352295 Filename: process_csv.py Line # Mem usage Increment Occurrences Line Contents ============================================================= 16 202.9 MiB 202.9 MiB 1 @profile 17 def main(): 18 19 204.4 MiB 0.0 MiB 2627 def pt_cond1(tree,branch,index,i,pt1,pt2): #"index" is index of the tau of concern, i is the index of the tau pair 20 ''' This returns True or False for a particular hltpt tau if it can be paired up 21 with the second tau and pass the pt cut''' 22 # Check if both the taus are above pt2 and check if atleast one of them is above pt2 23 204.4 MiB 0.0 MiB 2626 condition1 = getattr(tree,branch)[index].Pt()>pt2 24 204.4 MiB 0.0 MiB 2626 condition1 &= getattr(tree,branch)[i].Pt()>pt2 25 204.4 MiB 0.0 MiB 2626 condition1 &= (getattr(tree,branch)[index].Pt()>pt1 or getattr(tree,branch)[i].Pt()>pt1) 26 204.4 MiB 0.0 MiB 2626 if i!=index and condition1: 27 204.4 MiB 0.0 MiB 590 return True 28 204.4 MiB 0.0 MiB 2036 return False 29 30 204.4 MiB 0.0 MiB 591 def Online_mRNN_cond(tree,index,i, no_RNN = 440, m_RNN=280 ): 31 '''This returns True or False for a particlular hltpt tau if it can be paired up 32 with the second tau and pass the medium RNN cut''' 33 # For tau[index] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 34 204.4 MiB 0.2 MiB 590 RNN1_cond = (tree.TrigTRM_TauIDm[index]) and (tree.TrigTRM_Taus[index].Pt() < m_RNN) 35 204.4 MiB 0.3 MiB 590 RNN1_cond |= (tree.TrigTRM_TauIDl[index]) and (tree.TrigTRM_Taus[index].Pt() > m_RNN) and (tree.TrigTRM_Taus[index].Pt() < no_RNN) 36 204.4 MiB 0.0 MiB 590 RNN1_cond |= tree.TrigTRM_Taus[index].Pt() > no_RNN 37 # For tau[i] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 38 204.4 MiB 0.1 MiB 590 RNN2_cond = (tree.TrigTRM_TauIDm[i]) and (tree.TrigTRM_Taus[i].Pt() < m_RNN) 39 204.4 MiB 0.2 MiB 590 RNN2_cond |= (tree.TrigTRM_TauIDl[i]) and (tree.TrigTRM_Taus[i].Pt() > m_RNN) and (tree.TrigTRM_Taus[i].Pt() < no_RNN) 40 204.4 MiB 0.0 MiB 590 RNN2_cond |= tree.TrigTRM_Taus[i].Pt() > no_RNN 41 204.4 MiB 0.0 MiB 590 if RNN1_cond and RNN2_cond: 42 204.2 MiB 0.0 MiB 120 return True 43 else: 44 204.4 MiB 0.0 MiB 470 return False 45 46 204.2 MiB 0.0 MiB 121 def Online_DR_cond(tree,index,i,min_DR = 0.3, max_DR = 3): 47 '''This returns True or False for a particlular tau if it can be paired up 48 with the second tau and pass the hltpt Delta R cut''' 49 #Delta R should be greater than 0.3 and less than 3 50 204.2 MiB 0.0 MiB 120 hltptDR_cond = tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) > min_DR 51 204.2 MiB 0.0 MiB 120 hltptDR_cond &= tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) < max_DR 52 204.2 MiB 0.0 MiB 120 if hltptDR_cond: 53 return True 54 else: 55 204.2 MiB 0.0 MiB 120 return False 56 57 58 204.4 MiB 0.0 MiB 443 def Online_hltpt_cond(tree,tau_i,pt1=35,pt2=25, no_RNN = 440, m_RNN =280, min_DR =0.3,max_DR =3): 59 '''This returns True if the hltpt trigger condition is satisfied for tau_i''' 60 204.4 MiB 0.0 MiB 442 if len(tree.TrigTRM_Taus)>=2: 61 204.4 MiB 0.0 MiB 442 ptflag = 0 62 204.4 MiB 0.0 MiB 442 RNN_flag = 0 63 #Checking if tau_i has a pair that satidsfies the hltpt condition by looping over all taus 64 204.4 MiB 0.0 MiB 3068 for i in range(len(tree.TrigTRM_Taus)): 65 #Checking the pt condtion for tau_i and tau[i] 66 204.4 MiB 0.0 MiB 2626 if pt_cond1(tree,"TrigTRM_Taus",tau_i,i,pt1,pt2): 67 204.4 MiB 0.0 MiB 590 if ptflag ==0: 68 204.4 MiB 0.0 MiB 154 ptflag =1 69 #Checking the medium RNN condition for tau_i and tau[i] 70 204.4 MiB 0.0 MiB 590 if Online_mRNN_cond(tree,tau_i,i,no_RNN,m_RNN): 71 204.2 MiB 0.0 MiB 120 if RNN_flag == 0: 72 204.2 MiB 0.0 MiB 42 RNN_flag =1 73 #Checking the DeltaR condtion for tau_i and tau[i] 74 204.2 MiB 0.0 MiB 120 if Online_DR_cond(tree,tau_i,i,min_DR,max_DR): 75 return True 76 204.4 MiB 0.0 MiB 442 return False 77 79 80 81 202.9 MiB 0.0 MiB 1 histFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.root" 82 202.9 MiB 0.0 MiB 1 File = ROOT.TFile.Open(histFileRoot,"READ") 83 203.0 MiB 0.1 MiB 1 tree = File.Get("analysis") 84 85 203.0 MiB 0.0 MiB 1 weightFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.EBweights.root" 86 203.0 MiB 0.0 MiB 1 WeightFile = ROOT.TFile.Open(weightFileRoot,"READ") 87 203.0 MiB 0.0 MiB 1 weight_tree = WeightFile.Get('trig') 88 89 203.0 MiB 0.0 MiB 1 pt1 = np.linspace(20,45,6) 90 203.0 MiB 0.0 MiB 1 pt2 = np.linspace(15,40,6) 92 203.0 MiB 0.0 MiB 1 RNN = 440 93 203.0 MiB 0.0 MiB 1 m_RNN =280 95 203.0 MiB 0.0 MiB 1 DR = 0.3 96 203.0 MiB 0.0 MiB 1 max_DR = 3 97 203.0 MiB 0.0 MiB 1 t = 2860 98 203.0 MiB 0.0 MiB 1 rate_column = np.zeros(26) 99 203.0 MiB 0.0 MiB 1 N_events = 10 101 203.0 MiB 0.0 MiB 1 st = time.time() 102 203.0 MiB 0.0 MiB 1 with open('HLTpt_rates.csv', 'w', newline='') as csvfile: 103 203.0 MiB 0.0 MiB 1 csvwriter = csv.writer(csvfile) 104 203.0 MiB 0.0 MiB 1 csvwriter.writerow(['pt1','pt2','eff_HLTpt']) 105 204.4 MiB 0.0 MiB 11 for event in range(N_events): 106 204.4 MiB 0.3 MiB 10 tree.GetEntry(event) 107 204.4 MiB 0.2 MiB 10 weight_tree.GetEntry(event) 108 204.4 MiB 0.0 MiB 10 pass_events = np.array([]) 109 204.4 MiB 0.0 MiB 70 for pti in pt1: 110 204.4 MiB 0.0 MiB 420 for ptj in pt2: 111 204.4 MiB 0.0 MiB 360 if pti >= ptj: 112 204.4 MiB 0.0 MiB 260 hltptevent_flag = 0 113 204.4 MiB 0.0 MiB 260 if len(tree.TrigTRM_Taus)>=2: 114 204.4 MiB 0.0 MiB 520 for i in range(len(tree.TrigTRM_Taus)): 115 204.4 MiB 0.0 MiB 442 if hltptevent_flag == 0 and Online_hltpt_cond(tree,i,pti,ptj,no_RNN = 440, m_RNN =280, min_DR =0.3,max_DR =3): 116 pass_events = np.append(pass_events,weight_tree.EBweight) 117 hltptevent_flag = 1 118 204.4 MiB 0.0 MiB 260 if hltptevent_flag == 0: 119 204.4 MiB 0.0 MiB 260 pass_events = np.append(pass_events,0) 121 204.4 MiB 0.0 MiB 10 rate_column +=pass_events 122 123 204.4 MiB 0.0 MiB 1 index = 0 124 204.4 MiB 0.0 MiB 7 for pti in pt1: 125 204.4 MiB 0.0 MiB 42 for ptj in pt2: 126 204.4 MiB 0.0 MiB 36 if pti >= ptj: 127 204.4 MiB 0.0 MiB 26 csvwriter.writerow([pti,ptj,rate_column[index]/t]) 128 204.4 MiB 0.0 MiB 26 index+=1 129 130 204.4 MiB 0.0 MiB 1 csvfile.close() ##########################################################################################################