ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RootMacros/entriesVScuts.C
Revision: 1.1
Committed: Sat Mar 7 01:29:51 2009 UTC (16 years, 1 month ago) by anderson
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
List number of entries left in a TTree after each additional cut

File Contents

# User Rev Content
1 anderson 1.1 /*************************************************
2     This script lists the number of entries left
3     in a TTree after each additional cut.
4    
5     Michael B. Anderson
6     Feb 19, 2009
7     *************************************************/
8     {
9     //************************************************
10     // Variables
11     TFile *file1 = new TFile("PhotonJetPt15_realPhotons.root");
12    
13     TTree *tree1;
14     file1->GetObject("TreePhotonMatched",tree1);
15    
16     vector<TString> cuts;
17     cuts.push_back( "recPhoton.et>20&&abs(recPhoton.eta)<2.5&&recPhoton.hadronicOverEm<0.1" );
18     cuts.push_back( "recPhoton.hadronicOverEm<0.005" );
19     cuts.push_back( "recPhoton.r9>0.8" );
20     cuts.push_back( "recPhoton.isolationHcalRecHit<15" );
21     cuts.push_back( "recPhoton.isolationEcalRecHit<15" );
22     cuts.push_back( "recPhoton.SolidTrkCone<5" );
23     cuts.push_back( "((abs(recPhoton.eta)<1.48&&recPhoton.isEBGap<1)||abs(recPhoton.eta)>1.55)" );
24     //************************************************
25    
26    
27     //************************************************
28     cout << "File:\t" << file1.GetName() << endl;
29     cout << "Tree:\t" << tree1.GetName() << endl;
30     int initialEntries = tree1->GetEntries();
31     cout << initialEntries << " entries at start." << endl << endl;
32    
33     cout << "Entries left after each progressive cut:" << endl;
34     TCut currentCuts = "";
35     for (int i =0; i<cuts.size(); i++) {
36     currentCuts += cuts[i];
37     int currentEntries = tree1->GetEntries(currentCuts);
38    
39     // Print number of entries passing cuts
40     float precentLeft = (100.0 * currentEntries) / initialEntries;
41     printf("%i\t%4.1f\t%s \n",currentEntries,precentLeft,cuts[i].Data());
42     }
43     }