I have a simple code that load some previously saved cut files (absE1.C, absE2.C) and use these cuts on data. The problem is that the while the code is executing, the gates are not defined, but once its finished, I can bring up the gates via the terminal command fine.
Main code
int gate_sample(const int firstEvent=0, int lastEvent=10, string infileName="name"){
TCutG *absE1 = new TCutG();
TCutG *absE2 = new TCutG();
// load cut files
gROOT->ProcessLine(".L absE1.C");
gROOT->ProcessLine(".L absE2.C");
//gROOT->ProcessLine(".x absE1.C"); // .x or .L makes no differences
//gROOT->ProcessLine(".x absE2.C");
double X=10.0;
double Y=10.0;
for (int currentEvent=firstEvent; currentEvent<lastEvent; currentEvent++){
if(absE1->IsInside(X,Y)){
printf("inside Gate");
}
printf("%i \n",absE1->IsInside(10,10));
}
printf("\n");
return 1;
}
Is this the only way it is for ROOT6. I’m looking to write a script that will load lots of different prepared cut files, depending on different data files. So I would need to have the line [ gROOT->ProcessLine(".L cutg.C"); ] working right inside the script rather than having to manually typing it in before running the gate_sample.cxx script.
Not only that, now I have to manually edit all the gate macros to include [TCutG * xxxxxcut()] and [return absE1;]. It sounds like a step backward in term of reducing the programming efforts required to get to the data-analysis in ROOT 6
I’d recommend to put your cut definitions into header files, e.g. using static initialization, and to simply #include these files in your main macro. I.e.
(1) Since the gSystem->Load(". …") and gROOT->ProcessLine(" ") features are provided within ROOT, they should be accepted by ROOT as being proper right ?
(2) Also since all the cut macros are generated by ROOT, by default, they should also be proper C++ objects on their own without user intervention.
Now putting (1) and (2) together, all cuts should load and work proper in ROOT 6, just like they are in ROOT 5.