![]() |
![]() |
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "PhysicsTools/FWLite/interface/EventContainer.h"
#include "PhysicsTools/FWLite/interface/CommandLineParser.h"
#include "TROOT.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 23 of file jetPt.cc.
References fwlite::EventContainer::add(), fwlite::EventContainer::atEnd(), fwlite::EventContainer::getByLabel(), fwlite::EventContainer::hist(), edm::HandleBase::isValid(), optutl::CommandLineParser::parseArguments(), geometryXMLtoCSV::parser, optutl::VariableMapCont::stringValue(), and fwlite::EventContainer::toBegin().
{ // ////////////////////////// // // // Command Line Options // // // ////////////////////////// // // Tell people what this analysis code does and setup default options. optutl::CommandLineParser parser ("Plots Jet Pt"); // Change any defaults or add any new command // // line options you would like here. // parser.stringValue ("outputFile") = "jetPt"; // .root added automatically // Parse the command line arguments parser.parseArguments (argc, argv); // //////////////////////////// // // // Create Event Container // // // //////////////////////////// // // This object 'event' is used both to get all information from the // event as well as to store histograms, etc. fwlite::EventContainer eventCont (parser); // ////////////////////////////////// // // // Begin Run // // // // (e.g., book histograms, etc) // // // ////////////////////////////////// // // Setup a style gROOT->SetStyle ("Plain"); // Book those histograms! eventCont.add( new TH1F( "jetPt", "jetPt", 1000, 0, 1000) ); // //////////////// // // // Event Loop // // // //////////////// // // create labels edm::InputTag jetLabel ("selectedLayer1Jets"); for (eventCont.toBegin(); ! eventCont.atEnd(); ++eventCont) { // Take What We Need From Event // edm::Handle< vector< pat::Jet > > jetHandle; eventCont.getByLabel (jetLabel, jetHandle); assert ( jetHandle.isValid() ); // Loop over the jets const vector< pat::Jet >::const_iterator kJetEnd = jetHandle->end(); for (vector< pat::Jet >::const_iterator jetIter = jetHandle->begin(); kJetEnd != jetIter; ++jetIter) { eventCont.hist("jetPt")->Fill (jetIter->pt()); } // for jetIter } // for eventCont // ////////////////// // // // Clean Up Job // // // ////////////////// // // Histograms will be automatically written to the root file // specificed by command line options. // All done! Bye bye. return 0; }