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

Functions

 GetKeyNames (self, dir="")
 ReadEtaIntercalibrationDetailedStats (filename, dictionary)
 ReadEtaIntercalibrationHistograms (dirName, year="")

Variables

 GetKeyNames
dict SystematicNames_timeinvariant
dict SystematicNames_timedependent
dict jetDefDict

Function Documentation

◆ GetKeyNames()

ParseEtaIntercalInput_detailed.GetKeyNames ( self,
dir = "" )

Definition at line 8 of file ParseEtaIntercalInput_detailed.py.

8def GetKeyNames(self,dir=""):
9 self.cd(dir)
10 return [key.GetName() for key in gDirectory.GetListOfKeys()]

◆ ReadEtaIntercalibrationDetailedStats()

ParseEtaIntercalInput_detailed.ReadEtaIntercalibrationDetailedStats ( filename,
dictionary )

Definition at line 28 of file ParseEtaIntercalInput_detailed.py.

28def ReadEtaIntercalibrationDetailedStats(filename, dictionary) :
29 # Inside detailed stats files, individual components are inside of a directory.
30 # Make a special name for each and add it to the output dictionary
31
32 openFile = TFile.Open(filename,"READ")
33 dirName = "StatNuisanceParams"
34 stat_keys = openFile.GetKeyNames(dirName)
35
36 jet_def = ""
37 for thing in jetDefDict.keys() :
38 if thing in filename :
39 jet_def = thing
40
41 for key in stat_keys :
42 hist = openFile.Get(dirName+"/"+key)
43 hist.SetDirectory(0)
44
45 save_name = "EtaIntercalibration_"+key
46 hist.SetName(save_name+"_"+jet_def)
47 hist.SetTitle(save_name+"_"+jet_def)
48
49 dictionary[jetDefDict[jet_def]][save_name] = hist
50
51 return dictionary
52

◆ ReadEtaIntercalibrationHistograms()

ParseEtaIntercalInput_detailed.ReadEtaIntercalibrationHistograms ( dirName,
year = "" )

Definition at line 53 of file ParseEtaIntercalInput_detailed.py.

53def ReadEtaIntercalibrationHistograms(dirName,year=""):
54 if not dirName.endswith("/"):
55 dirName = dirName + "/"
56
57 # Run over each file (one per jet definition)
58 # Collect files and figure out what they are, matching year token specified in run
59 histos = {}
60 files = sorted(glob.glob(dirName+"*{0}*.root".format(year)))
61 for aFileName in files:
62 # Determine the jet definition
63 jetDef = ""
64 for aFileDef,aJetDef in jetDefDict.iteritems():
65 if aFileDef in aFileName:
66 jetDef = aJetDef
67 break
68 if jetDef == "":
69 print "Failed to determine jet definition for file:",aFileName
70 return None
71 if jetDef not in histos.keys() :
72 histos[jetDef] = {}
73
74 # Read in the histograms of interest from the file
75 inFile = TFile(aFileName,"READ")
76 contents = inFile.GetKeyNames()
77
78 if year :
79 SystematicNames = SystematicNames_timedependent
80 else :
81 SystematicNames = SystematicNames_timeinvariant
82
83 for aName in SystematicNames.keys():
84 if not "NonClosure" in SystematicNames[aName] :
85 if "Topo" in jetDef :
86 getsystematicName = aName + "_" + jetDef.replace("Topo","")
87 else :
88 getsystematicName = aName + "_" + jetDef.replace("4PFlow","4EMPFlow").replace("_EMJES","_PFlowJES")
89 else :
90 getsystematicName = aName
91
92 if not getsystematicName in contents :
93 continue
94
95 histo = inFile.Get(getsystematicName)
96
97 systematicName = SystematicNames[aName] + "_" + jetDef
98 histo.SetName(systematicName+"_old")
99
100 # Histo has different range, extend it
101 histoNew = ProviderHistoHelpers.ExtendPtRangeOfHisto(histo,systematicName)
102 histoNew.SetDirectory(0)
103 histos[jetDef][SystematicNames[aName]] = histoNew
104
105 # Done reading, close the file
106 inFile.Close()
107
108 # Since histos came from a whole mix of files, make sure we got them all in the end.
109 for aName,storeName in SystematicNames.iteritems():
110 for aJetDef in histos.keys():
111 if not storeName in histos[aJetDef].keys() :
112 print "Failed to find histogram:", storeName,"for jet definition",aJetDef
113
114 # Now, if this is year dependent, add stat histograms
115 if year :
116 for thisDef in jetDefDict.keys() :
117 files = sorted(glob.glob(dirName+"*{0}*_statErr_*{1}*.root".format(year,thisDef)))
118 if len(files) != 1 :
119 print "Did not find right number of stat term files!"
120 print files
121 exit(1)
122 filename = files[0]
123 print histos
124 histos = ReadEtaIntercalibrationDetailedStats(filename, histos)
125 print histos
126
127 print "Histos out here"
128 print histos
129 print "\n"
130 return histos
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

Variable Documentation

◆ GetKeyNames

ParseEtaIntercalInput_detailed.GetKeyNames

Definition at line 11 of file ParseEtaIntercalInput_detailed.py.

◆ jetDefDict

dict ParseEtaIntercalInput_detailed.jetDefDict
Initial value:
1= {
2 'AntiKt4EMTopo' : 'AntiKt4Topo_EMJES',
3 'AntiKt4EMPFlow' : 'AntiKt4PFlow_EMJES',
4 }

Definition at line 23 of file ParseEtaIntercalInput_detailed.py.

◆ SystematicNames_timedependent

dict ParseEtaIntercalInput_detailed.SystematicNames_timedependent
Initial value:
1= {
2 'E_4TeV' : 'EtaIntercalibration_NonClosure_highE',\
3 'Eta_2p4_to_2p6' : 'EtaIntercalibration_NonClosure_posEta',\
4 'Eta_m2p6_to_m2p4' : 'EtaIntercalibration_NonClosure_negEta'
5 }

Definition at line 17 of file ParseEtaIntercalInput_detailed.py.

◆ SystematicNames_timeinvariant

dict ParseEtaIntercalInput_detailed.SystematicNames_timeinvariant
Initial value:
1= {
2 'EtaIntercalibration_TotalSyst' : 'EtaIntercalibration_TotalSyst',\
3}

Definition at line 13 of file ParseEtaIntercalInput_detailed.py.