groups

name language licence
TClonesArray example C++ Other
Make command Other Other
Merging trees using a TChain C++ Other
Drawing a TTree Other Other
Sort a tree C++ Other
TTree Scan column size Other Other
Untitled Snippet Other Other
Remove ctrl-M line breaks Other Other

< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >



language: C++
licence: Other

Sort a tree

options: view full snippetsend to code collector
void sort() {

	TFile f("hsimple.root");
	TTree *tree = (TTree*)f.Get("ntuple");
	Int_t nentries = (Int_t)tree->GetEntries();
	//Drawing variable pz with no graphics option.
	//variable pz stored in array fV1 (see TTree::Draw)
	tree->Draw("pz","","goff");
	Int_t *index = new Int_t[nentries];
	//sort array containing pz in decreasing order
	//The array index contains the entry numbers in decreasing order
	// of pz
	TMath::Sort(nentries,tree->GetV1(),index);
	
	//open new file to store the sorted Tree
	
(Continues...)