[Rivet-svn] rivet: Fix booking in finalize

Rivet Mercurial rivet at projects.hepforge.org
Wed Sep 20 14:30:02 BST 2017


details:   https://rivet.hepforge.org/hg/rivet/rev/15a89d1c3521
branches:  multiweights-fixptrs
changeset: 6031:15a89d1c3521
user:      David Grellscheid <david.grellscheid at durham.ac.uk>
date:      Wed Sep 20 14:20:46 2017 +0100
description:
Fix booking in finalize

diffs (47 lines):

--- a/include/Rivet/Analyses/MC_ParticleAnalysis.hh	Wed Sep 20 13:39:01 2017 +0100
+++ b/include/Rivet/Analyses/MC_ParticleAnalysis.hh	Wed Sep 20 14:20:46 2017 +0100
@@ -50,6 +50,8 @@
     std::vector<Histo1DPtr> _h_eta_plus, _h_eta_minus;
     std::vector<Histo1DPtr> _h_rap;
     std::vector<Histo1DPtr> _h_rap_plus, _h_rap_minus;
+    std::vector<Scatter2DPtr> tmpeta, tmprap;
+    
     std::map<std::pair<size_t, size_t>, Histo1DPtr> _h_deta;
     std::map<std::pair<size_t, size_t>, Histo1DPtr> _h_dphi;
     std::map<std::pair<size_t, size_t>, Histo1DPtr> _h_dR;
--- a/src/AnalysisTools/MC_ParticleAnalysis.cc	Wed Sep 20 13:39:01 2017 +0100
+++ b/src/AnalysisTools/MC_ParticleAnalysis.cc	Wed Sep 20 14:20:46 2017 +0100
@@ -13,7 +13,8 @@
       _nparts(nparticles), _pname(particle_name),
       _h_pt(nparticles),
       _h_eta(nparticles), _h_eta_plus(nparticles), _h_eta_minus(nparticles),
-      _h_rap(nparticles), _h_rap_plus(nparticles), _h_rap_minus(nparticles)
+      _h_rap(nparticles), _h_rap_plus(nparticles), _h_rap_minus(nparticles),
+      tmpeta(nparticles), tmprap(nparticles)
   {
     setNeedsCrossSection(true); // legitimate use, since a base class has no .info file!
   }
@@ -24,6 +25,9 @@
   void MC_ParticleAnalysis::init() {
 
     for (size_t i = 0; i < _nparts; ++i) {
+      book(tmpeta[i], _pname + "_eta_pmratio_" + to_str(i+1));
+      book(tmprap[i], _pname + "_y_pmratio_" + to_str(i+1));
+
       const string ptname = _pname + "_pt_" + to_str(i+1);
       const double ptmax = 1.0/(double(i)+2.0) * (sqrtS()>0.?sqrtS():14000.)/GeV/2.0;
       const int nbins_pt = 100/(i+1);
@@ -122,11 +126,8 @@
       scale(_h_rap[i], scaling);
 
       // Create eta/rapidity ratio plots
-      Scatter2DPtr tmpeta, tmprap;
-      book(tmpeta, _pname + "_eta_pmratio_" + to_str(i+1));
-      book(tmprap, _pname + "_y_pmratio_" + to_str(i+1));
-      divide(_h_eta_plus[i], _h_eta_minus[i], tmpeta);
-      divide(_h_rap_plus[i], _h_rap_minus[i], tmprap);
+      divide(_h_eta_plus[i], _h_eta_minus[i], tmpeta[i]);
+      divide(_h_rap_plus[i], _h_rap_minus[i], tmprap[i]);
     }
 
     // Scale the d{eta,phi,R} histograms


More information about the Rivet-svn mailing list