How to ask a macro to wait until a cut is saved?


Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.24.06
_Platform: macOS Monterey 12.4
_Compiler: Apple clang version 13.1.6


Hi,

I am trying to write a macro that first makes a plot and then asks the user to make a cut on the said plot in order to make a second plot. What I am having trouble with is asking for the macro to wait for the cutting part. Here is what I have so far:

    TCanvas* c1 = new TCanvas("c1", "Histogram", 200, 10, 700, 900);
    c1->ToggleToolBar();

    TPad* pad1 = new TPad("pad1", "Pad1", 0.03, 0.55, 0.50, 0.98, 41);
    TPad* pad2 = new TPad("pad2", "The pad with the histogram", 0.51, 0.55, 0.98, 0.98, 41);

    pad1->Draw();
    pad2->Draw();

    pad1->cd();
    tree->Draw("a:b>>ab(100,0,1000,512,0,4096)","","colz");
    pad1->Update();

    std::string tmp;
    std::cout << "Done? ";
    std::cin >> tmp;

    TCutG* Cutab = (TCutG*)gROOT->GetListOfSpecials()->FindObject("CUTG");
    CutEdE->SetName("abcut");
    CutEdE->Write();

    pad2->cd();
    tree->Draw("a:c>>ac(600,-300,300,512,0,4096","abcut","colz");
    pad2->Update();

I have tried to use std::cin as a way for the macro to wait until some input is entered. However, with this, the canvas does not show up until an input for cin is entered, which defeats the purpose. So, what is the proper way to ask the macro to wait until a cut is made?

ROOT Forum → Search → non-blocking

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.