How to pass argument in Process function in TChain?

Dear ROOT Users

I am analysis the data files generated by the simulation and facing problem in passing the argument to the Process function of class corssanal, generated by MakeSelector. I have 10 root files each one having Tree of name “T” and each Tree carries 99 detector information. Now I have the analysis code generated by makeselector, through which I am analysis the data. I have to extract the results from each of the file at various detector threshold values . For instance, 0.5 to 2 MeV with a step of 0.5. Now, so there would be 40 such cases for 10 root files. I want to run these files in a loop with the threshold as a external argument, so first I want to loop over files and then over threshold. My question is how can I pass the threshold value in the Process function.{ TChain ch("T"); ch.Add("/home/dsiwal/simresults/withcrystal/NANDARRAY_1MeV.root"); ch.Process("crossanal.C+g");//6000000,0); }

I want to pass the threshold value in the above code and use that value inside the crossanal class which should get activated when Process function is called and I want to do it for the multiple times. Please help me out…

Kindly give me some idea to solve this issue.

I am not sure that’s the best academic solution (I will ask our expert to look at it) but The following seems to work.

  1. I made a class a.C with:
root [0] ntuple->MakeSelector("a")
  1. In a.h I added:
#include <TSelector.h>

static Int_t threshold; /// <<<<<<

and

   virtual void    Terminate();

   void SetThreshold(Int_t s){threshold=s;} /// <<<<<<
  1. in a.C I put a print in Process to check the value of threshold.
   // The return value is currently not used.

   printf("%d\n",threshold); /// <<<<<<
  1. then I do:
root [0] .L a.C
root [1] a sa;
root [2] sa.SetThreshold(2);
root [3] ntuple->Process("a");
2
2
2
....

As I said there is surely a better way …

From our expert:

Here is the non static way.

root [0] .L a.C
root [1] a sa;
root [2] sa.SetT(1)
root [3] ntuple->Process(&sa);

a.h (3 KB)
a.C (3.09 KB)

Thank you so much experts, I agree from both of you, thanks to add in my knowledge…