Problem with drawing in loop

Dear Rooters
I am calling a parameter function and then a Fit() in a for loop which access the parameters according to the loop variable "ptbin"from the parameter function. Few more functions are declared and are called in the loop and are drawn to extract the component peaks from the total Fit() . The problem is that the Fit() is fine for the first ptbin and as it passes to the second ptbin and extracts the components of the first , the first Fit() gets distorted and so on and so forth and hence gives only the last ptbin correct .
I will be obliged for any help
image.pdf (117 KB)
macro00.C (34.4 KB)

I think we need a bit more to help you:
Your macro gives:

root [0] .x macro00.C
Error in <TFile::TFile>: file /Users/inayat/RhoMacrosNoPID/AnalysisResultsRHODATA.root does not exist
Error: illegal pointer to class object _file0 0x0 6  macro00.C:348:
*** Interpreter error recovered ***
root [1]