Skip to content

Commit 564e2e4

Browse files
author
kreis
committed
First version of some Cornell code ported to run on RA2b's 41x Ntuples made by
TheNtupleMaker (https://twiki.cern.ch/twiki/bin/view/CMS/TheNtupleMaker). Some important features of the original Cornell code are currently missing. Resurrecting the use of the enums that ultimately specify which type of collection to use for the various objects and whether or not to turn on various corrections is important. We may also want to resurrect the class structure of the code. This analyzer was created with tag v5_1_2 of UserCode/SusySapien/PhysicsTools/TheNtupleMaker. The variables.txt file used in making the analyzer was created using an ntuple created with tag ngoodmuoc of UserCode/SusyAnalysis/RA2b/Ntuples/RA2b2011v1 and tag v5_1_1 (I think...) of TheNtupleMaker. Only the "Events" tree was included. The file is located here: /castor/cern.ch/user/s/ssekmen/RA2b2011v1/V00-01-03/QCD_Pt_170to300_TuneZ2_7TeV_pythia6_Spring11-PU_S1_START311_V1G1-v1_AODSIM/QCD_Pt_170to300_TuneZ2_7TeV_pythia6/ntuple_99_4_OhF.root. I hope we can develop this code in a way that only BasicLoopTools (and maybe BasicLoopCU.cc) has to be modified. The rest of the files are generated automatically by mkanalyzer.py, and it would be nice to keep it that way (especially true for BasicLoopCU.h).
0 parents  commit 564e2e4

12 files changed

+9030
-0
lines changed

BasicLoopCU.cc

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
//-----------------------------------------------------------------------------
2+
// File: BasicLoopCU.cc
3+
// Description: Analyzer for ntuples created by TheNtupleMaker
4+
// Created: Fri Jun 3 16:38:31 2011 by mkntanalyzer.py
5+
// Author: Ben Kreis
6+
//-----------------------------------------------------------------------------
7+
//#include "BasicLoopCU.h"
8+
#include "BasicLoopTools.h"
9+
10+
#ifdef PROJECT_NAME
11+
#include "PhysicsTools/TheNtupleMaker/interface/pdg.h"
12+
#else
13+
#include "pdg.h"
14+
#endif
15+
16+
using namespace std;
17+
//-----------------------------------------------------------------------------
18+
int main(int argc, char** argv)
19+
{
20+
// Get file list and histogram filename from command line
21+
22+
commandLine cmdline;
23+
decodeCommandLine(argc, argv, cmdline);
24+
25+
// Get names of ntuple files to be processed and open chain of ntuples
26+
27+
vector<string> filenames = getFilenames(cmdline.filelist);
28+
itreestream stream(filenames, "Events");
29+
if ( !stream.good() ) error("unable to open ntuple file(s)");
30+
31+
// Get number of events to be read
32+
33+
int nevents = stream.size();
34+
cout << "Number of events: " << nevents << endl;
35+
36+
// Select variables to be read
37+
38+
selectVariables(stream);
39+
cutflow(stream);
40+
reducedTree(".", stream);
41+
42+
43+
// The root application is needed to make canvases visible during
44+
// program execution. If this is not needed, just comment out the following
45+
// line
46+
47+
TApplication app("analyzer", &argc, argv);
48+
49+
/*
50+
Notes:
51+
52+
1. Use
53+
ofile = outputFile(cmdline.outputfile, stream)
54+
55+
to skim events to output file in addition to writing out histograms.
56+
57+
2. Use
58+
ofile.addEvent(event-weight)
59+
60+
to specify that the current event is to be added to the output file. If
61+
omitted, the event-weight is taken to 1.
62+
63+
3. Use
64+
ofile.count(cut-name, event-weight)
65+
66+
to keep track, in the count histogram, of the number of events passing
67+
a given cut. If omitted, the event-weight is taken to be 1. If you want
68+
the counts in the count histogram to appear in a given order, specify the
69+
order, before entering the event loop, as in the example below
70+
71+
ofile.count("NoCuts", 0)
72+
ofile.count("GoodEvent", 0)
73+
ofile.count("Vertex", 0)
74+
ofile.count("MET", 0)
75+
*/
76+
77+
outputFile ofile(cmdline.outputfilename);
78+
79+
//---------------------------------------------------------------------------
80+
// Declare histograms
81+
//---------------------------------------------------------------------------
82+
83+
84+
85+
//---------------------------------------------------------------------------
86+
// Loop over events
87+
//---------------------------------------------------------------------------
88+
89+
for(int entry=0; entry < nevents; ++entry)
90+
{
91+
// Read event into memory
92+
stream.read(entry);
93+
94+
// Uncomment the following line if you wish to copy variables into
95+
// structs. See the header file BasicLoopCU.h to find out what structs
96+
// are available.
97+
// fillObjects();
98+
99+
// ---------------------
100+
// -- event selection --
101+
// ---------------------
102+
103+
104+
// ---------------------
105+
// -- fill histograms --
106+
// ---------------------
107+
108+
}
109+
110+
stream.close();
111+
ofile.close();
112+
return 0;
113+
}

0 commit comments

Comments
 (0)