rivet is hosted by Hepforge, IPPP Durham
UA5_1987_S1640666.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetYODA.hh"
00004 #include "Rivet/Tools/Logging.hh"
00005 #include "Rivet/Projections/TriggerUA5.hh"
00006 #include "Rivet/Projections/ChargedFinalState.hh"
00007 
00008 namespace Rivet {
00009 
00010 
00011   class UA5_1987_S1640666 : public Analysis {
00012   public:
00013 
00014     /// Constructor
00015     UA5_1987_S1640666()
00016       : Analysis("UA5_1987_S1640666")
00017     {
00018       _sumWPassed = 0;
00019 
00020     }
00021 
00022     /// Book histograms and initialise projections before the run
00023     void init() {
00024       addProjection(TriggerUA5(), "Trigger");
00025       addProjection(ChargedFinalState(-5.0, 5.0), "CFS");
00026 
00027       _hist_mean_nch = bookHisto1D(1, 1, 1);
00028       _hist_nch      = bookHisto1D(3, 1, 1);
00029 
00030     }
00031 
00032 
00033     /// Perform the per-event analysis
00034     void analyze(const Event& event) {
00035       // Trigger
00036       const TriggerUA5& trigger = applyProjection<TriggerUA5>(event, "Trigger");
00037       if (!trigger.nsdDecision()) vetoEvent;
00038 
00039       const double weight = event.weight();
00040       _sumWPassed += weight;
00041 
00042       // Count final state particles in several eta regions
00043       const int Nch = applyProjection<ChargedFinalState>(event, "CFS").size();
00044 
00045       // Fill histograms
00046       _hist_nch->fill(Nch, weight);
00047       _hist_mean_nch->fill(_hist_mean_nch->bin(0).xMean(), Nch*weight);
00048 
00049     }
00050 
00051 
00052     /// Normalise histograms etc., after the run
00053     void finalize() {
00054 
00055       scale(_hist_nch, 1.0/_sumWPassed);
00056       scale(_hist_mean_nch, 1.0/_sumWPassed);
00057 
00058     }
00059 
00060   private:
00061 
00062     double _sumWPassed;
00063 
00064     Histo1DPtr _hist_mean_nch;
00065     Histo1DPtr _hist_nch;
00066 
00067   };
00068 
00069 
00070 
00071   // The hook for the plugin system
00072   DECLARE_RIVET_PLUGIN(UA5_1987_S1640666);
00073 
00074 
00075 }