[Rivet-svn] r4050 - in trunk: . include/Rivet src/Core

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Tue Nov 27 23:40:09 GMT 2012


Author: buckley
Date: Tue Nov 27 23:40:08 2012
New Revision: 4050

Log:
Adding XLabel and YLabel setting in histo/profile/scatter booking.

Modified:
   trunk/ChangeLog
   trunk/include/Rivet/Analysis.hh
   trunk/src/Core/Analysis.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Tue Nov 27 12:03:50 2012	(r4049)
+++ trunk/ChangeLog	Tue Nov 27 23:40:08 2012	(r4050)
@@ -1,3 +1,11 @@
+2012-11-27  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Adding XLabel and YLabel setting in histo/profile/scatter booking.
+
+2012-11-14  Hendrik Hoeth <hendrik.hoeth at cern.ch>
+
+	* Added CMS_2012_I1102908 analysis
+
 2012-11-27  Hendrik Hoeth <hendrik.hoeth at cern.ch>
 
 	* Fix make-plots png creation for SL5

Modified: trunk/include/Rivet/Analysis.hh
==============================================================================
--- trunk/include/Rivet/Analysis.hh	Tue Nov 27 12:03:50 2012	(r4049)
+++ trunk/include/Rivet/Analysis.hh	Tue Nov 27 23:40:08 2012	(r4050)
@@ -18,7 +18,7 @@
 
 /// @def vetoEvent
 /// Preprocessor define for vetoing events, including the log message and return.
-#define vetoEvent \
+#define vetoEvent                                                       \
   do { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } while(0)
 
 /// @def DECLARE_RIVET_PLUGIN
@@ -229,10 +229,12 @@
 
 
     /// Return true if this analysis needs to know the process cross-section.
+    /// @todo Remove this and require HepMC >= 2.06
     bool needsCrossSection() const {
       return info().needsCrossSection();
     }
     /// Declare whether this analysis needs to know the process cross-section from the generator.
+    /// @todo Remove this and require HepMC >= 2.06
     Analysis& setNeedsCrossSection(bool needed=true) {
       info().setNeedsCrossSection(needed);
       return *this;
@@ -241,7 +243,7 @@
     //@}
 
 
-    /// @name Internal metadata modifiying methods
+    /// @name Internal metadata modifying methods
     //@{
 
     /// Get the actual AnalysisInfo object in which all this metadata is stored (non-const).
@@ -321,13 +323,13 @@
 
     /// Helper for histogram division. Preserves the path information
     /// of the target.
-    void divide(const YODA::Histo1D & h1, 
-		const YODA::Histo1D & h2, Scatter2DPtr s) const;
+    void divide(const YODA::Histo1D & h1,
+                const YODA::Histo1D & h2, Scatter2DPtr s) const;
 
     /// Helper for profile histogram division. Preserves the path information
     /// of the target.
-    void divide(const YODA::Profile1D & p1, 
-		const YODA::Profile1D & p2, Scatter2DPtr s) const;
+    void divide(const YODA::Profile1D & p1,
+                const YODA::Profile1D & p2, Scatter2DPtr s) const;
 
 
   protected:
@@ -378,24 +380,24 @@
 
     /// Get reference data for a numbered histo
     const YODA::Scatter2D & referenceData(size_t datasetId,
-				    size_t xAxisId, size_t yAxisId) const;
+                                          size_t xAxisId, size_t yAxisId) const;
 
     /// Book a 1D histogram with @a nbins uniformly distributed across the range @a lower - @a upper .
     /// (NB. this returns a pointer rather than a reference since it will
     /// have to be stored in the analysis class - there's no point in forcing users to explicitly
     /// get the pointer from a reference before they can use it!)
     Histo1DPtr bookHisto1D(const std::string& name,
-			   size_t nbins, double lower, double upper,
-			   const std::string& title="",
-			   const std::string& xtitle="", const std::string& ytitle="");
+                           size_t nbins, double lower, double upper,
+                           const std::string& title="",
+                           const std::string& xtitle="", const std::string& ytitle="");
 
     /// Book a 1D histogram with non-uniform bins defined by the vector of bin edges @a binedges .
     /// (NB. this returns a pointer rather than a reference since it will
     /// have to be stored in the analysis class - there's no point in forcing users to explicitly
     /// get the pointer from a reference before they can use it!)
     Histo1DPtr bookHisto1D(const std::string& name,
-                                        const std::vector<double>& binedges, const std::string& title="",
-                                        const std::string& xtitle="", const std::string& ytitle="");
+                           const std::vector<double>& binedges, const std::string& title="",
+                           const std::string& xtitle="", const std::string& ytitle="");
 
     // /// Book a 2D histogram with @a nxbins and @a nybins uniformly
     // /// distributed across the ranges @a xlower - @a xupper and @a
