EXAMPLE.cc
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #include "Rivet/Analysis.hh" 00003 #include "Rivet/Projections/FinalState.hh" 00004 #include "Rivet/Projections/ChargedFinalState.hh" 00005 #include "Rivet/Projections/FastJets.hh" 00006 #include "Rivet/Projections/Thrust.hh" 00007 #include "Rivet/Projections/Sphericity.hh" 00008 00009 namespace Rivet { 00010 00011 00012 /// @brief Just measures a few random things as an example. 00013 class EXAMPLE : public Analysis { 00014 public: 00015 00016 /// Constructor 00017 DEFAULT_RIVET_ANALYSIS_CTOR(EXAMPLE); 00018 00019 /// @name Analysis methods 00020 //@{ 00021 00022 /// Set up projections and book histograms 00023 void init() { 00024 // Projections 00025 MSG_TRACE(0); 00026 const FinalState cnfs(Cuts::abseta < 4 && Cuts::pT > 500*MeV); 00027 MSG_TRACE(1); 00028 const ChargedFinalState cfs(cnfs); 00029 MSG_TRACE(2); 00030 declare(cnfs, "FS"); 00031 MSG_TRACE(3); 00032 declare(cfs, "CFS"); 00033 declare(FastJets(cnfs, FastJets::KT, 0.7), "Jets"); 00034 declare(Thrust(cfs), "Thrust"); 00035 declare(Sphericity(cfs), "Sphericity"); 00036 00037 // Histograms 00038 _histTot = bookHisto1D("TotalMult", 100, -0.5, 99.5); 00039 _histChTot = bookHisto1D("TotalChMult", 50, -1.0, 99.0); 00040 _histHadrTot = bookHisto1D("HadrTotalMult", 100, -0.5, 99.5); 00041 _histHadrChTot = bookHisto1D("HadrTotalChMult", 50, -1.0, 99.0); 00042 _histMajor = bookHisto1D("Major", 10, 0.0, 0.6); 00043 _histSphericity = bookHisto1D("Sphericity", 10, 0.0, 0.8); 00044 _histAplanarity = bookHisto1D("Aplanarity", 10, 0.0, 0.3); 00045 00046 // Non-uniform binning example: 00047 double edges[11] = { 0.5, 0.6, 0.7, 0.80, 0.85, 0.9, 0.92, 0.94, 0.96, 0.98, 1.0 }; 00048 vector<double> vedges(edges, edges+11); 00049 _histThrust = bookHisto1D("Thrust", vedges); 00050 } 00051 00052 00053 /// Do the analysis 00054 void analyze(const Event& event) { 00055 // Make sure to always include the event weight in histogram fills! 00056 const double weight = event.weight(); 00057 00058 const Particles& cnparticles = apply<FinalState>(event, "FS").particles(); 00059 MSG_DEBUG("Total multiplicity = " << cnparticles.size()); 00060 _histTot->fill(cnparticles.size(), weight); 00061 int cnhadronmult = 0; 00062 foreach (const Particle& p, cnparticles) if (isHadron(p)) cnhadronmult += 1; 00063 MSG_DEBUG("Hadron multiplicity = " << cnhadronmult); 00064 _histHadrTot->fill(cnhadronmult, weight); 00065 00066 const Particles& cparticles = apply<FinalState>(event, "CFS").particles(); 00067 MSG_DEBUG("Total charged multiplicity = " << cparticles.size()); 00068 _histChTot->fill(cparticles.size(), weight); 00069 int chadronmult = 0; 00070 foreach (const Particle& p, cparticles) if (isHadron(p)) chadronmult += 1; 00071 MSG_DEBUG("Hadron charged multiplicity = " << chadronmult); 00072 _histHadrChTot->fill(chadronmult, weight); 00073 00074 const Thrust& t = apply<Thrust>(event, "Thrust"); 00075 MSG_DEBUG("Thrust = " << t.thrust()); 00076 _histThrust->fill(t.thrust(), weight); 00077 _histMajor->fill(t.thrustMajor(), weight); 00078 00079 const Sphericity& s = apply<Sphericity>(event, "Sphericity"); 00080 MSG_DEBUG("Sphericity = " << s.sphericity()); 00081 _histSphericity->fill(s.sphericity(), weight); 00082 MSG_DEBUG("Aplanarity = " << s.aplanarity()); 00083 _histAplanarity->fill(s.aplanarity(), weight); 00084 00085 const Jets jets = apply<FastJets>(event, "Jets").jets(Cuts::pT > 5*GeV); 00086 size_t num_b_jets = count_if(jets.begin(), jets.end(), [](const Jet& j){ return j.bTagged(Cuts::pT > 500*MeV); }); 00087 MSG_DEBUG("Num B-jets with pT > 5 GeV = " << num_b_jets); 00088 } 00089 00090 00091 /// Finalize 00092 void finalize() { 00093 normalize(_histTot); 00094 normalize(_histChTot); 00095 normalize(_histHadrTot); 00096 normalize(_histHadrChTot); 00097 normalize(_histThrust); 00098 normalize(_histMajor); 00099 normalize(_histSphericity); 00100 normalize(_histAplanarity); 00101 } 00102 00103 //@} 00104 00105 00106 private: 00107 00108 //@{ 00109 /// Histograms 00110 Histo1DPtr _histTot; 00111 Histo1DPtr _histChTot; 00112 Histo1DPtr _histHadrTot; 00113 Histo1DPtr _histHadrChTot; 00114 Histo1DPtr _histThrust; 00115 Histo1DPtr _histMajor; 00116 Histo1DPtr _histSphericity; 00117 Histo1DPtr _histAplanarity; 00118 //@} 00119 00120 }; 00121 00122 00123 00124 // The hook for the plugin system 00125 DECLARE_RIVET_PLUGIN(EXAMPLE); 00126 00127 } Generated on Tue Dec 13 2016 16:32:37 for The Rivet MC analysis system by ![]() |