*** Break *** segmentation violation Generating stack trace

ROOT Version: 6.26.10
Platform: linux via ubuntu

Hi to everyone
I try to run this code but when i run it,This error is displayed:

How can I solve this?

At least: std::vector<...> *mmOnTrackNStrips = 0;

I tried but it didn’t change:

Attach the output of: tree->Print();

After the “tree->GetEntry(i);” line, add:
if (!(mmOnTrackNStrips && mmOnTrackNStrips->size() > 0)) continue; // just a precaution

This continues until here:

You need to check the “mmOnTrackNStrips” branch.

What should I check?

Find the line which contains “*Br ... : mmOnTrackNStrips : ... *

I mean find it in the output of “tree->Print();”.

Looks good.

With my “precaution”, do you still get a segmentation violation?

BTW. The “SetBranchStatus” usually uses 0 / 1, not false / true (but it probably doesn’t matter).

No,it stopped

but my hist can’t be filled

I am sorry.My wrong.It is filled.But why the entries is smaller than 43840?

I guess the “size” is 0 for some entries.

How can i change that?Because i want all entries

You need to ask the one who created this tree about what it contains.

Actually, if you look at the output of the “tree->Print();”, you can see that it has 43840 entries, so you do get all of them.

Maybe you want:

if (!mmOnTrackNStrips) continue; // just a precaution
for (unsigned j = 0; j < mmOnTrackNStrips->size(); j++) hist->Fill(mmOnTrackNStrips->at(j));

BTW. In the end of you routine, you should at least: tree->ResetBranchAddresses(); // disconnect from local variables

Now it show me again segmentation violation

Attach your source code for inspection.

hits_function_thita.C (1.4 KB)