Save multiple plots with variable filenames

Dear experts,

I have done a simultaneous fit and for changing the parameters, I am trying to pick many text files and save each of the plot corresponding to each .txt file. But, only the plot that occurs last in the code is saved while the others are not saved. Will you please have a look ?

Here’s my working directory.:
best_sim_fit.tar.gz (2.5 MB)

In your code you have long path names which does not exist except on your machine. Can you produce a macro which can be run anywhere ?

You have

  TString kk_d01, kk_d0bar1, d0pi_d01, d0pi_d0bar1;
  char *ext1=".pdf";

  TString output_kk_d0 = kk_d01 + outputpath + fname + ext1 ;
  TString output_kk_d0bar = kk_d0bar1+outputpath + fname + ext1;
  TString output_d0pi_d0 = d0pi_d01 + outputpath + fname + ext1;
  TString output_d0pi_d0bar = d0pi_d0bar1+outputpath + fname +ext1;

If the “output…” TStrings are supposed to point to different folders, this doesn’t work, as all the TStrings in the first line (kk_d01,…) are empty, so all “output…” TStrings are the same.
(also, make sure outputpath and fname have values at this point!)

Dear @couet and @dastudillo ,

Thank you for your responses. I have managed to solve all the problems with the code and I have added almost all the functionalities except one. Here’'s the macro that I am using:
asymmetry_all_params.C (40.6 KB)

Is there a way to put the condition so as to save the plots only if the fit converges ?
Also, is there a way to submit jobs in parallel for the multiple .txt files that I use.

Regards,
Sanjeeda

FitTo returns a RooFitResult, which has a status() method, returning an integer, and if this is zero the fit was ok. So you can do something like

  RooFitResult *res = simPdf.fitTo(combData,Strategy(2));
 if (res->status() == 0) cout << "Fit ok!" << endl;

I don’t know where you are submitting the jobs, so the how depends on the job queuing system, but if the txt files are used independently of each other in the macro, the simplest is to use and process only one of these files in the macro, and run the macro as many times as needed, once for each txt file (maybe giving the file name as argument to the macro), sending each run as separate job.

Thanks a lot @dastudillo.
For the fitresult, what you are suggesting actually works. However, I think, there is still a problem with this. which I try to explain below:

For a good fit, what I check is FROM MIGRAD STATUS=CONVERGED , ERR MATRIX ACCURATE and ERROR MATRIX ACCURATE. So, what I want is to check all the 4 conditions. While the above condition checks only if MIGRAD STATUS=CONVERGED and allows to pass even if ERR MATRIX is not ACCURATE (eg: if ERR MATRIX NOT POS-DEF ).

Is this expected? Can I check All the 4 conditions ?

Regards,
Sanjeeda

Dear @dastudillo,

I have checked that the covQual option in RooFitResult allows us to check the covariance quality. Using this, I can check the status and the error matrix from HESSE and as you have already pointed out, status allows us to check the status fro MIGRAD.

Is there a way to put a constraint so that the results are saved only of the Error Marrix corresponding to MIGRAD should be accurate?

Thanks for your help!

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