CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/Validation/Tools/examples/printJetInfo.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // CMS includes
00004 #include "FWCore/Utilities/interface/InputTag.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "DataFormats/JetReco/interface/CaloJet.h"
00007 
00008 #include "PhysicsTools/FWLite/interface/EventContainer.h"
00009 #include "PhysicsTools/FWLite/interface/CommandLineParser.h" 
00010 
00011 // Root includes
00012 #include "TString.h"
00013 #include "TROOT.h"
00014 
00015 using namespace std;
00016 
00018 // ///////////////////// //
00019 // // Main Subroutine // //
00020 // ///////////////////// //
00022 
00023 int main (int argc, char* argv[]) 
00024 {
00026    // ////////////////////////// //
00027    // // Command Line Options // //
00028    // ////////////////////////// //
00030 
00031 
00032    // Tell people what this analysis code does and setup default options.
00033    optutl::CommandLineParser parser ("");
00034 
00036    // Change any defaults or add any new command //
00037    //      line options you would like here.     //
00039 
00040    // Parse the command line arguments
00041    parser.parseArguments (argc, argv);
00042 
00044    // //////////////////////////// //
00045    // // Create Event Container // //
00046    // //////////////////////////// //
00048 
00049    // This object 'event' is used both to get all information from the
00050    // event as well as to store histograms, etc.
00051    fwlite::EventContainer eventCont (parser);
00052 
00054    // ////////////////////////////////// //
00055    // //         Begin Run            // //
00056    // // (e.g., book histograms, etc) // //
00057    // ////////////////////////////////// //
00059 
00060    // Setup a style
00061    gROOT->SetStyle ("Plain");
00062 
00063    // Book those histograms!
00064 
00066    // //////////////// //
00067    // // Event Loop // //
00068    // //////////////// //
00070 
00071    edm::Handle< std::vector< reco::CaloJet> > jetHandle;
00072    edm::InputTag jetLabel ("sisCone5CaloJets");
00073 
00074    for (eventCont.toBegin(); ! eventCont.atEnd(); ++eventCont) 
00075    {
00076 
00077       cout << "run " << eventCont.eventAuxiliary().run() << " event " 
00078            << eventCont.eventAuxiliary().event() << endl;
00079       cout << " index     Et         eta      phi" << endl;
00080 
00081 
00083       // Take What We Need From Event //
00085       eventCont.getByLabel (jetLabel, jetHandle);
00086       assert (jetHandle.isValid());
00087       const std::vector< reco::CaloJet > &jetVec( *jetHandle.product() );
00088       int index = 0;
00089       for (std::vector< reco::CaloJet >::const_iterator iter = jetVec.begin(); 
00090            jetVec.end() != iter;
00091            ++iter, ++index)
00092       {
00093          cout << "   " << setw(2) << index << ") ";
00094          cout << setw(8) << Form ("%8.4f", iter->et() ) << "  " 
00095               << setw(8) << Form ("%8.4f", iter->eta()) << "  " 
00096               << setw(8) << Form ("%8.4f", iter->phi()) << "  " << endl;              
00097       }
00098       
00099    } // for eventCont
00100 
00101       
00103    // ////////////////// //
00104    // // Clean Up Job // //
00105    // ////////////////// //
00107 
00108    // Histograms will be automatically written to the root file
00109    // specificed by command line options.
00110 
00111    // All done!  Bye bye.
00112    return 0;
00113 }