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

Functions

 ReadInSituHistograms (dirName)

Variables

dict SystematicNameDictionary
dict jetDefDict

Function Documentation

◆ ReadInSituHistograms()

ParseInsituInput.ReadInSituHistograms ( dirName)

Definition at line 82 of file Final2012/ParseInsituInput.py.

82def ReadInSituHistograms(dirName):
83 if not dirName.endswith("/"):
84 dirName = dirName + "/"
85
86 # Run over each subdirectory (one per jet definition)
87 histos = {}
88 subDirs = sorted(glob.glob(dirName+"*"))
89 for aSubDirName in subDirs:
90 # Determine the jet definition
91 jetDef = ""
92 for aDirDef,aJetDef in jetDefDict.iteritems():
93 if aDirDef in aSubDirName:
94 jetDef = aJetDef
95 break
96 if jetDef == "":
97 print "Failed to determine jet definition for directory:",aSubDirName
98 return None
99 histos[jetDef] = {}
100
101 # Loop over the systematic files in the subdirectory
102 systFiles = sorted(glob.glob(aSubDirName+"/SystError_*.txt"))
103 for aSystFile in systFiles:
104 # Figure out which component this is
105 systematicNameHandle = re.sub(aSubDirName+"/SystError_","",aSystFile)
106 systematicNameHandle = re.sub(".txt","",systematicNameHandle)
107 systematicName = SystematicNameDictionary[systematicNameHandle]
108 #print "Making histogram %s --> %s"%(systematicNameHandle,systematicName)
109
110 # Open the file
111 systematicFile = open(aSystFile,"r")
112
113 # Read the lines of the file into arrays
114 lowBinEdges = []
115 systValues = []
116 for line in systematicFile.readlines():
117 line = line.strip("\r\n")
118 lowEdge = float(line.split()[0])
119 systVal = float(line.split()[2].strip())
120
121 lowBinEdges.append(lowEdge)
122 systValues.append(systVal)
123
124 # Done reading, close the file
125 systematicFile.close()
126
127 # Make the last bin go up to 2500
128 lowBinEdges.append(2500.)
129 systValues.append(systValues[-1])
130
131 # Turn the lists into arrays and build the 1D histogram
132 lowBinEdgesArray = array('d',lowBinEdges)
133 systValuesArray = array('d',systValues)
134 histoName = systematicName+"_"+jetDef
135 histo1D = TH1D(histoName+"_1D",histoName+"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
136
137 # Fill it from the file values
138 for iBin in xrange(1,histo1D.GetNbinsX()+1):
139 histo1D.SetBinContent(iBin,systValues[iBin-1])
140
141 # Convert to a 2D provider-stlye histo
143 histo.SetDirectory(0)
144 histos[jetDef][systematicName] = histo
145
146 # EM has 10 stat parameters, LC has 11
147 # So for EM algorithms, make an empty histo for stat 11
148 if "EM" in jetDef:
149 systematicName = SystematicNameDictionary['mjbstat11']
150 histos[jetDef][systematicName] = ProviderHistoHelpers.MakeProviderHisto(systematicName+"_"+jetDef)
151 histos[jetDef][systematicName].SetDirectory(0)
152
153
154 # Done, return dictionary of histos
155 return histos
156
157
158
159
STL class.
void xrange(TH1 *h, bool symmetric)
MakeProviderHisto(histoName, ptBins=GetDefaultPtBins(), etaBins=GetDefaultEtaBins())
ConvertPtHistoToProviderHisto(histo1D, histoName)

Variable Documentation

◆ jetDefDict

dict ParseInsituInput.jetDefDict
Initial value:
1= {
2 'EMJES_R4' : 'AntiKt4Topo_EMJES',
3 'EMJES_R6' : 'AntiKt6Topo_EMJES',
4 'LCJES_R4' : 'AntiKt4Topo_LCJES',
5 'LCJES_R6' : 'AntiKt6Topo_LCJES'
6 }

Definition at line 75 of file Final2012/ParseInsituInput.py.

◆ SystematicNameDictionary

dict ParseInsituInput.SystematicNameDictionary

Definition at line 11 of file Final2012/ParseInsituInput.py.