@@ -406,10 +408,10 @@
     // /// reference before they can use it!)
     // AIDA::IHistogram2D*
     // bookHistogram2D(const std::string& name,
-    // 		    size_t nxbins, double xlower, double xupper,
-    // 		    size_t nybins, double ylower, double yupper,
-    // 		    const std::string& title="", const std::string& xtitle="",
-    // 		    const std::string& ytitle="", const std::string& ztitle="");
+    //          size_t nxbins, double xlower, double xupper,
+    //          size_t nybins, double ylower, double yupper,
+    //          const std::string& title="", const std::string& xtitle="",
+    //          const std::string& ytitle="", const std::string& ztitle="");
 
     // /// Book a 2D histogram with non-uniform bins defined by the
     // /// vectorx of bin edges @a xbinedges and @a ybinedges.
@@ -419,26 +421,26 @@
     // /// reference before they can use it!)
     // AIDA::IHistogram2D*
     // bookHistogram2D(const std::string& name,
-    // 		    const std::vector<double>& xbinedges,
-    // 		    const std::vector<double>& ybinedges,
-    // 		    const std::string& title="", const std::string& xtitle="",
-    // 		    const std::string& ytitle="", const std::string& ztitle="");
+    //          const std::vector<double>& xbinedges,
+    //          const std::vector<double>& ybinedges,
+    //          const std::string& title="", const std::string& xtitle="",
+    //          const std::string& ytitle="", const std::string& ztitle="");
 
     /// Book a 1D histogram based on the name in the corresponding AIDA
     /// file. The binnings will be obtained by reading the bundled AIDA data
     /// record file with the same filename as the analysis' name() property.
     Histo1DPtr bookHisto1D(const std::string& name,
-			   const std::string& title="",
-			   const std::string& xtitle="",
-			   const std::string& ytitle="");
+                           const std::string& title="",
+                           const std::string& xtitle="",
+                           const std::string& ytitle="");
 
     /// Book a 1D histogram based on the paper, dataset and x/y-axis IDs in the corresponding
     /// HepData record. The binnings will be obtained by reading the bundled AIDA data record file
     /// of the same filename as the analysis' name() property.
     Histo1DPtr bookHisto1D(size_t datasetId, size_t xAxisId, size_t yAxisId,
-			   const std::string& title="",
-			   const std::string& xtitle="",
-			   const std::string& ytitle="");
+                           const std::string& title="",
+                           const std::string& xtitle="",
+                           const std::string& ytitle="");
 
     //@}
 
@@ -451,31 +453,31 @@
     /// have to be stored in the analysis class - there's no point in forcing users to explicitly
     /// get the pointer from a reference before they can use it!)
     Profile1DPtr bookProfile1D(const std::string& name,
-			       size_t nbins, double lower, double upper,
-			       const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               size_t nbins, double lower, double upper,
+                               const std::string& title="",
+                               const std::string& xtitle="", const std::string& ytitle="");
 
     /// Book a 1D profile histogram with non-uniform bins defined by the vector of bin edges @a binedges .
     /// (NB. this returns a pointer rather than a reference since it will
     /// have to be stored in the analysis class - there's no point in forcing users to explicitly
     /// get the pointer from a reference before they can use it!)
     Profile1DPtr bookProfile1D(const std::string& name,
-			       const std::vector<double>& binedges,
-			       const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               const std::vector<double>& binedges,
+                               const std::string& title="",
+                               const std::string& xtitle="", const std::string& ytitle="");
 
     /// Book a 1D profile histogram based on the name in the corresponding AIDA
     /// file. The binnings will be obtained by reading the bundled AIDA data
     /// record file with the same filename as the analysis' name() property.
     Profile1DPtr bookProfile1D(const std::string& name, const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               const std::string& xtitle="", const std::string& ytitle="");
 
     /// Book a 1D profile histogram based on the paper, dataset and x/y-axis IDs in the corresponding
     /// HepData record. The binnings will be obtained by reading the bundled AIDA data record file
     /// of the same filename as the analysis' name() property.
     Profile1DPtr bookProfile1D(size_t datasetId, size_t xAxisId, size_t yAxisId,
-			       const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               const std::string& title="",
+                               const std::string& xtitle="", const std::string& ytitle="");
     //@}
 
 
