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

Functions

 ReadInSituHistograms (dirName)

Variables

dict SystematicNameDictionary
dict jetDefDict

Function Documentation

◆ ReadInSituHistograms()

ParseInsituInput_MJB.ReadInSituHistograms ( dirName)

Definition at line 71 of file ICHEP2016/ParseInsituInput_MJB.py.

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

Variable Documentation

◆ jetDefDict

dict ParseInsituInput_MJB.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 64 of file ICHEP2016/ParseInsituInput_MJB.py.

◆ SystematicNameDictionary

dict ParseInsituInput_MJB.SystematicNameDictionary

Definition at line 11 of file ICHEP2016/ParseInsituInput_MJB.py.