Event Trees - cut on dependent branches

Hi,

since I’m relatively new to the area of a ‘bare’ ROOT analysis, there is one
thing which is in particular interest for me:
Applying cuts to the whole tree when applying it to one branch.

Let me show you an examples (I can’t understand things without).
I have an ‘event’ TTree with three branches:

  • electron_pt
  • muon_pt
  • number of jets

Now I want to get only events which have
muon_pt > 20 and electron_pt >30

I can select them individually:

newmuon_pt = muon_pt->Draw(0, "x>20");
newelectron_pt = electron_pt->Draw(0, "x>30");

But of course I want the electron branch to be reduced by the same events
I already discarded with the muon_pt cut.

I also would like to print the number of passed events and then plot
the number of jets of the remaining events.

Usually I would accomplish this task by looping over all events and
discarding event by event.

I just thought there might be a better, faster
more ROOT way of doing so.

You cannot do branch->Draw, only tree->Draw. In your case, the problem is simple
and the solution is

Long64_t npass = tree->Draw("number_of_jets","electron_pt>20 & muon_pt>30");
npass will contain the number of events passing your cuts.
the “htemp” histogram will contain the number of jets for all events passing the cuts

for more information, see the documentation of TTree::Draw

Rene

Thank you very much for for you answer.

So basically, if I have more than one branch to draw/analyze,
I have to perform the cut for each branch, right?

So what if I want to remove all events (containing lets say 100 variables) which do not pass my cuts before I start looping over them?

Is there a way to do so?

This way I would reduce the number of cycles & memory usage and speed up
the analysis as turning off unused branches does for now.

You have several possibilities for your Tree analysis:

1- make your own event loop. see example in $ROOTSYS/tutorials/tree/tree4.C
Look at the function tree4r of this example and its event loop.
You call branch->GetEntry for the branch(es) with which you can take quick decisions.
You read all branches for the events passing all conditions.

2- create a selector. see $ROOTSYS/tutorials/tree/h1analysis.C.
This is our recommended procedure because you can run a large analysis
with the parallel system PROOF later on.
Have a look at the member function Process to see a similar selection
mechanism as in 1.

3- create a TEntryList with all events passing your cuts, then in subsequent sessions
loop on the entry list. see examples in
$ROOTSYS/tutorials/tree/h1analysisproxy.C
$ROOTSYS/test/stressEntryList.cxx

Rene

I think there is something wrong with the cuts I use:

[code]TCut HLT = “HLT_Ele15_LW_L1R == 1”;
TCut ComrelIso = “((els_dr04EcalRecHitSumEt + els_dr04HcalTowerSumEt + els_tIso)/els_et) >0.1”;
//Long64_t nEvents = chain->GetEntries();
// This gives the same:
Long64_t nEvents = chain->Draw(“NbeamSpot”, “NbeamSpot >0”);
Long64_t npass1 = chain->Draw(“NbeamSpot”, HLT);
Long64_t npass2 = chain->Draw(“NbeamSpot”, ComrelIso && HLT);

cout << “Stage 1” << nEvents << endl;
cout << “Stage 2” << npass1 << endl;
cout << “Stage 3” << npass2 << endl;[/code]

which gives me:

Stage 1 7000 Stage 2 4449 Stage 3 7529

I guess for stage 3 it returns the number of electrons which passed the cut rather than the number of beam spots after the electron cut.

Is this expected behaviour?

I’m using ROOT 5.22.00d

Could you put a small file in a public space?

Rene

[quote=“brun”]Could you put a small file in a public space?

Rene[/quote]

Do you mean a small ROOT file which includes the data?

The only file I have here is 300MB.

Is there a way I only copy the relevant branches into a new file?

I saw examples in the forum, I will have a look in the afternoon.