Doing a cut before filling a tree

From: Michelle Mesquita Medeiros <michelle_mmed_at_yahoo.com.br>
Date: Sun, 5 Jun 2011 19:25:55 -0700


Hello ROOTers,

I have a code that defines new variables based on an original variable contained in a tree. I want to fill this tree only if the entries pass a cut made on one of these new variables:

   for(Long64_t i = 0; i < tree->GetEntries(); ++i) 
   {

      tree->GetEntry(i);
      for(int sh = 0; sh < nshower; ++sh) {
    tgalpha[sh] = (1*55251.1*(pow(30.0,2)/2)*0.000001)/(shower->Energy);
    alphar[sh] = atan(tgalpha[sh]);
    alpha[sh] = (alphar[sh] * 180)/3.1415927;

      if (alpha[sh] > 0.15) newtree->Fill();
    }
   }

But this only works for the variable in which I am doing the cut: alpha (I'm using the Draw function to check this). That means that I get alpha > 0.15 but I get all the entries for the other variables. I would like this cut to select only the entries with alpha>0.5 for all the variables. How can I do this?

I should say that I also tried doing the cut and filling the tree outside the loop for [sh] entries:

   for(Long64_t i = 0; i < tree->GetEntries(); ++i) 
   {

      tree->GetEntry(i);
      for(int sh = 0; sh < nshower; ++sh) {
    tgalpha[sh] = (1*55251.1*(pow(30.0,2)/2)*0.000001)/(shower->Energy);
    alphar[sh] = atan(tgalpha[sh]);
    alpha[sh] = (alphar[sh] * 180)/3.1415927;
    }

      if (alpha[sh] > 0.15) newtree->Fill();
   }

This doesn't work at all. It only works if I do it using the original variable:

      if ( (((atan((1*55251.1*(pow(30.0,2)/2)*0.000001)/(shower->Energy)))*180)/3.1415927) > 0.15) newtree->Fill();

This is just a part of the cut that I need to do. The complete expression is written in more than 50 lines and takes too long to execute. Moreover this doesn't fix my original problem of still having all the entries for the other variables. Can someone give me a hint of what I should do or of what I am doind wrong?

I'm using ROOT 5.28.

Thanks in advance,



Michelle Mesquita de Medeiros
Instituto de Física - UFG
e-mail: medeiros_at_fnal.gov
medeiros_at_posgrad.ufg.br Received on Mon Jun 06 2011 - 04:26:02 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 07 2011 - 23:50:01 CEST