rivet is hosted by Hepforge, IPPP Durham
MC_WPOL.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 #include "Rivet/Projections/FinalState.hh"
00006 #include "Rivet/Projections/WFinder.hh"
00007 #include "Rivet/Projections/Beam.hh"
00008 #include "Rivet/Tools/ParticleIdUtils.hh"
00009 
00010 namespace Rivet {
00011 
00012 
00013   /// @brief MC validation analysis for W polarisation
00014   class MC_WPOL : public Analysis {
00015   public:
00016 
00017     /// @name Constructors etc.
00018     //@{
00019 
00020     /// Constructor
00021     MC_WPOL()
00022       : Analysis("MC_WPOL")
00023     {    }
00024 
00025     //@}
00026 
00027 
00028   public:
00029 
00030     /// @name Analysis methods
00031     //@{
00032 
00033     /// Book histograms and initialise projections before the run
00034     void init() {
00035 
00036       FinalState fs;
00037       WFinder wfinder(fs, -MAXRAPIDITY, MAXRAPIDITY, 0.0*GeV, ELECTRON,
00038                       60.0*GeV, 100.0*GeV, 0.0*GeV, 0.0);
00039       addProjection(wfinder, "WFinder");
00040       Beam beams;
00041       addProjection(beams, "Beams");
00042 
00043       vector<string> tags;
00044       tags += "_wplus", "_wminus";
00045       _h_dists.resize(tags.size());
00046       _h_histos.resize(tags.size());
00047       for (size_t i=0; i<tags.size(); ++i) {
00048         _h_dists[i].resize(11,Profile1DPtr());
00049         _h_dists[i][0] = bookProfile1D("A0"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00050         _h_dists[i][1] = bookProfile1D("A1"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00051         _h_dists[i][2] = bookProfile1D("A2"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00052         _h_dists[i][3] = bookProfile1D("A3"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00053         _h_dists[i][4] = bookProfile1D("A4"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00054         _h_dists[i][5] = bookProfile1D("A5"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00055         _h_dists[i][6] = bookProfile1D("A6"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00056         _h_dists[i][7] = bookProfile1D("A7"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00057         _h_dists[i][8] = bookProfile1D("fL"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00058         _h_dists[i][9] = bookProfile1D("fR"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00059         _h_dists[i][10] = bookProfile1D("f0"+tags[i],logspace(100, 1.0, 0.5*sqrtS()));
00060         _h_histos[i].resize(4,Histo1DPtr());
00061         _h_histos[i][0] = bookHisto1D("thetastar"+tags[i],100,-1.0,1.0);
00062         _h_histos[i][1] = bookHisto1D("phistar"+tags[i],90,0.0,360.0);
00063         _h_histos[i][2] = bookHisto1D("thetastar_ptw20"+tags[i],100,-1.0,1.0);
00064         _h_histos[i][3] = bookHisto1D("phistar_ptw20"+tags[i],90,0.0,360.0);
00065       }
00066     }
00067 
00068 
00069     /// Perform the per-event analysis
00070     void analyze(const Event& event) {
00071       const double weight = event.weight();
00072 
00073       const WFinder& wfinder = applyProjection<WFinder>(event, "WFinder");
00074       if (wfinder.bosons().size() != 1) {
00075         vetoEvent;
00076       }
00077       const ParticlePair& beams = applyProjection<Beam>(event, "Beams").beams();
00078 
00079       FourMomentum pb1(beams.second.momentum()), pb2(beams.first.momentum());
00080       Particle lepton=wfinder.constituentLeptons()[0];
00081       FourMomentum pl(lepton.momentum());
00082       size_t idx = (PID::threeCharge(lepton.pdgId())>0 ? 0 : 1);
00083       FourMomentum plnu(wfinder.bosons()[0].momentum());
00084 
00085       LorentzTransform cms(-plnu.boostVector());
00086       Matrix3 zrot(plnu.vector3(), Vector3(0.0, 0.0, 1.0));
00087       pl=cms.transform(pl);
00088       pb1=cms.transform(pb1);
00089       pb2=cms.transform(pb2);
00090       Vector3 pl3=pl.vector3();
00091       Vector3 pb13=pb1.vector3();
00092       Vector3 pb23=pb2.vector3();
00093       pl3=zrot*pl3;
00094       pb13=zrot*pb13;
00095       pb23=zrot*pb23;
00096       Vector3 xref(cos(pb13.theta())>cos(pb23.theta())?pb13:pb23);
00097       Matrix3 xrot(Vector3(xref.x(), xref.y(), 0.0), Vector3(1.0, 0.0, 0.0));
00098       pl3=xrot*pl3;
00099 
00100       double ptw(wfinder.bosons()[0].momentum().pT()/GeV);
00101       double thetas(pl3.theta()), phis(pl3.phi());
00102       double costhetas(cos(thetas)), sinthetas(sin(thetas));
00103       double cosphis(cos(phis)), sinphis(sin(phis));
00104       if (phis<0.0) phis+=2.0*M_PI;
00105 
00106       _h_histos[idx][0]->fill(costhetas,weight);
00107       _h_histos[idx][1]->fill(phis*180.0/M_PI,weight);
00108       if (ptw>20.0) {
00109         _h_histos[idx][2]->fill(costhetas,weight);
00110         _h_histos[idx][3]->fill(phis*180.0/M_PI,weight);
00111       }
00112       _h_dists[idx][0]->fill(ptw,10.0/3.0*(1.0-3.0*sqr(costhetas))+2.0/3.0,weight);
00113       _h_dists[idx][1]->fill(ptw,10.0*sinthetas*costhetas*cosphis,weight);
00114       _h_dists[idx][2]->fill(ptw,10.0*sqr(sinthetas)*(sqr(cosphis)-sqr(sinphis)),weight);
00115       _h_dists[idx][3]->fill(ptw,4.0*sinthetas*cosphis,weight);
00116       _h_dists[idx][4]->fill(ptw,4.0*costhetas,weight);
00117       _h_dists[idx][5]->fill(ptw,4.0*sinthetas*sinphis,weight);
00118       _h_dists[idx][6]->fill(ptw,10.0*costhetas*sinthetas*sinphis,weight);
00119       _h_dists[idx][7]->fill(ptw,10.0*sqr(sinthetas)*cosphis*sinphis,weight);
00120       _h_dists[idx][8]->fill(ptw,0.5*sqr(1.0-costhetas)-(1.0-2.0*sqr(costhetas)),weight);
00121       _h_dists[idx][9]->fill(ptw,0.5*sqr(1.0+costhetas)-(1.0-2.0*sqr(costhetas)),weight);
00122       _h_dists[idx][10]->fill(ptw,5.0*sqr(sinthetas)-3.0,weight);
00123 
00124     }
00125 
00126 
00127     /// Normalise histograms etc., after the run
00128     void finalize() {
00129 
00130       for (size_t i=0; i<_h_histos.size(); ++i) {
00131         foreach (Histo1DPtr histo, _h_histos[i]) {
00132           scale(histo, crossSectionPerEvent());
00133         }
00134       }
00135 
00136     }
00137 
00138     //@}
00139 
00140 
00141   private:
00142 
00143     /// @name Histograms
00144     //@{
00145 
00146     std::vector<std::vector<Profile1DPtr> > _h_dists;
00147     std::vector<std::vector<Histo1DPtr> > _h_histos;
00148     //@}
00149 
00150 
00151   };
00152 
00153 
00154 
00155   // The hook for the plugin system
00156   DECLARE_RIVET_PLUGIN(MC_WPOL);
00157 
00158 }