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 #include "Rivet/RivetYODA.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005 
00006 #include "Rivet/Projections/ZFinder.hh"
00007 #include "Rivet/Particle.fhh"
00008 
00009 #include "Rivet/Projections/FastJets.hh"
00010 
00011 #include "Rivet/Projections/FinalState.hh"
00012 #include "Rivet/Projections/VetoedFinalState.hh"
00013 #include "Rivet/Projections/IdentifiedFinalState.hh"
00014 #include "Rivet/Projections/LeadingParticlesFinalState.hh"
00015 
00016 #include "Rivet/Projections/ClusteredPhotons.hh"
00017 
00018 
00019 namespace Rivet {
00020 
00021 
00022   class ATLAS_2011_I945498 : public Analysis {
00023   public:
00024 
00025     /// @name Constructors etc.
00026     //@{
00027 
00028     /// Constructor
00029     ATLAS_2011_I945498()
00030       : Analysis("ATLAS_2011_I945498")
00031     {
00032       /// @todo Set whether your finalize method needs the generator cross section
00033       setNeedsCrossSection(true);
00034       for (size_t chn = 0; chn < 3; ++chn) {
00035         weights_nj0[chn] = 0.0;
00036         weights_nj1[chn] = 0.0;
00037         weights_nj2[chn] = 0.0;
00038         weights_nj3[chn] = 0.0;
00039         weights_nj4[chn] = 0.0;
00040       }
00041     }
00042 
00043     //@}
00044 
00045 
00046   public:
00047 
00048 
00049     /// Book histograms and initialise projections before the run
00050     void init() {
00051 
00052       // Set up projections
00053       ZFinder zfinder_mu(-2.4, 2.4, 20, MUON, 66.0*GeV, 116.0*GeV, 0.1, true, false);
00054       addProjection(zfinder_mu, "ZFinder_mu");
00055 
00056       std::vector<std::pair<double, double> > eta_e;
00057       eta_e.push_back(make_pair(-2.47,-1.52));
00058       eta_e.push_back(make_pair(-1.37,1.37));
00059       eta_e.push_back(make_pair(1.52,2.47));
00060       ZFinder zfinder_el(eta_e, 20, ELECTRON, 66.0*GeV, 116.0*GeV, 0.1, true, false);
00061       addProjection(zfinder_el, "ZFinder_el");
00062 
00063       // Define veto FS in order to prevent Z-decay products entering the jet algorithm
00064       VetoedFinalState remfs;
00065       remfs.addVetoOnThisFinalState(zfinder_el);
00066       remfs.addVetoOnThisFinalState(zfinder_mu);
00067 
00068       FastJets jets(remfs, FastJets::ANTIKT, 0.4);
00069       jets.useInvisibles();
00070       addProjection(jets, "jets");
00071 
00072       // 0=el, 1=mu, 2=comb
00073       for (size_t chn = 0; chn < 3; ++chn) {
00074         _h_njet_incl[chn]  = bookHisto1D(1, 1, chn+1);
00075         _h_njet_ratio[chn] = bookScatter2D(2, 1, chn+1);
00076         _h_ptjet[chn]      = bookHisto1D(3, 1, chn+1);
00077         _h_ptlead[chn]     = bookHisto1D(4, 1, chn+1);
00078         _h_ptseclead[chn]  = bookHisto1D(5, 1, chn+1);
00079         _h_yjet[chn]       = bookHisto1D(6, 1, chn+1);
00080         _h_ylead[chn]      = bookHisto1D(7, 1, chn+1);
00081         _h_yseclead[chn]   = bookHisto1D(8, 1, chn+1);
00082         _h_mass[chn]       = bookHisto1D(9, 1, chn+1);
00083         _h_deltay[chn]     = bookHisto1D(10, 1, chn+1);
00084         _h_deltaphi[chn]   = bookHisto1D(11, 1, chn+1);
00085         _h_deltaR[chn]     = bookHisto1D(12, 1, chn+1);
00086       }
00087     }
00088 
00089     // Jet selection criteria universal for electron and muon channel
00090     Jets selectJets(const ZFinder* zf, const Event& event) {
00091       FourMomentum l1=zf->constituents()[0].momentum();
00092       FourMomentum l2=zf->constituents()[1].momentum();
00093       Jets jets;
00094 
00095       foreach (const Jet& jet, applyProjection<FastJets>(event, "jets").jetsByPt(30.0*GeV)) {
00096         FourMomentum jmom = jet.momentum();
00097         if (fabs(jmom.rapidity()) < 4.4 && deltaR(l1, jmom) > 0.5  && deltaR(l2, jmom) > 0.5) {
00098           jets.push_back(jet);
00099         }
00100       }
00101       return jets;
00102     }
00103 
00104     /// Perform the per-event analysis
00105     void analyze(const Event& event) {
00106 
00107       const double weight = event.weight();
00108 
00109       vector<const ZFinder*> zfs;
00110       zfs.push_back(& (applyProjection<ZFinder>(event, "ZFinder_el")));
00111       zfs.push_back(& (applyProjection<ZFinder>(event, "ZFinder_mu")));
00112 
00113 
00114       // Require exactly one electronic or muonic Z-decay in the event
00115       if (!( (zfs[0]->bosons().size()==1 && zfs[1]->bosons().size()!=1) || (zfs[1]->bosons().size()==1 && zfs[0]->bosons().size()!=1) )) vetoEvent;
00116 
00117       int chn = (zfs[0]->bosons().size()==1 ? 0:1);
00118 
00119       Jets jets=selectJets(zfs[chn], event);
00120 
00121 
00122       /// TODO: Holger wrote in his commit message that the njet_ratio
00123       /// histograms need fixing/checking, and therefore the analysis
00124       /// is marked unvalidated!
00125 
00126       // Some silly weight counters for the njet-ratio histo
00127       // --- not sure about the njet=0 case, the Figure ca[ption says
00128       // that selected events require at least one jet with 20 GeV
00129       if (jets.size() == 0) {
00130         weights_nj0[chn] += 1.0;
00131       }
00132       else if (jets.size() == 1) {
00133         weights_nj0[chn] += 1.0;
00134         weights_nj1[chn] += 1.0;
00135       }
00136       else if (jets.size() == 2) {
00137         weights_nj0[chn] += 1.0;
00138         weights_nj1[chn] += 1.0;
00139         weights_nj2[chn] += 1.0;
00140       }
00141       else if (jets.size() == 3) {
00142         weights_nj0[chn] += 1.0;
00143         weights_nj1[chn] += 1.0;
00144         weights_nj2[chn] += 1.0;
00145         weights_nj3[chn] += 1.0;
00146       }
00147       else if (jets.size() >= 4) {
00148         weights_nj0[chn] += 1.0;
00149         weights_nj1[chn] += 1.0;
00150         weights_nj2[chn] += 1.0;
00151         weights_nj3[chn] += 1.0;
00152         weights_nj4[chn] += 1.0;
00153       }
00154 
00155       if (jets.size() <1) vetoEvent;
00156 
00157       _h_njet_incl[chn]    ->fill(jets.size(), weight);
00158       _h_njet_incl[2]      ->fill(jets.size(), weight);
00159 
00160       // Loop over selected jets, fill inclusive jet distributions
00161       for (unsigned int ijet=0; ijet<jets.size(); ijet++){
00162         _h_ptjet[chn]     ->fill(jets[ijet].momentum().pT()/GeV, weight);
00163         _h_ptjet[2]       ->fill(jets[ijet].momentum().pT()/GeV, weight);
00164         _h_yjet[chn]      ->fill(fabs(jets[ijet].momentum().rapidity()), weight);
00165         _h_yjet[2]        ->fill(fabs(jets[ijet].momentum().rapidity()), weight);
00166       }
00167 
00168       // The leading jet histos
00169       if (jets.size()>=1) {
00170         double ptlead = jets[0].momentum().pT()/GeV;
00171         double yabslead = fabs(jets[0].momentum().rapidity());
00172         _h_ptlead[chn]   ->fill(ptlead,   weight);
00173         _h_ptlead[2]     ->fill(ptlead,   weight);
00174 
00175         _h_ylead[chn]    ->fill(yabslead, weight);
00176         _h_ylead[2]      ->fill(yabslead, weight);
00177       }
00178 
00179       if (jets.size()>=2) {
00180         // The second to leading jet histos
00181         double pt2ndlead   = jets[1].momentum().pT()/GeV;
00182         double yabs2ndlead = fabs(jets[1].momentum().rapidity());
00183 
00184         _h_ptseclead[chn]   ->fill(pt2ndlead,   weight);
00185         _h_ptseclead[2]     ->fill(pt2ndlead,   weight);
00186         _h_yseclead[chn]    ->fill(yabs2ndlead, weight);
00187         _h_yseclead[2]      ->fill(yabs2ndlead, weight);
00188 
00189         // Dijet histos
00190         double deltaphi = fabs(deltaPhi(jets[1], jets[0]));
00191         double deltarap = fabs(jets[0].momentum().rapidity() - jets[1].momentum().rapidity()) ;
00192         double deltar   = fabs(deltaR(jets[0], jets[1], RAPIDITY));
00193         double mass     = (jets[0].momentum() + jets[1].momentum()).mass();
00194 
00195         _h_mass[chn]       ->fill(mass,     weight);
00196         _h_mass[2]         ->fill(mass,     weight);
00197         _h_deltay[chn]     ->fill(deltarap, weight);
00198         _h_deltay[2]       ->fill(deltarap, weight);
00199         _h_deltaphi[chn]   ->fill(deltaphi, weight);
00200         _h_deltaphi[2]     ->fill(deltaphi, weight);
00201         _h_deltaR[chn]     ->fill(deltar,   weight);
00202         _h_deltaR[2]       ->fill(deltar,   weight);
00203       }
00204     }
00205 
00206     /// Normalise histograms etc., after the run
00207 
00208 
00209     std::vector<double> ratio(double a, double b) {
00210       double ratio=0.0;
00211       double ratio_err=0.0;
00212       std::vector<double> temp;
00213       cout << "a: " << a << " b: " << b << endl;
00214       if (b>0. && a>0.) {
00215         ratio = a/b;
00216         ratio_err = sqrt(a/pow(b,2) + pow(a,2)*b/pow(b,4));
00217       }
00218       temp.push_back(ratio);
00219       temp.push_back(ratio_err);
00220       return temp;
00221     }
00222 
00223     void finalize() {
00224 
00225       // Fill RATIO histograms (DataPointSets)
00226       vector<double> yvals_ratio[3];
00227       vector<double> yerrs_ratio[3];
00228 
00229       for (size_t chn = 0; chn < 2; ++chn) {
00230         yvals_ratio[chn].push_back(ratio(weights_nj1[chn], weights_nj0[chn])[0]);
00231         yvals_ratio[chn].push_back(ratio(weights_nj2[chn], weights_nj1[chn])[0]);
00232         yvals_ratio[chn].push_back(ratio(weights_nj3[chn], weights_nj2[chn])[0]);
00233         yvals_ratio[chn].push_back(ratio(weights_nj4[chn], weights_nj3[chn])[0]);
00234         // Errors
00235         yerrs_ratio[chn].push_back(ratio(weights_nj1[chn], weights_nj0[chn])[1]);
00236         yerrs_ratio[chn].push_back(ratio(weights_nj2[chn], weights_nj1[chn])[1]);
00237         yerrs_ratio[chn].push_back(ratio(weights_nj3[chn], weights_nj2[chn])[1]);
00238         yerrs_ratio[chn].push_back(ratio(weights_nj4[chn], weights_nj3[chn])[1]);
00239         // Actually fill histo
00240         /// \todo YODA
00241         //_h_njet_ratio[chn]  ->setCoordinate(1, yvals_ratio[chn],   yerrs_ratio[chn]);
00242         // Combined histos
00243         yvals_ratio[2].push_back(ratio(weights_nj1[chn], weights_nj0[chn])[0]);
00244         yvals_ratio[2].push_back(ratio(weights_nj2[chn], weights_nj1[chn])[0]);
00245         yvals_ratio[2].push_back(ratio(weights_nj3[chn], weights_nj2[chn])[0]);
00246         yvals_ratio[2].push_back(ratio(weights_nj4[chn], weights_nj3[chn])[0]);
00247         // Errors
00248         yerrs_ratio[2].push_back(ratio(weights_nj1[chn], weights_nj0[chn])[1]);
00249         yerrs_ratio[2].push_back(ratio(weights_nj2[chn], weights_nj1[chn])[1]);
00250         yerrs_ratio[2].push_back(ratio(weights_nj3[chn], weights_nj2[chn])[1]);
00251         yerrs_ratio[2].push_back(ratio(weights_nj4[chn], weights_nj3[chn])[1]);
00252       }
00253       /// \todo YODA
00254       //_h_njet_ratio[2]  ->setCoordinate(1, yvals_ratio[2],   yerrs_ratio[2]);
00255 
00256 
00257       const double xs = crossSectionPerEvent()/picobarn;
00258       for (size_t chn = 0; chn < 3; ++chn) {
00259         scale(_h_njet_incl[chn], xs);
00260         scale(_h_ptjet[chn]    , xs);
00261         scale(_h_ptlead[chn]   , xs);
00262         scale(_h_ptseclead[chn], xs);
00263         scale(_h_yjet[chn]     , xs);
00264         scale(_h_ylead[chn]    , xs);
00265         scale(_h_yseclead[chn] , xs);
00266         scale(_h_deltaphi[chn] , xs);
00267         scale(_h_deltay[chn]   , xs);
00268         scale(_h_deltaR[chn]   , xs);
00269         scale(_h_mass[chn]     , xs);
00270       }
00271     }
00272 
00273     //@}
00274 
00275 
00276   private:
00277 
00278     double weights_nj0[3];
00279     double weights_nj1[3];
00280     double weights_nj2[3];
00281     double weights_nj3[3];
00282     double weights_nj4[3];
00283 
00284     //
00285     Scatter2DPtr _h_njet_ratio[3];
00286     Histo1DPtr _h_njet_incl[3];
00287     Histo1DPtr _h_ptjet[3];
00288     Histo1DPtr _h_ptlead[3];
00289     Histo1DPtr _h_ptseclead[3];
00290     Histo1DPtr _h_yjet[3];
00291     Histo1DPtr _h_ylead[3];
00292     Histo1DPtr _h_yseclead[3];
00293     Histo1DPtr _h_deltaphi[3];
00294     Histo1DPtr _h_deltay[3];
00295     Histo1DPtr _h_deltaR[3];
00296     Histo1DPtr _h_mass[3];
00297 
00298   };
00299 
00300   // This global object acts as a hook for the plugin system
00301   DECLARE_RIVET_PLUGIN(ATLAS_2011_I945498);
00302 }