|
[Rivet-svn] r2968 - in trunk: . include/Rivet include/Rivet/Tools src/Core src/Toolsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Feb 24 14:58:53 GMT 2011
Author: buckley Date: Thu Feb 24 14:58:52 2011 New Revision: 2968 Log: Changing analysis loader and analysis lib paths behaviour... pretty straightforward, actually. Looks like it works, but only tested on the plane as I was running out of battery. Can you see if the mkhtml issue is solved now, Hendrik? Added: trunk/include/Rivet/AnalysisBuilder.hh - copied, changed from r2957, trunk/include/Rivet/Analysis.hh Modified: trunk/ChangeLog trunk/include/Rivet/Analysis.hh trunk/include/Rivet/AnalysisLoader.hh trunk/include/Rivet/Makefile.am trunk/include/Rivet/Tools/Logging.hh trunk/src/Core/Analysis.cc trunk/src/Core/AnalysisLoader.cc trunk/src/Tools/RivetPaths.cc Modified: trunk/ChangeLog ============================================================================== --- trunk/ChangeLog Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/ChangeLog Thu Feb 24 14:58:52 2011 (r2968) @@ -1,3 +1,12 @@ +2011-02-24 Andy Buckley <andy at insectnation.org> + + * Changing analysis plugin registration to fall back through + available paths rather than have RIVET_ANALYSIS_PATH totally + override the built-in paths. The first analysis hook of a given + name to be found is now the one that's used: any duplicates found + will be warned about but unused. getAnalysisLibPaths() now returns + *all* the search paths, in keeping with the new search behaviour. + 2011-02-22 Andy Buckley <andy at insectnation.org> * Moving the definition of the MSG_* macros into the Logging.hh Modified: trunk/include/Rivet/Analysis.hh ============================================================================== --- trunk/include/Rivet/Analysis.hh Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/include/Rivet/Analysis.hh Thu Feb 24 14:58:52 2011 (r2968) @@ -503,49 +503,11 @@ }; +} - ///////////////////////////////////////////////////////////////////// - - - /// @cond ANALYSIS_PLUGIN_DETAILS - - /// @brief Interface for analysis builders - class AnalysisBuilderBase { - public: - AnalysisBuilderBase() { } - virtual ~AnalysisBuilderBase() { } - - virtual Analysis* mkAnalysis() const = 0; - - const string name() const { - Analysis* a = mkAnalysis(); - string rtn = a->name(); - delete a; - return rtn; - } - - protected: - void _register() { - AnalysisLoader::_registerBuilder(this); - } - }; - - - /// @brief Self-registering analysis plugin builder - template <typename T> - class AnalysisBuilder : public AnalysisBuilderBase { - public: - AnalysisBuilder() { - _register(); - } - - Analysis* mkAnalysis() const { - return new T(); - } - }; - /// @endcond +// Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh +#include "Rivet/AnalysisBuilder.hh" -} #endif Copied and modified: trunk/include/Rivet/AnalysisBuilder.hh (from r2957, trunk/include/Rivet/Analysis.hh) ============================================================================== --- trunk/include/Rivet/Analysis.hh Tue Feb 22 23:43:11 2011 (r2957, copy source) +++ trunk/include/Rivet/AnalysisBuilder.hh Thu Feb 24 14:58:52 2011 (r2968) @@ -1,511 +1,14 @@ // -*- C++ -*- -#ifndef RIVET_Analysis_HH -#define RIVET_Analysis_HH +#ifndef RIVET_AnalysisBuilder_HH +#define RIVET_AnalysisBuilder_HH #include "Rivet/Rivet.hh" #include "Rivet/Analysis.fhh" -#include "Rivet/Event.hh" -#include "Rivet/Projection.hh" -#include "Rivet/ProjectionApplier.hh" -#include "Rivet/ProjectionHandler.hh" -#include "Rivet/Constraints.hh" -#include "Rivet/AnalysisHandler.fhh" #include "Rivet/AnalysisLoader.hh" #include "Rivet/Tools/Logging.fhh" -#include "Rivet/RivetAIDA.fhh" - - -/// @def vetoEvent -/// Preprocessor define for vetoing events, including the log message and return. -#define vetoEvent { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } - namespace Rivet { - // Forward declaration - class AnalysisInfo; - - - /// @brief This is the base class of all analysis classes in Rivet. - /// - /// There are - /// three virtual functions which should be implemented in base classes: - /// - /// void init() is called by Rivet before a run is started. Here the - /// analysis class should book necessary histograms. The needed - /// projections should probably rather be constructed in the - /// constructor. - /// - /// void analyze(const Event&) is called once for each event. Here the - /// analysis class should apply the necessary Projections and fill the - /// histograms. - /// - /// void finalize() is called after a run is finished. Here the analysis - /// class should do whatever manipulations are necessary on the - /// histograms. Writing the histograms to a file is, however, done by - /// the Rivet class. - class Analysis : public ProjectionApplier { - - /// The AnalysisHandler is a friend. - friend class AnalysisHandler; - - - public: - - /// @name Standard constructors and destructors. - //@{ - - /// The default constructor. - //Analysis(); - - /// Constructor - Analysis(const std::string& name); - - /// The destructor. - virtual ~Analysis(); - - //@} - - - public: - - /// @name Main analysis methods - //@{ - - /// Initialize this analysis object. A concrete class should here - /// book all necessary histograms. An overridden function must make - /// sure it first calls the base class function. - virtual void init() = 0; - - /// Analyze one event. A concrete class should here apply the - /// necessary projections on the \a event and fill the relevant - /// histograms. An overridden function must make sure it first calls - /// the base class function. - virtual void analyze(const Event& event) = 0; - - /// Finalize this analysis object. A concrete class should here make - /// all necessary operations on the histograms. Writing the - /// histograms to a file is, however, done by the Rivet class. An - /// overridden function must make sure it first calls the base class - /// function. - virtual void finalize() = 0; - - //@} - - - public: - - /// @name Metadata - /// Metadata is used for querying from the command line and also for - /// building web pages and the analysis pages in the Rivet manual. - //@{ - - /// Get the actual AnalysisInfo object in which all this metadata is stored. - virtual const AnalysisInfo& info() const; - - /// @brief Get the name of the analysis. - /// - /// By default this is computed by combining the results of the experiment, - /// year and Spires ID metadata methods and you should only override it if - /// there's a good reason why those won't work. - virtual std::string name() const; - - /// Get a the SPIRES/Inspire ID code for this analysis. - virtual std::string spiresId() const; - - /// @brief Names & emails of paper/analysis authors. - /// - /// Names and email of authors in 'NAME \<EMAIL\>' format. The first - /// name in the list should be the primary contact person. - virtual std::vector<std::string> authors() const; - - /// @brief Get a short description of the analysis. - /// - /// Short (one sentence) description used as an index entry. - /// Use @a description() to provide full descriptive paragraphs - /// of analysis details. - virtual std::string summary() const; - - /// @brief Get a full description of the analysis. - /// - /// Full textual description of this analysis, what it is useful for, - /// what experimental techniques are applied, etc. Should be treated - /// as a chunk of restructuredText (http://docutils.sourceforge.net/rst.html), - /// with equations to be rendered as LaTeX with amsmath operators. - virtual std::string description() const; - - /// @brief Information about the events needed as input for this analysis. - /// - /// Event types, energies, kinematic cuts, particles to be considered - /// stable, etc. etc. Should be treated as a restructuredText bullet list - /// (http://docutils.sourceforge.net/rst.html) - virtual std::string runInfo() const; - - /// Experiment which performed and published this analysis. - virtual std::string experiment() const; - - /// Collider on which the experiment ran. - virtual std::string collider() const; - - /// Return the pair of incoming beams required by this analysis. - virtual const std::vector<PdgIdPair>& requiredBeams() const; - - /// Sets of valid beam energy pairs, in GeV - virtual const std::vector<std::pair<double, double> >& energies() const; - - /// @brief When the original experimental analysis was published. - /// - /// When the refereed paper on which this is based was published, - /// according to SPIRES. - virtual std::string year() const; - - /// Journal, and preprint references. - virtual std::vector<std::string> references() const; - - /// BibTeX citation key for this article. - virtual std::string bibKey() const; - - /// BibTeX citation entry for this article. - virtual std::string bibTeX() const; - - /// Whether this analysis is trusted (in any way!) - virtual std::string status() const; - - /// Any work to be done on this analysis. - virtual std::vector<std::string> todos() const; - - //@} - - - /// @name Run conditions - - /// Incoming beams for this run - const ParticlePair& beams() const; - - /// Incoming beam IDs for this run - const PdgIdPair beamIds() const; - - /// Centre of mass energy for this run - double sqrtS() const; - - //@} - - - public: - - /// Is this analysis able to run on the supplied pair of beams? - virtual bool isCompatible(PdgId beam1, PdgId beam2) const; - - /// Is this analysis able to run on the PdgIdPair @a beams ? - virtual bool isCompatible(const PdgIdPair& beams) const; - - /// Access the controlling AnalysisHandler object. - AnalysisHandler& handler() const; - - /// Normalize the given histogram, @a histo. After this call the - /// histogram will have been transformed to a DataPointSet with the - /// same name and path. It has the same effect as - /// @c scale(histo, norm/sumOfWeights). - /// @param histo The histogram to be normalised. - /// @param norm The new area of the histogram. - /// @warning The old histogram will be deleted, and its pointer set to zero. - void normalize(AIDA::IHistogram1D*& histo, double norm=1.0); - - /// Multiplicatively scale the given histogram, @a histo. After this call the - /// histogram will have been transformed to a DataPointSet with the same name and path. - /// @param histo The histogram to be scaled. - /// @param scale The factor used to multiply the histogram bin heights. - /// @warning The old histogram will be deleted, and its pointer set to zero. - void scale(AIDA::IHistogram1D*& histo, double scale); - - /// Normalize the given histogram, @a histo. After this call the - /// histogram will have been transformed to a DataPointSet with the - /// same name and path. It has the same effect as - /// @c scale(histo, norm/sumOfWeights). - /// @param histo The histogram to be normalised. - /// @param norm The new area of the histogram. - /// @warning The old histogram will be deleted, and its pointer set to zero. - void normalize(AIDA::IHistogram2D*& histo, double norm=1.0); - - /// Multiplicatively scale the given histogram, @a histo. After this call the - /// histogram will have been transformed to a DataPointSet with the same name and path. - /// @param histo The histogram to be scaled. - /// @param scale The factor used to multiply the histogram bin heights. - /// @warning The old histogram will be deleted, and its pointer set to zero. - void scale(AIDA::IHistogram2D*& histo, double scale); - - /// Set the cross section from the generator - Analysis& setCrossSection(double xs); - - /// Return true if this analysis needs to know the process cross-section. - bool needsCrossSection() const; - - - protected: - - - /// Get a Log object based on the name() property of the calling analysis object. - Log& getLog() const; - - /// Get the process cross-section in pb. Throws if this hasn't been set. - double crossSection() const; - - /// Get the process cross-section per generated event in pb. Throws if this - /// hasn't been set. - double crossSectionPerEvent() const; - - /// Get the number of events seen (via the analysis handler). Use in the - /// finalize phase only. - size_t numEvents() const; - - /// Get the sum of event weights seen (via the analysis handler). Use in the - /// finalize phase only. - double sumOfWeights() const; - - - protected: - - /// @name AIDA analysis infrastructure. - //@{ - /// Access the AIDA analysis factory of the controlling AnalysisHandler object. - AIDA::IAnalysisFactory& analysisFactory(); - - /// Access the AIDA tree of the controlling AnalysisHandler object. - AIDA::ITree& tree(); - - /// Access the AIDA histogram factory of the controlling AnalysisHandler object. - AIDA::IHistogramFactory& histogramFactory(); - - /// Access the AIDA histogram factory of the controlling AnalysisHandler object. - AIDA::IDataPointSetFactory& datapointsetFactory(); - - /// Get the canonical histogram "directory" path for this analysis. - const std::string histoDir() const; - - /// Get the canonical histogram path for the named histogram in this analysis. - const std::string histoPath(const std::string& hname) const; - - //@} - - - /// @name Internal histogram booking (for use by Analysis sub-classes). - //@{ - - /// Get bin edges for a named histo (using ref AIDA caching) - const BinEdges& binEdges(const std::string& hname) const; - - /// Get bin edges for a numbered histo (using ref AIDA caching) - const BinEdges& binEdges(size_t datasetId, size_t xAxisId, size_t yAxisId) const; - - /// Get bin edges with logarithmic widths - BinEdges logBinEdges(size_t nbins, double lower, double upper); - - /// 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!) - AIDA::IHistogram1D* bookHistogram1D(const std::string& name, - 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!) - AIDA::IHistogram1D* bookHistogram1D(const std::string& name, - 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 - /// ylower - @a yupper respectively along the x- and y-axis. - /// (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!) - 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=""); - - /// Book a 2D histogram with non-uniform bins defined by the - /// vectorx of bin edges @a xbinedges and @a ybinedges. - /// (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!) - 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=""); - - /// 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. - AIDA::IHistogram1D* bookHistogram1D(const std::string& name, 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. - AIDA::IHistogram1D* bookHistogram1D(size_t datasetId, size_t xAxisId, size_t yAxisId, - const std::string& title="", - const std::string& xtitle="", const std::string& ytitle=""); - - //@} - - - /// @name Internal profile histogram booking (for use by Analysis sub-classes). - //@{ - - /// Book a 1D profile 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!) - AIDA::IProfile1D* bookProfile1D(const std::string& name, - 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!) - AIDA::IProfile1D* bookProfile1D(const std::string& name, - 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. - AIDA::IProfile1D* bookProfile1D(const std::string& name, const std::string& title="", - 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. - AIDA::IProfile1D* bookProfile1D(size_t datasetId, size_t xAxisId, size_t yAxisId, - const std::string& title="", - const std::string& xtitle="", const std::string& ytitle=""); - //@} - - - /// @name Internal data point set booking (for use by Analysis sub-classes). - //@{ - - /// Book a 2-dimensional data point set. - /// (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!) - AIDA::IDataPointSet* bookDataPointSet(const std::string& name, const std::string& title="", - const std::string& xtitle="", const std::string& ytitle=""); - - - /// Book a 2-dimensional data point set with equally spaced points in a range. - /// (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!) - AIDA::IDataPointSet* bookDataPointSet(const std::string& name, - 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 - /// AIDA data record file of the same filename as the analysis' name() - /// property. - //AIDA::IDataPointSet* bookDataPointSet(const std::string& name, const std::string& title); - - /// Book a 2-dimensional data point set based on the paper, dataset and x/y-axis IDs in the corresponding - /// 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. - AIDA::IDataPointSet* bookDataPointSet(size_t datasetId, size_t xAxisId, size_t yAxisId, - const std::string& title="", - const std::string& xtitle="", const std::string& ytitle=""); - - //@} - - - private: - - /// @name Utility functions - //@{ - - /// Make the histogram directory. - void _makeHistoDir(); - - /// Get the bin edges for this paper from the reference AIDA file, and cache them. - void _cacheBinEdges() const; - - /// Get the x-axis points for this paper from the reference AIDA file, and cache them. - void _cacheXAxisData() const; - - //@} - - - protected: - - /// Set the colliding beam pair. - /// @deprecated Use .info file and AnalysisInfo class instead - Analysis& setBeams(PdgId beam1, PdgId beam2); - - /// Declare whether this analysis needs to know the process cross-section from the generator. - Analysis& setNeedsCrossSection(bool needed); - - - protected: - - /// Name passed to constructor (used to find .info analysis data file, and as a fallback) - string _defaultname; - - /// Pointer to analysis metadata object - shared_ptr<AnalysisInfo> _info; - - - private: - - /// @name Cross-section variables - //@{ - double _crossSection; - bool _gotCrossSection; - bool _needsCrossSection; - //@} - - /// The controlling AnalysisHandler object. - AnalysisHandler* _analysishandler; - - /// Flag to indicate whether the histogram directory is present - mutable bool _madeHistoDir; - - /// Collection of x-axis point data to speed up many autobookings: the - /// reference data file should only be read once. - /// @todo Reduce memory occupancy, or clear after initialisation? - mutable map<string, vector<DPSXPoint> > _dpsData; - - /// Collection of cached bin edges to speed up many autobookings: the - /// reference data file should only be read once. - /// @todo Reduce memory occupancy, or clear after initialisation? - mutable map<string, BinEdges> _histBinEdges; - - - private: - - /// The assignment operator is private and must never be called. - /// In fact, it should not even be implemented. - Analysis& operator=(const Analysis&); - - }; - - - - ///////////////////////////////////////////////////////////////////// - /// @cond ANALYSIS_PLUGIN_DETAILS Modified: trunk/include/Rivet/AnalysisLoader.hh ============================================================================== --- trunk/include/Rivet/AnalysisLoader.hh Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/include/Rivet/AnalysisLoader.hh Thu Feb 24 14:58:52 2011 (r2968) @@ -3,6 +3,7 @@ #define RIVET_AnalysisLoader_HH #include "Rivet/Rivet.hh" +#include "Rivet/Tools/Logging.fhh" #include <map> #include <string> @@ -32,6 +33,7 @@ private: + /// Allow the analysis builders to call the private _registerBuilder function friend class AnalysisBuilderBase; Modified: trunk/include/Rivet/Makefile.am ============================================================================== --- trunk/include/Rivet/Makefile.am Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/include/Rivet/Makefile.am Thu Feb 24 14:58:52 2011 (r2968) @@ -13,7 +13,7 @@ ParticleBase.hh Jet.hh \ Particle.hh Particle.fhh \ RivetAIDA.hh RivetAIDA.fhh \ - Analysis.hh Analysis.fhh \ + Analysis.hh Analysis.fhh AnalysisBuilder.hh \ AnalysisHandler.hh AnalysisHandler.fhh \ AnalysisInfo.hh ProjectionHandler.hh \ ProjectionApplier.hh ProjectionApplier.fhh \ Modified: trunk/include/Rivet/Tools/Logging.hh ============================================================================== --- trunk/include/Rivet/Tools/Logging.hh Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/include/Rivet/Tools/Logging.hh Thu Feb 24 14:58:52 2011 (r2968) @@ -172,8 +172,8 @@ // NB. Only usable in classes where a getLog() method is provided #define MSG_LVL(lvl, x) \ do { \ - if (this->getLog().isActive(lvl)) { \ - this->getLog() << lvl << x << endl; \ + if (getLog().isActive(lvl)) { \ + getLog() << lvl << x << endl; \ } \ } while (0) Modified: trunk/src/Core/Analysis.cc ============================================================================== --- trunk/src/Core/Analysis.cc Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/src/Core/Analysis.cc Thu Feb 24 14:58:52 2011 (r2968) @@ -513,7 +513,7 @@ // Build the axis code const string axisCode = makeAxisCode(datasetId, xAxisId, yAxisId); //const map<string, vector<DPSXPoint> > xpoints = getDPSXValsErrs(papername); - getLog() << Log::TRACE << "Using DPS x-positions for " << name() << ":" << axisCode << endl; + MSG_TRACE("Using DPS x-positions for " << name() << ":" << axisCode); IDataPointSet* dps = bookDataPointSet(axisCode, title, xtitle, ytitle); const vector<DPSXPoint> xpts = _dpsData.find(axisCode)->second; for (size_t pt = 0; pt < xpts.size(); ++pt) { @@ -523,7 +523,7 @@ meas->setErrorPlus(xpts[pt].errplus); meas->setErrorMinus(xpts[pt].errminus); } - getLog() << Log::TRACE << "Made DPS " << axisCode << " for " << name() << endl; + MSG_TRACE("Made DPS " << axisCode << " for " << name()); return dps; } Modified: trunk/src/Core/AnalysisLoader.cc ============================================================================== --- trunk/src/Core/AnalysisLoader.cc Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/src/Core/AnalysisLoader.cc Thu Feb 24 14:58:52 2011 (r2968) @@ -9,6 +9,12 @@ namespace Rivet { + namespace { + inline Log& getLog() { + return Log::getLog("Rivet.AnalysisLoader"); + } + } + // Initialise static ptr collection AnalysisLoader::AnalysisBuilderMap AnalysisLoader::_ptrs; @@ -53,13 +59,13 @@ if (!ab) return; const string name = ab->name(); if (_ptrs.find(name) != _ptrs.end()) { - // Protect against overwriting analyses by throwing an error - /// @todo Tidy this up! - cerr << "Tried to register a second plugin analysis called '" << name << "'" << endl; - exit(1); + // Duplicate analyses will be ignored... loudly + cerr << "Ignoring duplicate plugin analysis called '" << name << "'" << endl; + MSG_WARNING("Ignoring duplicate plugin analysis called '" << name << "'"); + } else { + MSG_TRACE("Registering a plugin analysis called '" << name << "'"); + _ptrs[name] = ab; } - Log::getLog("Rivet.AnalysisLoader") << Log::TRACE << "Registering a plugin analysis called '" << name << "'" << endl; - _ptrs[name] = ab; } @@ -78,7 +84,7 @@ oslink::directory dir(d); while (dir) { string filename = dir.next(); - // Require that name *starts* with 'Rivet' with new loader + // Require that plugin lib name starts with 'Rivet' if (filename.find("Rivet") != 0) continue; size_t posn = filename.find(libsuffix); if (posn == string::npos || posn != filename.length()-libsuffix.length()) continue; @@ -93,12 +99,12 @@ } // Load the plugin files - Log::getLog("Rivet.AnalysisLoader") << Log::TRACE << "Candidate analysis plugin libs: " << pluginfiles << endl; + MSG_TRACE("Candidate analysis plugin libs: " << pluginfiles); foreach (const string& pf, pluginfiles) { - Log::getLog("Rivet.AnalysisLoader") << Log::TRACE << "Trying to load plugin analyses from file " << pf << endl; + MSG_TRACE("Trying to load plugin analyses from file " << pf); void* handle = dlopen(pf.c_str(), RTLD_LAZY); if (!handle) { - Log::getLog("Rivet.AnalysisLoader") << Log::WARN << "Cannot open " << pf << ": " << dlerror() << endl; + MSG_WARNING("Cannot open " << pf << ": " << dlerror()); continue; } } Modified: trunk/src/Tools/RivetPaths.cc ============================================================================== --- trunk/src/Tools/RivetPaths.cc Thu Feb 24 14:57:47 2011 (r2967) +++ trunk/src/Tools/RivetPaths.cc Thu Feb 24 14:58:52 2011 (r2968) @@ -63,10 +63,9 @@ if (env) { // Use the Rivet analysis path variable if set... dirs += pathsplit(env); - } else { - // ... otherwise fall back to the Rivet library install path - dirs += getLibPath(); } + // ... otherwise fall back to the Rivet library install path + dirs += getLibPath(); return dirs; }
More information about the Rivet-svn mailing list |