164 def scaleGraph(graphToScale, scalingInputGraph, oneMinus = False) :
167 nPointsGraphToScale= graphToScale.GetN()
168 nPointsScalingInputGraph = scalingInputGraph.GetN()
170 if nPointsGraphToScale!=nPointsScalingInputGraph :
171 print "ERROR in JESUncertainty_RatioUtils::scaleGraph: graphs don't have the same number of points"
175 scaledGraph = graphToScale.Clone()
176 scaledGraph.SetName(graphToScale.GetName()+
"_Scaled")
179 for iPoint
in xrange(0,nPointsGraphToScale) :
183 maxPointError = Double(0)
186 dataPointXgraphToScale = Double(0)
187 dataPointYgraphToScale = Double(0)
188 errorXgraphToScale= graphToScale.GetErrorX(iPoint)
189 errorYgraphToScale = graphToScale.GetErrorY(iPoint)
190 graphToScale.GetPoint(iPoint,dataPointXgraphToScale,dataPointYgraphToScale)
192 dataPointXscalingInputGraph = Double(0)
193 dataPointYscalingInputGraph = Double(0)
194 errorXscalingInputGraph = scalingInputGraph.GetErrorX(iPoint)
195 errorYscalingInputGraph = scalingInputGraph.GetErrorY(iPoint)
196 scalingInputGraph.GetPoint(iPoint,dataPointXscalingInputGraph,dataPointYscalingInputGraph)
198 if abs(dataPointXgraphToScale-dataPointXscalingInputGraph) > 0.0001:
199 print "ERROR in JESUncertainty_RatioUtils::scaleGraph: x coordinates of data points do not match"
203 if abs(dataPointYscalingInputGraph) < 0:
204 print "WARNING in JESUncertainty_RatioUtils::scaleGraph: negative scale factor for point: ", iPoint,
", X:", dataPointXgraphToScale
205 scaledGraph.SetPoint(iPoint, dataPointXgraphToScale, dataPointYscalingInputGraph*dataPointYgraphToScale)
206 scaledGraph.SetPointError(iPoint, errorXgraphToScale, abs(dataPointYscalingInputGraph)*dataPointYgraphToScale)
209 scaledGraph.SetPoint(iPoint, dataPointXgraphToScale, (1-dataPointYscalingInputGraph)*dataPointYgraphToScale)
210 scaledGraph.SetPointError(iPoint, errorXgraphToScale, abs(dataPointYscalingInputGraph)*dataPointYgraphToScale)