rivet is hosted by Hepforge, IPPP Durham
close Warning: Can't synchronize with repository "(default)" (Repository path '/hepforge/hg/rivet/public/rivet' does not exist.). Look in the Trac log for more information.

Changes between Version 30 and Version 31 of WritingAnAnalysis


Ignore:
Timestamp:
May 31, 2018 3:33:59 PM (7 months ago)
Author:
Andy Buckley
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WritingAnAnalysis

    v30 v31  
    4646This probably looks similar to every analysis system you've ever used, so hopefully you're not worried about Rivet being weird or difficult to learn ;-)
    4747
    48 Rivet 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.
     48Rivet 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' {{{apply(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, "Tracks");
     50  const FinalState& cfs = apply<FinalState>(event, "Tracks");
    5151}}}
    52 The 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!
     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 {{{declare}}} 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 style!
    5353
    5454
    5555=== Example ===
    5656
    57 Here is an example of the whole Rivet analysis shebang. We've compressed it into a single .cc file since the {{{analyze}}} method is nice and short:
     57Here is an example of the whole Rivet analysis shebang. We've compressed it into a single .cc file since the {{{analyze}}} method is nice and short and there is no reason to make a header:
    5858
    5959{{{
     
    7676    void init() {
    7777      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");
     78      declare(FastJets(fs, FastJets::ANTIKT, 0.5), "Jets");
     79      declare(ChargedFinalState(Cuts::abseta < 2.5 && Cuts::pT > 500*MeV), "Tracks");
    8080    }
    8181   
    8282    void analyze(const Event& event) {
    83       const Jets jets = applyProjection<ChargedFinalState>(event, "Jets")
     83      const Jets& jets = apply<ChargedFinalState>(event, "Jets")
    8484        .jetsByPt(Cuts::pT > 20*GeV && Cuts::abseta < 4.4);
    8585      MSG_DEBUG("Jet multiplicity = " << jets.size());
    8686
    87       const Particles& trks = applyProjection<FinalState>(event, "Tracks").particles();
     87      const Particles& trks = apply<FinalState>(event, "Tracks").particles();
    8888      MSG_DEBUG("Track multiplicity = " << trks.size());
    8989    }
     
    9898
    9999
    100   // This is a required hook for the plugin system 
     100  // Magic required by the plugin system 
    101101  DECLARE_RIVET_PLUGIN(MyAnalysis);
    102102