Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:40

0001 // -*- C++ -*-
0002 
0003 // CMS includes
0004 #include "FWCore/Utilities/interface/InputTag.h"
0005 #include "DataFormats/Common/interface/Handle.h"
0006 #include "DataFormats/JetReco/interface/CaloJet.h"
0007 
0008 #include "PhysicsTools/FWLite/interface/EventContainer.h"
0009 #include "PhysicsTools/FWLite/interface/CommandLineParser.h" 
0010 
0011 // Root includes
0012 #include "TString.h"
0013 #include "TROOT.h"
0014 
0015 using namespace std;
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 
0032    // Tell people what this analysis code does and setup default options.
0033    optutl::CommandLineParser parser ("");
0034 
0035    ////////////////////////////////////////////////
0036    // Change any defaults or add any new command //
0037    //      line options you would like here.     //
0038    ////////////////////////////////////////////////
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 
0065    //////////////////////
0066    // //////////////// //
0067    // // Event Loop // //
0068    // //////////////// //
0069    //////////////////////
0070 
0071    edm::Handle< std::vector< reco::CaloJet> > jetHandle;
0072    edm::InputTag jetLabel ("sisCone5CaloJets");
0073 
0074    for (eventCont.toBegin(); ! eventCont.atEnd(); ++eventCont) 
0075    {
0076 
0077       cout << "run " << eventCont.eventAuxiliary().run() << " event " 
0078            << eventCont.eventAuxiliary().event() << endl;
0079       cout << " index     Et         eta      phi" << endl;
0080 
0081 
0082       //////////////////////////////////
0083       // Take What We Need From Event //
0084       //////////////////////////////////
0085       eventCont.getByLabel (jetLabel, jetHandle);
0086       assert (jetHandle.isValid());
0087       const std::vector< reco::CaloJet > &jetVec( *jetHandle.product() );
0088       int index = 0;
0089       for (std::vector< reco::CaloJet >::const_iterator iter = jetVec.begin(); 
0090            jetVec.end() != iter;
0091            ++iter, ++index)
0092       {
0093          cout << "   " << setw(2) << index << ") ";
0094          cout << setw(8) << Form ("%8.4f", iter->et() ) << "  " 
0095               << setw(8) << Form ("%8.4f", iter->eta()) << "  " 
0096               << setw(8) << Form ("%8.4f", iter->phi()) << "  " << endl;              
0097       }
0098       
0099    } // for eventCont
0100 
0101       
0102    ////////////////////////
0103    // ////////////////// //
0104    // // Clean Up Job // //
0105    // ////////////////// //
0106    ////////////////////////
0107 
0108    // Histograms will be automatically written to the root file
0109    // specificed by command line options.
0110 
0111    // All done!  Bye bye.
0112    return 0;
0113 }