ATLAS Offline Software
Functions | Variables
rename_histos_in_files_from_old_code Namespace Reference

Functions

def get_name_associations (list)
 

Variables

string input_file_name = '/afs/cern.ch/user/j/juhofer/WORK/validation/data/QSP_on/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.NTUP_PHYSVAL.e4993_s3641_r12287_p4360_p3821_tid24086162_00/NTUP_PHYSVAL.24086162._000001.pool.root.1'
 
string production_process = 'ttbar'
 
bool verbose = False
 
list jet_collections
 
list var_name_list
 don't change here More...
 
list name_list = []
 
def name_associations = get_name_associations(name_list)
 
string output_file_name = input_file_name[:-5] + '_renamed.root'
 
 output_file = ROOT.TFile(output_file_name, 'RECREATE')
 
string path = "BTag/" + jet_col + "/"
 
 input_file = ROOT.TFile(input_file_name, 'READ')
 
 currentdir = ROOT.gDirectory.GetPath()
 
 dirlist = input_file.Get(currentdir).GetListOfKeys()
 
list histograms = []
 
 obj = subdir.ReadObj()
 
 new_histo = obj
 

Function Documentation

◆ get_name_associations()

def rename_histos_in_files_from_old_code.get_name_associations (   list)

Definition at line 150 of file rename_histos_in_files_from_old_code.py.

150 def get_name_associations(list):
151 
152  taggers = ["_IP3D_", "_SV1_", "_JetFitter_"]
153  old_taggers = ["_IP2D_"]
154  oneToOne_associations = {
155  '_truthLabel ': '_jet_truthLabel ',
156  '_IP3Dpb ': '_tagger_IP3D_pb ',
157  '_IP3Dpc ': '_tagger_IP3D_pc ',
158  '_IP3Dpu ': '_tagger_IP3D_pu ',
159  '_SV1pb ': '_tagger_SV1_pb ',
160  '_SV1pc ': '_tagger_SV1_pc ',
161  '_SV1pu ': '_tagger_SV1_pu ',
162  '_NTracksIP3D ': '_tagger_IP3D_NTracks_incl ',
163  '_NTracksIP2D ': '_old_taggers_IP2D_NTracks_incl ',
164  '_NGTinSvx1 ': '_tagger_SV1_nGoodTracks_incl ',
165  '_eta ': '_jet_jet_eta ',
166  '_phi ': '_jet_jet_phi ',
167  '_d0 ': '_tracks_d0_b ',
168  '_z0 ': '_tracks_z0_b ',
169  '_IP3DgradeOfTracks ': '_tagger_IP3D_gradeOfTracks_incl ',
170  '_IP2DgradeOfTracks ': '_old_taggers_IP2D_gradeOfTracks_incl ',
171  }
172  oneToOne_associations_ttbar = {
173  '_TruthBpt ': '_jet_jet_pt_b_ttbar ',
174  '_TruthLpt ': '_jet_jet_pt_l_ttbar ',
175  '_TruthCpt ': '_jet_jet_pt_c_ttbar ',
176  '_e ': '_jet_jet_e ',
177  '_pt ': '_jet_jet_pt_ttbar ',
178  }
179  oneToOne_associations_Zprime = {
180  '_TruthBpt ': '_jet_jet_pt_b_Zprime ',
181  '_TruthLpt ': '_jet_jet_pt_l_Zprime ',
182  '_TruthCpt ': '_jet_jet_pt_c_Zprime ',
183  '_e ': '_jet_jet_e_Zprime ',
184  '_pt ': '_jet_jet_pt_Zprime ',
185  }
186 
187  name_associations = {}
188 
189  for name in list:
190  new_name = name
191 
192  for tag in taggers:
193  if tag in new_name:
194  new_name = new_name.replace(tag, "_tagger" + tag)
195 
196  for tag in old_taggers:
197  if tag in new_name:
198  new_name = new_name.replace(tag, "_old_taggers" + tag)
199 
200  if "_matched_pt" in new_name:
201  new_name = new_name.replace("_matched_pt", "_matched_pt_" + production_process)
202 
203  if "AntiKt4EMPFlowJets" in new_name:
204  new_name = new_name.replace("AntiKt4EMPFlowJets", "AntiKt4EMPFlowJets_")
205 
206  if "AntiKtVR30Rmax4Rmin02TrackJets" in new_name:
207  new_name = new_name.replace("AntiKtVR30Rmax4Rmin02TrackJets", "AntiKtVR30Rmax4Rmin02TrackJets_")
208 
209  for key in oneToOne_associations:
210  if key in new_name:
211  new_name = new_name.replace(key, oneToOne_associations[key])
212 
213  if production_process == 'ttbar':
214  for key in oneToOne_associations_ttbar:
215  if key in new_name:
216  new_name = new_name.replace(key, oneToOne_associations_ttbar[key])
217 
218  if production_process == 'Zprime':
219  for key in oneToOne_associations_Zprime:
220  if key in new_name:
221  new_name = new_name.replace(key, oneToOne_associations_Zprime[key])
222 
223  # if new_name not in new_list and "tau" not in new_name and "Tau" not in new_name and not "_NGTinSvx0" in new_name:
224  # print(new_name)
225 
226  # remove spaces
227  name = name.replace(" ", "")
228  new_name = new_name.replace(" ", "")
229 
230  # fill the dict
231  name_associations[name] = new_name
232 
233  return name_associations
234 
235 
236 
237 # get the name_list for all jet collections

