Hi,
I create a tree to which I add in loop histograms. I name them with name of file I read earlier and value read from array I have and it works perfectly when I use commented code. But when I try to use code signed below with stars I got errors. It’s even more confusing because using code with stars, loop over threshold for ind=0 always works properly, for ind=1 I have error:
Analysis of Const Threshold with threshold = -0.05
Analysis of Const Threshold with threshold = -0.06
*** Break *** segmentation violation
and for ind=2 I have another error:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)
Even more confusing is that this errors does not change no matter what is the initial value of ind. Furthermore for ind>2 occurs second type of errors from above but not for every value - rather for every second value.
My code looks like this:
//------ Create file to save data ---------------------------
TFile *file1 = new TFile("../root_files/ConstThresholdResults.root", "update");
Double_t dt1_2_1, dt3_4_1;
//------ Loop over all thresholds -----------------------------
for(Int_t ind=0; ind<threshold.size();ind++){
std::cout<<"Analysis of Const Threshold with threshold = "<<threshold[ind]<<std::endl;
//------ Remove tree to overwrite --------------------------
std::string treename1 = "delay_"+delays[ind]+".root_thr_"+std::to_string(threshold[ind]); //***
//std::string treename1 = strstr(argv[1],"delay");
//treename1 += "_thr_"+std::to_string(threshold[ind]);
std::string to_remove_name1 =treename1;
to_remove_name1+=";*";
Whole code to my source code you can find here:
Edit!!
Working solution
ROOT Version: 6.12
Platform: Linux Mint
Compiler: gcc