rivet is hosted by Hepforge, IPPP Durham
BABAR_2003_I593379.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Projections/Beam.hh"
00004 #include "Rivet/Projections/UnstableFinalState.hh"
00005 
00006 namespace Rivet {
00007 
00008 
00009   /// @brief Babar charmonium spectra
00010   /// @author Peter Richardson
00011   class BABAR_2003_I593379 : public Analysis {
00012   public:
00013 
00014     BABAR_2003_I593379()
00015       : Analysis("BABAR_2003_I593379"), _weightSum(0.)
00016     { }
00017 
00018 
00019     void analyze(const Event& e) {
00020       const double weight = e.weight();
00021 
00022       // Find the charmonia
00023       Particles upsilons;
00024       // First in unstable final state
00025       const UnstableFinalState& ufs = apply<UnstableFinalState>(e, "UFS");
00026       foreach (const Particle& p, ufs.particles())
00027         if (p.pid() == 300553) upsilons.push_back(p);
00028       // Then in whole event if fails
00029       if (upsilons.empty()) {
00030         foreach (const GenParticle* p, Rivet::particles(e.genEvent())) {
00031           if (p->pdg_id() != 300553) continue;
00032           const GenVertex* pv = p->production_vertex();
00033           bool passed = true;
00034           if (pv) {
00035             foreach (const GenParticle* pp, particles_in(pv)) {
00036               if ( p->pdg_id() == pp->pdg_id() ) {
00037                 passed = false;
00038                 break;
00039               }
00040             }
00041           }
00042           if (passed) upsilons.push_back(Particle(*p));
00043         }
00044       }
00045 
00046       // Find upsilons
00047       foreach (const Particle& p, upsilons) {
00048         _weightSum += weight;
00049         // Find the charmonium resonances
00050         /// @todo Use Rivet::Particles
00051         vector<const GenParticle*> allJpsi, primaryJpsi, Psiprime, all_chi_c1, all_chi_c2, primary_chi_c1, primary_chi_c2;
00052         findDecayProducts(p.genParticle(), allJpsi, primaryJpsi, Psiprime,
00053                           all_chi_c1, all_chi_c2, primary_chi_c1, primary_chi_c2);
00054         const LorentzTransform cms_boost = LorentzTransform::mkFrameTransformFromBeta(p.mom().betaVec());
00055         for (size_t i = 0; i < allJpsi.size(); i++) {
00056           const double pcm = cms_boost.transform(FourMomentum(allJpsi[i]->momentum())).p();
00057           _hist_all_Jpsi->fill(pcm, weight);
00058         }
00059         _mult_JPsi->fill(10.58, weight*double(allJpsi.size()));
00060         for (size_t i = 0; i < primaryJpsi.size(); i++) {
00061           const double pcm = cms_boost.transform(FourMomentum(primaryJpsi[i]->momentum())).p();
00062           _hist_primary_Jpsi->fill(pcm, weight);
00063         }
00064         _mult_JPsi_direct->fill(10.58, weight*double(primaryJpsi.size()));
00065         for (size_t i=0; i<Psiprime.size(); i++) {
00066           const double pcm = cms_boost.transform(FourMomentum(Psiprime[i]->momentum())).p();
00067           _hist_Psi_prime->fill(pcm, weight);
00068         }
00069         _mult_Psi2S->fill(10.58, weight*double(Psiprime.size()));
00070         for (size_t i = 0; i < all_chi_c1.size(); i++) {
00071           const double pcm = cms_boost.transform(FourMomentum(all_chi_c1[i]->momentum())).p();
00072           _hist_chi_c1->fill(pcm, weight);
00073         }
00074         _mult_chi_c1->fill(10.58, weight*double(all_chi_c1.size()));
00075         _mult_chi_c1_direct->fill(10.58, weight*double(primary_chi_c1.size()));
00076         for (size_t i = 0; i < all_chi_c2.size(); i++) {
00077           const double pcm = cms_boost.transform(FourMomentum(all_chi_c2[i]->momentum())).p();
00078           _hist_chi_c2->fill(pcm, weight);
00079         }
00080         _mult_chi_c2->fill(10.58, weight*double(all_chi_c2.size()));
00081         _mult_chi_c2_direct->fill(10.58, weight*double(primary_chi_c2.size()));
00082       }
00083     } // analyze
00084 
00085 
00086     void finalize() {
00087       scale(_hist_all_Jpsi     , 0.5*0.1/_weightSum);
00088       scale(_hist_chi_c1       , 0.5*0.1/_weightSum);
00089       scale(_hist_chi_c2       , 0.5*0.1/_weightSum);
00090       scale(_hist_Psi_prime    , 0.5*0.1/_weightSum);
00091       scale(_hist_primary_Jpsi , 0.5*0.1/_weightSum);
00092       scale(_mult_JPsi         , 0.5*100./_weightSum);
00093       scale(_mult_JPsi_direct  , 0.5*100./_weightSum);
00094       scale(_mult_chi_c1       , 0.5*100./_weightSum);
00095       scale(_mult_chi_c1_direct, 0.5*100./_weightSum);
00096       scale(_mult_chi_c2       , 0.5*100./_weightSum);
00097       scale(_mult_chi_c2_direct, 0.5*100./_weightSum);
00098       scale(_mult_Psi2S        , 0.5*100./_weightSum);
00099     } // finalize
00100 
00101 
00102     void init() {
00103       declare(UnstableFinalState(), "UFS");
00104 
00105       _mult_JPsi          = bookHisto1D(1, 1, 1);
00106       _mult_JPsi_direct   = bookHisto1D(1, 1, 2);
00107       _mult_chi_c1        = bookHisto1D(1, 1, 3);
00108       _mult_chi_c1_direct = bookHisto1D(1, 1, 4);
00109       _mult_chi_c2        = bookHisto1D(1, 1, 5);
00110       _mult_chi_c2_direct = bookHisto1D(1, 1, 6);
00111       _mult_Psi2S         = bookHisto1D(1, 1, 7);
00112       _hist_all_Jpsi      = bookHisto1D(6, 1, 1);
00113       _hist_chi_c1        = bookHisto1D(7, 1, 1);
00114       _hist_chi_c2        = bookHisto1D(7, 1, 2);
00115       _hist_Psi_prime     = bookHisto1D(8, 1, 1);
00116       _hist_primary_Jpsi  = bookHisto1D(10, 1, 1);
00117     } // init
00118 
00119   private:
00120 
00121     //@{
00122     // count of weights
00123     double _weightSum;
00124     /// Histograms
00125     Histo1DPtr _hist_all_Jpsi;
00126     Histo1DPtr _hist_chi_c1;
00127     Histo1DPtr _hist_chi_c2;
00128     Histo1DPtr _hist_Psi_prime;
00129     Histo1DPtr _hist_primary_Jpsi;
00130 
00131     Histo1DPtr _mult_JPsi;
00132     Histo1DPtr _mult_JPsi_direct;
00133     Histo1DPtr _mult_chi_c1;
00134     Histo1DPtr _mult_chi_c1_direct;
00135     Histo1DPtr _mult_chi_c2;
00136     Histo1DPtr _mult_chi_c2_direct;
00137     Histo1DPtr _mult_Psi2S;
00138     //@}
00139 
00140     void findDecayProducts(const GenParticle* p,
00141                            vector<const GenParticle*>& allJpsi,
00142                            vector<const GenParticle*>& primaryJpsi,
00143                            vector<const GenParticle*>& Psiprime,
00144                            vector<const GenParticle*>& all_chi_c1, vector<const GenParticle*>& all_chi_c2,
00145                            vector<const GenParticle*>& primary_chi_c1, vector<const GenParticle*>& primary_chi_c2) {
00146       const GenVertex* dv = p->end_vertex();
00147       bool isOnium = false;
00148       /// @todo Use better looping
00149       for (GenVertex::particles_in_const_iterator pp = dv->particles_in_const_begin() ; pp != dv->particles_in_const_end() ; ++pp) {
00150         int id = (*pp)->pdg_id();
00151         id = id%1000;
00152         id -= id%10;
00153         id /= 10;
00154         if (id==44) isOnium = true;
00155       }
00156       /// @todo Use better looping
00157       for (GenVertex::particles_out_const_iterator pp = dv->particles_out_const_begin(); pp != dv->particles_out_const_end(); ++pp) {
00158         int id = (*pp)->pdg_id();
00159         if (id==100443) {
00160           Psiprime.push_back(*pp);
00161         }
00162         else if (id==20443) {
00163           all_chi_c1.push_back(*pp);
00164           if (!isOnium) primary_chi_c1.push_back(*pp);
00165         }
00166         else if (id==445) {
00167           all_chi_c2.push_back(*pp);
00168           if (!isOnium) primary_chi_c2.push_back(*pp);
00169         }
00170         else if (id==443) {
00171           allJpsi.push_back(*pp);
00172           if (!isOnium) primaryJpsi.push_back(*pp);
00173         }
00174         if ((*pp)->end_vertex()) {
00175           findDecayProducts(*pp, allJpsi, primaryJpsi, Psiprime, all_chi_c1, all_chi_c2, primary_chi_c1, primary_chi_c2);
00176         }
00177       }
00178     }
00179 
00180   };
00181 
00182 
00183   // The hook for the plugin system
00184   DECLARE_RIVET_PLUGIN(BABAR_2003_I593379);
00185 
00186 }