|
[Rivet-svn] r3491 - in trunk: . bin data include/Rivet/Projections src/Projectionsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgSat Nov 19 21:21:31 GMT 2011
Author: buckley Date: Sat Nov 19 21:21:31 2011 New Revision: 3491 Log: bin/rivet: Adding a more helpful error message if the rivet module can't be loaded, grouping the option parser options, removing the -A option (this just doesn't seem useful anymore), and providing a --pwd option as a shortcut to append . to the search path. Modified: trunk/ChangeLog trunk/bin/rivet trunk/data/rivet-completion trunk/include/Rivet/Projections/FastJets.hh trunk/src/Projections/FastJets.cc Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Fri Nov 18 14:23:53 2011 (r3490) +++ trunk/ChangeLog Sat Nov 19 21:21:31 2011 (r3491) @@ -1,3 +1,11 @@ +2011-11-19 Andy Buckley <andy.buckley at cern.ch> + + * bin/rivet: Adding a more helpful error message if the rivet + module can't be loaded, grouping the option parser options, + removing the -A option (this just doesn't seem useful anymore), + and providing a --pwd option as a shortcut to append "." to the + search path. + 2011-11-18 Andy Buckley <andy.buckley at cern.ch> * Adding a guide to compiling a new analysis template to the Modified: trunk/bin/rivet ============================================================================== --- trunk/bin/rivet Fri Nov 18 14:23:53 2011 (r3490) +++ trunk/bin/rivet Sat Nov 19 21:21:31 2011 (r3491) @@ -61,53 +61,68 @@ import rivet rivet.check_python_version() except Exception, e: - sys.stderr.write(PROGNAME + " requires the 'rivet' Python module\n") + sys.stderr.write(PROGNAME + " requires the 'rivet' Python module but it cannot be loaded:\n") sys.stderr.write(str(e)+'\n') + sys.stderr.write("Try re-running with the -v switch to enable more debugging output \n") sys.exit(1) ## Parse command line options from optparse import OptionParser, OptionGroup parser = OptionParser(usage=__doc__, version="rivet v%s" % rivet.version()) -parser.add_option("-n", "--nevts", dest="MAXEVTNUM", type="int", - default=None, metavar="NUM", - help="max number of events to read.") -parser.add_option("-a", "--analysis", dest="ANALYSES", action="append", - default=[], metavar="ANA", - help="add an analysis to the processing list.") -parser.add_option("-A", "--all-analyses", dest="ALL_ANALYSES", action="store_true", - default=False, help="add all analyses to the processing list.") -parser.add_option("--analysis-path", dest="ANALYSIS_PATH", metavar="PATH", default=None, - help="specify the analysis search path (cf. $RIVET_ANALYSIS_PATH).") -parser.add_option("--analysis-path-append", dest="ANALYSIS_PATH_APPEND", metavar="PATH", default=None, - help="append to the analysis search path (cf. $RIVET_ANALYSIS_PATH).") -parser.add_option("--list-analyses", dest="LIST_ANALYSES", action="store_true", - default=False, help="show the list of available analyses' names. With -v, it shows the descriptions, too") -parser.add_option("--list-used-analyses", action="store_true", dest="LIST_USED_ANALYSES", - default=False, help="list the analyses used by this command (after subtraction of inappropriate ones)") -parser.add_option("--show-analysis", "--show-analyses", dest="SHOW_ANALYSES", action="append", - default=[], help="show the details of an analysis") -parser.add_option("--runname", dest="RUN_NAME", default=None, metavar="NAME", - help="give an optional run name, to be prepended as a 'top level directory' in histo paths") -parser.add_option("-H", "--histo-file", dest="HISTOFILE", - default="Rivet.aida", help="specify the output histo file path (default = %default)") -parser.add_option("--event-timeout", dest="EVENT_TIMEOUT", type="int", - default=21600, metavar="NSECS", - help="max time in whole seconds to wait for an event to be generated from the specified source (default = %default)") -parser.add_option("--run-timeout", dest="RUN_TIMEOUT", type="int", - default=None, metavar="NSECS", - help="max time in whole seconds to wait for the run to finish. This can be useful on batch systems such " - "as the LCG Grid where tokens expire on a fixed wall-clock and can render long Rivet runs unable to write " - "out the final histogram file (default = unlimited)") -parser.add_option("--histo-interval", dest="HISTO_WRITE_INTERVAL", type=int, - default=None, help="[experimental!] specify the number of events between histogram file updates. " - "Default is to only write out at the end of the run. Note that intermediate histograms will be those " - "from the analyze step only: analysis finalizing is currently not executed until the end of the run.") -parser.add_option("-x", "--cross-section", dest="CROSS_SECTION", - default=None, metavar="XS", - help="specify the signal process cross-section in pb") -parser.add_option("--ignore-beams", dest="IGNORE_BEAMS", action="store_true", default=False, - help="Ignore input event beams when checking analysis compatibility.") + +anagroup = OptionGroup(parser, "Analysis handling") +anagroup.add_option("-a", "--analysis", dest="ANALYSES", action="append", + default=[], metavar="ANA", + help="add an analysis to the processing list.") +# anagroup.add_option("-A", "--all-analyses", dest="ALL_ANALYSES", action="store_true", +# default=False, help="add all analyses to the processing list.") +anagroup.add_option("--list-analyses", dest="LIST_ANALYSES", action="store_true", + default=False, help="show the list of available analyses' names. With -v, it shows the descriptions, too") +anagroup.add_option("--list-used-analyses", action="store_true", dest="LIST_USED_ANALYSES", + default=False, help="list the analyses used by this command (after subtraction of inappropriate ones)") +anagroup.add_option("--show-analysis", "--show-analyses", dest="SHOW_ANALYSES", action="append", + default=[], help="show the details of an analysis") +anagroup.add_option("--analysis-path", dest="ANALYSIS_PATH", metavar="PATH", default=None, + help="specify the analysis search path (cf. $RIVET_ANALYSIS_PATH).") +anagroup.add_option("--analysis-path-append", dest="ANALYSIS_PATH_APPEND", metavar="PATH", default=None, + help="append to the analysis search path (cf. $RIVET_ANALYSIS_PATH).") +anagroup.add_option("--pwd", dest="ANALYSIS_PATH_PWD", action="store_true", default=False, + help="append the current directory (pwd) to the analysis search path (cf. $RIVET_ANALYSIS_PATH).") +parser.add_option_group(anagroup) + + +extragroup = OptionGroup(parser, "Extra run settings") +extragroup.add_option("-H", "--histo-file", dest="HISTOFILE", + default="Rivet.aida", help="specify the output histo file path (default = %default)") +extragroup.add_option("-x", "--cross-section", dest="CROSS_SECTION", + default=None, metavar="XS", + help="specify the signal process cross-section in pb") +extragroup.add_option("-n", "--nevts", dest="MAXEVTNUM", type="int", + default=None, metavar="NUM", + help="restrict the max number of events to read.") +extragroup.add_option("--runname", dest="RUN_NAME", default=None, metavar="NAME", + help="give an optional run name, to be prepended as a 'top level directory' in histo paths") +extragroup.add_option("--ignore-beams", dest="IGNORE_BEAMS", action="store_true", default=False, + help="Ignore input event beams when checking analysis compatibility.") +parser.add_option_group(extragroup) + + +timinggroup = OptionGroup(parser, "Timeouts and periodic operations") +timinggroup.add_option("--event-timeout", dest="EVENT_TIMEOUT", type="int", + default=21600, metavar="NSECS", + help="max time in whole seconds to wait for an event to be generated from the specified source (default = %default)") +timinggroup.add_option("--run-timeout", dest="RUN_TIMEOUT", type="int", + default=None, metavar="NSECS", + help="max time in whole seconds to wait for the run to finish. This can be useful on batch systems such " + "as the LCG Grid where tokens expire on a fixed wall-clock and can render long Rivet runs unable to write " + "out the final histogram file (default = unlimited)") +timinggroup.add_option("--histo-interval", dest="HISTO_WRITE_INTERVAL", type=int, + default=None, help="[experimental!] specify the number of events between histogram file updates. " + "Default is to only write out at the end of the run. Note that intermediate histograms will be those " + "from the analyze step only: analysis finalizing is currently not executed until the end of the run.") +parser.add_option_group(timinggroup) + verbgroup = OptionGroup(parser, "Verbosity control") parser.add_option("-l", dest="NATIVE_LOG_STRS", action="append", @@ -222,7 +237,8 @@ if opts.ANALYSIS_PATH_APPEND: for ap in opts.ANALYSIS_PATH_APPEND.split(":"): rivet.addAnalysisLibPath(ap) - +if opts.ANALYSIS_PATH_PWD: + rivet.addAnalysisLibPath(".") ## List of analyses all_analyses = rivet.AnalysisLoader.analysisNames() Modified: trunk/data/rivet-completion ============================================================================== --- trunk/data/rivet-completion Fri Nov 18 14:23:53 2011 (r3490) +++ trunk/data/rivet-completion Sat Nov 19 21:21:31 2011 (r3491) @@ -18,7 +18,7 @@ opts="--help --verbose --quiet --version --nevts --cross-section" opts="$opts --analysis --runname --list-analyses --show-analysis" - opts="$opts --analysis-path --analysis-path-append" + opts="$opts --analysis-path --analysis-path-append --pwd" opts="$opts --histo-file --histo-interval --event-timeout" opts="$opts -a -A -n -h -x -H -l -v -q" if [[ ${cur} == -* ]] ; then Modified: trunk/include/Rivet/Projections/FastJets.hh ============================================================================== --- trunk/include/Rivet/Projections/FastJets.hh Fri Nov 18 14:23:53 2011 (r3490) +++ trunk/include/Rivet/Projections/FastJets.hh Sat Nov 19 21:21:31 2011 (r3491) @@ -67,22 +67,35 @@ /// E-scheme recombination is used. For full control of /// FastJet built-in jet algs, use the native arg constructor. FastJets(const FinalState& fsp, JetAlgName alg, - double rparameter, double seed_threshold=1.0); + double rparameter, double seed_threshold=1.0) + : JetAlg(fsp), _adef(0) { _init1(alg, rparameter, seed_threshold); } /// Native argument constructor, using FastJet alg/scheme enums. FastJets(const FinalState& fsp, fastjet::JetAlgorithm type, - fastjet::RecombinationScheme recom, double rparameter); + fastjet::RecombinationScheme recom, double rparameter) + : JetAlg(fsp), _adef(0) { _init2(type, recom, rparameter); } - /// Explicitly pass in an externally-constructed plugin - FastJets(const FinalState& fsp, fastjet::JetDefinition::Plugin& plugin); + /// Explicitly pass in an externally-constructed plugin (must be heap-allocated, Rivet will delete) + FastJets(const FinalState& fsp, fastjet::JetDefinition::Plugin* plugin); + : JetAlg(fsp), _adef(0) { _init3(plugin); } + /// Explicitly pass in an externally-constructed plugin (must be heap-allocated, Rivet will delete) + FastJets(const FinalState& fsp, fastjet::JetDefinition::Plugin& plugin) + : JetAlg(fsp), _adef(0) { _init3(&plugin); } + + + /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) + FastJets(JetAlgName alg, double rparameter, double seed_threshold=1.0) + : _adef(0) { _init1(alg, rparameter, seed_threshold); } + /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) + FastJets(fastjet::JetAlgorithm type, fastjet::RecombinationScheme recom, double rparameter) + : _adef(0) { _init2(type, recom, rparameter); } + /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) + FastJets(fastjet::JetDefinition::Plugin* plugin) + : _adef(0) { _init3(plugin); } + /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) + FastJets(fastjet::JetDefinition::Plugin& plugin) + : _adef(0) { _init3(&plugin); } - /// Same thing as above, but we want to pass the particles directly to the calc method - FastJets(JetAlgName alg, double rparameter, double seed_threshold=1.0); - FastJets(fastjet::JetAlgorithm type, fastjet::RecombinationScheme recom, double rparameter); - FastJets(fastjet::JetDefinition::Plugin& plugin); - - // /// Explicit copy constructor. - // FastJets(const FastJets& other); /// Clone on the heap. virtual const Projection* clone() const { @@ -170,63 +183,11 @@ Jets _pseudojetsToJets(const PseudoJets& pjets) const; - void _init1(JetAlgName alg, double rparameter, double seed_threshold) { - setName("FastJets"); - MSG_DEBUG("R parameter = " << rparameter); - MSG_DEBUG("Seed threshold = " << seed_threshold); - if (alg == KT) { - _jdef = fastjet::JetDefinition(fastjet::kt_algorithm, rparameter, fastjet::E_scheme); - } else if (alg == CAM) { - _jdef = fastjet::JetDefinition(fastjet::cambridge_algorithm, rparameter, fastjet::E_scheme); - } else if (alg == ANTIKT) { - _jdef = fastjet::JetDefinition(fastjet::antikt_algorithm, rparameter, fastjet::E_scheme); - } else if (alg == DURHAM) { - _jdef = fastjet::JetDefinition(fastjet::ee_kt_algorithm, fastjet::E_scheme); - } else { - // Plugins: - if (alg == SISCONE) { - const double OVERLAP_THRESHOLD = 0.75; - _plugin.reset(new fastjet::SISConePlugin(rparameter, OVERLAP_THRESHOLD)); - } else if (alg == PXCONE) { - string msg = "PxCone currently not supported, since FastJet doesn't install it by default. "; - msg += "Please notify the Rivet authors if this behaviour should be changed."; - throw Error(msg); - //_plugin.reset(new fastjet::PxConePlugin(rparameter)); - } else if (alg == ATLASCONE) { - const double OVERLAP_THRESHOLD = 0.5; - _plugin.reset(new fastjet::ATLASConePlugin(rparameter, seed_threshold, OVERLAP_THRESHOLD)); - } else if (alg == CMSCONE) { - _plugin.reset(new fastjet::CMSIterativeConePlugin(rparameter, seed_threshold)); - } else if (alg == CDFJETCLU) { - const double OVERLAP_THRESHOLD = 0.75; - _plugin.reset(new fastjet::CDFJetCluPlugin(rparameter, OVERLAP_THRESHOLD, seed_threshold)); - } else if (alg == CDFMIDPOINT) { - const double OVERLAP_THRESHOLD = 0.5; - _plugin.reset(new fastjet::CDFMidPointPlugin(rparameter, OVERLAP_THRESHOLD, seed_threshold)); - } else if (alg == D0ILCONE) { - const double min_jet_Et = 6.0; - _plugin.reset(new fastjet::D0RunIIConePlugin(rparameter, min_jet_Et)); - } else if (alg == JADE) { - _plugin.reset(new fastjet::JadePlugin()); - } else if (alg == TRACKJET) { - _plugin.reset(new fastjet::TrackJetPlugin(rparameter)); - } - _jdef = fastjet::JetDefinition(_plugin.get()); - } - } - + /// Shared utility functions to implement constructor behaviour + void _init1(JetAlgName alg, double rparameter, double seed_threshold); void _init2(fastjet::JetAlgorithm type, - fastjet::RecombinationScheme recom, double rparameter) { - setName("FastJets"); - _jdef = fastjet::JetDefinition(type, rparameter, recom); - } - - void _init3(fastjet::JetDefinition::Plugin& plugin) { - setName("FastJets"); - /// @todo Should we be copying the plugin? - _plugin.reset(&plugin); - _jdef = fastjet::JetDefinition(_plugin.get()); - } + fastjet::RecombinationScheme recom, double rparameter); + void _init3(fastjet::JetDefinition::Plugin* plugin); protected: Modified: trunk/src/Projections/FastJets.cc ============================================================================== --- trunk/src/Projections/FastJets.cc Fri Nov 18 14:23:53 2011 (r3490) +++ trunk/src/Projections/FastJets.cc Sat Nov 19 21:21:31 2011 (r3491) @@ -6,49 +6,65 @@ namespace Rivet { - FastJets::FastJets(const FinalState& fsp, JetAlgName alg, double rparameter, double seed_threshold) - : JetAlg(fsp), _adef(0) - { - _init1(alg, rparameter, seed_threshold); - } - - - FastJets::FastJets(const FinalState& fsp, fastjet::JetAlgorithm type, - fastjet::RecombinationScheme recom, double rparameter) - : JetAlg(fsp), _adef(0) - { - _init2(type, recom, rparameter); - } - - - FastJets::FastJets(const FinalState& fsp, - fastjet::JetDefinition::Plugin& plugin) - : JetAlg(fsp), _adef(0) - { - _init3(plugin); + void FastJets::_init1(JetAlgName alg, double rparameter, double seed_threshold) { + setName("FastJets"); + MSG_DEBUG("R parameter = " << rparameter); + MSG_DEBUG("Seed threshold = " << seed_threshold); + if (alg == KT) { + _jdef = fastjet::JetDefinition(fastjet::kt_algorithm, rparameter, fastjet::E_scheme); + } else if (alg == CAM) { + _jdef = fastjet::JetDefinition(fastjet::cambridge_algorithm, rparameter, fastjet::E_scheme); + } else if (alg == ANTIKT) { + _jdef = fastjet::JetDefinition(fastjet::antikt_algorithm, rparameter, fastjet::E_scheme); + } else if (alg == DURHAM) { + _jdef = fastjet::JetDefinition(fastjet::ee_kt_algorithm, fastjet::E_scheme); + } else { + // Plugins: + if (alg == SISCONE) { + const double OVERLAP_THRESHOLD = 0.75; + _plugin.reset(new fastjet::SISConePlugin(rparameter, OVERLAP_THRESHOLD)); + } else if (alg == PXCONE) { + string msg = "PxCone currently not supported, since FastJet doesn't install it by default. "; + msg += "Please notify the Rivet authors if this behaviour should be changed."; + throw Error(msg); + //_plugin.reset(new fastjet::PxConePlugin(rparameter)); + } else if (alg == ATLASCONE) { + const double OVERLAP_THRESHOLD = 0.5; + _plugin.reset(new fastjet::ATLASConePlugin(rparameter, seed_threshold, OVERLAP_THRESHOLD)); + } else if (alg == CMSCONE) { + _plugin.reset(new fastjet::CMSIterativeConePlugin(rparameter, seed_threshold)); + } else if (alg == CDFJETCLU) { + const double OVERLAP_THRESHOLD = 0.75; + _plugin.reset(new fastjet::CDFJetCluPlugin(rparameter, OVERLAP_THRESHOLD, seed_threshold)); + } else if (alg == CDFMIDPOINT) { + const double OVERLAP_THRESHOLD = 0.5; + _plugin.reset(new fastjet::CDFMidPointPlugin(rparameter, OVERLAP_THRESHOLD, seed_threshold)); + } else if (alg == D0ILCONE) { + const double min_jet_Et = 6.0; + _plugin.reset(new fastjet::D0RunIIConePlugin(rparameter, min_jet_Et)); + } else if (alg == JADE) { + _plugin.reset(new fastjet::JadePlugin()); + } else if (alg == TRACKJET) { + _plugin.reset(new fastjet::TrackJetPlugin(rparameter)); + } + _jdef = fastjet::JetDefinition(_plugin.get()); + } } - - FastJets::FastJets(JetAlgName alg, double rparameter, double seed_threshold) - : _adef(0) - { - _init1(alg, rparameter, seed_threshold); + void FastJets::_init2(fastjet::JetAlgorithm type, + fastjet::RecombinationScheme recom, double rparameter) { + setName("FastJets"); + _jdef = fastjet::JetDefinition(type, rparameter, recom); } - FastJets::FastJets(fastjet::JetAlgorithm type, - fastjet::RecombinationScheme recom, double rparameter) - : _adef(0) - { - _init2(type, recom, rparameter); + void FastJets::_init3(fastjet::JetDefinition::Plugin* plugin) { + setName("FastJets"); + /// @todo Should we be copying the plugin? + _plugin.reset(plugin); + _jdef = fastjet::JetDefinition(_plugin.get()); } - FastJets::FastJets(fastjet::JetDefinition::Plugin& plugin) - : _adef(0) - { - _init3(plugin); - } - int FastJets::compare(const Projection& p) const { const FastJets& other = dynamic_cast<const FastJets&>(p); @@ -243,4 +259,5 @@ return reconst_jet; } + }
More information about the Rivet-svn mailing list |