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