@@ -487,7 +489,7 @@
     /// have to be stored in the analysis class - there's no point in forcing users to explicitly
     /// get the pointer from a reference before they can use it!)
     Scatter2DPtr bookScatter2D(const std::string& name, const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               const std::string& xtitle="", const std::string& ytitle="");
 
 
     /// Book a 2-dimensional data point set with equally spaced points in a range.
@@ -495,9 +497,9 @@
     /// have to be stored in the analysis class - there's no point in forcing users to explicitly
     /// get the pointer from a reference before they can use it!)
     Scatter2DPtr bookScatter2D(const std::string& name,
-			       size_t npts, double lower, double upper,
-			       const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               size_t npts, double lower, double upper,
+                               const std::string& title="",
+                               const std::string& xtitle="", const std::string& ytitle="");
 
     /// Book a 2-dimensional data point set based on the corresponding AIDA data
     /// file. The binnings (x-errors) will be obtained by reading the bundled
@@ -509,8 +511,8 @@
     /// HepData record. The binnings (x-errors) will be obtained by reading the bundled AIDA data record file
     /// of the same filename as the analysis' name() property.
     Scatter2DPtr bookScatter2D(size_t datasetId, size_t xAxisId, size_t yAxisId,
-			       const std::string& title="",
-			       const std::string& xtitle="", const std::string& ytitle="");
+                               const std::string& title="",
+                               const std::string& xtitle="", const std::string& ytitle="");
 
     //@}
 

Modified: trunk/src/Core/Analysis.cc
==============================================================================
--- trunk/src/Core/Analysis.cc	Tue Nov 27 12:03:50 2012	(r4049)
+++ trunk/src/Core/Analysis.cc	Tue Nov 27 23:40:08 2012	(r4050)
@@ -196,60 +196,59 @@
 
 
   Histo1DPtr Analysis::bookHisto1D(const string& hname, const string& title,
-				   const string& xtitle, const string& ytitle)
+                                   const string& xtitle, const string& ytitle)
   {
-    // Get the bin edges (only read the AIDA file once)
     const Scatter2D & refdata = referenceData(hname);
     const string path = histoPath(hname);
     Histo1DPtr hist( new Histo1D(refdata, path) );
     addPlot(hist);
     MSG_TRACE("Made histogram " << hname <<  " for " << name());
     hist->setTitle(title);
-    // hist->setXTitle(xtitle);
-    // hist->setYTitle(ytitle);
+    hist->setAnnotation("XLabel", xtitle);
+    hist->setAnnotation("YLabel", ytitle);
     return hist;
   }
 
 
   Histo1DPtr Analysis::bookHisto1D(const string& hname,
-				   size_t nbins, double lower, double upper,
-				   const string& title,
-				   const string& xtitle, const string& ytitle) {
+                                   size_t nbins, double lower, double upper,
+                                   const string& title,
+                                   const string& xtitle, const string& ytitle) {
     const string path = histoPath(hname);
     Histo1DPtr hist( new Histo1D(nbins, lower, upper, path, title) );
     addPlot(hist);
     MSG_TRACE("Made histogram " << hname <<  " for " << name());
-    // hist->setXTitle(xtitle);
-    // hist->setYTitle(ytitle);
+    hist->setAnnotation("XLabel", xtitle);
+    hist->setAnnotation("YLabel", ytitle);
     return hist;
   }
 
 
   Histo1DPtr Analysis::bookHisto1D(const string& hname,
-				   const vector<double>& binedges,
-				   const string& title,
-				   const string& xtitle,
-				   const string& ytitle) {
+                                   const vector<double>& binedges,
+                                   const string& title,
+                                   const string& xtitle,
+                                   const string& ytitle) {
     const string path = histoPath(hname);
     Histo1DPtr hist( new Histo1D(binedges, path, title) );
     addPlot(hist);
     MSG_TRACE("Made histogram " << hname <<  " for " << name());
-    // hist->setXTitle(xtitle);
-    // hist->setYTitle(ytitle);
+    hist->setAnnotation("XLabel", xtitle);
+    hist->setAnnotation("YLabel", ytitle);
     return hist;
   }
 
   // IHistogram2D*
   // Analysis::bookHistogram2D(const string& hname,
