rivet is hosted by Hepforge, IPPP Durham
UA5_1982_S875503.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetYODA.hh"
00004 #include "Rivet/Projections/ChargedFinalState.hh"
00005 #include "Rivet/Projections/TriggerUA5.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// @brief UA5 multiplicity and \f$ \eta \f$ distributions
00011   class UA5_1982_S875503 : public Analysis {
00012   public:
00013 
00014     /// Default constructor
00015     UA5_1982_S875503() : Analysis("UA5_1982_S875503") {
00016       _sumWTrig = 0;
00017     }
00018 
00019 
00020     /// @name Analysis methods
00021     //@{
00022 
00023     /// Set up projections and book histos
00024     void init() {
00025       addProjection(TriggerUA5(), "Trigger");
00026       addProjection(ChargedFinalState(-3.5, 3.5), "CFS");
00027 
00028       // Book histos based on pp or ppbar beams
00029       if (beamIds().first == beamIds().second) {
00030         _hist_nch = bookHisto1D(2,1,1);
00031         _hist_eta = bookHisto1D(3,1,1);
00032       } else {
00033         _hist_nch = bookHisto1D(2,1,2);
00034         _hist_eta = bookHisto1D(4,1,1);
00035       }
00036     }
00037 
00038 
00039     void analyze(const Event& event) {
00040       // Trigger
00041       const TriggerUA5& trigger = applyProjection<TriggerUA5>(event, "Trigger");
00042       if (!trigger.nsdDecision()) vetoEvent;
00043       const double weight = event.weight();
00044       _sumWTrig += weight;
00045 
00046       // Get tracks
00047       const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS");
00048 
00049       // Fill mean charged multiplicity histos
00050       _hist_nch->fill(_hist_nch->bin(0).xMean(), cfs.size()*weight);
00051 
00052       // Iterate over all tracks and fill eta histograms
00053       foreach (const Particle& p, cfs.particles()) {
00054         const double eta = fabs(p.momentum().pseudorapidity());
00055         _hist_eta->fill(eta, weight);
00056       }
00057 
00058     }
00059 
00060 
00061     void finalize() {
00062       /// @todo Why the factor of 2 on Nch for ppbar?
00063       if (beamIds().first == beamIds().second) {
00064         scale(_hist_nch, 1.0/_sumWTrig);
00065       } else {
00066         scale(_hist_nch, 0.5/_sumWTrig);
00067       }
00068       scale(_hist_eta, 0.5/_sumWTrig);
00069     }
00070 
00071     //@}
00072 
00073 
00074   private:
00075 
00076     /// @name Counters
00077     //@{
00078     double _sumWTrig;
00079     //@}
00080 
00081     /// @name Histogram collections
00082     //@{
00083     Histo1DPtr _hist_nch;
00084     Histo1DPtr _hist_eta;
00085     //@}
00086 
00087   };
00088 
00089 
00090 
00091   // The hook for the plugin system
00092   DECLARE_RIVET_PLUGIN(UA5_1982_S875503);
00093 
00094 }