UA5_1987_S1640666.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/RivetAIDA.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       setBeams(PROTON, ANTIPROTON);
00019       _sumWPassed = 0;
00020       
00021     }
00022 
00023     /// Book histograms and initialise projections before the run
00024     void init() {
00025       addProjection(TriggerUA5(), "Trigger");
00026       addProjection(ChargedFinalState(-5.0, 5.0), "CFS");
00027 
00028       _hist_mean_nch = bookHistogram1D(1, 1, 1);
00029       _hist_nch      = bookHistogram1D(3, 1, 1);
00030 
00031     }
00032 
00033 
00034     /// Perform the per-event analysis
00035     void analyze(const Event& event) {
00036       // Trigger
00037       const TriggerUA5& trigger = applyProjection<TriggerUA5>(event, "Trigger");
00038       if (!trigger.nsdDecision()) vetoEvent;
00039 
00040       const double weight = event.weight();
00041       _sumWPassed += weight;
00042 
00043       // Count final state particles in several eta regions
00044       const int Nch = applyProjection<ChargedFinalState>(event, "CFS").size();
00045 
00046       // Fill histograms
00047       _hist_nch->fill(Nch, weight);
00048       _hist_mean_nch->fill(_hist_mean_nch->binMean(0), Nch);
00049 
00050     }
00051 
00052 
00053     /// Normalise histograms etc., after the run
00054     void finalize() {
00055       
00056       scale(_hist_nch, _sumWPassed);
00057       scale(_hist_mean_nch, 1.0/_sumWPassed);
00058       
00059     }
00060 
00061   private:
00062     
00063     double _sumWPassed;
00064 
00065     AIDA::IHistogram1D *_hist_mean_nch;
00066     AIDA::IHistogram1D *_hist_nch;
00067 
00068   };
00069 
00070 
00071 
00072   // This global object acts as a hook for the plugin system
00073   AnalysisBuilder<UA5_1987_S1640666> plugin_UA5_1987_S1640666;
00074 
00075 
00076 }