PelROOT
The Pelletron-Linac data analysis tools for ROOT

Using Graphical Cuts (bananas) in your analysis

Graphical cuts, as known as BANANAS, are widely used in Nuclear Physics analysis. Sometimes we want to make calculations with data that are inside a particular region in a 2-D spectrum. In this case, Graphical Cuts are the solution. Next I show an example on how to use them.

Program banana.cxx
// Graphical cuts, as known as BANANAS, are
// widely used in Nuclear Physics analysis.
// Sometimes we want to make calculations with
// data that are inside a particular region in
// a 2-D spectrum. In this case, Graphical Cuts
// are the solution.
// 
// In order to use graphical cuts, you first
// need to create them and save in a root file.
// You can use PelTools to create such file,
// create the graphical cuts and save them
// to this file. Each saved cut (banana) will
// be identified with an unique name in the file.
// Please be aware of spaces and special symbols
// that are also included as part of a name.
//
// After you create the file you need to open
// it back, read the graphical cut and use in
// your analysis. The program bellow is an
// example on how to use graphical cuts in your
// analysis program.
//
//                   Alexandre Suaide (2008)

#include "TH2.h"
#include "ScanRoot.h"
#include "TCutG.h"

TH1F* h1[100];

// I created one global variable named banana1
// that will hold the pointer to the TCutG object
// that I will load from file. It is a global
// variable in order to use in many functions.
TCutG *banana1;

void fillHistograms(short npar, float *par)
{
        if(npar==0) return;	
	
	// The next line tests if a pair of parameters
	// x=par[2] and y=par[1] is inside of the
	// geometrical region of the graphical cut
	// your created. It returns true if is inside.
	// 
	// In this case, the histogram h1[0] will be
	// filled *ONLY* if the pair (par[2],par[1])
	// is inside the graphical cut.
	//
	// The function to use is TCutG::IsInside(x,y)
	//
	if(banana1->IsInside(par[2],par[1]))
	{
	  h1[0]->Fill(par[2]);
	}

}
void bookHistograms(ScanRoot* spm)
{
        spm->cd();
  
	h1[0] = new TH1F("h1","h1",10000,1000,2000);

        spm->fillHistograms = &fillHistograms;
	
	// This line opens the root file which contains
	// all the saved graphical cuts (bananas)
	// for reading
	TFile *f = new TFile("banana.root");
	
	// next line loads the graphical cut named
	// "b1" from the file and store its pointer
        // in banana1. Note that banana1 is a global
	// variable in order to use it in other functions
	banana1 = (TCutG*)f->Get("b1");
	
	// please note the the TFile is not closed.
	// if you close or delete the TFile, all the
	// objects inside it will be erased from memory
   
        return;
}


06 05 08 - 15:34 |

Last Comments

Hey, appreciate it for taking the effort to do this. I like your webpage, although it took a sluggish reader like me some time to via throughout entire page and the many comments.
Supra Sneakers (Email) (URL) - 09 06 11 - 21:59

Thanks for your sharing.i like your post very muh and learn a lot information from your article,thanks.
cheap nashville predators jersey (Email) (URL) - 25 08 12 - 00:23

  
Remember personal info?

Emoticons / Textile


 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.

Options:

Calendar

« May 2024
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Last Comments

admin (version 3.01): Both men and women are wo…
Appannababu (Make your questio…): Hello Patrico, Thanks, I …
Patricio Carnelli… (Make your questio…): Hi Appannababu, This scri…
Appannababu (Make your questio…): Hello, I am new t…
cheap nashville p… (Using Graphical C…): Thanks for your sharing.i…
Supra Skytop (version 3.01): This topic was really edu…
Supra Sneakers (Using Graphical C…): Hey, appreciate it for ta…
Patricio Carnelli… (Make your questio…): Hello, I’m a PhD student …
Bob (Pivot 1.30 Beta 2…): And this is what a commen…

Search site

Archives

01 Sep - 30 Sep 2006
01 Dec - 31 Dec 2006
01 Jan - 31 Jan 2007
01 Feb - 28 Feb 2007
01 Mar - 31 Mar 2007
01 Apr - 30 Apr 2007
01 Jun - 30 Jun 2007
01 Oct - 31 Oct 2007
01 May - 31 May 2008
01 Oct - 31 Oct 2008
01 May - 31 May 2013
01 Nov - 30 Nov 2013
01 Jun - 30 Jun 2014

RSS & Atom

XML: RSS Feed XML: Atom Feed