UA5_1986_S1583476.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/ChargedFinalState.hh"
00006 #include "Rivet/Projections/Beam.hh"
00007 #include "Rivet/Projections/TriggerUA5.hh"
00008 
00009 namespace Rivet {
00010 
00011   class UA5_1986_S1583476 : public Analysis {
00012   public:
00013 
00014     /// Constructor
00015     UA5_1986_S1583476() : Analysis("UA5_1986_S1583476") {
00016       setBeams(PROTON, ANTIPROTON);
00017       _sumWTrig = 0;
00018       _sumWTrigNSD = 0;
00019     }
00020 
00021 
00022     /// @name Analysis methods
00023     //@{
00024 
00025     /// Set up projections and histograms 
00026     void init() {
00027       addProjection(TriggerUA5(), "Trigger");
00028       addProjection(Beam(), "Beams");
00029       addProjection(ChargedFinalState(-5.0, 5.0), "CFS50");
00030 
00031       // Histograms
00032       if (fuzzyEquals(sqrtS()/GeV, 200.0, 1E-4)) {
00033         _hist_eta_nsd       = bookHistogram1D(1,1,1);
00034         _hist_eta_inelastic = bookHistogram1D(1,1,2);
00035         for (int i = 1; i <= 6; ++i) {
00036           _sumWn += 0.0;
00037           _hists_eta_nsd += bookHistogram1D(2,1,i);
00038         }
00039       } else if (fuzzyEquals(sqrtS()/GeV, 900.0, 1E-4)) {
00040         _hist_eta_nsd       = bookHistogram1D(1,1,3);
00041         _hist_eta_inelastic = bookHistogram1D(1,1,4);
00042         for (int i = 1; i <= 9; ++i) {
00043           _sumWn += 0.0;
00044           _hists_eta_nsd += bookHistogram1D(3,1,i);
00045         }
00046       }
00047     }
00048 
00049 
00050     /// Fill eta histograms (in Nch bins)
00051     void analyze(const Event& event) {
00052       // Trigger
00053       const TriggerUA5& trigger = applyProjection<TriggerUA5>(event, "Trigger");
00054       if (!trigger.sdDecision()) vetoEvent;
00055       const bool isNSD = trigger.nsdDecision();
00056 
00057       // Get the index corresponding to the max Nch range histo/sum(w) vector index
00058       const ChargedFinalState& cfs50 = applyProjection<ChargedFinalState>(event, "CFS50");
00059       const int numP = cfs50.size();
00060       const int ni = (int)floor(static_cast<float>(numP-2)/10.0);
00061       const int num_idx = min(ni, (int)_sumWn.size()-1);
00062       getLog() << Log::TRACE << "Multiplicity index: " << numP << " charged particles -> #" << num_idx << endl;
00063 
00064       // Update weights
00065       const double weight = event.weight();
00066       _sumWTrig += weight;
00067       if (isNSD) {
00068         _sumWTrigNSD += weight;
00069         if (num_idx >= 0) _sumWn[num_idx] += weight;
00070       }
00071 
00072       // Fill histos
00073       foreach (const Particle& p, cfs50.particles()) {
00074         const double eta = fabs(p.momentum().pseudorapidity());
00075         _hist_eta_inelastic->fill(eta, weight);
00076         if (isNSD) {
00077           _hist_eta_nsd->fill(eta, weight);
00078           if (num_idx >= 0) _hists_eta_nsd[num_idx]->fill(eta, weight);
00079         }
00080       }
00081     }
00082 
00083 
00084     /// Scale histos
00085     void finalize() {
00086       getLog() << Log::DEBUG << "sumW_NSD,inel = " << _sumWTrigNSD << ", " << _sumWTrig << endl;
00087       scale(_hist_eta_nsd, 0.5/_sumWTrigNSD);
00088       scale(_hist_eta_inelastic, 0.5/_sumWTrig);
00089       //
00090       getLog() << Log::DEBUG << "sumW[n] = " << _sumWn << endl;
00091       for (size_t i = 0; i < _hists_eta_nsd.size(); ++i) {
00092         scale(_hists_eta_nsd[i], 0.5/_sumWn[i]);
00093       }
00094     }
00095  
00096 
00097   private:
00098 
00099     /// @name Weight counters
00100     //@{
00101     double _sumWTrig;
00102     double _sumWTrigNSD;
00103     vector<double> _sumWn;
00104     //@}
00105 
00106     /// @name Histograms
00107     //@{
00108     AIDA::IHistogram1D *_hist_eta_nsd;
00109     AIDA::IHistogram1D *_hist_eta_inelastic;
00110     vector<AIDA::IHistogram1D*> _hists_eta_nsd;
00111     //@}
00112 
00113   };
00114 
00115 
00116 
00117   // This global object acts as a hook for the plugin system
00118   AnalysisBuilder<UA5_1986_S1583476> plugin_UA5_1986_S1583476;
00119 
00120 }