ATLAS Offline Software
Loading...
Searching...
No Matches
rename_histos_in_files_from_old_code Namespace Reference

Functions

 get_name_associations (list)

Variables

str 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'
str production_process = 'ttbar'
bool verbose = False
list jet_collections
list var_name_list
 don't change here
list name_list = []
 name_associations = get_name_associations(name_list)
str output_file_name = input_file_name[:-5] + '_renamed.root'
 output_file = ROOT.TFile(output_file_name, 'RECREATE')
str 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()

rename_histos_in_files_from_old_code.get_name_associations ( list)

Definition at line 144 of file rename_histos_in_files_from_old_code.py.

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

◆ histograms

list rename_histos_in_files_from_old_code.histograms = []

Definition at line 286 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 266 of file rename_histos_in_files_from_old_code.py.

◆ input_file_name

str 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 14 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= [ 'AntiKt4EMPFlowJets',
2 'AntiKt4EMTopoJets']

Definition at line 21 of file rename_histos_in_files_from_old_code.py.

◆ name_associations

rename_histos_in_files_from_old_code.name_associations = get_name_associations(name_list)

Definition at line 238 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 229 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 305 of file rename_histos_in_files_from_old_code.py.

◆ obj

rename_histos_in_files_from_old_code.obj = subdir.ReadObj()

Definition at line 290 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 251 of file rename_histos_in_files_from_old_code.py.

◆ output_file_name

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

Definition at line 244 of file rename_histos_in_files_from_old_code.py.

◆ path

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

Definition at line 256 of file rename_histos_in_files_from_old_code.py.

◆ production_process

str rename_histos_in_files_from_old_code.production_process = 'ttbar'

Definition at line 17 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 30 of file rename_histos_in_files_from_old_code.py.

◆ verbose

bool rename_histos_in_files_from_old_code.verbose = False

Definition at line 19 of file rename_histos_in_files_from_old_code.py.