[Rivet-svn] r2521 - trunk/bin

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Jun 23 15:03:56 BST 2010


Author: fsiegert
Date: Wed Jun 23 15:04:01 2010
New Revision: 2521

Log:
rivet-mkanalysis: Add option for inlining metadata instead of writing it
into a separate .info file.

Modified:
   trunk/bin/rivet-mkanalysis

Modified: trunk/bin/rivet-mkanalysis
==============================================================================
--- trunk/bin/rivet-mkanalysis	Wed Jun 23 14:54:05 2010	(r2520)
+++ trunk/bin/rivet-mkanalysis	Wed Jun 23 15:04:01 2010	(r2521)
@@ -22,6 +22,8 @@
                   action="store_const", const=logging.WARNING, help="only write out warning and error messages")
 parser.add_option("-v", "--verbose", dest="LOGLEVEL", default=logging.INFO,
                   action="store_const", const=logging.DEBUG, help="provide extra debugging messages")
+parser.add_option("-i", "--inline-info", dest="INLINE", action="store_true",
+                  default=False, help="Put analysis info into source file instead of separate data file.")
 opts, args = parser.parse_args()
 try:
     logging.basicConfig(format="%(msg)s", level=opts.LOGLEVEL)
@@ -105,6 +107,29 @@
     KEYWORDS["ANABIBTEX"] = ANABIBTEX
 
 
+    if opts.INLINE:
+        INLINEMETHODS="""
+  public:
+    string experiment()         const { return "%(ANAEXPT)s"; }
+    string year()               const { return "%(ANAYEAR)s"; }
+    string spiresId()           const { return "%(ANASPIRESID)s"; }
+    string collider()           const { return "None"; }
+    string summary()            const { return "None"; }
+    string description()        const { return "None"; }
+    string runInfo()            const { return "None"; }
+    string bibKey()             const { return "%(ANABIBKEY)s"; }
+    string bibTeX()             const { return "%(ANABIBTEX)s"; }
+    string status()             const { return "UNVALIDATED"; }
+    vector<string> authors()    const { return vector<string>(); }
+    vector<string> references() const { return vector<string>(); }
+    vector<std::string> todos() const { return vector<string>(); }
+    """ % KEYWORDS
+    else:
+        INLINEMETHODS=""
+
+    KEYWORDS["INLINEMETHODS"] = INLINEMETHODS
+
+
     ANASRCFILE = os.path.join(ANASRCDIR, ANANAME+".cc")
     logging.debug("Writing implementation template to %s" % ANASRCFILE)
     f = open(ANASRCFILE, "w")
@@ -129,9 +154,6 @@
     %(ANANAME)s()
       : Analysis("%(ANANAME)s")
     {
-      /// @todo Set approriate for your analysis
-      setBeams(PROTON, ANTIPROTON);
-
       /// @todo Set whether your finalize method needs the generator cross section
       setNeedsCrossSection(true);
     }
@@ -150,8 +172,8 @@
       /// @todo Initialise and register projections here
 
       /// @todo Book histograms here, e.g.:
-      // _histXXXX = bookProfile1D(1, 1, 1);
-      // _histYYYY = bookHistogram1D(2, 1, 1);
+      // _h_XXXX = bookProfile1D(1, 1, 1);
+      // _h_YYYY = bookHistogram1D(2, 1, 1);
 
     }
 
@@ -170,8 +192,8 @@
 
       /// @todo Normalise, scale and otherwise manipulate histograms here
 
-      // scale(_histYYYY, crossSection()/sumOfWeights()); # norm to cross section
-      // normalize(_histYYYY); # normalize to unity
+      // scale(_h_YYYY, crossSection()/sumOfWeights()); # norm to cross section
+      // normalize(_h_YYYY); # normalize to unity
 
     }
 
@@ -188,9 +210,10 @@
     /// @name Histograms
     //@{
 
-    AIDA::IProfile1D *_histXXXX;
-    AIDA::IHistogram1D *_histYYYY;
+    AIDA::IProfile1D *_h_XXXX;
+    AIDA::IHistogram1D *_h_YYYY;
     //@}
+%(INLINEMETHODS)s
 
   };
 
@@ -205,6 +228,24 @@
     f.write(src)
     f.close()
 
+    ANAPLOTFILE = os.path.join(ANAPLOTDIR, ANANAME+".plot")
+    logging.debug("Writing plot template to %s" % ANAPLOTFILE)
+    f = open(ANAPLOTFILE, "w")
+    src = """\
+# BEGIN PLOT /%(ANANAME)s/d01-x01-y01
+Title=[Insert title for histogram d01-x01-y01 here]
+XLabel=[Insert x-axis label for histogram d01-x01-y01 here]
+YLabel=[Insert y-axis label for histogram d01-x01-y01 here]
+# + any additional plot settings you might like, see make-plots documentation
+# END PLOT
+
+# ... add more histograms as you need them ...
+""" % KEYWORDS
+    f.write(src)
+    f.close()
+
+    if opts.INLINE:
+        sys.exit(0)
     ANAINFOFILE = os.path.join(ANAINFODIR, ANANAME+".info")
     logging.debug("Writing info template to %s" % ANAINFOFILE)
     f = open(ANAINFOFILE, "w")
@@ -245,20 +286,3 @@
 """ % KEYWORDS
     f.write(src)
     f.close()
-
-
-    ANAPLOTFILE = os.path.join(ANAPLOTDIR, ANANAME+".plot")
-    logging.debug("Writing plot template to %s" % ANAPLOTFILE)
-    f = open(ANAPLOTFILE, "w")
-    src = """\
-# BEGIN PLOT /%(ANANAME)s/d01-x01-y01
-Title=[Insert title for histogram d01-x01-y01 here]
-XLabel=[Insert x-axis label for histogram d01-x01-y01 here]
-YLabel=[Insert y-axis label for histogram d01-x01-y01 here]
-# + any additional plot settings you might like, see make-plots documentation
-# END PLOT
-
-# ... add more histograms as you need them ...
-""" % KEYWORDS
-    f.write(src)
-    f.close()


More information about the Rivet-svn mailing list