Rivet is hosted by Hepforge, IPPP Durham

Changes between Version 29 and Version 30 of WritingAnAnalysis


Ignore:
Timestamp:
Mar 15, 2016, 3:09:06 PM (19 months ago)
Author:
buckley
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WritingAnAnalysis

    v29 v30  
    4848Rivet provides implementations of many calculational tools, called "projections". These are just observable calculator objects with a silly name, so don't get worried. (They automatically cache their results, to make Rivet automatically efficient, but you don't have to worry about that since it's, well, automatic.) The projections are used by calling the analysis' {{{applyProjection(event)}}} method. This will return a const reference to the completed projection object and takes the type of the reference as a template argument, e.g.
    4949{{{
    50   const FinalState& cfs = applyProjection<FinalState>(event, "CFS");
     50  const FinalState& cfs = applyProjection<FinalState>(event, "Tracks");
    5151}}}
    52 The name "CFS" has been registered in the {{{init}}} method as referring to a projection of type "ChargedFinalState" --- a calculator which provides a list of charged particles with certain basic cuts applied. This is done via the {{{addProjection}}} method. Note that a) you don't have to manage the memory yourself, and b) polymorphism via the reference is both allowed and encouraged. If b) means nothing to you, don't worry... we just want to reassure C++ fiends who might think we're cramping their OO style!
     52The name "Tracks" here will have been registered in the {{{init}}} method as referring to a projection of type "ChargedFinalState" --- a calculator which provides a list of charged particles with certain basic cuts applied. This is done via the {{{addProjection}}} method. Note that a) you don't have to manage the memory yourself, and b) polymorphism via the reference is both allowed and encouraged. If b) means nothing to you, don't worry... we just want to reassure C++ fiends who might think we're cramping their OO style!
    5353
    5454
     
    6161#include "Rivet/Projections/FinalState.hh"
    6262#include "Rivet/Projections/ChargedFinalState.hh"
    63 #include "Rivet/AnalysisLoader.hh"
     63#include "Rivet/Projections/FastJets.hh"
    6464
    6565namespace Rivet {
     
    7575    //@{
    7676    void init() {
    77       const FinalState cnfs;
    78       addProjection(cnfs, "CNFS");
    79       const ChargedFinalState cfs;
    80       addProjection(cfs, "CFS");
     77      const FinalState fs(Cuts::abseta < 5);
     78      addProjection(FastJets(fs, FastJets::ANTIKT, 0.5), "Jets");
     79      addProjection(ChargedFinalState(Cuts::abseta < 2.5 && Cuts::pT > 500*MeV), "Tracks");
    8180    }
    8281   
    8382    void analyze(const Event& event) {
    84       const ChargedFinalState& cfs = applyProjection<ChargedFinalState>(event, "CFS");
    85       const FinalState& cnfs = applyProjection<FinalState>(event, "CNFS");
    86       MSG_DEBUG("Total multiplicity         = " << cnfs.particles().size());
    87       MSG_DEBUG("Total charged multiplicity = " << cfs.particles().size());
     83      const Jets jets = applyProjection<ChargedFinalState>(event, "Jets")
     84        .jetsByPt(Cuts::pT > 20*GeV && Cuts::abseta < 4.4);
     85      MSG_DEBUG("Jet multiplicity = " << jets.size());
     86
     87      const Particles& trks = applyProjection<FinalState>(event, "Tracks").particles();
     88      MSG_DEBUG("Track multiplicity = " << trks.size());
    8889    }
     90
    8991   
    9092    // No histos, so no need for a finalize()!
     93
    9194
    9295    //@}
     
    100103}
    101104}}}
     105
     106
     107=== Cut objects ===
     108
     109Note the use of objects in the {{{Cuts}}} namespace to specify kinematic cuts on particles or jets selected by projections, or returned from them as lists. These predefined objects of type {{{Rivet::Cut}}} can be combined together using arbitrary combinations of logical operators, with the combined object also being of type {{{Cut}}}.
     110
     111Many functions in Rivet accept a (potentially compound) {{{Cut}}} as an argument, so this is a very flexible, unambiguous, and human-readable way to express analysis selection logic. There is not much to know from the user point of view beyond what you see above!
     112
     113The standard Rivet predefined cuts are (all in the {{{Rivet::Cuts}}} namespace): pT, Et, mass, phi, eta, abseta, rap, absrap.
    102114
    103115