Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32: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 #include "DataFormats/Math/interface/deltaPhi.h"
0008 
0009 #include "PhysicsTools/FWLite/interface/EventContainer.h"
0010 #include "PhysicsTools/FWLite/interface/CommandLineParser.h" 
0011 
0012 // Root includes
0013 #include "TROOT.h"
0014 
0015 using namespace std;
0016 
0017 
0018 ///////////////////////////
0019 // ///////////////////// //
0020 // // Main Subroutine // //
0021 // ///////////////////// //
0022 ///////////////////////////
0023 
0024 int main (int argc, char* argv[]) 
0025 {
0026    ////////////////////////////////
0027    // ////////////////////////// //
0028    // // Command Line Options // //
0029    // ////////////////////////// //
0030    ////////////////////////////////
0031 
0032    // Tell people what this analysis code does and setup default options.
0033    optutl::CommandLineParser parser ("Playing with jets");
0034 
0035    ////////////////////////////////////////////////
0036    // Change any defaults or add any new command //
0037    //      line options you would like here.     //
0038    ////////////////////////////////////////////////
0039    // change default output filename
0040    parser.stringValue ("outputFile") = "jetInfo.root";
0041    
0042    // Parse the command line arguments
0043    parser.parseArguments (argc, argv);
0044 
0045    //////////////////////////////////
0046    // //////////////////////////// //
0047    // // Create Event Container // //
0048    // //////////////////////////// //
0049    //////////////////////////////////
0050 
0051    // This object 'event' is used both to get all information from the
0052    // event as well as to store histograms, etc.
0053    fwlite::EventContainer eventCont (parser);
0054 
0055    ////////////////////////////////////////
0056    // ////////////////////////////////// //
0057    // //         Begin Run            // //
0058    // // (e.g., book histograms, etc) // //
0059    // ////////////////////////////////// //
0060    ////////////////////////////////////////
0061 
0062    // Setup a style
0063    gROOT->SetStyle ("Plain");
0064 
0065    // Book those histograms!
0066    eventCont.add( new TH1F( "jetpt",        "Jet p_{T} using standard absolute p_{T} calibration", 100, 0, 60) );
0067    eventCont.add( new TH1F( "jeteta",       "Jet eta using standard absolute p_{T} calibration",   100, 0, 10) );
0068    eventCont.add( new TH1F( "reljetpt",     "Jet p_{T} using relative inter eta calibration",      100, 0, 60) );
0069    eventCont.add( new TH1F( "reljeteta",    "Jet eta using relative inter eta calibration",        100, 0, 10) );
0070    eventCont.add( new TH1F( "phijet1jet2",  "Phi between Jet 1 and Jet 2",                        100, 0, 3.5) );
0071    eventCont.add( new TH1F( "invarMass",    "Invariant Mass of the 4-vector sum of Two Jets",     100, 0, 200) );
0072 
0073    //////////////////////
0074    // //////////////// //
0075    // // Event Loop // //
0076    // //////////////// //
0077    //////////////////////
0078 
0079    // create labels
0080    edm::InputTag jetLabel ("selectedLayer1Jets");
0081 
0082    for (eventCont.toBegin(); ! eventCont.atEnd(); ++eventCont) 
0083    {
0084       //////////////////////////////////
0085       // Take What We Need From Event //
0086       //////////////////////////////////
0087 
0088       // Get jets
0089       edm::Handle< vector< pat::Jet > > jetHandle;
0090       eventCont.getByLabel (jetLabel, jetHandle);
0091       assert ( jetHandle.isValid() );
0092 
0093       const vector< pat::Jet >::const_iterator kJetEnd = jetHandle->end();
0094       for (vector< pat::Jet >::const_iterator jetIter = jetHandle->begin(); 
0095            jetIter != kJetEnd; 
0096            ++jetIter) 
0097       {    
0098          // A few correctedJet options:
0099          // ABS - absolute pt calibration (automatic)
0100          // REL - relative inter eta calibration  
0101          // EMF - calibration as a function of the jet EMF
0102          eventCont.hist("reljetpt") ->Fill( jetIter->correctedJet("REL").pt() );
0103          eventCont.hist("reljeteta")->Fill( jetIter->correctedJet("REL").eta() );
0104          eventCont.hist("jetpt")    ->Fill( jetIter->correctedJet("ABS").pt() );
0105          // Automatically ABS
0106          eventCont.hist("jeteta")   ->Fill( jetIter->eta() );
0107       } // for jetIter
0108 
0109       // Do we have at least two jets?
0110       if (jetHandle->size() < 2)
0111       {
0112          // Nothing to do here
0113          continue;
0114       }
0115 
0116       // Store invariant mass and delta phi between two leading jets.
0117       eventCont.hist("invarMass")->Fill( (jetHandle->at(0).p4() + jetHandle->at(1).p4()).M() );
0118       eventCont.hist("phijet1jet2")->Fill( deltaPhi( jetHandle->at(0).phi(), jetHandle->at(1).phi() ) );
0119    } // for eventCont
0120 
0121       
0122    ////////////////////////
0123    // ////////////////// //
0124    // // Clean Up Job // //
0125    // ////////////////// //
0126    ////////////////////////
0127 
0128    // Histograms will be automatically written to the root file
0129    // specificed by command line options.
0130 
0131    // All done!  Bye bye.
0132    return 0;
0133 }