-  // 			    size_t nxbins, double xlower, double xupper,
-  // 			    size_t nybins, double ylower, double yupper,
-  // 			    const string& title, const string& xtitle,
-  // 			    const string& ytitle, const string& ztitle) {
+  //                size_t nxbins, double xlower, double xupper,
+  //                size_t nybins, double ylower, double yupper,
+  //                const string& title, const string& xtitle,
+  //                const string& ytitle, const string& ztitle) {
   //   _makeHistoDir();
   //   const string path = histoPath(hname);
   //   IHistogram2D* hist =
   //     histogramFactory().createHistogram2D(path, title, nxbins, xlower, xupper,
-  // 					   nybins, ylower, yupper);
+  //                       nybins, ylower, yupper);
   //   MSG_TRACE("Made 2D histogram " << hname <<  " for " << name());
   //   hist->setXTitle(xtitle);
   //   hist->setYTitle(ytitle);
@@ -260,10 +259,10 @@
 
   // IHistogram2D*
   // Analysis::bookHistogram2D(const string& hname,
-  // 			    const vector<double>& xbinedges,
-  // 			    const vector<double>& ybinedges,
-  // 			    const string& title, const string& xtitle,
-  // 			    const string& ytitle, const string& ztitle) {
+  //                const vector<double>& xbinedges,
+  //                const vector<double>& ybinedges,
+  //                const string& title, const string& xtitle,
+  //                const string& ytitle, const string& ztitle) {
   //   _makeHistoDir();
   //   const string path = histoPath(hname);
   //   IHistogram2D* hist =
@@ -280,59 +279,59 @@
 
 
   Profile1DPtr Analysis::bookProfile1D(size_t datasetId, size_t xAxisId,
-				       size_t yAxisId, const string& title,
-				       const string& xtitle, const string& ytitle) {
+                                       size_t yAxisId, const string& title,
+                                       const string& xtitle, const string& ytitle) {
     const string axisCode = makeAxisCode(datasetId, xAxisId, yAxisId);
     return bookProfile1D(axisCode, title, xtitle, ytitle);
   }
 
 
   Profile1DPtr Analysis::bookProfile1D(const string& hname, const string& title,
-				       const string& xtitle, const string& ytitle)
+                                       const string& xtitle, const string& ytitle)
   {
-    // Get the bin edges (only read the AIDA file once)
     const Scatter2D & refdata = referenceData(hname);
     const string path = histoPath(hname);
     Profile1DPtr prof( new Profile1D(refdata, path) );
     addPlot(prof);
     MSG_TRACE("Made profile histogram " << hname <<  " for " << name());
     prof->setTitle(title);
-    // prof->setXTitle(xtitle);
-    // prof->setYTitle(ytitle);
+    prof->setAnnotation("XLabel", xtitle);
+    prof->setAnnotation("YLabel", ytitle);
     return prof;
   }
 
 
   Profile1DPtr Analysis::bookProfile1D(const string& hname,
-				       size_t nbins, double lower, double upper,
-				       const string& title,
-				       const string& xtitle, const string& ytitle) {
+                                       size_t nbins, double lower, double upper,
+                                       const string& title,
+                                       const string& xtitle, const string& ytitle) {
     const string path = histoPath(hname);
     Profile1DPtr prof( new Profile1D(nbins, lower, upper, path, title) );
     addPlot(prof);
     MSG_TRACE("Made profile histogram " << hname <<  " for " << name());
-    // prof->setXTitle(xtitle);
-    // prof->setYTitle(ytitle);
+    prof->setAnnotation("XLabel", xtitle);
+    prof->setAnnotation("YLabel", ytitle);
     return prof;
   }
 
 
   Profile1DPtr Analysis::bookProfile1D(const string& hname,
-				       const vector<double>& binedges,
-				       const string& title,
-				       const string& xtitle, const string& ytitle) {
+                                       const vector<double>& binedges,
+                                       const string& title,
+                                       const string& xtitle, const string& ytitle) {
     const string path = histoPath(hname);
     Profile1DPtr prof( new Profile1D(binedges, path, title) );
     addPlot(prof);
     MSG_TRACE("Made profile histogram " << hname <<  " for " << name());
-    // prof->setXTitle(xtitle);
-    // prof->setYTitle(ytitle);
+    prof->setAnnotation("XLabel", xtitle);
+    prof->setAnnotation("YLabel", ytitle);
     return prof;
   }
 
 
   ///////////////////
 
