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