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/RivetYODA.hh"
00005 #include "Rivet/Tools/ParticleIdUtils.hh"
00006 #include "Rivet/Projections/UnstableFinalState.hh"
00007 #include "Rivet/ParticleName.hh"
00008 
00009 namespace Rivet {
00010 
00011 
00012   /// @brief BABAR tau lepton to three charged hadrons
00013   /// @author Peter Richardson
00014   class BABAR_2007_S7266081 : public Analysis {
00015   public:
00016 
00017     BABAR_2007_S7266081()
00018       : Analysis("BABAR_2007_S7266081"), _weight_total(0.),
00019         _weight_pipippi(0.),_weight_Kpipi(0.),_weight_KpiK(0.),_weight_KKK(0.)
00020     { }
00021 
00022 
00023     void analyze(const Event& e) {
00024 
00025       const UnstableFinalState& ufs = applyProjection<UnstableFinalState>(e, "UFS");
00026 
00027       // find the taus
00028       ParticleVector taus;
00029       foreach (const Particle& p, ufs.particles()) {
00030         if(abs(p.pdgId())!=15) continue;
00031         _weight_total += 1.;
00032         ParticleVector pip,pim,Kp,Km;
00033         unsigned int nstable = 0.;
00034         // get the boost to the rest frame
00035         LorentzTransform cms_boost;
00036         if(p.momentum().vector3().mod()>0.001)
00037           cms_boost = LorentzTransform(-p.momentum().boostVector());
00038         // find the decay products we want
00039         findDecayProducts(p.genParticle(),nstable,pip,pim,Kp,Km);
00040         if(p.pdgId()<0) {
00041           swap(pip,pim);
00042           swap(Kp ,Km );
00043         }
00044         if(nstable!=4) continue;
00045         // pipipi
00046         if(pim.size()==2&&pip.size()==1) {
00047           _weight_pipippi += 1.;
00048           _hist_pipipi_pipipi->
00049             fill((pip[0].momentum()+pim[0].momentum()+pim[1].momentum()).mass(),1.);
00050           _hist_pipipi_pipi->
00051             fill((pip[0].momentum()+pim[0].momentum()).mass(),1.);
00052           _hist_pipipi_pipi->
00053             fill((pip[0].momentum()+pim[1].momentum()).mass(),1.);
00054         }
00055         else if(pim.size()==1&&pip.size()==1&&Km.size()==1) {
00056           _weight_Kpipi += 1.;
00057           _hist_Kpipi_Kpipi->
00058             fill((pim[0].momentum()+pip[0].momentum()+Km[0].momentum()).mass(),1.);
00059           _hist_Kpipi_Kpi->
00060             fill((pip[0].momentum()+Km[0].momentum()).mass(),1.);
00061           _hist_Kpipi_pipi->
00062             fill((pim[0].momentum()+pip[0].momentum()).mass(),1.);
00063         }
00064         else if(Kp.size()==1&&Km.size()==1&&pim.size()==1) {
00065           _weight_KpiK += 1.;
00066           _hist_KpiK_KpiK->
00067             fill((Kp[0].momentum()+Km[0].momentum()+pim[0].momentum()).mass(),1.);
00068           _hist_KpiK_KK->
00069             fill((Kp[0].momentum()+Km[0].momentum()).mass(),1.);
00070           _hist_KpiK_piK->
00071             fill((Kp[0].momentum()+pim[0].momentum()).mass(),1.);
00072         }
00073         else if(Kp.size()==1&&Km.size()==2) {
00074           _weight_KKK += 1.;
00075           _hist_KKK_KKK->
00076             fill((Kp[0].momentum()+Km[0].momentum()+Km[1].momentum()).mass(),1.);
00077           _hist_KKK_KK->
00078             fill((Kp[0].momentum()+Km[0].momentum()).mass(),1.);
00079           _hist_KKK_KK->
00080             fill((Kp[0].momentum()+Km[1].momentum()).mass(),1.);
00081         }
00082       }
00083     } // analyze
00084 
00085     void finalize() {
00086       if(_weight_pipippi>0.) {
00087         scale(_hist_pipipi_pipipi, 1./_weight_pipippi);
00088         scale(_hist_pipipi_pipi  ,0.5/_weight_pipippi);
00089       }
00090       if(_weight_Kpipi>0.) {
00091         scale(_hist_Kpipi_Kpipi  , 1./_weight_Kpipi);
00092         scale(_hist_Kpipi_Kpi    , 1./_weight_Kpipi);
00093         scale(_hist_Kpipi_pipi   , 1./_weight_Kpipi);
00094       }
00095       if(_weight_KpiK>0.) {
00096         scale(_hist_KpiK_KpiK    , 1./_weight_KpiK);
00097         scale(_hist_KpiK_KK      , 1./_weight_KpiK);
00098         scale(_hist_KpiK_piK     , 1./_weight_KpiK);
00099       }
00100       if(_weight_KKK>0.) {
00101         scale(_hist_KKK_KKK      , 1./_weight_KKK);
00102         scale(_hist_KKK_KK       ,0.5/_weight_KKK);
00103       }
00104       // @todo YODA
00105       //AIDA::IDataPointSet * br_pipipi = bookDataPointSet(11,1,1);
00106       //br_pipipi->point(0)->coordinate(1)->setValue     ( 100.*_weight_pipippi/_weight_total);
00107       //br_pipipi->point(0)->coordinate(1)->setErrorPlus ( 100.*sqrt(_weight_pipippi)/_weight_total);
00108       //br_pipipi->point(0)->coordinate(1)->setErrorMinus( 100.*sqrt(_weight_pipippi)/_weight_total);
00109       //AIDA::IDataPointSet * br_Kpipi  = bookDataPointSet(12,1,1);
00110       //br_Kpipi->point(0)->coordinate(1)->setValue     ( 100.*_weight_Kpipi/_weight_total);
00111       //br_Kpipi->point(0)->coordinate(1)->setErrorPlus ( 100.*sqrt(_weight_Kpipi)/_weight_total);
00112       //br_Kpipi->point(0)->coordinate(1)->setErrorMinus( 100.*sqrt(_weight_Kpipi)/_weight_total);
00113       //AIDA::IDataPointSet * br_KpiK   = bookDataPointSet(13,1,1);
00114       //br_KpiK->point(0)->coordinate(1)->setValue     ( 100.*_weight_KpiK/_weight_total);
00115       //br_KpiK->point(0)->coordinate(1)->setErrorPlus ( 100.*sqrt(_weight_KpiK)/_weight_total);
00116       //br_KpiK->point(0)->coordinate(1)->setErrorMinus( 100.*sqrt(_weight_KpiK)/_weight_total);
00117       //AIDA::IDataPointSet * br_KKK    = bookDataPointSet(14,1,1);
00118       //br_KKK->point(0)->coordinate(1)->setValue     ( 100.*_weight_KKK/_weight_total);
00119       //br_KKK->point(0)->coordinate(1)->setErrorPlus ( 100.*sqrt(_weight_KKK)/_weight_total);
00120       //br_KKK->point(0)->coordinate(1)->setErrorMinus( 100.*sqrt(_weight_KKK)/_weight_total);
00121     } // finalize
00122 
00123     void init() {
00124       addProjection(UnstableFinalState(), "UFS");
00125 
00126       _hist_pipipi_pipipi = bookHisto1D( 1,1,1);
00127       _hist_pipipi_pipi   = bookHisto1D( 2,1,1);
00128       _hist_Kpipi_Kpipi   = bookHisto1D( 3,1,1);
00129       _hist_Kpipi_Kpi     = bookHisto1D( 4,1,1);
00130       _hist_Kpipi_pipi    = bookHisto1D( 5,1,1);
00131       _hist_KpiK_KpiK     = bookHisto1D( 6,1,1);
00132       _hist_KpiK_KK       = bookHisto1D( 7,1,1);
00133       _hist_KpiK_piK      = bookHisto1D( 8,1,1);
00134       _hist_KKK_KKK       = bookHisto1D( 9,1,1);
00135       _hist_KKK_KK        = bookHisto1D(10,1,1);
00136 
00137     } // init
00138 
00139   private:
00140 
00141     //@{
00142     Histo1DPtr _hist_pipipi_pipipi;
00143     Histo1DPtr _hist_pipipi_pipi  ;
00144     Histo1DPtr _hist_Kpipi_Kpipi  ;
00145     Histo1DPtr _hist_Kpipi_Kpi    ;
00146     Histo1DPtr _hist_Kpipi_pipi   ;
00147     Histo1DPtr _hist_KpiK_KpiK    ;
00148     Histo1DPtr _hist_KpiK_KK      ;
00149     Histo1DPtr _hist_KpiK_piK     ;
00150     Histo1DPtr _hist_KKK_KKK      ;
00151     Histo1DPtr _hist_KKK_KK       ;
00152 
00153     // count of weights
00154     double _weight_total,_weight_pipippi,_weight_Kpipi,_weight_KpiK,_weight_KKK;
00155     //@}
00156 
00157     void findDecayProducts(const GenParticle & p, unsigned int & nstable,
00158                            ParticleVector & pip, ParticleVector & pim,
00159                            ParticleVector &  Kp, ParticleVector & Km) {
00160       const GenVertex* dv = p.end_vertex();
00161       for (GenVertex::particles_out_const_iterator
00162              pp = dv->particles_out_const_begin();
00163            pp != dv->particles_out_const_end(); ++pp) {
00164         int id = (*pp)->pdg_id();
00165         if( id == PI0 )
00166           ++nstable;
00167         else if ( id == K0S)
00168           ++nstable;
00169         else if(id==PIPLUS) {
00170           pip.push_back(Particle(**pp));
00171           ++nstable;
00172         }
00173         else if(id==PIMINUS) {
00174           pim.push_back(Particle(**pp));
00175           ++nstable;
00176         }
00177         else if(id==KPLUS) {
00178           Kp.push_back(Particle(**pp));
00179           ++nstable;
00180         }
00181         else if(id==KMINUS) {
00182           Km.push_back(Particle(**pp));
00183           ++nstable;
00184         }
00185         else if((*pp)->end_vertex()) {
00186           findDecayProducts(**pp,nstable,pip,pim,Kp,Km);
00187         }
00188         else
00189           ++nstable;
00190       }
00191     }
00192   };
00193 
00194   // The hook for the plugin system
00195   DECLARE_RIVET_PLUGIN(BABAR_2007_S7266081);
00196 
00197 }