+
   Scatter2DPtr Analysis::bookScatter2D(size_t datasetId, size_t xAxisId,
                                        size_t yAxisId, const string& title,
                                        const string& xtitle, const string& ytitle) {
@@ -342,26 +341,26 @@
 
 
   Scatter2DPtr Analysis::bookScatter2D(const string& hname, const string& title,
-				       const string& xtitle, const string& ytitle) {
+                                       const string& xtitle, const string& ytitle) {
     const string path = histoPath(hname);
     Scatter2DPtr dps( new Scatter2D(path, title) );
     addPlot(dps);
     MSG_TRACE("Made data point set " << hname <<  " for " << name());
-    // dps->setXTitle(xtitle);
-    // dps->setYTitle(ytitle);
+    dps->setAnnotation("XLabel", xtitle);
+    dps->setAnnotation("YLabel", ytitle);
     return dps;
   }
 
 
   Scatter2DPtr Analysis::bookScatter2D(const string& hname,
-				       size_t npts, double lower, double upper,
-				       const string& title,
-				       const string& xtitle, const string& ytitle) {
+                                       size_t npts, double lower, double upper,
+                                       const string& title,
+                                       const string& xtitle, const string& ytitle) {
     Scatter2DPtr dps = bookScatter2D(hname, title, xtitle, ytitle);
     const double binwidth = (upper-lower)/npts;
     for (size_t pt = 0; pt < npts; ++pt) {
       const double bincentre = lower + (pt + 0.5) * binwidth;
-      // \todo YODA check
+      // @todo YODA check
       dps->addPoint(bincentre, 0, binwidth/2.0, 0);
       // IMeasurement* meas = dps->point(pt)->coordinate(0);
       // meas->setValue(bincentre);
@@ -371,10 +370,10 @@
     return dps;
   }
 
-  // \todo YODA
+  // @todo YODA
   // Scatter2DPtr Analysis::bookScatter2D(size_t datasetId, size_t xAxisId,
-  // 				       size_t yAxisId, const string& title,
-  // 				       const string& xtitle, const string& ytitle) {
+  //                       size_t yAxisId, const string& title,
+  //                       const string& xtitle, const string& ytitle) {
   //   // Get the bin edges (only read the AIDA file once)
   //   _cacheXAxisData();
   //   // Build the axis code
@@ -411,18 +410,18 @@
     s->setPath( path );
   }
 
-  void Analysis::divide(const Histo1D & h1, 
-			const Histo1D & h2, 
-			Scatter2DPtr s) const {
+  void Analysis::divide(const Histo1D & h1,
+                        const Histo1D & h2,
+                        Scatter2DPtr s) const {
     // preserve the path info
     std::string path = s->path();
     *s = h1 / h2;
     s->setPath( path );
   }
 
-  void Analysis::divide(const Profile1D & p1, 
-			const Profile1D & p2, 
-			Scatter2DPtr s) const {
+  void Analysis::divide(const Profile1D & p1,
+                        const Profile1D & p2,
+                        Scatter2DPtr s) const {
     // preserve the path info
     std::string path = s->path();
     *s = p1 / p2;


More information about the Rivet-svn mailing list