Variable Documentation

◆ currentdir

rename_histos_in_files_from_old_code.currentdir = ROOT.gDirectory.GetPath()

Definition at line 289 of file rename_histos_in_files_from_old_code.py.

◆ dirlist

rename_histos_in_files_from_old_code.dirlist = input_file.Get(currentdir).GetListOfKeys()

Definition at line 290 of file rename_histos_in_files_from_old_code.py.

◆ histograms

list rename_histos_in_files_from_old_code.histograms = []

Definition at line 295 of file rename_histos_in_files_from_old_code.py.

◆ input_file

rename_histos_in_files_from_old_code.input_file = ROOT.TFile(input_file_name, 'READ')

Definition at line 275 of file rename_histos_in_files_from_old_code.py.

◆ input_file_name

string rename_histos_in_files_from_old_code.input_file_name = '/afs/cern.ch/user/j/juhofer/WORK/validation/data/QSP_on/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.merge.NTUP_PHYSVAL.e4993_s3641_r12287_p4360_p3821_tid24086162_00/NTUP_PHYSVAL.24086162._000001.pool.root.1'

Definition at line 17 of file rename_histos_in_files_from_old_code.py.

◆ jet_collections

list rename_histos_in_files_from_old_code.jet_collections
Initial value:
1 = [ 'AntiKt2PV0TrackJets',
2  'AntiKt4EMPFlowJets',
3  'AntiKt4EMTopoJets',
4  'AntiKt4PV0TrackJets',
5  'AntiKtVR30Rmax4Rmin02TrackJets']

Definition at line 24 of file rename_histos_in_files_from_old_code.py.

◆ name_associations

def rename_histos_in_files_from_old_code.name_associations = get_name_associations(name_list)

Definition at line 247 of file rename_histos_in_files_from_old_code.py.

◆ name_list

list rename_histos_in_files_from_old_code.name_list = []

Definition at line 238 of file rename_histos_in_files_from_old_code.py.

◆ new_histo

rename_histos_in_files_from_old_code.new_histo = obj

Definition at line 314 of file rename_histos_in_files_from_old_code.py.

◆ obj

rename_histos_in_files_from_old_code.obj = subdir.ReadObj()

Definition at line 299 of file rename_histos_in_files_from_old_code.py.

◆ output_file

rename_histos_in_files_from_old_code.output_file = ROOT.TFile(output_file_name, 'RECREATE')

Definition at line 260 of file rename_histos_in_files_from_old_code.py.

◆ output_file_name

string rename_histos_in_files_from_old_code.output_file_name = input_file_name[:-5] + '_renamed.root'

Definition at line 253 of file rename_histos_in_files_from_old_code.py.

◆ path

string rename_histos_in_files_from_old_code.path = "BTag/" + jet_col + "/"

Definition at line 265 of file rename_histos_in_files_from_old_code.py.

◆ production_process

string rename_histos_in_files_from_old_code.production_process = 'ttbar'

Definition at line 20 of file rename_histos_in_files_from_old_code.py.

◆ var_name_list

list rename_histos_in_files_from_old_code.var_name_list

don't change here

Definition at line 36 of file rename_histos_in_files_from_old_code.py.

◆ verbose

bool rename_histos_in_files_from_old_code.verbose = False

Definition at line 22 of file rename_histos_in_files_from_old_code.py.

rename_histos_in_files_from_old_code.get_name_associations
def get_name_associations(list)
Definition: rename_histos_in_files_from_old_code.py:150