Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:18

0001 // -*- C++ -*-
0002 //
0003 // AnalysisFactory.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef LWH_AnalysisFactory_H
0010 #define LWH_AnalysisFactory_H
0011 //
0012 // This is the declaration of the AnalysisFactory class.
0013 //
0014 
0015 #include "AIAnalysisFactory.h"
0016 #include "TreeFactory.h"
0017 #include "HistogramFactory.h"
0018 #include "DataPointSetFactory.h"
0019 #include <set>
0020 
0021 /**
0022  * The LWH namespace contains a Light-Weight Histogram package which
0023  * implements the most rudimentary histogramming facilities according
0024  * to the <a href="http://aida.freehep.org">AIDA</a> interface
0025  * specifications. Currently the only thing that is supported is
0026  * simple, equally binned, one dimensional histograms and data
0027  * points. It is mainly intended to be used in applications where one
0028  * needs to fill simple histograms and output them. With LWH it is
0029  * then possible to do this without the overhead of a full AIDA
0030  * implementation, but still having the option to use a full
0031  * implementation later on with minimal changes. Note also that since
0032  * LWH consists only of header files, the installation is trivial -
0033  * just put the header files where they can be found by your compiler.
0034  */
0035 namespace LWH {
0036 
0037 using namespace AIDA;
0038 
0039 /**
0040  * The "master" factory from which other factories are obtained.
0041  * Typically accessed by:
0042  * <pre>IAnalysisFactory* af = AIDA_createAnalysisFactory();</pre>
0043  */
0044 class AnalysisFactory: public IAnalysisFactory {
0045 
0046 public: 
0047   /// Destructor.
0048   virtual ~AnalysisFactory() {
0049     clear();
0050   }
0051 
0052   /**
0053    * Create an ITreeFactory.
0054    * @return The ITreeFactory.
0055    */
0056   ITreeFactory * createTreeFactory() {
0057     return new TreeFactory;
0058   }
0059 
0060   /**
0061    * Create an HistogramFactory.
0062    * @param tree The ITree which created histograms will be associated to.
0063    * @return     The IHistogramFactory.
0064    *
0065    */
0066   IHistogramFactory * createHistogramFactory(ITree & tree) {
0067     Tree & tr = dynamic_cast<Tree &>(tree);
0068     HistogramFactory * hf = new HistogramFactory(tr);
0069     histfacs.insert(hf);
0070     return hf;
0071   }
0072 
0073   /**
0074    * Not implemented in LWH.
0075    * @return     null pointer always.
0076    *
0077    */
0078   IDataPointSetFactory * createDataPointSetFactory(ITree & tree) {
0079     Tree & tr = dynamic_cast<Tree &>(tree);
0080     DataPointSetFactory * df = new DataPointSetFactory(tr);
0081     datafacs.insert(df);
0082     return df;
0083   }
0084 
0085   /**
0086    * Not implemented in LWH.
0087    * @return     null pointer always.
0088    */
0089   ITupleFactory * createTupleFactory(ITree &) {
0090     return 0;
0091   }
0092 
0093   /**
0094    * Not implemented in LWH.
0095    * @return     null pointer always.
0096    */
0097   IFunctionFactory * createFunctionFactory(ITree &) {
0098     return 0;
0099   }
0100 
0101   /**
0102    * Not implemented in LWH.
0103    * @return     null pointer always.
0104    */
0105   IPlotterFactory * createPlotterFactory(int = 0, char * * = 0,
0106                      const std::string & = "",
0107                      const std::string & = "") {
0108     return 0;
0109   }
0110 
0111   /**
0112    * Not implemented in LWH.
0113    * @return     null pointer always.
0114    */
0115   IFitFactory * createFitFactory() {
0116     return 0;
0117   }
0118 
0119 private:
0120 
0121   /** Delete all produced factories. */
0122   void clear() {
0123     for ( std::set<HistogramFactory *>::iterator it = histfacs.begin();
0124       it != histfacs.end(); ++it ) delete *it;
0125     for ( std::set<DataPointSetFactory *>::iterator it = datafacs.begin();
0126       it != datafacs.end(); ++it ) delete *it;
0127     for ( std::set<TreeFactory *>::iterator it = treefacs.begin();
0128       it != treefacs.end(); ++it ) delete *it;
0129     histfacs.clear();
0130     datafacs.clear();
0131     treefacs.clear();
0132   }
0133 
0134   /** The histogram factories. */
0135   std::set<HistogramFactory *> histfacs;
0136 
0137   /** The dataset factories. */
0138   std::set<DataPointSetFactory *> datafacs;
0139 
0140   /** The tree factories. */
0141   std::set<TreeFactory *> treefacs;
0142 
0143 };
0144 
0145 }
0146 
0147 #endif /* LWH_AnalysisFactory_H */