EXAMPLE.cc
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #include "Rivet/Analysis.hh" 00003 #include "Rivet/Tools/Logging.hh" 00004 #include "Rivet/RivetYODA.hh" 00005 #include "Rivet/Projections/FinalState.hh" 00006 #include "Rivet/Projections/ChargedFinalState.hh" 00007 #include "Rivet/Projections/FastJets.hh" 00008 #include "Rivet/Projections/Multiplicity.hh" 00009 #include "Rivet/Projections/Thrust.hh" 00010 #include "Rivet/Projections/Sphericity.hh" 00011 00012 namespace Rivet { 00013 00014 00015 /// @brief Just measures a few random things as an example. 00016 class EXAMPLE : public Analysis { 00017 public: 00018 00019 /// Constructor 00020 EXAMPLE() 00021 : Analysis("EXAMPLE") 00022 { 00023 // No counters etc. to initialise, hence nothing to do here! 00024 } 00025 00026 00027 /// @name Analysis methods 00028 //@{ 00029 00030 /// Set up projections and book histograms 00031 void init() { 00032 // Projections 00033 const FinalState cnfs(-4, 4, 2*GeV); 00034 const ChargedFinalState cfs(-4, 4, 2*GeV); 00035 addProjection(cnfs, "FS"); 00036 addProjection(cfs, "CFS"); 00037 addProjection(FastJets(cnfs, FastJets::KT, 0.7), "Jets"); 00038 addProjection(Multiplicity(cfs), "CMult"); 00039 addProjection(Multiplicity(cnfs), "CNMult"); 00040 addProjection(Thrust(cfs), "Thrust"); 00041 addProjection(Sphericity(cfs), "Sphericity"); 00042 00043 // Histograms 00044 _histTot = bookHisto1D("TotalMult", 100, -0.5, 99.5); 00045 _histChTot = bookHisto1D("TotalChMult", 50, -1.0, 99.0); 00046 _histHadrTot = bookHisto1D("HadrTotalMult", 100, -0.5, 99.5); 00047 _histHadrChTot = bookHisto1D("HadrTotalChMult", 50, -1.0, 99.0); 00048 _histMajor = bookHisto1D("Major", 10, 0.0, 0.6); 00049 _histSphericity = bookHisto1D("Sphericity", 10, 0.0, 0.8); 00050 _histAplanarity = bookHisto1D("Aplanarity", 10, 0.0, 0.3); 00051 00052 // Non-uniform binning example: 00053 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 }; 00054 vector<double> vedges(edges, edges+11); 00055 _histThrust = bookHisto1D("Thrust", vedges); 00056 } 00057 00058 00059 /// Do the analysis 00060 void analyze(const Event& event) { 00061 // Make sure to always include the event weight in histogram fills! 00062 const double weight = event.weight(); 00063 00064 const Multiplicity& cnm = applyProjection<Multiplicity>(event, "CNMult"); 00065 MSG_DEBUG("Total multiplicity = " << cnm.totalMultiplicity()); 00066 _histTot->fill(cnm.totalMultiplicity(), weight); 00067 MSG_DEBUG("Hadron multiplicity = " << cnm.hadronMultiplicity()); 00068 _histHadrTot->fill(cnm.hadronMultiplicity(), weight); 00069 00070 const Multiplicity& cm = applyProjection<Multiplicity>(event, "CMult"); 00071 MSG_DEBUG("Total charged multiplicity = " << cm.totalMultiplicity()); 00072 _histChTot->fill(cm.totalMultiplicity(), weight); 00073 MSG_DEBUG("Hadron charged multiplicity = " << cm.hadronMultiplicity()); 00074 _histHadrChTot->fill(cm.hadronMultiplicity(), weight); 00075 00076 const Thrust& t = applyProjection<Thrust>(event, "Thrust"); 00077 MSG_DEBUG("Thrust = " << t.thrust()); 00078 _histThrust->fill(t.thrust(), weight); 00079 _histMajor->fill(t.thrustMajor(), weight); 00080 00081 const Sphericity& s = applyProjection<Sphericity>(event, "Sphericity"); 00082 MSG_DEBUG("Sphericity = " << s.sphericity()); 00083 _histSphericity->fill(s.sphericity(), weight); 00084 MSG_DEBUG("Aplanarity = " << s.aplanarity()); 00085 _histAplanarity->fill(s.aplanarity(), weight); 00086 00087 unsigned int num_b_jets = 0; 00088 const Jets jets = applyProjection<FastJets>(event, "Jets").jets(5*GeV); 00089 foreach (const Jet& j, jets) { 00090 if (j.containsBottom()) num_b_jets += 1; 00091 } 00092 MSG_DEBUG("Num B-jets with pT > 5 GeV = " << num_b_jets); 00093 } 00094 00095 00096 /// Finalize 00097 void finalize() { 00098 normalize(_histTot); 00099 normalize(_histChTot); 00100 normalize(_histHadrTot); 00101 normalize(_histHadrChTot); 00102 normalize(_histThrust); 00103 normalize(_histMajor); 00104 normalize(_histSphericity); 00105 normalize(_histAplanarity); 00106 } 00107 00108 //@} 00109 00110 00111 private: 00112 00113 //@{ 00114 /// Histograms 00115 Histo1DPtr _histTot; 00116 Histo1DPtr _histChTot; 00117 Histo1DPtr _histHadrTot; 00118 Histo1DPtr _histHadrChTot; 00119 Histo1DPtr _histThrust; 00120 Histo1DPtr _histMajor; 00121 Histo1DPtr _histSphericity; 00122 Histo1DPtr _histAplanarity; 00123 //@} 00124 00125 }; 00126 00127 00128 00129 // The hook for the plugin system 00130 DECLARE_RIVET_PLUGIN(EXAMPLE); 00131 00132 } Generated on Fri Dec 21 2012 15:03:40 for The Rivet MC analysis system by ![]() |