Seems all of a sudden I can’t plot more than one canvas when they are constructed at the start of the script. Old scripts don’t work either. System is MacOS 10.14.6, Xcode 10.0, root 6.18.04 (and installed 6.22.06 - same result).
Here is the code:
void plot_clusters_on_midstream_plates()
{
int events;
std::vector<int> *clusters_on_midstream_plates;
TCanvas *c1 = new TCanvas("c1", "c1", 5, 26, 1200, 815);
TCanvas *c2 = new TCanvas("c2", "c2", 5, 26, 1200, 815);
TH1F* h101 = new TH1F("plate_4", "plate_4", 20, 0, 20);
// ...
TH1F* h201 = new TH1F("cl_pl", "cl_pl", 10, 0, 10);
TFile* in_file = new TFile("../output.root", "READ");
//TTree* in_tree = new TTree();
//in_tree = (TTree*) in_file->Get("ssd_tracks");
TTree* in_tree = (TTree*) in_file->Get("ssd_tracks");
in_tree->SetBranchAddress("clusters_on_midstream_plates", &clusters_on_midstream_plates);
events = in_tree->GetEntries();
cout << in_tree->GetEntries() << endl;
for (int i = 0; i < events; i++)
{
in_tree->GetEntry(i);
if (clusters_on_midstream_plates->size() == 5)
{
h101->Fill(clusters_on_midstream_plates->at(0));
// ...
h201->AddBinContent(4, clusters_on_midstream_plates->at(0));
// ...
}
else
{
cout << "Wrong number of plates in event..." << endl;
}
}
c1->cd();
h101->Draw();
h102->Draw("sames");
// ...
c2->cd();
h201->Draw();
}
The error is (in 6.22.06):
*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[<unknown binary>] (no debug info)
[/Applications/root_v6.22.06/lib/libRIO.so] TBufferFile::ApplySequence(TStreamerInfoActions::TActionSequence const&, void*) (no debug info)
[/Applications/root_v6.22.06/lib/libTree.6.22.06.so] TBranchElement::ReadLeavesMember(TBuffer&) (no debug info)
[/Applications/root_v6.22.06/lib/libTree.6.22.06.so] TBranch::GetEntry(long long, int) (no debug info)
[/Applications/root_v6.22.06/lib/libTree.6.22.06.so] TBranchElement::GetEntry(long long, int) (no debug info)
[/Applications/root_v6.22.06/lib/libTree.6.22.06.so] TTree::GetEntry(long long, int) (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)
[/Applications/root_v6.22.06/lib/libCling.so] TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) (no debug info)
[/Applications/root_v6.22.06/lib/libCore.6.22.so] TApplication::ExecuteFile(char const*, int*, bool) (no debug info)
[/Applications/root_v6.22.06/lib/libRint.6.22.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/Applications/root_v6.22.06/lib/libRint.6.22.so] TRint::HandleTermInput() (no debug info)
[/Applications/root_v6.22.06/lib/libCore.6.22.so] TUnixSystem::CheckDescriptors() (no debug info)
[/Applications/root_v6.22.06/lib/libCore.6.22.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)
[/Applications/root_v6.22.06/lib/libCore.6.22.so] TSystem::InnerLoop() (no debug info)
[/Applications/root_v6.22.06/lib/libCore.6.22.so] TSystem::Run() (no debug info)
[/Applications/root_v6.22.06/lib/libCore.6.22.so] TApplication::Run(bool) (no debug info)
[/Applications/root_v6.22.06/lib/libRint.6.22.so] TRint::Run(bool) (no debug info)
[/Applications/root_v6.22.06/bin/root.exe] main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
When I move the construction of c2 right before c2->cd() it works. Either canvas works separately if I comment the other one.