TString problems

Hello all,

I’m having a problem with a part of my code that involves TStrings in an array. It only occurs when running the code a second or more times in the same instance of ROOT.

Here’s the problem code:

TString prop[5]={"jet.Et","jet.Eta","jet.Phi","summary.fnTightJet","summary.fnLooseJet"};
TString xmin[5]={"-20.","-4.0","-1.0","0.0","-1.0"};
TString xmax[5]={"200.0","4.0","7.0","10.0","7.0"};

It ends up throwing:

*** Break *** Segmentation Violation

To fix it I tried using delete at the end of the macro to to hopefully clear the variable all together but it didn’t work either. I wrote the delete code as follows:

delete [] prop;
delete [] xmin;
delete [] xmax;

If you could provide any help, I would greatly appreciate it.

Cheers,
Bryan

[quote]To fix it I tried using delete at the end of the macro to to hopefully clear the variable all together but it didn’t work either. I wrote the delete code as follows: [/quote]That would lead to a double deletion.
Here’s the problem code:TString prop[5]={"jet.Et","jet.Eta","jet.Phi","summary.fnTightJet","summary.fnLooseJet"};
Array of objects, especially there lifetime, is a current weakness in CINT.
In order to work around the problem you should call

gROOT->Reset()before re-executing your code (note that this should not be called from within a function).

Cheers,
Philippe

Thanks for your reply. After typing gRoot->Reset() in ROOT, I got the following error:

Error: Symbol gRoot is not defined in current scope FILE:(tmpfile) LINE:1
Error: Failed to evaluate gRoot->Reset()Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***

I’m not quite sure what that means either.

I also tried putting the line into my macro, but I got the same error.

I meant gROOT->Reset() in my previous post…

[quote]Error: Symbol gRoot is not defined in current scope FILE:(tmpfile) LINE:1[/quote]says that you mistype gROOT. It should work with the correct casing.

Cheers,
Philippe

Thank you so much, it works perfectly now.

Cheers,
Bryan