rivet is hosted by Hepforge, IPPP Durham
ATLAS_2015_CONF_2015_041.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Projections/ZFinder.hh"
00004 #include "Rivet/Projections/FastJets.hh"
00005 #include "Rivet/Projections/VetoedFinalState.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// Z + jets in pp at 13 TeV 
00011   /// @note This base class contains a "mode" variable for combined, e, and mu channel derived classes
00012   class ATLAS_2015_CONF_2015_041 : public Analysis {
00013   public:
00014 
00015     /// @name Constructors etc.
00016     //@{
00017 
00018     /// Constructor
00019     ATLAS_2015_CONF_2015_041(string name="ATLAS_2015_CONF_2015_041")
00020       : Analysis(name),
00021         _weights(5, 0.0)
00022     {
00023       // This class uses the combined e+mu mode
00024       _mode = 0;
00025     }
00026 
00027     //@}
00028 
00029 
00030     /// Book histograms and initialise projections before the run
00031     void init() {
00032       const FinalState fs;
00033 
00034       Cut cuts = (Cuts::pT > 25*GeV) & (Cuts::abseta < 2.5);
00035       ZFinder zfinder(fs, cuts, _mode? PID::MUON : PID::ELECTRON, 66*GeV, 116*GeV);
00036       addProjection(zfinder, "zfinder");
00037 
00038       // Define veto FS in order to prevent Z-decay products entering the jet algorithm
00039       VetoedFinalState had_fs;
00040       had_fs.addVetoOnThisFinalState(zfinder);
00041       FastJets jets(had_fs, FastJets::ANTIKT, 0.4);
00042       jets.useInvisibles(true);
00043       addProjection(jets, "jets");
00044 
00045       // individual channels
00046       _hNjets      = bookHisto1D(1, 1, _mode + 1);
00047       _hNjetsRatio = bookScatter2D(2, 1, _mode + 1, true);
00048       // combination
00049       _hNjets_comb      = bookHisto1D(1, 2, _mode + 1);
00050       _hNjetsRatio_comb = bookScatter2D(2, 2, _mode + 1, true);
00051     }
00052 
00053 
00054     /// Perform the per-event analysis
00055     void analyze(const Event& event) {
00056 
00057       const double weight = event.weight();
00058 
00059       const ZFinder& zfinder = applyProjection<ZFinder>(event, "zfinder");
00060       const Particles& leptons = zfinder.constituents();
00061       if (leptons.size() != 2)  vetoEvent;
00062 
00063       Jets jets;
00064       foreach (Jet j, applyProjection<JetAlg>(event, "jets").jetsByPt(Cuts::pT > 30*GeV && Cuts::absrap < 2.5)) {
00065         bool keep = true;
00066         foreach(const Particle& l, leptons)  keep &= deltaR(j, l) > 0.4;
00067         if (keep)  jets += j;
00068       }
00069 
00070       size_t njets = jets.size();
00071 
00072       for(size_t i = 0; i <= njets; ++i) {
00073         _hNjets->fill(i + 0.5, weight);
00074         _hNjets_comb->fill(i + 0.5, weight);
00075       }
00076 
00077       for (size_t i = 0; i < 5; ++i) {
00078         if (njets >= i) _weights[i] += weight;
00079       }
00080 
00081     }
00082 
00083     /// @name Ratio calculator util functions
00084     //@{
00085 
00086     /// Calculate the ratio, being careful about div-by-zero
00087     double ratio(double a, double b) {
00088       return (b != 0) ? a/b : 0;
00089     }
00090 
00091     /// Calculate the ratio error, being careful about div-by-zero
00092     double ratio_err(double a, double b) {
00093       return (b != 0) ? sqrt(a/b*(1-a/b)/b) : 0;
00094     }
00095 
00096     //@}
00097 
00098     void finalize() {
00099       for (size_t i = 0; i < 4; ++i) {
00100         double  n = _hNjets->bin(i + 1).sumW();
00101         double dN = _hNjets->bin(i + 1).sumW2();
00102         double  d = _hNjets->bin(i).sumW();
00103         double dD = _hNjets->bin(i).sumW2();
00104         double r = safediv(n, d);
00105         double e = sqrt( safediv(r * (1 - r), d) );
00106         if ( _hNjets->effNumEntries() != _hNjets->numEntries() ) {
00107           // use F. James's approximation for weighted events:
00108           e = sqrt( safediv((1 - 2 * r) * dN + r * r * dD, d * d) );
00109         }
00110         _hNjetsRatio->point(i).setY(r, e);
00111         _hNjetsRatio_comb->point(i).setY(r, e);
00112       }
00113 
00114       scale(_hNjets,      crossSectionPerEvent() );
00115       scale(_hNjets_comb, crossSectionPerEvent() );
00116     }
00117 
00118     //@}
00119 
00120 
00121   protected:
00122 
00123     size_t _mode;
00124 
00125 
00126   private:
00127 
00128     vector<double> _weights;
00129     Scatter2DPtr _hNjetsRatio, _hNjetsRatio_comb;
00130     Histo1DPtr _hNjets, _hNjets_comb;
00131   };
00132 
00133 
00134 
00135   class ATLAS_2015_CONF_2015_041_EL : public ATLAS_2015_CONF_2015_041 {
00136   public:
00137     ATLAS_2015_CONF_2015_041_EL()
00138       : ATLAS_2015_CONF_2015_041("ATLAS_2015_CONF_2015_041_EL")
00139     {
00140       _mode = 0;
00141     }
00142   };
00143 
00144 
00145 
00146   class ATLAS_2015_CONF_2015_041_MU : public ATLAS_2015_CONF_2015_041 {
00147   public:
00148     ATLAS_2015_CONF_2015_041_MU()
00149       : ATLAS_2015_CONF_2015_041("ATLAS_2015_CONF_2015_041_MU")
00150     {
00151       _mode = 1;
00152     }
00153   };
00154 
00155 
00156 
00157   DECLARE_RIVET_PLUGIN(ATLAS_2015_CONF_2015_041);
00158   DECLARE_RIVET_PLUGIN(ATLAS_2015_CONF_2015_041_EL);
00159   DECLARE_RIVET_PLUGIN(ATLAS_2015_CONF_2015_041_MU);
00160 }