Process data with saved cuts as cut.C


How to process data with saved cuts of a particular 2D plot, so that only those selected events will come up in all other plots in the tree structure of the same root file!

May be, I should use TChain::MakeClass()…but I do not know how to do it. Any help!


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Hi Sandy,
Are these cuts of type TCutG?

@Axel. I think you mean TCutG

Absolutely :slight_smile: Thanks, Olivier! I edited my question.

Yes, @Axel those are TCutG

To use the a graphical cut in TTree::Draw you only need to do:


But that will not work if your cut has been defined on a histogram. You will have first to reassigned proper names to the cut variables. ie: name of variables members of the tree t. For that simply do:

  1. If I do it that way, it is saying that “cutg was not declared in this scope”

  2. I think, using this I can only generate that “x:y 2D” plot with that “cutg”, not that only those many events would be processed in the next compilation to other 1D and 2D plots.

I was assuming you have the TCutG object ready ? don’t you ?

I have put a cut in the canvas…and saved it with a name. not inside the program with TCutG.

How ? can you post the file in which the cut is saved ?

@couet here it is…

xy.C (491 Bytes)

This macro defines your cut. You need to change it to define the proper TTree variables on which it applies

Now you have:

   cutg->SetVarX("X1 vs Y1");

change it to something like:


where x an y are your TTree variables.

But, that will only gate xy 2D, right?
I want to propagate this selection to all other plots. How do I do that then?

You need to specify on which variables the cut apply. That’s what SetVarX/Y is doing.

I shall change in the cut.C macro:


but in the program, how do I call that saved “cut.C”!! Otherwise it will give again error like “cutg was not declared in this scope”!

I do not know what is exactly “the program” … But basically you need to include the code you have in xy.C in it.

That is working, fine.

But, what I meant in the title, is:

I have a code (“the program”) which processes raw data and creates a .root file having several tree leafs and 2Ds. One of them is xy 2D. On this xy 2D I have put a gate and saved as cut.C.

If I put cutg in the way you suggested, it only put a cut on xy 2D, but does not do anything to other plots. That’s what I don’t want.
I want to see the effect of the applied gate on xy 2D on other 2Ds (e.g. P1 vs P2, Z1 vs Z2 etc.) as well, which are obviously dependent on x and y values.

A TCutG applies on the variables defined by SetVarX/Y you can do:

Tree->Draw("P1:P2", "[cutg]");

It will draw P1vsP2 for all the events passing [cutg] where cutg will be apply on the x and y variable in Tree.

okkk…just putting cutg condition is doing the job. Great! thanks!

Though it is doing the job, I have a further query…is it not possible to call cut.C inside the macro and do such gating instead of copying the content of it inside the macro!

As in this process every time one has to change inside the main program.