rivet is hosted by Hepforge, IPPP Durham

Rivet analyses reference

BABAR_2008_I776519

Cross section for $e^+e^-\to D^+D^-$ and $D^0\bar{D}^0$ below 5 GeV
Experiment: BABAR (PEP-II)
Inspire ID: 776519
Status: VALIDATED
Authors:
  • Peter Richardson
References: Beams: e+ e-
Beam energies: ANY
Run details:
  • e+e- to hadrons

Cross section for $e^+e^-\to D^+D^-$ and $D^0\bar{D}^0$ below 5 GeV

Source code: BABAR_2008_I776519.cc
  1// -*- C++ -*-
  2#include "Rivet/Analysis.hh"
  3#include "Rivet/Projections/FinalState.hh"
  4#include "Rivet/Projections/UnstableParticles.hh"
  5
  6namespace Rivet {
  7
  8
  9  /// @brief Add a short analysis description here
 10  class BABAR_2008_I776519 : public Analysis {
 11  public:
 12
 13    /// Constructor
 14    RIVET_DEFAULT_ANALYSIS_CTOR(BABAR_2008_I776519);
 15
 16
 17    /// @name Analysis methods
 18    //@{
 19
 20    /// Book histograms and initialise projections before the run
 21    void init() {
 22
 23      // Initialise and register projections
 24      declare(FinalState(), "FS");
 25      declare(UnstableParticles(), "UFS");
 26      book(_nD0, "/TMP/nD0");
 27      book(_nDp, "/TMP/nDp");
 28
 29    }
 30
 31    void findChildren(const Particle & p,map<long,int> & nRes, int &ncount) {
 32      for (const Particle &child : p.children()) {
 33	if(child.children().empty()) {
 34	  nRes[child.pid()]-=1;
 35	  --ncount;
 36	}
 37	else
 38	  findChildren(child,nRes,ncount);
 39      }
 40    }
 41
 42    /// Perform the per-event analysis
 43    void analyze(const Event& event) {
 44
 45      const FinalState& fs = apply<FinalState>(event, "FS");
 46
 47      map<long,int> nCount;
 48      int ntotal(0);
 49      for (const Particle& p : fs.particles()) {
 50	nCount[p.pid()] += 1;
 51	++ntotal;
 52      }
 53      const FinalState& ufs = apply<FinalState>(event, "UFS");
 54
 55      for(unsigned int ix=0;ix<ufs.particles().size();++ix) {
 56	const Particle& p1 = ufs.particles()[ix];
 57	if(abs(p1.pid())!=411 && abs(p1.pid())!=421)
 58	  continue;
 59	map<long,int> nRes = nCount;
 60	int ncount = ntotal;
 61	findChildren(p1,nRes,ncount);
 62	bool matched=false;
 63	for(unsigned int iy=0;iy<ufs.particles().size();++iy) {
 64	  if(ix==iy) continue;
 65	  const Particle& p2 = ufs.particles()[iy];
 66	  if(p2.pid()!=-p1.pid()) continue;
 67	  map<long,int> nRes2 = nRes;
 68	  int ncount2 = ncount;
 69	  findChildren(p2,nRes2,ncount2);
 70	  if(ncount2!=0) continue;
 71	  matched=true;
 72	  for(auto const & val : nRes2) {
 73	    if(val.second!=0) {
 74	      matched = false;
 75	      break;
 76	    }
 77	  }
 78	  if(matched) break;
 79	}
 80	if(matched) {
 81	  if(abs(p1.pid())==411)
 82	    _nDp->fill();
 83	  else if(abs(p1.pid())==421)
 84	    _nD0->fill();
 85	}
 86      }
 87    }
 88
 89
 90    /// Normalise histograms etc., after the run
 91    void finalize() {
 92
 93      for(unsigned int ix=1;ix<3;++ix) {
 94	double sigma,error;
 95	if(ix==1) {
 96	  sigma = _nD0->val();
 97	  error = _nD0->err();
 98	}
 99	else {
100	  sigma = _nDp->val();
101	  error = _nDp->err();
102	}
103    	sigma *= crossSection()/ sumOfWeights() /nanobarn;
104    	error *= crossSection()/ sumOfWeights() /nanobarn; 
105	Scatter2D temphisto(refData(1, 1, ix));
106    	Scatter2DPtr  mult;
107        book(mult, 1, 1, ix);
108	for (size_t b = 0; b < temphisto.numPoints(); b++) {
109	  const double x  = temphisto.point(b).x();
110	  pair<double,double> ex = temphisto.point(b).xErrs();
111	  pair<double,double> ex2 = ex;
112	  if(ex2.first ==0.) ex2. first=0.0001;
113	  if(ex2.second==0.) ex2.second=0.0001;
114	  if (inRange(sqrtS()/GeV, x-ex2.first, x+ex2.second)) {
115	    mult->addPoint(x, sigma, ex, make_pair(error,error));
116	  }
117	  else {
118	    mult->addPoint(x, 0., ex, make_pair(0.,.0));
119	  }
120	}
121      }
122    }
123
124    //@}
125
126
127    /// @name Histograms
128    //@{
129    CounterPtr _nD0,_nDp;
130    //@}
131
132
133  };
134
135
136  // The hook for the plugin system
137  RIVET_DECLARE_PLUGIN(BABAR_2008_I776519);
138
139
140}