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
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
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