thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
FactoryBase.h
1 // -*- C++ -*-
2 //
3 // FactoryBase.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef THEPEG_FactoryBase_H
10 #define THEPEG_FactoryBase_H
11 //
12 // This is the declaration of the FactoryBase class.
13 //
14 
15 #include "ThePEG/Interface/Interfaced.h"
16 #include "FactoryBase.fh"
17 
18 namespace AIDA {
19  class IHistogram1D;
20  class IHistogram2D;
21  class IDataPointSet;
22  class IAnalysisFactory;
23  class ITree;
24  class IHistogramFactory;
25  class IDataPointSetFactory;
26 }
27 
28 namespace ThePEG {
29 
47 class FactoryBase: public Interfaced {
48 
49 public:
50 
54  typedef AIDA::IHistogram1D * tH1DPtr;
55 
59  typedef const AIDA::IHistogram1D * tcH1DPtr;
60 
64  typedef AIDA::IHistogram2D * tH2DPtr;
65 
69  typedef const AIDA::IHistogram2D * tcH2DPtr;
70 
74  typedef AIDA::IDataPointSet * tDSetPtr;
75 
79  typedef const AIDA::IDataPointSet * tcDSetPtr;
80 
81 public:
82 
90  class DataFiller {
91 
92  public:
93 
97  DataFiller(AIDA::IDataPointSet * dps) : dset(dps) {}
98 
102  DataFiller(const DataFiller & df) : dset(df.dset) {}
103 
108  ~DataFiller();
109 
113  DataFiller & operator<<(double x) {
114  v.push_back(x);
115  return *this;
116  }
117 
121  operator AIDA::IDataPointSet * () { return dset; }
122 
123  private:
124 
128  AIDA::IDataPointSet * dset;
129 
133  deque<double> v;
134 
135  };
136 
137 public:
138 
144  FactoryBase();
145 
149  FactoryBase(const FactoryBase &);
150 
154  virtual ~FactoryBase();
156 
157 public:
158 
166  const string & filename() const { return theFilename; }
167 
172  const string & suffix() const { return theSuffix; }
173 
177  const string & storeType() const { return theStoreType; }
179 
187  virtual void
188  normalizeToXSec(tH1DPtr histogram, CrossSection unit = picobarn) const = 0;
189 
195  virtual void
196  normalizeToXSec(tH2DPtr histogram, CrossSection unit = picobarn) const = 0;
197 
203  virtual void normalizeToXSecFraction(tH1DPtr histogram) const = 0;
204 
210  virtual void normalizeToXSecFraction(tH2DPtr histogram) const = 0;
211 
216  virtual void normalizeToUnity(tH1DPtr histogram) const = 0;
217 
222  virtual void normalizeToUnity(tH2DPtr histogram) const = 0;
224 
230  AIDA::IAnalysisFactory & analysisFactory() const {
231  return *theAnalysisFactory;
232  }
233 
237  AIDA::ITree & tree() const;
238 
242  AIDA::IHistogramFactory & histogramFactory() const;
243 
247  AIDA::IDataPointSetFactory & dataSetFactory() const;
248 
252  void mkdir(const string & path);
253 
257  void mkdirs(const string & path);
258 
262  void cd(const string & path);
263 
279  tH1DPtr createHistogram1D(const string & path, int nb, double lo, double up);
280 
296  tH1DPtr createHistogram1D(const string & path, const string & title, int nb,
297  double lo, double up);
298 
312  tH1DPtr createHistogram1D(const string & path, const string & title,
313  const std::vector<double> & edges);
314 
333  tH2DPtr createHistogram2D(const string & path,
334  int nbx, double xlo, double xup,
335  int nby, double ylo, double yup);
336 
355  tH2DPtr createHistogram2D(const string & path, const string & title,
356  int nbx, double xlo, double xup,
357  int nby, double ylo, double yup);
358 
373  tH2DPtr createHistogram2D(const string & path, const string & title,
374  const std::vector<double> & xedges,
375  const std::vector<double> & yedges);
376 
384  DataFiller createDataSet(const string & path, const string & title, int dim);
385 
393  void registerClient(tIPtr client);
395 
396 protected:
397 
406  void analysisFactory(AIDA::IAnalysisFactory * x) {
407  theAnalysisFactory = x;
408  }
409 
414  void clear();
415 
416 
417 public:
418 
425  void persistentOutput(PersistentOStream & os) const;
426 
432  void persistentInput(PersistentIStream & is, int version);
434 
441  static void Init();
442 
443 protected:
444 
451  virtual void doinitrun();
452 
457  virtual void dofinish();
459 
460 private:
461 
467  string theFilename;
468 
473  string theSuffix;
474 
478  string theStoreType;
479 
483  AIDA::IAnalysisFactory * theAnalysisFactory;
484 
488  AIDA::ITree * theTree;
489 
493  AIDA::IHistogramFactory * theHistogramFactory;
494 
498  AIDA::IDataPointSetFactory * theDataSetFactory;
499 
504  set<IPtr> clients;
505 
506 private:
507 
513 
518  FactoryBase & operator=(const FactoryBase &) = delete;
519 
520 };
521 
522 }
523 
524 #include "ThePEG/Utilities/ClassTraits.h"
525 
526 namespace ThePEG {
527 
532 template <>
533 struct BaseClassTrait<FactoryBase,1> {
535  typedef Interfaced NthBase;
536 };
537 
540 template <>
541 struct ClassTraits<FactoryBase>
542  : public ClassTraitsBase<FactoryBase> {
544  static string className() { return "ThePEG::FactoryBase"; }
545 };
546 
549 }
550 
551 #endif /* THEPEG_FactoryBase_H */
const string & filename() const
Together with suffix(), the name of the file where the resulting histograms will be stored...
Definition: FactoryBase.h:166
string theFilename
Together with theSuffix, the name of the file where the resulting histograms will be stored...
Definition: FactoryBase.h:467
PersistentIStream is used to read persistent objects from a stream where they were previously written...
void analysisFactory(AIDA::IAnalysisFactory *x)
Set the underlying AIDA::IAnalysisFactory object.
Definition: FactoryBase.h:406
static AbstractClassDescription< FactoryBase > initFactoryBase
The static object used to initialize the description of this class.
Definition: FactoryBase.h:512
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data...
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
AIDA::IHistogram2D * tH2DPtr
Convenient typedef for pointer to AIDA::IHistogram2D.
Definition: FactoryBase.h:64
Here is the documentation of the FactoryBase class.
Definition: FactoryBase.h:47
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
string theSuffix
Together with theFilename, the name of the file where the resulting histograms will be stored...
Definition: FactoryBase.h:473
string theStoreType
The format in which the histograms are stored in the output file.
Definition: FactoryBase.h:478
AIDA::IDataPointSet * tDSetPtr
Convenient typedef for pointer to AIDA::IHistogram1D.
Definition: FactoryBase.h:74
const AIDA::IHistogram2D * tcH2DPtr
Convenient typedef for pointer to const AIDA::IHistogram2D.
Definition: FactoryBase.h:69
DataFiller & operator<<(double x)
Add a number to measurement currently being read.
Definition: FactoryBase.h:113
const string & suffix() const
Together with filename(), the name of the file where the resulting histograms will be stored...
Definition: FactoryBase.h:172
DataFiller is a helper class to facilitate adding data to a DataPointSet.
Definition: FactoryBase.h:90
AIDA::IDataPointSet * dset
The underlying IDataPointSet.
Definition: FactoryBase.h:128
deque< double > v
The collected numbers to be committed to the IDataPointSet.
Definition: FactoryBase.h:133
set< IPtr > clients
A set of client objects which have required histograms from this factory.
Definition: FactoryBase.h:504
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
AIDA::IHistogram1D * tH1DPtr
Convenient typedef for pointer to AIDA::IHistogram1D.
Definition: FactoryBase.h:54
DataFiller(AIDA::IDataPointSet *dps)
The standard constructor needs a IDataPointSet as argument.
Definition: FactoryBase.h:97
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
AIDA::IDataPointSetFactory * theDataSetFactory
A pointer to the underlying AIDA::IDataPointSetFactory object.
Definition: FactoryBase.h:498
const AIDA::IDataPointSet * tcDSetPtr
Convenient typedef for pointer to const AIDA::IHistogram1D.
Definition: FactoryBase.h:79
AIDA::IAnalysisFactory & analysisFactory() const
Access the underlying AIDA::IAnalysisFactory object.
Definition: FactoryBase.h:230
AIDA::ITree * theTree
A pointer to the underlying AIDA::ITree object.
Definition: FactoryBase.h:488
const AIDA::IHistogram1D * tcH1DPtr
Convenient typedef for pointer to const AIDA::IHistogram1D.
Definition: FactoryBase.h:59
DataFiller(const DataFiller &df)
Copy constructor.
Definition: FactoryBase.h:102
const string & storeType() const
The format in which the histograms are stored in the output file.
Definition: FactoryBase.h:177
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
AIDA::IAnalysisFactory * theAnalysisFactory
A pointer to the underlying AIDA::IAnalysisFactory object.
Definition: FactoryBase.h:483
AIDA::IHistogramFactory * theHistogramFactory
A pointer to the underlying AIDA::IHistogramFactory object.
Definition: FactoryBase.h:493
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52