rivet is hosted by Hepforge, IPPP Durham
ATLAS_2010_S8914702.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include <iostream>
00003 #include <sstream>
00004 #include <string>
00005 
00006 #include "Rivet/Analysis.hh"
00007 #include "Rivet/RivetYODA.hh"
00008 #include "Rivet/Tools/Logging.hh"
00009 #include "Rivet/Projections/FinalState.hh"
00010 
00011 #include "Rivet/Projections/LeadingParticlesFinalState.hh"
00012 #include "Rivet/Jet.hh"
00013 #include "Rivet/Projections/FastJets.hh"
00014 
00015 #include "fastjet/internal/base.hh"
00016 #include "fastjet/JetDefinition.hh"
00017 #include "fastjet/AreaDefinition.hh"
00018 #include "fastjet/ClusterSequence.hh"
00019 #include "fastjet/ClusterSequenceArea.hh"
00020 #include "fastjet/PseudoJet.hh"
00021 
00022 namespace Rivet {
00023 
00024 
00025   class ATLAS_2010_S8914702 : public Analysis {
00026   public:
00027 
00028     /// Constructor
00029     ATLAS_2010_S8914702()
00030       : Analysis("ATLAS_2010_S8914702")
00031     {
00032       _eta_bins.push_back( 0.00);
00033       _eta_bins.push_back( 0.60);
00034       _eta_bins.push_back( 1.37);
00035       _eta_bins.push_back( 1.52);
00036       _eta_bins.push_back( 1.81);
00037 
00038       _eta_bins_areaoffset.push_back(0.0);
00039       _eta_bins_areaoffset.push_back(1.5);
00040       _eta_bins_areaoffset.push_back(3.0);
00041     }
00042 
00043 
00044     /// Book histograms and initialise projections before the run
00045     void init() {
00046       FinalState fs;
00047       addProjection(fs, "FS");
00048 
00049       FastJets fj(fs, FastJets::KT, 0.5);
00050       _area_def = new fastjet::AreaDefinition(fastjet::VoronoiAreaSpec());
00051       fj.useJetArea(_area_def);
00052       addProjection(fj, "KtJetsD05");
00053 
00054       LeadingParticlesFinalState photonfs(FinalState(-1.81, 1.81, 15.0*GeV));
00055       photonfs.addParticleId(PHOTON);
00056       addProjection(photonfs, "LeadingPhoton");
00057 
00058       int hist_bin = 0;
00059       for (int i = 0; i < (int)_eta_bins.size()-1; ++i) {
00060         if (fabs(_eta_bins[i] - 1.37) < .0001) continue;
00061         _h_Et_photon[i] = bookHisto1D(1, 1, hist_bin+1);
00062         hist_bin += 1;
00063       }
00064     }
00065 
00066 
00067     int getEtaBin(double eta_w, bool area_eta) const {
00068       double eta = fabs(eta_w);
00069       int v_iter = 0;
00070       if (!area_eta) {
00071         for (v_iter=0; v_iter < (int)_eta_bins.size()-1; ++v_iter) {
00072           if (eta >= _eta_bins.at(v_iter) && eta < _eta_bins.at(v_iter+1)) break;
00073         }
00074       } else {
00075         for (v_iter=0; v_iter < (int)_eta_bins_areaoffset.size()-1; ++v_iter) {
00076           if (eta >= _eta_bins_areaoffset.at(v_iter) && eta < _eta_bins_areaoffset.at(v_iter+1)) break;
00077         }
00078       }
00079       return v_iter;
00080     }
00081 
00082 
00083     /// Perform the per-event analysis
00084     void analyze(const Event& event) {
00085       const double weight = event.weight();
00086 
00087       ParticleVector photons = applyProjection<LeadingParticlesFinalState>(event, "LeadingPhoton").particles();
00088       if (photons.size() != 1) {
00089         vetoEvent;
00090       }
00091 
00092       FourMomentum leadingPhoton = photons[0].momentum();
00093       double eta_P = leadingPhoton.eta();
00094       double phi_P = leadingPhoton.phi();
00095 
00096       if(fabs(eta_P)>=1.37 && fabs(eta_P)<1.52){
00097         vetoEvent;
00098       }
00099 
00100       int eta_bin = getEtaBin(eta_P,false);
00101 
00102       ParticleVector fs = applyProjection<FinalState>(event, "FS").particles();
00103       FourMomentum mom_in_EtCone;
00104       foreach (const Particle& p, fs) {
00105         // check if it's in the cone of .4
00106         if (deltaR(eta_P, phi_P, p.momentum().eta(), p.momentum().phi()) >= 0.4) continue;
00107 
00108         // check if it's in the 5x7 central core
00109         if (fabs(eta_P-p.momentum().eta()) < .025*7.0*0.5 &&
00110             fabs(phi_P-p.momentum().phi()) < (PI/128.)*5.0*0.5) continue;
00111         mom_in_EtCone += p.momentum();
00112       }
00113       MSG_DEBUG("Done with initial EtCone.");
00114 
00115       // Now compute the median energy density
00116       _ptDensity.clear();
00117       _sigma.clear();
00118       _Njets.clear();
00119 
00120       std::vector< std::vector<double> > ptDensities;
00121       std::vector<double> emptyVec;
00122       ptDensities.assign(_eta_bins_areaoffset.size()-1,emptyVec);
00123 
00124       const fastjet::ClusterSequenceArea* clust_seq_area = applyProjection<FastJets>(event, "KtJetsD05").clusterSeqArea();
00125       foreach (const fastjet::PseudoJet& jet, applyProjection<FastJets>(event, "KtJetsD05").pseudoJets(0.0*GeV)) {
00126         //const double y = fabs(jet.rapidity());
00127         const double eta = fabs(jet.eta());
00128         const double pt = fabs(jet.perp());
00129 
00130         // Get the cluster sequence
00131         double area = clust_seq_area->area(jet);
00132 
00133         if (area > 10e-4 && fabs(eta)<_eta_bins_areaoffset[_eta_bins_areaoffset.size()-1]) {
00134           ptDensities.at(getEtaBin(fabs(eta),true)).push_back(pt/area);
00135         }
00136       }
00137 
00138       for (int b = 0; b < (int)_eta_bins_areaoffset.size()-1; ++b) {
00139         double median = 0.0;
00140         double sigma = 0.0;
00141         int Njets = 0;
00142         if (ptDensities[b].size() > 0) {
00143           std::sort(ptDensities[b].begin(), ptDensities[b].end());
00144           int nDens = ptDensities[b].size();
00145           if (nDens % 2 == 0) {
00146             median = (ptDensities[b][nDens/2]+ptDensities[b][(nDens-2)/2])/2;
00147           } else {
00148             median = ptDensities[b][(nDens-1)/2];
00149           }
00150           sigma = ptDensities[b][(int)(.15865*nDens)];
00151           Njets = nDens;
00152         }
00153         _ptDensity.push_back(median);
00154         _sigma.push_back(sigma);
00155         _Njets.push_back(Njets);
00156       }
00157 
00158       // Now figure out the correction
00159       float EtCone_area = PI*.4*.4 - (7.0*.025)*(5.0*PI/128.);
00160       float correction = _ptDensity[getEtaBin(eta_P,true)]*EtCone_area;
00161       MSG_DEBUG("Jet area correction done.");
00162 
00163       // Shouldn't need to subtract photon
00164       // NB. Using expected cut at hadron/particle level, not cut at reco level
00165       if (mom_in_EtCone.Et() - correction/*-leadingPhoton.Et()*/ > 4.0*GeV) {
00166         vetoEvent;
00167       }
00168       MSG_DEBUG("Passed isolation cut.");
00169 
00170       _h_Et_photon[eta_bin]->fill(leadingPhoton.Et(), weight);
00171     }
00172 
00173 
00174     /// Normalise histograms etc., after the run
00175     void finalize() {
00176       for (int i = 0; i < (int)_eta_bins.size()-1; ++i) {
00177         if (fabs(_eta_bins[i] - 1.37) < .0001) continue;
00178         scale(_h_Et_photon[i], crossSection()/sumOfWeights());
00179       }
00180     }
00181 
00182 
00183   private:
00184 
00185     Histo1DPtr _h_Et_photon[6];
00186 
00187     fastjet::AreaDefinition* _area_def;
00188 
00189     std::vector<float> _eta_bins;
00190     std::vector<float> _eta_bins_areaoffset;
00191 
00192     std::vector<float> _ptDensity;
00193     std::vector<float> _sigma;
00194     std::vector<float> _Njets;
00195   };
00196 
00197 
00198 
00199   // The hook for the plugin system
00200   DECLARE_RIVET_PLUGIN(ATLAS_2010_S8914702);
00201 
00202 }