rivet is hosted by Hepforge, IPPP Durham
ALICE_2012_I1181770.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Analysis.hh"
00003 #include "Rivet/Projections/ChargedFinalState.hh"
00004 
00005 namespace Rivet {
00006 
00007   class ALICE_2012_I1181770 : public Analysis {
00008   public:
00009 
00010     ALICE_2012_I1181770()
00011       : Analysis("ALICE_2012_I1181770")
00012     {    }
00013 
00014 
00015     void init() {
00016       // Projection setup
00017       addProjection(ChargedFinalState(), "CFS");
00018 
00019       // Book (energy-specific) histograms
00020       int isqrts = -1;
00021       if (fuzzyEquals(sqrtS()/GeV, 900, 1E-3)) isqrts = 1;
00022       else if (fuzzyEquals(sqrtS()/GeV, 2760, 1E-3)) isqrts = 2;
00023       else if (fuzzyEquals(sqrtS()/GeV, 7000, 1E-3)) isqrts = 3;
00024       assert(isqrts > 0);
00025 
00026       _h_frac_sd_inel = bookScatter2D(1, 1, isqrts);
00027       _h_frac_dd_inel = bookScatter2D(2, 1, isqrts);
00028       _h_xsec_sd      = bookHisto1D  (3, 1, isqrts);
00029       _h_xsec_dd      = bookHisto1D  (4, 1, isqrts);
00030       _h_xsec_inel    = bookHisto1D  (5, 1, isqrts);
00031     }
00032 
00033 
00034     void analyze(const Event& event) {
00035       const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS");
00036       if (cfs.size() < 2) vetoEvent; // need at least two particles to calculate gaps
00037 
00038       const double weight = event.weight();
00039 
00040       // Fill INEL plots for each event
00041       _h_xsec_inel->fill(sqrtS()/GeV, weight);
00042 
00043       // Identify particles with most positive/most negative rapidities
00044       const Particles particlesByRap = cfs.particlesByRapidity();
00045       const Particle pslowest = particlesByRap.front();
00046       const Particle pfastest = particlesByRap.back();
00047 
00048       // Find gap sizes
00049       const Particles particlesByEta = cfs.particlesByEta(); // sorted from minus to plus
00050       const size_t num_particles = particlesByEta.size();
00051       vector<double> gaps;
00052       for (size_t ip = 1; ip < num_particles; ++ip) {
00053         const Particle& p1 = particlesByEta[ip-1];
00054         const Particle& p2 = particlesByEta[ip];
00055         const double gap = p2.eta() - p1.eta();
00056         assert(gap >= 0);
00057         gaps.push_back(gap);
00058       }
00059 
00060       // First, last, and largest gaps
00061       const double gapmax = *max_element(gaps.begin(), gaps.end());
00062       const double gapbwd = gaps.front();
00063       const double gapfwd = gaps.back();
00064 
00065       // Mx calculation
00066       FourMomentum p4lead;
00067       if (pslowest.pdgId() == PID::PROTON && pfastest.pdgId() == PID::PROTON) {
00068         p4lead = (fabs(pslowest.rapidity()) > fabs(pfastest.rapidity())) ? pslowest.momentum() : pfastest.momentum();
00069       } else if (pslowest.pdgId() == PID::PROTON) {
00070         p4lead = pslowest.momentum();
00071       } else if (pfastest.pdgId() == PID::PROTON) {
00072         p4lead = pfastest.momentum();
00073       }
00074       const double Mx = sqrt( (sqrtS()-p4lead.E()-p4lead.vector3().mod()) * (sqrtS()-p4lead.E()+p4lead.vector3().mod()) );
00075 
00076       // Fill SD (and escape) if Mx is sufficiently low
00077       if (Mx < 200*GeV) {
00078         _h_xsec_sd->fill(sqrtS()/GeV, weight);
00079         return;
00080       }
00081 
00082       // Also remove SD-like events in NSD events
00083       if (fuzzyEquals(gapbwd, gapmax) || fuzzyEquals(gapfwd, gapmax)) vetoEvent;
00084 
00085       // Fill DD plots
00086       if (gapmax > 3) _h_xsec_dd->fill(sqrtS()/GeV, weight);
00087     }
00088 
00089 
00090     void finalize() {
00091 
00092       // get the ratio plots: SD/inel, DD/inel
00093       divide(_h_xsec_sd , _h_xsec_inel, _h_frac_sd_inel);
00094       divide(_h_xsec_sd , _h_xsec_inel, _h_frac_dd_inel);
00095 
00096       scale(_h_xsec_sd,   crossSection()/millibarn/sumOfWeights());
00097       scale(_h_xsec_dd,   crossSection()/millibarn/sumOfWeights());
00098       scale(_h_xsec_inel, crossSection()/millibarn/sumOfWeights());
00099 
00100     }
00101 
00102   private:
00103 
00104     Scatter2DPtr _h_frac_sd_inel;
00105     Scatter2DPtr _h_frac_dd_inel;
00106     Histo1DPtr   _h_xsec_sd;
00107     Histo1DPtr   _h_xsec_dd;
00108     Histo1DPtr   _h_xsec_inel;
00109 
00110   };
00111 
00112   // Hook for the plugin system
00113   DECLARE_RIVET_PLUGIN(ALICE_2012_I1181770);
00114 
00115 }