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