rivet is hosted by Hepforge, IPPP Durham
MC_JETTAGS.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analyses/MC_JetAnalysis.hh"
00003 #include "Rivet/Projections/FinalState.hh"
00004 #include "Rivet/Projections/FastJets.hh"
00005 
00006 namespace Rivet {
00007 
00008   
00009 
00010 
00011   /// @brief MC validation analysis for jet events
00012   class MC_JETTAGS : public Analysis {
00013   public:
00014 
00015     MC_JETTAGS()
00016       : Analysis("MC_JETTAGS")
00017     {    }
00018 
00019 
00020     void init() {
00021       FinalState fs;
00022       addProjection(FastJets(fs, FastJets::ANTIKT, 0.4), "Jets04");
00023       addProjection(FastJets(fs, FastJets::ANTIKT, 0.6), "Jets06");
00024 
00025       _h_numBTagsPerJet[0] = bookHisto1D("numBTagsPer04Jet", 5, -0.5, 4.5);
00026       _h_numBTagsPerJet[1] = bookHisto1D("numBTagsPer06Jet", 5, -0.5, 4.5);
00027       _h_numCTagsPerJet[0] = bookHisto1D("numCTagsPer04Jet", 5, -0.5, 4.5);
00028       _h_numCTagsPerJet[1] = bookHisto1D("numCTagsPer06Jet", 5, -0.5, 4.5);
00029       _h_numTauTagsPerJet[0] = bookHisto1D("numTauTagsPer04Jet", 5, -0.5, 4.5);
00030       _h_numTauTagsPerJet[1] = bookHisto1D("numTauTagsPer06Jet", 5, -0.5, 4.5);
00031     }
00032 
00033 
00034     void analyze(const Event& event) {
00035       const double weight = event.weight();
00036 
00037       const Jets jets04 = applyProjection<FastJets>(event, "Jets04").jetsByPt(20*GeV);
00038       const Jets jets06 = applyProjection<FastJets>(event, "Jets06").jetsByPt(20*GeV);
00039 
00040       foreach (const Jet& j, jets04) {
00041         _h_numBTagsPerJet[0]->fill(j.bTags().size(), weight);
00042         _h_numCTagsPerJet[0]->fill(j.cTags().size(), weight);
00043         _h_numTauTagsPerJet[0]->fill(j.tauTags().size(), weight);
00044       }
00045       foreach (const Jet& j, jets06) {
00046         _h_numBTagsPerJet[1]->fill(j.bTags().size(), weight);
00047         _h_numCTagsPerJet[1]->fill(j.cTags().size(), weight);
00048         _h_numTauTagsPerJet[1]->fill(j.tauTags().size(), weight);
00049       }
00050     }
00051 
00052 
00053     void finalize() {
00054       for (size_t i = 0; i < 2; ++i) {
00055         normalize(_h_numBTagsPerJet[i]);
00056         normalize(_h_numCTagsPerJet[i]);
00057         normalize(_h_numTauTagsPerJet[i]);
00058       }
00059     }
00060 
00061 
00062   private:
00063 
00064     Histo1DPtr _h_numBTagsPerJet[2], _h_numCTagsPerJet[2], _h_numTauTagsPerJet[2];
00065 
00066   };
00067 
00068 
00069   // The hook for the plugin system
00070   DECLARE_RIVET_PLUGIN(MC_JETTAGS);
00071 
00072 }