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