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