TestAnalysis.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #include "Rivet/Tools/Logging.hh"
00003 #include "Rivet/Analyses/TestAnalysis.hh"
00004 #include "Rivet/RivetAIDA.hh"
00005 
00006 
00007 namespace Rivet {
00008 
00009   // Book histograms
00010   void TestAnalysis::init() {
00011     // Using histogram auto-booking is preferable if there are comparison datasets in HepData.
00012     // Since this is just a demo analysis, there is no associate paper!
00013     _histTot         = bookHistogram1D("TotalMult", "Total multiplicity", 100, -0.5, 99.5);
00014     _histChTot       = bookHistogram1D("TotalChMult", "Total charged multiplicity", 50, -1.0, 99.0);
00015     _histUnchTot     = bookHistogram1D("TotalUnchMult", "Total uncharged multiplicity", 100, -0.5, 99.5);
00016     _histHadrTot     = bookHistogram1D("HadrTotalMult", "Total hadronic multiplicity", 100, -0.5, 99.5);
00017     _histHadrChTot   = bookHistogram1D("HadrTotalChMult", "Total hadronic charged multiplicity", 50, -1.0, 99.0);
00018     _histHadrUnchTot = bookHistogram1D("HadrTotalUnchMult", "Total hadronic uncharged multiplicity", 100, -0.5, 99.5);
00019     //_histThrust      = bookHistogram1D("Thrust", "Thrust", 100, 0.5, 1.0);
00020     double edges[11] = { 0.0, 0.25, 0.5, 0.75, 0.80, 0.85, 0.9, 0.925, 0.95, 0.975, 1.0 };
00021     _histThrust     = bookHistogram1D("Thrust", "Thrust with different binning", vector<double>(edges, edges+11));
00022   }
00023 
00024 
00025   // Do the analysis
00026   void TestAnalysis::analyze(const Event& event) {
00027     Log log = getLog();
00028     log << Log::DEBUG << "Starting analyzing" << endl;
00029 
00030     // Analyse and print some info
00031     const Multiplicity& m = event.applyProjection(_multproj);
00032     log << Log::DEBUG << "Total multiplicity            = " << m.totalMultiplicity()           << endl;
00033     log << Log::DEBUG << "Total charged multiplicity    = " << m.totalChargedMultiplicity()    << endl;
00034     log << Log::DEBUG << "Total uncharged multiplicity  = " << m.totalUnchargedMultiplicity()  << endl;
00035     log << Log::DEBUG << "Hadron multiplicity           = " << m.hadronMultiplicity()          << endl;
00036     log << Log::DEBUG << "Hadron charged multiplicity   = " << m.hadronChargedMultiplicity()   << endl;
00037     log << Log::DEBUG << "Hadron uncharged multiplicity = " << m.hadronUnchargedMultiplicity() << endl;
00038 
00039     const Thrust& t = event.applyProjection(_thrustproj);
00040     log << Log::DEBUG << "Thrust = " << t.thrust() << endl;
00041 
00042     // Fill histograms
00043     const double weight = event.weight();
00044     _histTot->fill(m.totalMultiplicity(), weight);
00045     _histChTot->fill(m.totalChargedMultiplicity(), weight);
00046     _histUnchTot->fill(m.totalUnchargedMultiplicity(), weight);
00047     _histHadrTot->fill(m.hadronMultiplicity(), weight);
00048     _histHadrChTot->fill(m.hadronChargedMultiplicity(), weight);
00049     _histHadrUnchTot->fill(m.hadronUnchargedMultiplicity(), weight);
00050     //
00051     _histThrust->fill(t.thrust(), weight);
00052 
00053     // Finished
00054     log << Log::DEBUG << "Finished analyzing" << endl;
00055   }
00056 
00057 
00058   // Finalize
00059   void TestAnalysis::finalize() { 
00060     normalize(_histTot);
00061     normalize(_histChTot);
00062     normalize(_histUnchTot);
00063     normalize(_histHadrTot);
00064     normalize(_histHadrChTot);
00065     normalize(_histHadrUnchTot);
00066     normalize(_histThrust);
00067   }
00068 
00069 }