rivet is hosted by Hepforge, IPPP Durham
LHCB_2015_I1333223.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Tools/Logging.hh"
00004 #include "Rivet/Projections/ChargedFinalState.hh"
00005 #include "Rivet/Math/Units.hh"
00006 #include <vector>
00007 
00008 using namespace std;
00009 
00010 namespace Rivet {
00011 
00012 
00013   class  LHCB_2015_I1333223 : public Analysis {
00014   public:
00015 
00016     /// @name Constructors etc.
00017     //@{
00018 
00019     /// Constructor
00020      LHCB_2015_I1333223()
00021       : Analysis("LHCB_2015_I1333223")
00022     {    }
00023 
00024     //@}
00025 
00026 
00027   public:
00028 
00029     /// @name Analysis methods
00030     //@{
00031 
00032     /// Book histograms and initialise projections before the run
00033     void init() {
00034       // Charged particles
00035       declare(ChargedFinalState(Cuts::eta> 2.0 && Cuts::eta <4.5 && Cuts::pT >0.2*GeV), "CFS");
00036       // Reproducing only measurement for prompt charged particles
00037       _hInelasticXs = bookHisto1D(1, 1, 1);
00038     }
00039 
00040 
00041     /// Perform the per-event analysis
00042     void analyze(const Event& event) {
00043       const double             weight  = event.weight();
00044       const ChargedFinalState   &cfs    = apply<ChargedFinalState> (event, "CFS");
00045 
00046       // eliminate non-inelastic events and empty events in LHCb
00047       if (cfs.particles().size() == 0) vetoEvent;
00048 
00049       // See if this event has at least one prompt particle
00050       foreach (const Particle &myp, cfs.particles()){
00051           double dPV = getPVDCA(myp);
00052           // if IP > 200 microns the particle is not considered prompt
00053           if ((dPV < 0.) || (dPV > 0.2 * millimeter)) {
00054             MSG_DEBUG(" Vetoing " << myp.pdgId() << " at " << dPV);
00055             continue;
00056           }
00057           // histo gets filled only for inelastic events (at least one prompt charged particle)
00058           _hInelasticXs->fill(sqrtS(), weight);
00059           break;
00060       } //end loop on particles
00061 
00062     }
00063 
00064 
00065     /// Normalise histograms etc., after the run
00066     void finalize() {
00067       scale(_hInelasticXs, crossSection()/sumOfWeights()/millibarn);
00068     }
00069 
00070     //@}
00071 
00072 
00073   private:
00074 
00075     /*
00076      * Compute Distance of Closest Approach in z range for one particle. 
00077      * Assuming length unit is mm.
00078      * Returns -1. if unable to compute the DCA to PV.
00079      */
00080     double getPVDCA(const Particle& p) {
00081       const HepMC::GenVertex* vtx = p.genParticle()->production_vertex();
00082       if ( 0 == vtx ) return -1.;
00083       
00084       // Unit vector of particle's MOMENTUM three vector
00085       const Vector3 u = p.momentum().p3().unit();
00086       
00087       // The interaction point is always at (0, 0,0,0) hence the
00088       // vector pointing from the PV to the particle production vertex is:
00089       Vector3 d(vtx->position().x(), vtx->position().y(), vtx->position().z());
00090 
00091       // Subtract projection of d onto u from d
00092       double proj = d.dot(u);
00093       d -= (u * proj);
00094 
00095       // d should be orthogonal to u and it's length give the distance of 
00096       // closest approach
00097       return d.mod();
00098     }
00099 
00100 
00101     /// @name Histograms
00102     //@{
00103     Histo1DPtr _hInelasticXs;
00104     //@}
00105     //
00106   };
00107 
00108 
00109 
00110   // The hook for the plugin system
00111   DECLARE_RIVET_PLUGIN(LHCB_2015_I1333223);
00112 
00113 }