rivet is hosted by Hepforge, IPPP Durham
ATLAS_2013_I1230812.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 7 TeV (combined channel / base class)
00011   /// @note This base class contains a "mode" variable for combined, e, and mu channel derived classes
00012   class ATLAS_2013_I1230812 : public Analysis {
00013   public:
00014 
00015     /// @name Constructors etc.
00016     //@{
00017 
00018     /// Constructor
00019     ATLAS_2013_I1230812(string name="ATLAS_2013_I1230812")
00020       : Analysis(name),
00021         _weights_incl(7, 0.0),
00022         _weights_excl(7, 0.0),
00023         _weights_excl_pt150(7, 0.0),
00024         _weights_excl_vbf(7, 0.0)
00025     {
00026       // This class uses the combined e+mu mode
00027       _mode = 1;
00028     }
00029 
00030     //@}
00031 
00032 
00033     /// Book histograms and initialise projections before the run
00034     void init() {
00035       // Determine the e/mu decay channels used
00036       /// @todo Note that Zs are accepted with any rapidity: the cuts are on the e/mu: is this correct?
00037       Cut pt20 = Cuts::pT >= 20.0*GeV;
00038       if (_mode == 1) {
00039         // Combined
00040         ZFinder zfinder(FinalState(-2.5, 2.5), pt20, PID::ELECTRON, 66*GeV, 116*GeV);
00041         addProjection(zfinder, "zfinder");
00042       } else if (_mode == 2) {
00043         // Electron
00044         Cut eta_e = ( EtaIn(-2.47, -1.52)
00045              | EtaIn(-1.37,  1.37)
00046              | EtaIn( 1.52,  2.47) );
00047         ZFinder zfinder(FinalState(eta_e), pt20, PID::ELECTRON, 66*GeV, 116*GeV);
00048         addProjection(zfinder, "zfinder");
00049       } else if (_mode == 3) {
00050         // Muon
00051         ZFinder zfinder(FinalState(-2.4, 2.4), pt20, PID::MUON, 66*GeV, 116*GeV);
00052         addProjection(zfinder, "zfinder");
00053       } else {
00054         MSG_ERROR("Unknown decay channel mode!!!");
00055       }
00056 
00057       // Define veto FS in order to prevent Z-decay products entering the jet algorithm
00058       VetoedFinalState had_fs;
00059       had_fs.addVetoOnThisFinalState(getProjection<ZFinder>("zfinder"));
00060       FastJets jets(had_fs, FastJets::ANTIKT, 0.4);
00061       jets.useInvisibles(true);
00062       addProjection(jets, "jets");
00063 
00064       _h_njet_incl  = bookHisto1D (1,  1, _mode);
00065       _h_njet_incl_ratio = bookScatter2D(2,  1, _mode, true);
00066       _h_njet_excl  = bookHisto1D (3,  1, _mode);
00067       _h_njet_excl_ratio  = bookScatter2D (4,  1, _mode, true);
00068       _h_njet_excl_pt150  = bookHisto1D (5,  1, _mode);
00069       _h_njet_excl_pt150_ratio  = bookScatter2D (6,  1, _mode, true);
00070       _h_njet_excl_vbf  = bookHisto1D (7,  1, _mode);
00071       _h_njet_excl_vbf_ratio  = bookScatter2D (8,  1, _mode, true);
00072       _h_ptlead      = bookHisto1D (9,  1, _mode);
00073       _h_ptseclead  = bookHisto1D (10,  1, _mode);
00074       _h_ptthirdlead  = bookHisto1D (11,  1, _mode);
00075       _h_ptfourthlead  = bookHisto1D (12,  1, _mode);
00076       _h_ptlead_excl      = bookHisto1D (13,  1, _mode);
00077       _h_pt_ratio      = bookHisto1D (14,  1, _mode);
00078       _h_pt_z      = bookHisto1D (15,  1, _mode);
00079       _h_pt_z_excl      = bookHisto1D (16,  1, _mode);
00080       _h_ylead      = bookHisto1D (17,  1, _mode);
00081       _h_yseclead   = bookHisto1D (18,  1, _mode);
00082       _h_ythirdlead   = bookHisto1D (19,  1, _mode);
00083       _h_yfourthlead   = bookHisto1D (20,  1, _mode);
00084       _h_deltay     = bookHisto1D (21, 1, _mode);
00085       _h_mass       = bookHisto1D (22,  1, _mode);
00086       _h_deltaphi   = bookHisto1D (23, 1, _mode);
00087       _h_deltaR     = bookHisto1D (24, 1, _mode);
00088       _h_ptthirdlead_vbf  = bookHisto1D (25,  1, _mode);
00089       _h_ythirdlead_vbf   = bookHisto1D (26,  1, _mode);
00090       _h_ht     = bookHisto1D (27, 1, _mode);
00091       _h_st     = bookHisto1D (28, 1, _mode);
00092     }
00093 
00094 
00095     /// Perform the per-event analysis
00096     void analyze(const Event& event) {
00097 
00098       const ZFinder& zfinder = applyProjection<ZFinder>(event, "zfinder");
00099       if (zfinder.constituents().size()!=2) vetoEvent;
00100 
00101       FourMomentum z = zfinder.bosons()[0].momentum();
00102       FourMomentum lp = zfinder.constituents()[0].momentum();
00103       FourMomentum lm = zfinder.constituents()[1].momentum();
00104       if (deltaR(lp, lm)<0.2) vetoEvent;
00105 
00106       Jets jets;
00107       /// @todo Replace with a Cut passed to jetsByPt
00108       foreach(const Jet& jet, applyProjection<FastJets>(event, "jets").jetsByPt(30*GeV)) {
00109         FourMomentum jmom = jet.momentum();
00110         if (fabs(jmom.rapidity()) < 4.4 && deltaR(lp, jmom) > 0.5  && deltaR(lm, jmom) > 0.5) {
00111           jets.push_back(jet);
00112         }
00113       }
00114 
00115       const double weight = event.weight();
00116 
00117       if (jets.size() < 7) _weights_excl[jets.size()] += weight;
00118       for (size_t i = 0; i < 7; ++i) {
00119         if (jets.size() >= i) _weights_incl[i] += weight;
00120       }
00121 
00122       // Fill jet multiplicities
00123       for (size_t ijet = 1; ijet <= jets.size(); ++ijet) {
00124         _h_njet_incl->fill(ijet, weight);
00125       }
00126       _h_njet_excl->fill(jets.size(), weight);
00127 
00128       // Require at least one jet
00129       if (jets.size() >= 1) {
00130         // Leading jet histos
00131         const double ptlead   = jets[0].momentum().pT()/GeV;
00132         const double yabslead = fabs(jets[0].momentum().rapidity());
00133         const double ptz   = z.pT()/GeV;
00134         _h_ptlead->fill(ptlead,   weight);
00135         _h_ylead ->fill(yabslead, weight);
00136         _h_pt_z  ->fill(ptz, weight);
00137         // Fill jet multiplicities
00138         if (ptlead > 150) {
00139           _h_njet_excl_pt150->fill(jets.size(), weight);
00140           if (jets.size()<7) _weights_excl_pt150[jets.size()] += weight;
00141         }
00142 
00143         // Loop over selected jets, fill inclusive distributions
00144         double st=0;
00145         double ht=lp.pT()/GeV+lm.pT()/GeV;
00146         for (size_t ijet = 0; ijet < jets.size(); ++ijet) {
00147           ht+=jets[ijet].momentum().pT()/GeV;
00148           st+=jets[ijet].momentum().pT()/GeV;
00149         }
00150         _h_ht->fill(ht, weight);
00151         _h_st->fill(st, weight);
00152 
00153         // Require exactly one jet
00154         if (jets.size() == 1) {
00155           _h_ptlead_excl->fill(ptlead,   weight);
00156           _h_pt_z_excl  ->fill(ptz, weight);
00157         }
00158       }
00159 
00160 
00161       // Require at least two jets
00162       if (jets.size() >= 2) {
00163         // Second jet histos
00164         const double ptlead      = jets[0].momentum().pT()/GeV;
00165         const double pt2ndlead   = jets[1].momentum().pT()/GeV;
00166         const double ptratio     = pt2ndlead/ptlead;
00167         const double yabs2ndlead = fabs(jets[1].momentum().rapidity());
00168         _h_ptseclead ->fill(pt2ndlead,   weight);
00169         _h_yseclead  ->fill(yabs2ndlead, weight);
00170         _h_pt_ratio  ->fill(ptratio, weight);
00171 
00172         // Dijet histos
00173         const double deltaphi = fabs(deltaPhi(jets[1], jets[0]));
00174         const double deltarap = fabs(jets[0].momentum().rapidity() - jets[1].momentum().rapidity()) ;
00175         const double deltar   = fabs(deltaR(jets[0], jets[1], RAPIDITY));
00176         const double mass     = (jets[0].momentum() + jets[1].momentum()).mass()/GeV;
00177         _h_mass     ->fill(mass,     weight);
00178         _h_deltay   ->fill(deltarap, weight);
00179         _h_deltaphi ->fill(deltaphi, weight);
00180         _h_deltaR   ->fill(deltar,   weight);
00181 
00182         if (mass > 350 && deltarap > 3) {
00183           _h_njet_excl_vbf->fill(jets.size(), weight);
00184           if (jets.size()<7) _weights_excl_vbf[jets.size()] += weight;
00185         }
00186       }
00187 
00188       // Require at least three jets
00189       if (jets.size() >= 3) {
00190         // Third jet histos
00191         const double pt3rdlead   = jets[2].momentum().pT()/GeV;
00192         const double yabs3rdlead = fabs(jets[2].momentum().rapidity());
00193         _h_ptthirdlead ->fill(pt3rdlead,   weight);
00194         _h_ythirdlead  ->fill(yabs3rdlead, weight);
00195 
00196         //Histos after VBF preselection
00197         const double deltarap = fabs(jets[0].momentum().rapidity() - jets[1].momentum().rapidity()) ;
00198         const double mass     = (jets[0].momentum() + jets[1].momentum()).mass();
00199         if (mass > 350 && deltarap > 3) {
00200           _h_ptthirdlead_vbf ->fill(pt3rdlead,   weight);
00201           _h_ythirdlead_vbf  ->fill(yabs3rdlead, weight);
00202         }
00203       }
00204 
00205       // Require at least four jets
00206       if (jets.size() >= 4) {
00207         // Fourth jet histos
00208         const double pt4thlead   = jets[3].momentum().pT()/GeV;
00209         const double yabs4thlead = fabs(jets[3].momentum().rapidity());
00210         _h_ptfourthlead ->fill(pt4thlead,   weight);
00211         _h_yfourthlead  ->fill(yabs4thlead, weight);
00212       }
00213     }
00214 
00215     /// @name Ratio calculator util functions
00216     //@{
00217 
00218     /// Calculate the ratio, being careful about div-by-zero
00219     double ratio(double a, double b) {
00220       return (b != 0) ? a/b : 0;
00221     }
00222 
00223     /// Calculate the ratio error, being careful about div-by-zero
00224     double ratio_err_incl(double a, double b) {
00225       return (b != 0) ? sqrt(a/b*(1-a/b)/b) : 0;
00226     }
00227 
00228     /// Calculate the ratio error, being careful about div-by-zero
00229     double ratio_err_excl(double a, double b) {
00230       return (b != 0) ? sqrt(a/sqr(b) + sqr(a)/(b*b*b)) : 0;
00231     }
00232 
00233     //@}
00234 
00235     void finalize() {
00236       for (size_t i = 0; i < 6; ++i) {
00237         _h_njet_incl_ratio->point(i).setY(ratio(_weights_incl[i+1], _weights_incl[i]),
00238                                           ratio_err_incl(_weights_incl[i+1], _weights_incl[i]));
00239         _h_njet_excl_ratio->point(i).setY(ratio(_weights_excl[i+1], _weights_excl[i]),
00240                                           ratio_err_excl(_weights_excl[i+1], _weights_excl[i]));
00241         if (i>=1) _h_njet_excl_pt150_ratio->point(i-1).setY
00242                     (ratio(_weights_excl_pt150[i+1], _weights_excl_pt150[i]),
00243                      ratio_err_excl(_weights_excl_pt150[i+1], _weights_excl_pt150[i]));
00244 
00245         if (i>=2) _h_njet_excl_vbf_ratio->point(i-2).setY
00246                     (ratio(_weights_excl_vbf[i+1], _weights_excl_vbf[i]),
00247                      ratio_err_excl(_weights_excl_vbf[i+1], _weights_excl_vbf[i]));
00248       }
00249 
00250       const double xs = crossSectionPerEvent()/picobarn;
00251       scale(_h_njet_incl      , xs);
00252       scale(_h_njet_excl      , xs);
00253       scale(_h_njet_excl_pt150, xs);
00254       scale(_h_njet_excl_vbf  , xs);
00255       scale(_h_ptlead         , xs);
00256       scale(_h_ptseclead      , xs);
00257       scale(_h_ptthirdlead    , xs);
00258       scale(_h_ptfourthlead   , xs);
00259       scale(_h_ptlead_excl    , xs);
00260       scale(_h_pt_ratio       , xs);
00261       scale(_h_pt_z           , xs);
00262       scale(_h_pt_z_excl      , xs);
00263       scale(_h_ylead          , xs);
00264       scale(_h_yseclead       , xs);
00265       scale(_h_ythirdlead     , xs);
00266       scale(_h_yfourthlead    , xs);
00267       scale(_h_deltay         , xs);
00268       scale(_h_mass           , xs);
00269       scale(_h_deltaphi       , xs);
00270       scale(_h_deltaR         , xs);
00271       scale(_h_ptthirdlead_vbf, xs);
00272       scale(_h_ythirdlead_vbf , xs);
00273       scale(_h_ht             , xs);
00274       scale(_h_st             , xs);
00275     }
00276 
00277     //@}
00278 
00279 
00280   protected:
00281 
00282     size_t _mode;
00283 
00284 
00285   private:
00286 
00287     vector<double> _weights_incl;
00288     vector<double> _weights_excl;
00289     vector<double> _weights_excl_pt150;
00290     vector<double> _weights_excl_vbf;
00291 
00292     Scatter2DPtr _h_njet_incl_ratio;
00293     Scatter2DPtr _h_njet_excl_ratio;
00294     Scatter2DPtr _h_njet_excl_pt150_ratio;
00295     Scatter2DPtr _h_njet_excl_vbf_ratio;
00296     Histo1DPtr _h_njet_incl;
00297     Histo1DPtr _h_njet_excl;
00298     Histo1DPtr _h_njet_excl_pt150;
00299     Histo1DPtr _h_njet_excl_vbf;
00300     Histo1DPtr _h_ptlead;
00301     Histo1DPtr _h_ptseclead;
00302     Histo1DPtr _h_ptthirdlead;
00303     Histo1DPtr _h_ptfourthlead;
00304     Histo1DPtr _h_ptlead_excl;
00305     Histo1DPtr _h_pt_ratio;
00306     Histo1DPtr _h_pt_z;
00307     Histo1DPtr _h_pt_z_excl;
00308     Histo1DPtr _h_ylead;
00309     Histo1DPtr _h_yseclead;
00310     Histo1DPtr _h_ythirdlead;
00311     Histo1DPtr _h_yfourthlead;
00312     Histo1DPtr _h_deltay;
00313     Histo1DPtr _h_mass;
00314     Histo1DPtr _h_deltaphi;
00315     Histo1DPtr _h_deltaR;
00316     Histo1DPtr _h_ptthirdlead_vbf;
00317     Histo1DPtr _h_ythirdlead_vbf;
00318     Histo1DPtr _h_ht;
00319     Histo1DPtr _h_st;
00320   };
00321 
00322 
00323 
00324   class ATLAS_2013_I1230812_EL : public ATLAS_2013_I1230812 {
00325   public:
00326     ATLAS_2013_I1230812_EL()
00327       : ATLAS_2013_I1230812("ATLAS_2013_I1230812_EL")
00328     {
00329       _mode = 2;
00330     }
00331   };
00332 
00333 
00334 
00335   class ATLAS_2013_I1230812_MU : public ATLAS_2013_I1230812 {
00336   public:
00337     ATLAS_2013_I1230812_MU()
00338       : ATLAS_2013_I1230812("ATLAS_2013_I1230812_MU")
00339     {
00340       _mode = 3;
00341     }
00342   };
00343 
00344 
00345 
00346   DECLARE_RIVET_PLUGIN(ATLAS_2013_I1230812);
00347   DECLARE_RIVET_PLUGIN(ATLAS_2013_I1230812_EL);
00348   DECLARE_RIVET_PLUGIN(ATLAS_2013_I1230812_MU);
00349 }