ATLAS Offline Software
Class_InformationHandler.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 import string
4 
6 
7  def __init__(self, flags):
8 
9  #setup the member variables
10  # they are filled in the helper functions setupInfo_*
11  self.m_Infos_Int = {}
12  self.m_Infos_Double = {}
13  self.m_Infos_String = {}
16 
17  #fill member variables
18  self.setupInfo_Int(flags)
19  self.setupInfo_Double(flags)
20  self.setupInfo_String(flags)
21  self.setupInfo_VecDouble(flags)
22  self.setupInfo_VecString(flags)
23 
24  #fill the feature types and default values
25  # -> a bit more involved, have extra function for this
26  self.setupInfo_Features(flags)
27 
28 
29  def dump(self):
30  print("PanTau::InformationHandler: Printing stored information")
31 
32  print("PanTau::InformationHandler: \tIntegers:")
33  for iInfo in sorted(self.m_Infos_Int.iterkeys()):
34  print("\t\t" + string.ljust(iInfo, 50) + ": " + string.rjust(str(self.m_Infos_Int[iInfo]), 10) )
35 
36  print("PanTau::InformationHandler: \tDoubles:")
37  for iInfo in sorted(self.m_Infos_Double.iterkeys()):
38  print("\t\t" + string.ljust(iInfo, 50) + ": " + string.rjust(str(self.m_Infos_Double[iInfo]), 10) )
39 
40  print("PanTau::InformationHandler: \tStrings:")
41  for iInfo in sorted(self.m_Infos_String.iterkeys()):
42  print("\t\t" + string.ljust(iInfo, 50) + ": " + string.ljust(self.m_Infos_String[iInfo], 80) )
43 
44  print("PanTau::InformationHandler: \tVecDoubles:")
45  for iInfo in sorted(self.m_Infos_VecDouble.iterkeys()):
46  print("InformationHandler: \t\t" + string.ljust(iInfo, 50) + ":")
47  for iVal in self.m_Infos_VecDouble[iInfo]:
48  print("InformationHandler: \t\t\t" + string.rjust(str(iVal), 10) )
49 
50  print("PanTau::InformationHandler: \tVecStrings:")
51  for iInfo in sorted(self.m_Infos_VecString.iterkeys()):
52  print("InformationHandler: \t\t" + string.ljust(iInfo, 50) + ":")
53  for iVal in self.m_Infos_VecString[iInfo]:
54  print("InformationHandler: \t\t\t" + string.ljust(str(iVal), 80) )
55 
56  print("PanTau::InformationHandler: Done printing stored information")
57 
58 
59 
60  def setupInfo_Int(self, flags):
61  self.m_Infos_Int["TauConstituents_UsePionMass"] = int(flags.Tau.PanTau.TauConstituents_UsePionMass)
62  self.m_Infos_Int["FeatureExtractor_UseEmptySeeds"] = int(flags.Tau.PanTau.FeatureExtractor_UseEmptySeeds)
63  #nothing to do here yet (no integer infos...)
64 
65 
66  def setupInfo_Double(self, flags):
67  self.m_Infos_Double["TauConstituents_Types_DeltaRCore"] = flags.Tau.PanTau.TauConstituents_Types_DeltaRCore
68  self.m_Infos_Double["TauConstituents_MaxEta"] = flags.Tau.PanTau.TauConstituents_MaxEta
69  self.m_Infos_Double["TauConstituents_PreselectionMinEnergy"] = flags.Tau.PanTau.TauConstituents_PreselectionMinEnergy
70 
71  self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R10X_CellBased"] = flags.Tau.PanTau.DecayModeDeterminator_BDTCutValue_R10X_CellBased
72  self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R11X_CellBased"] = flags.Tau.PanTau.DecayModeDeterminator_BDTCutValue_R11X_CellBased
73  self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R110_CellBased"] = flags.Tau.PanTau.DecayModeDeterminator_BDTCutValue_R110_CellBased
74  self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R1XX_CellBased"] = flags.Tau.PanTau.DecayModeDeterminator_BDTCutValue_R1XX_CellBased
75  self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R30X_CellBased"] = flags.Tau.PanTau.DecayModeDeterminator_BDTCutValue_R30X_CellBased
76  self.m_Infos_Double["DecayModeDeterminator_BDTCutValue_R3XX_CellBased"] = flags.Tau.PanTau.DecayModeDeterminator_BDTCutValue_R3XX_CellBased
77 
78  def setupInfo_String(self, flags):
79  self.m_Infos_String["ModeDiscriminator_TMVAMethod"] = flags.Tau.PanTau.ModeDiscriminator_TMVAMethod
80 
81 
82  def setupInfo_VecDouble(self, flags):
83  self.m_Infos_VecDouble["TauConstituents_BinEdges_Eta"] = flags.Tau.PanTau.TauConstituents_BinEdges_Eta
84  self.m_Infos_VecDouble["TauConstituents_Selection_Neutral_EtaBinned_EtCut"] = flags.Tau.PanTau.TauConstituents_Selection_Neutral_EtaBinned_EtCut
85  self.m_Infos_VecDouble["CellBased_BinEdges_Eta"] = flags.Tau.PanTau.CellBased_BinEdges_Eta
86  self.m_Infos_VecDouble["CellBased_EtaBinned_Pi0MVACut_1prong"] = flags.Tau.PanTau.CellBased_EtaBinned_Pi0MVACut_1prong
87  self.m_Infos_VecDouble["CellBased_EtaBinned_Pi0MVACut_3prong"] = flags.Tau.PanTau.CellBased_EtaBinned_Pi0MVACut_3prong
88  self.m_Infos_VecDouble["ModeDiscriminator_BinEdges_Pt"] = flags.Tau.PanTau.ModeDiscriminator_BinEdges_Pt
89 
90 
91  def setupInfo_VecString(self, flags):
92  self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n"] = flags.Tau.PanTau.ModeDiscriminator_BDTVariableNames_CellBased_1p0n_vs_1p1n
93  self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn"] = flags.Tau.PanTau.ModeDiscriminator_BDTVariableNames_CellBased_1p1n_vs_1pXn
94  self.m_Infos_VecString["ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn"] = flags.Tau.PanTau.ModeDiscriminator_BDTVariableNames_CellBased_3p0n_vs_3pXn
95 
96 
97  def setupInfo_Features(self, flags):
98 
99  #get list of signal modes from config
100  List_ModeCases = flags.Tau.PanTau.Names_ModeCases
101 
102  #get the feature handler
103  from PanTauAlgs.Class_FeatureHandler import FeatureHandler
104  theFeatureHandler = FeatureHandler()
105 
106  #for each algorithm and mode, loop over variables to be used in BDT
107  # and fetch the type of the variable and the name
108  # these are needed for the PanTauFillerTool in TauD3PDMaker
109  for iModeCase in List_ModeCases:
110 
111  infoKey_Names = "ModeDiscriminator_BDTVariableNames_CellBased_" + iModeCase
112  curVarList = self.m_Infos_VecString[infoKey_Names]
113 
114  BDTVariable_TypeList = []
115  BDTVariable_DefaultValList = []
116 
117  for iVar in curVarList:
118  theType = theFeatureHandler.m_Feature_Types[iVar]
119  theDefVal = theFeatureHandler.m_Feature_Defaults[iVar]
120  BDTVariable_TypeList += [theType]
121  BDTVariable_DefaultValList += [theDefVal]
122  #end loop over variables
123 
124  infoKey_Types = "ModeDiscriminator_BDTVariableTypes_CellBased_" + iModeCase
125  self.m_Infos_VecString[infoKey_Types] = BDTVariable_TypeList
126 
127  infoKey_Defaults = "ModeDiscriminator_BDTVariableDefaults_CellBased_" + iModeCase
128  self.m_Infos_VecDouble[infoKey_Defaults] = BDTVariable_DefaultValList
129  #end loop over signal modes
130 
131  #add the prefixes for the variables
132  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Sum"] = theFeatureHandler.m_VarTypeName_Sum
133  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Ratio"] = theFeatureHandler.m_VarTypeName_Ratio
134  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Isolation"] = theFeatureHandler.m_VarTypeName_Isolation
135  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Num"] = theFeatureHandler.m_VarTypeName_Num
136  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Mean"] = theFeatureHandler.m_VarTypeName_Mean
137  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_StdDev"] = theFeatureHandler.m_VarTypeName_StdDev
138  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_HLV"] = theFeatureHandler.m_VarTypeName_HLV
139  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Angle"] = theFeatureHandler.m_VarTypeName_Angle
140  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_DeltaR"] = theFeatureHandler.m_VarTypeName_DeltaR
141  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_JetMoment"] = theFeatureHandler.m_VarTypeName_JetMoment
142  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Combined"] = theFeatureHandler.m_VarTypeName_Combined
143  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Basic"] = theFeatureHandler.m_VarTypeName_Basic
144  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_PID"] = theFeatureHandler.m_VarTypeName_PID
145  self.m_Infos_String["FeatureExtractor_VarTypeName_varTypeName_Shots"] = theFeatureHandler.m_VarTypeName_Shots
146  #end def setupInfo_Features
147 
148 #end class config_FeatureCalculator
python.Class_InformationHandler.InformationHandler.m_Infos_String
m_Infos_String
Definition: Class_InformationHandler.py:13
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
python.Class_InformationHandler.InformationHandler.setupInfo_VecString
def setupInfo_VecString(self, flags)
Definition: Class_InformationHandler.py:91
python.Class_InformationHandler.InformationHandler.__init__
def __init__(self, flags)
Definition: Class_InformationHandler.py:7
python.Class_InformationHandler.InformationHandler.setupInfo_Int
def setupInfo_Int(self, flags)
Definition: Class_InformationHandler.py:60
python.Class_InformationHandler.InformationHandler.setupInfo_Features
def setupInfo_Features(self, flags)
Definition: Class_InformationHandler.py:97
python.Class_InformationHandler.InformationHandler.dump
def dump(self)
Definition: Class_InformationHandler.py:29
python.Class_InformationHandler.InformationHandler.m_Infos_VecString
m_Infos_VecString
Definition: Class_InformationHandler.py:15
python.Class_InformationHandler.InformationHandler.m_Infos_Double
m_Infos_Double
Definition: Class_InformationHandler.py:12
python.Bindings.iterkeys
iterkeys
Definition: Control/AthenaPython/python/Bindings.py:813
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
python.Class_InformationHandler.InformationHandler
Definition: Class_InformationHandler.py:5
python.Class_InformationHandler.InformationHandler.setupInfo_Double
def setupInfo_Double(self, flags)
Definition: Class_InformationHandler.py:66
python.Class_InformationHandler.InformationHandler.setupInfo_VecDouble
def setupInfo_VecDouble(self, flags)
Definition: Class_InformationHandler.py:82
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.Class_InformationHandler.InformationHandler.m_Infos_VecDouble
m_Infos_VecDouble
Definition: Class_InformationHandler.py:14
str
Definition: BTagTrackIpAccessor.cxx:11
python.Class_InformationHandler.InformationHandler.m_Infos_Int
m_Infos_Int
Definition: Class_InformationHandler.py:11
python.Class_InformationHandler.InformationHandler.setupInfo_String
def setupInfo_String(self, flags)
Definition: Class_InformationHandler.py:78