MC_WPOL.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.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       WFinder wfinder(-MAXRAPIDITY, MAXRAPIDITY, 0.0*GeV, ELECTRON,
00037                       60.0*GeV, 100.0*GeV, 0.0*GeV, 0.0);
00038       addProjection(wfinder, "WFinder");
00039       Beam beams;
00040       addProjection(beams, "Beams");
00041 
00042       vector<string> tags;
00043       tags += "_wplus", "_wminus";
00044       _h_dists.resize(tags.size());
00045       _h_histos.resize(tags.size());
00046       for (size_t i=0; i<tags.size(); ++i) {
00047         _h_dists[i].resize(11,NULL);
00048         _h_dists[i][0] = bookProfile1D("A0"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00049         _h_dists[i][1] = bookProfile1D("A1"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00050         _h_dists[i][2] = bookProfile1D("A2"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00051         _h_dists[i][3] = bookProfile1D("A3"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00052         _h_dists[i][4] = bookProfile1D("A4"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00053         _h_dists[i][5] = bookProfile1D("A5"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00054         _h_dists[i][6] = bookProfile1D("A6"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00055         _h_dists[i][7] = bookProfile1D("A7"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00056         _h_dists[i][8] = bookProfile1D("fL"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00057         _h_dists[i][9] = bookProfile1D("fR"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00058         _h_dists[i][10] = bookProfile1D("f0"+tags[i],logBinEdges(100, 1.0, 0.5*sqrtS()));
00059         _h_histos[i].resize(4,NULL);
00060         _h_histos[i][0] = bookHistogram1D("thetastar"+tags[i],100,-1.0,1.0);
00061         _h_histos[i][1] = bookHistogram1D("phistar"+tags[i],90,0.0,360.0);
00062         _h_histos[i][2] = bookHistogram1D("thetastar_ptw20"+tags[i],100,-1.0,1.0);
00063         _h_histos[i][3] = bookHistogram1D("phistar_ptw20"+tags[i],90,0.0,360.0);
00064       }
00065     }
00066 
00067 
00068     /// Perform the per-event analysis
00069     void analyze(const Event& event) {
00070       const double weight = event.weight();
00071 
00072       const WFinder& wfinder = applyProjection<WFinder>(event, "WFinder");
00073       if (wfinder.bosons().size() != 1) {
00074         vetoEvent;
00075       }
00076       const ParticlePair& beams = applyProjection<Beam>(event, "Beams").beams();
00077 
00078       FourMomentum pb1(beams.second.momentum()), pb2(beams.first.momentum());
00079       Particle lepton=wfinder.constituentLeptons()[0];
00080       FourMomentum pl(lepton.momentum());
00081       size_t idx = (PID::threeCharge(lepton.pdgId())>0 ? 0 : 1);
00082       FourMomentum plnu(wfinder.bosons()[0].momentum());
00083 
00084       LorentzTransform cms(-plnu.boostVector());
00085       Matrix3 zrot(plnu.vector3(), Vector3(0.0, 0.0, 1.0));
00086       pl=cms.transform(pl);
00087       pb1=cms.transform(pb1);
00088       pb2=cms.transform(pb2);
00089       Vector3 pl3=pl.vector3();
00090       Vector3 pb13=pb1.vector3();
00091       Vector3 pb23=pb2.vector3();
00092       pl3=zrot*pl3;
00093       pb13=zrot*pb13;
00094       pb23=zrot*pb23;
00095       Vector3 xref(cos(pb13.theta())>cos(pb23.theta())?pb13:pb23);
00096       Matrix3 xrot(Vector3(xref.x(), xref.y(), 0.0), Vector3(1.0, 0.0, 0.0));
00097       pl3=xrot*pl3;
00098 
00099       double ptw(wfinder.bosons()[0].momentum().pT()/GeV);
00100       double thetas(pl3.theta()), phis(pl3.phi());
00101       double costhetas(cos(thetas)), sinthetas(sin(thetas));
00102       double cosphis(cos(phis)), sinphis(sin(phis));
00103       if (phis<0.0) phis+=2.0*M_PI;
00104 
00105       _h_histos[idx][0]->fill(costhetas,weight);
00106       _h_histos[idx][1]->fill(phis*180.0/M_PI,weight);
00107       if (ptw>20.0) {
00108         _h_histos[idx][2]->fill(costhetas,weight);
00109         _h_histos[idx][3]->fill(phis*180.0/M_PI,weight);
00110       }
00111       _h_dists[idx][0]->fill(ptw,10.0/3.0*(1.0-3.0*sqr(costhetas))+2.0/3.0,weight);
00112       _h_dists[idx][1]->fill(ptw,10.0*sinthetas*costhetas*cosphis,weight);
00113       _h_dists[idx][2]->fill(ptw,10.0*sqr(sinthetas)*(sqr(cosphis)-sqr(sinphis)),weight);
00114       _h_dists[idx][3]->fill(ptw,4.0*sinthetas*cosphis,weight);
00115       _h_dists[idx][4]->fill(ptw,4.0*costhetas,weight);
00116       _h_dists[idx][5]->fill(ptw,4.0*sinthetas*sinphis,weight);
00117       _h_dists[idx][6]->fill(ptw,10.0*costhetas*sinthetas*sinphis,weight);
00118       _h_dists[idx][7]->fill(ptw,10.0*sqr(sinthetas)*cosphis*sinphis,weight);
00119       _h_dists[idx][8]->fill(ptw,0.5*sqr(1.0-costhetas)-(1.0-2.0*sqr(costhetas)),weight);
00120       _h_dists[idx][9]->fill(ptw,0.5*sqr(1.0+costhetas)-(1.0-2.0*sqr(costhetas)),weight);
00121       _h_dists[idx][10]->fill(ptw,5.0*sqr(sinthetas)-3.0,weight);
00122 
00123     }
00124 
00125 
00126     /// Normalise histograms etc., after the run
00127     void finalize() {
00128 
00129       for (size_t i=0; i<_h_histos.size(); ++i) {
00130         foreach (AIDA::IHistogram1D* histo, _h_histos[i]) {
00131           scale(histo, crossSectionPerEvent());
00132         }
00133       }
00134 
00135     }
00136 
00137     //@}
00138 
00139 
00140   private:
00141 
00142     /// @name Histograms
00143     //@{
00144 
00145     std::vector<std::vector<AIDA::IProfile1D*> > _h_dists;
00146     std::vector<std::vector<AIDA::IHistogram1D*> > _h_histos;
00147     //@}
00148 
00149 
00150   };
00151 
00152 
00153 
00154   // The hook for the plugin system
00155   DECLARE_RIVET_PLUGIN(MC_WPOL);
00156 
00157 }