rivet is hosted by Hepforge, IPPP Durham
ATLAS_2011_I945498.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 
00004 #include "Rivet/Projections/ZFinder.hh"
00005 #include "Rivet/Projections/FastJets.hh"
00006 #include "Rivet/Projections/FinalState.hh"
00007 #include "Rivet/Projections/VetoedFinalState.hh"
00008 #include "Rivet/Projections/IdentifiedFinalState.hh"
00009 #include "Rivet/Projections/LeadingParticlesFinalState.hh"
00010 
00011 
00012 namespace Rivet {
00013 
00014   using namespace Cuts;
00015 
00016 
00017   /// ATLAS Z+jets in pp at 7 TeV
00018   class ATLAS_2011_I945498 : public Analysis {
00019   public:
00020 
00021     /// Constructor
00022     ATLAS_2011_I945498()
00023       : Analysis("ATLAS_2011_I945498")
00024     {    }
00025 
00026 
00027     /// Book histograms and initialise projections before the run
00028     void init() {
00029 
00030       // Variable initialisation
00031       _isZeeSample = false;
00032       _isZmmSample = false;
00033       for (size_t chn = 0; chn < 3; ++chn) {
00034         weights_nj0[chn] = 0;
00035         weights_nj1[chn] = 0;
00036         weights_nj2[chn] = 0;
00037         weights_nj3[chn] = 0;
00038         weights_nj4[chn] = 0;
00039       }
00040 
00041       // Set up projections
00042       FinalState fs;
00043       ZFinder zfinder_mu(fs, etaIn(-2.4, 2.4) & (pT >= 20*GeV), PID::MUON, 66*GeV, 116*GeV, 0.1, ZFinder::CLUSTERNODECAY);
00044       addProjection(zfinder_mu, "ZFinder_mu");
00045 
00046       Cut cuts = ( etaIn(-2.47, -1.52)
00047            | etaIn(-1.37,  1.37)
00048            | etaIn( 1.52,  2.47) ) & (pT >= 20.0*GeV);
00049 
00050       ZFinder zfinder_el(fs, cuts, PID::ELECTRON, 66*GeV, 116*GeV, 0.1, ZFinder::CLUSTERNODECAY);
00051       addProjection(zfinder_el, "ZFinder_el");
00052 
00053       Cut cuts25_20 = etaIn(-2.5,2.5) & (pT >= 20.0*GeV);
00054       // For combined cross-sections (combined phase space + dressed level)
00055       ZFinder zfinder_comb_mu(fs, cuts25_20, PID::MUON, 66.0*GeV, 116.0*GeV, 0.1, ZFinder::CLUSTERNODECAY);
00056       addProjection(zfinder_comb_mu, "ZFinder_comb_mu");
00057       ZFinder zfinder_comb_el(fs, cuts25_20, PID::ELECTRON, 66.0*GeV, 116.0*GeV, 0.1, ZFinder::CLUSTERNODECAY);
00058       addProjection(zfinder_comb_el, "ZFinder_comb_el");
00059 
00060       // Define veto FS in order to prevent Z-decay products entering the jet algorithm
00061       VetoedFinalState remfs;
00062       remfs.addVetoOnThisFinalState(zfinder_el);
00063       remfs.addVetoOnThisFinalState(zfinder_mu);
00064       VetoedFinalState remfs_comb;
00065       remfs_comb.addVetoOnThisFinalState(zfinder_comb_el);
00066       remfs_comb.addVetoOnThisFinalState(zfinder_comb_mu);
00067 
00068       FastJets jets(remfs, FastJets::ANTIKT, 0.4);
00069       jets.useInvisibles();
00070       addProjection(jets, "jets");
00071       FastJets jets_comb(remfs_comb, FastJets::ANTIKT, 0.4);
00072       jets_comb.useInvisibles();
00073       addProjection(jets_comb, "jets_comb");
00074 
00075       // 0=el, 1=mu, 2=comb
00076       for (size_t chn = 0; chn < 3; ++chn) {
00077         _h_njet_incl[chn]  = bookHisto1D(1, 1, chn+1);
00078         _h_njet_ratio[chn] = bookScatter2D(2, 1, chn+1);
00079         _h_ptjet[chn]      = bookHisto1D(3, 1, chn+1);
00080         _h_ptlead[chn]     = bookHisto1D(4, 1, chn+1);
00081         _h_ptseclead[chn]  = bookHisto1D(5, 1, chn+1);
00082         _h_yjet[chn]       = bookHisto1D(6, 1, chn+1);
00083         _h_ylead[chn]      = bookHisto1D(7, 1, chn+1);
00084         _h_yseclead[chn]   = bookHisto1D(8, 1, chn+1);
00085         _h_mass[chn]       = bookHisto1D(9, 1, chn+1);
00086         _h_deltay[chn]     = bookHisto1D(10, 1, chn+1);
00087         _h_deltaphi[chn]   = bookHisto1D(11, 1, chn+1);
00088         _h_deltaR[chn]     = bookHisto1D(12, 1, chn+1);
00089       }
00090     }
00091 
00092 
00093     // Jet selection criteria universal for electron and muon channel
00094     /// @todo Replace with a Cut passed to jetsByPt
00095     Jets selectJets(const ZFinder* zf, const FastJets* allJets) {
00096       const FourMomentum l1 = zf->constituents()[0].momentum();
00097       const FourMomentum l2 = zf->constituents()[1].momentum();
00098       Jets jets;
00099       foreach (const Jet& jet, allJets->jetsByPt(30*GeV)) {
00100         const FourMomentum jmom = jet.momentum();
00101         if (jmom.absrap() < 4.4 &&
00102             deltaR(l1, jmom) > 0.5  && deltaR(l2, jmom) > 0.5) {
00103           jets.push_back(jet);
00104         }
00105       }
00106       return jets;
00107     }
00108 
00109 
00110     /// Perform the per-event analysis
00111     void analyze(const Event& event) {
00112       const double weight = event.weight();
00113 
00114       vector<const ZFinder*> zfs;
00115       zfs.push_back(& (applyProjection<ZFinder>(event, "ZFinder_el")));
00116       zfs.push_back(& (applyProjection<ZFinder>(event, "ZFinder_mu")));
00117       zfs.push_back(& (applyProjection<ZFinder>(event, "ZFinder_comb_el")));
00118       zfs.push_back(& (applyProjection<ZFinder>(event, "ZFinder_comb_mu")));
00119 
00120       vector<const FastJets*> fjs;
00121       fjs.push_back(& (applyProjection<FastJets>(event, "jets")));
00122       fjs.push_back(& (applyProjection<FastJets>(event, "jets_comb")));
00123 
00124       // Determine what kind of MC sample this is
00125       const bool isZee = (zfs[0]->bosons().size() == 1) || (zfs[2]->bosons().size() == 1);
00126       const bool isZmm = (zfs[1]->bosons().size() == 1) || (zfs[3]->bosons().size() == 1);
00127       if (isZee) _isZeeSample = true;
00128       if (isZmm) _isZmmSample = true;
00129 
00130       // Require exactly one electronic or muonic Z-decay in the event
00131       bool isZeemm = ( (zfs[0]->bosons().size() == 1 && zfs[1]->bosons().size() != 1) ||
00132                        (zfs[1]->bosons().size() == 1 && zfs[0]->bosons().size() != 1) );
00133       bool isZcomb = ( (zfs[2]->bosons().size() == 1 && zfs[3]->bosons().size() != 1) ||
00134                        (zfs[3]->bosons().size() == 1 && zfs[2]->bosons().size() != 1) );
00135       if (!isZeemm && !isZcomb) vetoEvent;
00136 
00137       vector<int> zfIDs;
00138       vector<int> fjIDs;
00139       if (isZeemm) {
00140         int chn = zfs[0]->bosons().size() == 1 ? 0 : 1;
00141         zfIDs.push_back(chn);
00142         fjIDs.push_back(0);
00143       }
00144       if (isZcomb) {
00145         int chn = zfs[2]->bosons().size() == 1 ? 2 : 3;
00146         zfIDs.push_back(chn);
00147         fjIDs.push_back(1);
00148       }
00149 
00150       for (size_t izf = 0; izf < zfIDs.size(); ++izf) {
00151         int zfID = zfIDs[izf];
00152         int fjID = fjIDs[izf];
00153 
00154         int chn = zfID;
00155         if (zfID == 2 || zfID == 3) chn = 2;
00156 
00157         Jets jets = selectJets(zfs[zfID], fjs[fjID]);
00158 
00159         switch (jets.size()) {
00160         case 0:
00161           weights_nj0[chn] += weight;
00162           break;
00163         case 1:
00164           weights_nj0[chn] += weight;
00165           weights_nj1[chn] += weight;
00166           break;
00167         case 2:
00168           weights_nj0[chn] += weight;
00169           weights_nj1[chn] += weight;
00170           weights_nj2[chn] += weight;
00171           break;
00172         case 3:
00173           weights_nj0[chn] += weight;
00174           weights_nj1[chn] += weight;
00175           weights_nj2[chn] += weight;
00176           weights_nj3[chn] += weight;
00177           break;
00178         default: // >= 4
00179           weights_nj0[chn] += weight;
00180           weights_nj1[chn] += weight;
00181           weights_nj2[chn] += weight;
00182           weights_nj3[chn] += weight;
00183           weights_nj4[chn] += weight;
00184         }
00185 
00186         // Require at least one jet
00187         if (jets.empty()) continue;
00188 
00189         // Fill jet multiplicities
00190         for (size_t ijet = 1; ijet <= jets.size(); ++ijet) {
00191           _h_njet_incl[chn]->fill(ijet, weight);
00192         }
00193 
00194         // Loop over selected jets, fill inclusive jet distributions
00195         for (size_t ijet = 0; ijet < jets.size(); ++ijet) {
00196           _h_ptjet[chn]->fill(jets[ijet].pT()/GeV, weight);
00197           _h_yjet [chn]->fill(fabs(jets[ijet].rapidity()), weight);
00198         }
00199 
00200         // Leading jet histos
00201         const double ptlead   = jets[0].pT()/GeV;
00202         const double yabslead = fabs(jets[0].rapidity());
00203         _h_ptlead[chn]->fill(ptlead,   weight);
00204         _h_ylead [chn]->fill(yabslead, weight);
00205 
00206         if (jets.size() >= 2) {
00207           // Second jet histos
00208           const double pt2ndlead   = jets[1].pT()/GeV;
00209           const double yabs2ndlead = fabs(jets[1].rapidity());
00210           _h_ptseclead[chn] ->fill(pt2ndlead,   weight);
00211           _h_yseclead [chn] ->fill(yabs2ndlead, weight);
00212 
00213           // Dijet histos
00214           const double deltaphi = fabs(deltaPhi(jets[1], jets[0]));
00215           const double deltarap = fabs(jets[0].rapidity() - jets[1].rapidity()) ;
00216           const double deltar   = fabs(deltaR(jets[0], jets[1], RAPIDITY));
00217           const double mass     = (jets[0].momentum() + jets[1].momentum()).mass();
00218           _h_mass    [chn] ->fill(mass/GeV, weight);
00219           _h_deltay  [chn] ->fill(deltarap, weight);
00220           _h_deltaphi[chn] ->fill(deltaphi, weight);
00221           _h_deltaR  [chn] ->fill(deltar,   weight);
00222         }
00223       }
00224     }
00225 
00226 
00227     /// @name Ratio calculator util functions
00228     //@{
00229 
00230     /// Calculate the ratio, being careful about div-by-zero
00231     double ratio(double a, double b) {
00232       return (b != 0) ? a/b : 0;
00233     }
00234 
00235     /// Calculate the ratio error, being careful about div-by-zero
00236     double ratio_err(double a, double b) {
00237       return (b != 0) ? sqrt(a/sqr(b) + sqr(a)/(b*b*b)) : 0;
00238     }
00239 
00240     //@}
00241 
00242 
00243     void finalize() {
00244       // Fill ratio histograms
00245       for (size_t chn = 0; chn < 3; ++chn) {
00246         _h_njet_ratio[chn]->addPoint(1, ratio(weights_nj1[chn], weights_nj0[chn]), 0.5, ratio_err(weights_nj1[chn], weights_nj0[chn]));
00247         _h_njet_ratio[chn]->addPoint(2, ratio(weights_nj2[chn], weights_nj1[chn]), 0.5, ratio_err(weights_nj2[chn], weights_nj1[chn]));
00248         _h_njet_ratio[chn]->addPoint(3, ratio(weights_nj3[chn], weights_nj2[chn]), 0.5, ratio_err(weights_nj3[chn], weights_nj2[chn]));
00249         _h_njet_ratio[chn]->addPoint(4, ratio(weights_nj4[chn], weights_nj3[chn]), 0.5, ratio_err(weights_nj4[chn], weights_nj3[chn]));
00250       }
00251 
00252       // Scale other histos
00253       for (size_t chn = 0; chn < 3; ++chn) {
00254         // For ee and mumu channels: normalize to Njet inclusive cross-section
00255         double xs = (chn == 2) ? crossSectionPerEvent()/picobarn : 1 / weights_nj0[chn];
00256         // For inclusive MC sample(ee/mmu channels together) we want the single-lepton-flavor xsec
00257         if (_isZeeSample && _isZmmSample) xs /= 2;
00258 
00259         // Special case histogram: always not normalized
00260         scale(_h_njet_incl[chn], (chn < 2) ? crossSectionPerEvent()/picobarn : xs);
00261 
00262         scale(_h_ptjet[chn]    , xs);
00263         scale(_h_ptlead[chn]   , xs);
00264         scale(_h_ptseclead[chn], xs);
00265         scale(_h_yjet[chn]     , xs);
00266         scale(_h_ylead[chn]    , xs);
00267         scale(_h_yseclead[chn] , xs);
00268         scale(_h_deltaphi[chn] , xs);
00269         scale(_h_deltay[chn]   , xs);
00270         scale(_h_deltaR[chn]   , xs);
00271         scale(_h_mass[chn]     , xs);
00272       }
00273 
00274     }
00275 
00276     //@}
00277 
00278 
00279   private:
00280 
00281     bool _isZeeSample;
00282     bool _isZmmSample;
00283 
00284     double weights_nj0[3];
00285     double weights_nj1[3];
00286     double weights_nj2[3];
00287     double weights_nj3[3];
00288     double weights_nj4[3];
00289 
00290     Scatter2DPtr _h_njet_ratio[3];
00291     Histo1DPtr _h_njet_incl[3];
00292     Histo1DPtr _h_ptjet[3];
00293     Histo1DPtr _h_ptlead[3];
00294     Histo1DPtr _h_ptseclead[3];
00295     Histo1DPtr _h_yjet[3];
00296     Histo1DPtr _h_ylead[3];
00297     Histo1DPtr _h_yseclead[3];
00298     Histo1DPtr _h_deltaphi[3];
00299     Histo1DPtr _h_deltay[3];
00300     Histo1DPtr _h_deltaR[3];
00301     Histo1DPtr _h_mass[3];
00302 
00303   };
00304 
00305 
00306   DECLARE_RIVET_PLUGIN(ATLAS_2011_I945498);
00307 
00308 
00309 }