rivet is hosted by Hepforge, IPPP Durham
BABAR_2007_S7266081.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include <iostream>
00003 #include "Rivet/Analysis.hh"
00004 #include "Rivet/Projections/UnstableFinalState.hh"
00005 #include "Rivet/ParticleName.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// @brief BABAR tau lepton to three charged hadrons
00011   /// @author Peter Richardson
00012   class BABAR_2007_S7266081 : public Analysis {
00013   public:
00014 
00015     BABAR_2007_S7266081()
00016       : Analysis("BABAR_2007_S7266081"),
00017         _weight_total(0),
00018         _weight_pipipi(0), _weight_Kpipi(0), _weight_KpiK(0), _weight_KKK(0)
00019     {   }
00020 
00021 
00022     void init() {
00023       addProjection(UnstableFinalState(), "UFS");
00024       _hist_pipipi_pipipi = bookHisto1D( 1, 1, 1);
00025       _hist_pipipi_pipi   = bookHisto1D( 2, 1, 1);
00026       _hist_Kpipi_Kpipi   = bookHisto1D( 3, 1, 1);
00027       _hist_Kpipi_Kpi     = bookHisto1D( 4, 1, 1);
00028       _hist_Kpipi_pipi    = bookHisto1D( 5, 1, 1);
00029       _hist_KpiK_KpiK     = bookHisto1D( 6, 1, 1);
00030       _hist_KpiK_KK       = bookHisto1D( 7, 1, 1);
00031       _hist_KpiK_piK      = bookHisto1D( 8, 1, 1);
00032       _hist_KKK_KKK       = bookHisto1D( 9, 1, 1);
00033       _hist_KKK_KK        = bookHisto1D(10, 1, 1);
00034     }
00035 
00036 
00037     void analyze(const Event& e) {
00038       // Find the taus
00039       Particles taus;
00040       const UnstableFinalState& ufs = applyProjection<UnstableFinalState>(e, "UFS");
00041       foreach (const Particle& p, ufs.particles()) {
00042         if (abs(p.pdgId()) != PID::TAU) continue;
00043         _weight_total += 1.;
00044         Particles pip, pim, Kp, Km;
00045         unsigned int nstable = 0;
00046         // get the boost to the rest frame
00047         LorentzTransform cms_boost;
00048         if (p.momentum().vector3().mod() > 1*MeV)
00049           cms_boost = LorentzTransform(-p.momentum().boostVector());
00050         // find the decay products we want
00051         findDecayProducts(p.genParticle(), nstable, pip, pim, Kp, Km);
00052         if (p.pdgId() < 0) {
00053           swap(pip, pim);
00054           swap(Kp, Km );
00055         }
00056         if (nstable != 4) continue;
00057         // pipipi
00058         if (pim.size() == 2 && pip.size() == 1) {
00059           _weight_pipipi += 1.;
00060           _hist_pipipi_pipipi->
00061             fill((pip[0].momentum()+pim[0].momentum()+pim[1].momentum()).mass(),1.);
00062           _hist_pipipi_pipi->
00063             fill((pip[0].momentum()+pim[0].momentum()).mass(),1.);
00064           _hist_pipipi_pipi->
00065             fill((pip[0].momentum()+pim[1].momentum()).mass(),1.);
00066         }
00067         else if (pim.size() == 1 && pip.size() == 1 && Km.size() == 1) {
00068           _weight_Kpipi += 1.;
00069           _hist_Kpipi_Kpipi->
00070             fill((pim[0].momentum()+pip[0].momentum()+Km[0].momentum()).mass(),1.);
00071           _hist_Kpipi_Kpi->
00072             fill((pip[0].momentum()+Km[0].momentum()).mass(),1.);
00073           _hist_Kpipi_pipi->
00074             fill((pim[0].momentum()+pip[0].momentum()).mass(),1.);
00075         }
00076         else if (Kp.size() == 1 && Km.size() == 1 && pim.size() == 1) {
00077           _weight_KpiK += 1.;
00078           _hist_KpiK_KpiK->
00079             fill((Kp[0].momentum()+Km[0].momentum()+pim[0].momentum()).mass(),1.);
00080           _hist_KpiK_KK->
00081             fill((Kp[0].momentum()+Km[0].momentum()).mass(),1.);
00082           _hist_KpiK_piK->
00083             fill((Kp[0].momentum()+pim[0].momentum()).mass(),1.);
00084         }
00085         else if (Kp.size() == 1 && Km.size() == 2) {
00086           _weight_KKK += 1.;
00087           _hist_KKK_KKK->
00088             fill((Kp[0].momentum()+Km[0].momentum()+Km[1].momentum()).mass(),1.);
00089           _hist_KKK_KK->
00090             fill((Kp[0].momentum()+Km[0].momentum()).mass(),1.);
00091           _hist_KKK_KK->
00092             fill((Kp[0].momentum()+Km[1].momentum()).mass(),1.);
00093         }
00094       }
00095     }
00096 
00097 
00098     void finalize() {
00099       if (_weight_pipipi > 0.) {
00100         scale(_hist_pipipi_pipipi, 1.0/_weight_pipipi);
00101         scale(_hist_pipipi_pipi  , 0.5/_weight_pipipi);
00102       }
00103       if (_weight_Kpipi > 0.) {
00104         scale(_hist_Kpipi_Kpipi  , 1.0/_weight_Kpipi);
00105         scale(_hist_Kpipi_Kpi    , 1.0/_weight_Kpipi);
00106         scale(_hist_Kpipi_pipi   , 1.0/_weight_Kpipi);
00107       }
00108       if (_weight_KpiK > 0.) {
00109         scale(_hist_KpiK_KpiK    , 1.0/_weight_KpiK);
00110         scale(_hist_KpiK_KK      , 1.0/_weight_KpiK);
00111         scale(_hist_KpiK_piK     , 1.0/_weight_KpiK);
00112       }
00113       if (_weight_KKK > 0.) {
00114         scale(_hist_KKK_KKK      , 1.0/_weight_KKK);
00115         scale(_hist_KKK_KK       , 0.5/_weight_KKK);
00116       }
00117       /// @note Using autobooking for these scatters since their x values are not really obtainable from the MC data
00118       bookScatter2D(11, 1, 1, true)->point(0).setY(100*_weight_pipipi/_weight_total, 100*sqrt(_weight_pipipi)/_weight_total);
00119       bookScatter2D(12, 1, 1, true)->point(0).setY(100*_weight_Kpipi/_weight_total, 100*sqrt(_weight_Kpipi)/_weight_total);
00120       bookScatter2D(13, 1, 1, true)->point(0).setY(100*_weight_KpiK/_weight_total, 100*sqrt(_weight_KpiK)/_weight_total);
00121       bookScatter2D(14, 1, 1, true)->point(0).setY(100*_weight_KKK/_weight_total, 100*sqrt(_weight_KKK)/_weight_total);
00122     }
00123 
00124 
00125   private:
00126 
00127     //@{
00128 
00129     // Histograms
00130     Histo1DPtr _hist_pipipi_pipipi, _hist_pipipi_pipi;
00131     Histo1DPtr _hist_Kpipi_Kpipi, _hist_Kpipi_Kpi, _hist_Kpipi_pipi;
00132     Histo1DPtr _hist_KpiK_KpiK, _hist_KpiK_KK, _hist_KpiK_piK;
00133     Histo1DPtr _hist_KKK_KKK, _hist_KKK_KK;
00134 
00135     // Weights counters
00136     double _weight_total, _weight_pipipi, _weight_Kpipi, _weight_KpiK, _weight_KKK;
00137 
00138     //@}
00139 
00140     void findDecayProducts(const GenParticle* p,
00141                            unsigned int & nstable,
00142                            Particles& pip, Particles& pim,
00143                            Particles& Kp, Particles& Km) {
00144       const GenVertex* dv = p->end_vertex();
00145       /// @todo Use better looping
00146       for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin(); pp != dv->particles_out_const_end(); ++pp) {
00147         int id = (*pp)->pdg_id();
00148         if (id == PID::PI0 )
00149           ++nstable;
00150         else if (id == PID::K0S)
00151           ++nstable;
00152         else if (id == PID::PIPLUS) {
00153           pip.push_back(Particle(**pp));
00154           ++nstable;
00155         }
00156         else if (id == PID::PIMINUS) {
00157           pim.push_back(Particle(**pp));
00158           ++nstable;
00159         }
00160         else if (id == PID::KPLUS) {
00161           Kp.push_back(Particle(**pp));
00162           ++nstable;
00163         }
00164         else if (id == PID::KMINUS) {
00165           Km.push_back(Particle(**pp));
00166           ++nstable;
00167         }
00168         else if ((*pp)->end_vertex()) {
00169           findDecayProducts(*pp, nstable, pip, pim, Kp, Km);
00170         }
00171         else
00172           ++nstable;
00173       }
00174     }
00175 
00176 
00177   };
00178 
00179 
00180   // The hook for the plugin system
00181   DECLARE_RIVET_PLUGIN(BABAR_2007_S7266081);
00182 
00183 }