vectors in selection cuts in TTrees

From: suvayu ali <fatkasuvayu_at_gmail.com>
Date: Thu, 30 Sep 2010 01:11:52 -0700


Hi ROOT users,

I am trying to skim an ntuple based on MC data. The MC branches I am using for my selection look like this,

Int_t                           mc_n;
vector<int>               *mc_pdgId;

vector<vector<int> > *mc_parent_index;

I want to make a selection equivalent to this,

  for(int i=0; i<mc_n;i++){
    if (abs(mc_pdgId[i])==13) {
      firstparentindex.push_back(mc_parent_index[i][0]);     }
}

  if (firstparentindex.size()>0){
    for(int i=0; i<mc_n;i++){

      if (i==firstparentindex[0] && abs(mc_pdgId[i])==24) {
        ismuondecay =  true;
      }

    }
}

I wanted to avoid fiddling with MakeClass() so I tried something like this,

TTree *newTree = physics->CopyTree("abs(mc_pdgId[]) == 13 && abs(mc_pdgId[ mc_parent_index[Iteration$][0] ])== 24");

But this gives me an empty TTree! If I remove the later cut asking for the parent, I do get a TTree which has W's in them. I test this by looking at the histogram drawn by double clicking on the mc_pdgId branch from a TBrowser.

root [1] TBrowser b
root [2] htemp->Print("all")
TH1.Print Name = htemp, Entries= 86496, Total sum= 86496  .....
 fSumw[3]=0, x=-24.5
 fSumw[4]=349, x=-23.5
 .....
 fSumw[52]=556, x=24.5
 fSumw[53]=0, x=25.5

What am I doing wrong? Thanks for any insights.

-- 
Suvayu

Open source is the future. It sets us free.
Received on Thu Sep 30 2010 - 10:12:17 CEST

This archive was generated by hypermail 2.2.0 : Thu Sep 30 2010 - 17:50:01 CEST