TGraph conditions to use Y from Binary file

Hello,
I have to fit my data from one measurement…so I saved the results for the Y parameter in Binary file then I want to fit that data by TGrapgh …But I got the problem the function not match the TGrpah condtions:
This is the case what I have:

cout << "Hello to Binary data"<< endl;
        // TGraph *graph_Total1= NULL;
         TF1 *fit_Total          = NULL;
        // TCanvas*can_Total1= NULL;

         fstream TotalFile;
         TotalFile.open("/.../Total.bin",ios_base::in | ios_base::binary);
         if(!TotalFile.good()) cout << "Total.bin Problem" << endl;

        double totalP = 0.0;
         int Time=7000;
         for (int isec=0; isec<Time; isec++) {

         	TotalFile.read(reinterpret_cast<char*>(&totalP),sizeof(totalP));

         	totalP = 0.0;
         }

       
     //    unsigned long int total_totalPPairs;
     //    for(int i = 0; i < Time; i++){
     //    	totalP[i]= (double)total_totalPPairs[i];
     //
     //    }

         double *time_x1 = new double[Time];
          for(int i = 0; i < Time; i++){
        	  time_x1[i]= (double)i;
          }


         fit_Total = new TF1("fit_Total",this,&MyClass:TotalCorrP ,stop_time, start_time,3);

         fit_Total ->SetParameter(0,totalP);
         fit_Total ->SetParameter(1,0.000002);
         fit_Total ->SetParameter(2,1);
         fit_Total ->SetParName(0,"TotalP");
         fit_Total ->SetParName(1,"dt");
         fit_Total ->SetParName(2,"lub");

         fit_Total  ->SetLineColor(kBlue);
         fit_Total ->SetLineWidth(2);
         fit_Total->SetLineStyle(2);


      //   TGraph graph_expected("/localdata/Bineary_data/TotalPrompts.bin", "%lg %lg %lg");

        // TGraph* graph_Total1= new TGraph(".../TotalP.bin");

         //TGraph* graph_Total1= new TGraph(7000,time_x1,totalPrompts);
         graph_Total1->SetLineColor(kPink);
         graph_Total1->Fit(fit_TotalP);

         TCanvas* can_Total1 = new TCanvas("fit_TotalPe","fit_TotalP");
         can_Total1->SetGrid();
         can_Total1->BuildLegend();
         graph_Total1->GetXaxis()->SetTitle("Time");
         graph_Total1->GetYaxis()->SetTitle("TotalPrompts");
         graph_Total1->Draw("AL");
         can_Total1->Update();



         TotalPFile.close();

Please note I working on the class

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

The code you posted cannot be run. Can you post something we can run ?