|
| 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