Dear experts
When I try to SetHighLightConnect()
to another function I got segfault, please give me some suggestions, thank you in advance! (slot function for the connection is empty)
std::map<int, TH1D*> map_driftTime;
TCanvas* c_pos;
TGraph* g_pos;
void DocaHighlighted(TVirtualPad* pad, TObject* obj, Int_t ihp, Int_t y){}
void checkDriftTime(std::string fileName){
TCanvas* c_doca = new TCanvas();
c_doca->SetTitle("Doca distribution");
c_doca->HighlightConnect("DocaHighlighted(TVirtualPad* pad, TObject* obj, Int_t ihp, Int_t y)");
TH1D* h_doca = new TH1D("h_doca", "doca distribution", 75, 0., 1.5);
TGraph* g_doca = new TGraph();
g_pos = new TGraph();
std::vector<double>* x0 = nullptr;
std::vector<double>* y0 = nullptr;
std::vector<double>* t1 = nullptr;
TFile* f = new TFile(fileName.c_str(), "READ");
if(!f){
std::cerr<<"Can not find input file"<<std::endl;
exit(1);
}
TTree* t = (TTree*)f->Get("t");
t->SetBranchAddress("x0", &x0);
t->SetBranchAddress("y0", &y0);
t->SetBranchAddress("t1", &t1);
for(int iEvent = 0; iEvent < t->GetEntries(); ++iEvent){
t->GetEntry(iEvent);
if(x0->size() > 0){
double x = x0->at(0);
double y = y0->at(0);
TH1D* h = new TH1D(Form("h_%.2f_%.2f", x, y), Form("drift time distribution at (%.2f, %.2f)", x, y), 3000, 0, 3000);
for(auto itr = t1->begin(); itr != t1->end(); ++itr){
h_doca->Fill(sqrt(x*x + y*y));
h->Fill(*itr);
}
g_pos->SetPoint(iEvent, x, y);
map_driftTime[iEvent] = h;
}
}
for(int iBin = 1; iBin < h_doca->GetNbinsX(); ++iBin){
g_doca->AddPoint(h_doca->GetBinCenter(iBin), h_doca->GetBinContent(iBin));
}
g_doca->SetHighlight();
g_doca->SetMarkerStyle(29);
g_doca->SetMarkerColor(2);
g_doca->Draw("AP");
}
error message:
*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TQConnection::SetArg(long const*, int) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGpad.so] void TQObject::EmitVA<long [4]>(char const*, int, long const (&) [4]) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGpad.so] TCanvas::Highlighted(TVirtualPad*, TObject*, int, int) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libHistPainter.so] TGraphPainter::HighlightPoint(TGraph*, int, int) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libHistPainter.so] TGraphPainter::DistancetoPrimitiveHelper(TGraph*, int, int) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGpad.so] TPad::Pick(int, int, TObjLink*&) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGpad.so] TCanvas::Pick(int, int, TObject*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGpad.so] TCanvas::HandleInput(EEventType, int, int) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGui.so] TRootContainer::HandleMotion(Event_t*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGui.so] TGFrame::HandleEvent(Event_t*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGui.so] TGClient::HandleEvent(Event_t*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGui.so] TGClient::ProcessOneEvent() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libGui.so] TGInputHandler::Notify() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TSystem::InnerLoop() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TSystem::Run() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TApplication::Run(bool) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libRint.so] TRint::Run(bool) (no debug info)
[/Users/siyuan/Physics/root/install/bin/root.exe] main (no debug info)
[/usr/lib/dyld] start (no debug info)
Root > .q
*** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TList::FindObject(TObject const*) const (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] THashTable::FindObject(TObject const*) const (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] THashList::RecursiveRemove(TObject*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TROOT::RecursiveRemove(TObject*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TNamed::~TNamed() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libHist.so] TH1D::~TH1D() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] THashList::Delete(char const*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TROOT::EndOfProcessCleanups() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TUnixSystem::Exit(int, bool) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TApplication::Terminate(int) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TApplication::ProcessLine(char const*, bool, int*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libRint.so] TRint::HandleTermInput() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TUnixSystem::CheckDescriptors() (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TMacOSXSystem::DispatchOneEvent(bool) (no debug info)
[/Users/siyuan/Physics/root/install/lib/libCore.so] TSystem::InnerLoop() (no debug info)