After disabling the Online_mRNN_cond() : Line # Mem usage Increment Occurrences Line Contents ============================================================= 15 172.227 MiB 172.227 MiB 1 @profile 16 def main(): 17 18 200.453 MiB 0.000 MiB 25803 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 19 ''' This returns True or False for a particular hltpt tau if it can be paired up 20 with the second tau and pass the pt cut''' 21 # Check if both the taus are above pt2 and check if atleast one of them is above pt2 22 200.453 MiB 0.496 MiB 25802 condition1 = getattr(tree,branch)[index].Pt()>pt2 23 200.453 MiB 0.000 MiB 25802 condition1 &= getattr(tree,branch)[i].Pt()>pt2 24 200.453 MiB 0.000 MiB 25802 condition1 &= (getattr(tree,branch)[index].Pt()>pt1 or getattr(tree,branch)[i].Pt()>pt1) 25 200.453 MiB 0.000 MiB 25802 if i!=index and condition1: 26 200.453 MiB 0.000 MiB 12514 return True 27 200.453 MiB 0.000 MiB 13288 return False 28 29 200.453 MiB 0.000 MiB 12515 def Online_mRNN_cond(tree,index,i, no_RNN = 440, m_RNN=280 ): 30 '''This returns True or False for a particlular hltpt tau if it can be paired up 31 with the second tau and pass the medium RNN cut''' 32 200.453 MiB 0.000 MiB 12514 return True 33 # For tau[index] RNN Medium(Loose) if pt < m_RNN(no_RNN) | no RNN ID if pt > no_RNN GeV 34 RNN1_cond = (tree.TrigTRM_TauIDm[index]) and (tree.TrigTRM_Taus[index].Pt() < m_RNN) 35 RNN1_cond |= (tree.TrigTRM_TauIDl[index]) and (tree.TrigTRM_Taus[index].Pt() > m_RNN) and (tree.TrigTRM_Taus[index].Pt() < no_RNN) 36 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 RNN2_cond = (tree.TrigTRM_TauIDm[i]) and (tree.TrigTRM_Taus[i].Pt() < m_RNN) 39 RNN2_cond |= (tree.TrigTRM_TauIDl[i]) and (tree.TrigTRM_Taus[i].Pt() > m_RNN) and (tree.TrigTRM_Taus[i].Pt() < no_RNN) 40 RNN2_cond |= tree.TrigTRM_Taus[i].Pt() > no_RNN 41 if RNN1_cond and RNN2_cond: 42 return True 43 else: 44 return False 45 46 200.453 MiB 0.000 MiB 12515 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 200.453 MiB 0.000 MiB 12514 hltptDR_cond = tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) > min_DR 51 200.453 MiB 0.000 MiB 12514 hltptDR_cond &= tree.TrigTRM_Taus[index].DeltaR(tree.TrigTRM_Taus[i]) < max_DR 52 200.453 MiB 0.000 MiB 12514 if hltptDR_cond: 53 200.453 MiB 0.000 MiB 60 return True 54 else: 55 200.453 MiB 0.000 MiB 12454 return False 56 57 58 200.453 MiB 0.000 MiB 3627 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 200.453 MiB 0.000 MiB 3626 if len(tree.TrigTRM_Taus)>=2: 61 200.453 MiB 0.000 MiB 3626 ptflag = 0 62 200.453 MiB 0.000 MiB 3626 RNN_flag = 0 63 #Checking if tau_i has a pair that satidsfies the hltpt condition by looping over all taus 64 200.453 MiB 0.000 MiB 29368 for i in range(len(tree.TrigTRM_Taus)): 65 #Checking the pt condtion for tau_i and tau[i] 66 200.453 MiB 0.000 MiB 25802 if pt_cond1(tree,"TrigTRM_Taus",tau_i,i,pt1,pt2): 67 200.453 MiB 0.000 MiB 12514 if ptflag ==0: 68 200.453 MiB 0.000 MiB 2116 ptflag =1 69 #Checking the medium RNN condition for tau_i and tau[i] 70 200.453 MiB 0.000 MiB 12514 if Online_mRNN_cond(tree,tau_i,i,no_RNN,m_RNN): 71 200.453 MiB 0.000 MiB 12514 if RNN_flag == 0: 72 200.453 MiB 0.000 MiB 2116 RNN_flag =1 73 #Checking the DeltaR condtion for tau_i and tau[i] 74 200.453 MiB 0.000 MiB 12514 if Online_DR_cond(tree,tau_i,i,min_DR,max_DR): 75 200.453 MiB 0.000 MiB 60 return True 76 200.453 MiB 0.000 MiB 3566 return False 77 78 ############################################################################################## 79 80 81 172.227 MiB 0.000 MiB 1 histFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.root" 82 186.098 MiB 13.871 MiB 1 File = ROOT.TFile.Open(histFileRoot,"READ") 83 195.312 MiB 9.215 MiB 1 tree = File.Get("analysis") 84 85 195.312 MiB 0.000 MiB 1 weightFileRoot = "user.asudhaka.32997101.ANALYSIS._000001.refined.EBweights.root" 86 195.312 MiB 0.000 MiB 1 WeightFile = ROOT.TFile.Open(weightFileRoot,"READ") 87 195.312 MiB 0.000 MiB 1 weight_tree = WeightFile.Get('trig') 88 89 195.566 MiB 0.254 MiB 1 pt1 = np.linspace(20,45,6) #looped 90 195.566 MiB 0.000 MiB 1 pt2 = np.linspace(15,40,6) #looped 91 # no_RNN = [440,0] #looped 92 195.566 MiB 0.000 MiB 1 RNN = 440 93 195.566 MiB 0.000 MiB 1 m_RNN =280 94 # min_DR =[0.3,0] #looped 95 195.566 MiB 0.000 MiB 1 DR = 0.3 96 195.566 MiB 0.000 MiB 1 max_DR = 3 97 195.566 MiB 0.000 MiB 1 t = 2860 98 195.566 MiB 0.000 MiB 1 rate_column = np.zeros(26) 99 195.566 MiB 0.000 MiB 1 N_events = 100 #tree.GetEntries() 100 101 195.566 MiB 0.000 MiB 1 st = time.time() 102 195.566 MiB 0.000 MiB 1 with open('HLTpt_rates.csv', 'w', newline='') as csvfile: 103 195.566 MiB 0.000 MiB 1 csvwriter = csv.writer(csvfile) 104 195.566 MiB 0.000 MiB 1 csvwriter.writerow(['pt1','pt2','eff_HLTpt']) 105 200.453 MiB 0.000 MiB 101 for event in range(N_events): 106 200.453 MiB 1.234 MiB 100 tree.GetEntry(event) 107 200.453 MiB 0.254 MiB 100 weight_tree.GetEntry(event) 108 200.453 MiB 0.000 MiB 100 pass_events = np.array([]) # No of events that passed each trigger 109 200.453 MiB 0.000 MiB 700 for pti in pt1: 110 200.453 MiB 0.000 MiB 4200 for ptj in pt2: 111 200.453 MiB 0.000 MiB 3600 if pti >= ptj: 112 200.453 MiB 0.000 MiB 2600 hltptevent_flag = 0 113 200.453 MiB 2.902 MiB 2600 if len(tree.TrigTRM_Taus)>=2: 114 200.453 MiB 0.000 MiB 4706 for i in range(len(tree.TrigTRM_Taus)): 115 200.453 MiB 0.000 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 200.453 MiB 0.000 MiB 60 pass_events = np.append(pass_events,weight_tree.EBweight) 117 200.453 MiB 0.000 MiB 60 hltptevent_flag = 1 118 200.453 MiB 0.000 MiB 2600 if hltptevent_flag == 0: 119 200.453 MiB 0.000 MiB 2540 pass_events = np.append(pass_events,0) 120 # print(pass_events.shape) 121 200.453 MiB 0.000 MiB 100 rate_column +=pass_events 122 123 200.453 MiB 0.000 MiB 1 index = 0 124 200.453 MiB 0.000 MiB 7 for pti in pt1: 125 200.453 MiB 0.000 MiB 42 for ptj in pt2: 126 200.453 MiB 0.000 MiB 36 if pti >= ptj: 127 200.453 MiB 0.000 MiB 26 csvwriter.writerow([pti,ptj,rate_column[index]/t]) 128 200.453 MiB 0.000 MiB 26 index+=1 129 130 200.453 MiB 0.000 MiB 1 csvfile.close() 131 200.453 MiB 0.000 MiB 1 et = time.time() 132 200.453 MiB 0.000 MiB 1 print(et-st) ############################################################################################################################################################################################################# Before disabling Online_mRNN_cond(): 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 78 ############################################################################################## 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) #looped 90 195.4 MiB 0.0 MiB 1 pt2 = np.linspace(15,40,6) #looped 91 # no_RNN = [440,0] #looped 92 195.4 MiB 0.0 MiB 1 RNN = 440 93 195.4 MiB 0.0 MiB 1 m_RNN =280 94 # min_DR =[0.3,0] #looped 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 #tree.GetEntries() 100 101 195.4 MiB 0.0 MiB 1 st = time.time() 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([]) # No of events that passed each trigger 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) 120 # print(pass_events.shape) 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() 131 228.1 MiB 0.0 MiB 1 et = time.time() 132 228.1 MiB 0.0 MiB 1 print(et-st)