|
||||
File indexing completed on 2024-04-06 12:23:22
0001 // -*- C++ -*- 0002 0003 // CMS includes 0004 #include "FWCore/Utilities/interface/InputTag.h" 0005 #include "DataFormats/Common/interface/Handle.h" 0006 #include "DataFormats/PatCandidates/interface/Jet.h" 0007 0008 #include "PhysicsTools/FWLite/interface/EventContainer.h" 0009 #include "PhysicsTools/FWLite/interface/CommandLineParser.h" 0010 0011 // Root includes 0012 #include "TROOT.h" 0013 0014 using namespace std; 0015 0016 0017 /////////////////////////// 0018 // ///////////////////// // 0019 // // Main Subroutine // // 0020 // ///////////////////// // 0021 /////////////////////////// 0022 0023 int main (int argc, char* argv[]) 0024 { 0025 //////////////////////////////// 0026 // ////////////////////////// // 0027 // // Command Line Options // // 0028 // ////////////////////////// // 0029 //////////////////////////////// 0030 0031 // Tell people what this analysis code does and setup default options. 0032 optutl::CommandLineParser parser ("Plots Jet Pt"); 0033 0034 //////////////////////////////////////////////// 0035 // Change any defaults or add any new command // 0036 // line options you would like here. // 0037 //////////////////////////////////////////////// 0038 parser.stringValue ("outputFile") = "jetPt"; // .root added automatically 0039 0040 // Parse the command line arguments 0041 parser.parseArguments (argc, argv); 0042 0043 ////////////////////////////////// 0044 // //////////////////////////// // 0045 // // Create Event Container // // 0046 // //////////////////////////// // 0047 ////////////////////////////////// 0048 0049 // This object 'event' is used both to get all information from the 0050 // event as well as to store histograms, etc. 0051 fwlite::EventContainer eventCont (parser); 0052 0053 //////////////////////////////////////// 0054 // ////////////////////////////////// // 0055 // // Begin Run // // 0056 // // (e.g., book histograms, etc) // // 0057 // ////////////////////////////////// // 0058 //////////////////////////////////////// 0059 0060 // Setup a style 0061 gROOT->SetStyle ("Plain"); 0062 0063 // Book those histograms! 0064 eventCont.add( new TH1F( "jetPt", "jetPt", 1000, 0, 1000) ); 0065 0066 ////////////////////// 0067 // //////////////// // 0068 // // Event Loop // // 0069 // //////////////// // 0070 ////////////////////// 0071 0072 // create labels 0073 edm::InputTag jetLabel ("selectedLayer1Jets"); 0074 0075 for (eventCont.toBegin(); ! eventCont.atEnd(); ++eventCont) 0076 { 0077 ////////////////////////////////// 0078 // Take What We Need From Event // 0079 ////////////////////////////////// 0080 edm::Handle< vector< pat::Jet > > jetHandle; 0081 eventCont.getByLabel (jetLabel, jetHandle); 0082 assert ( jetHandle.isValid() ); 0083 0084 // Loop over the jets 0085 const vector< pat::Jet >::const_iterator kJetEnd = jetHandle->end(); 0086 for (vector< pat::Jet >::const_iterator jetIter = jetHandle->begin(); 0087 kJetEnd != jetIter; 0088 ++jetIter) 0089 { 0090 eventCont.hist("jetPt")->Fill (jetIter->pt()); 0091 } // for jetIter 0092 } // for eventCont 0093 0094 0095 //////////////////////// 0096 // ////////////////// // 0097 // // Clean Up Job // // 0098 // ////////////////// // 0099 //////////////////////// 0100 0101 // Histograms will be automatically written to the root file 0102 // specificed by command line options. 0103 0104 // All done! Bye bye. 0105 return 0; 0106 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |