thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
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
18namespace AIDA {
19 class IHistogram1D;
20 class IHistogram2D;
21 class IDataPointSet;
22 class IAnalysisFactory;
23 class ITree;
24 class IHistogramFactory;
25 class IDataPointSetFactory;
26}
27
28namespace ThePEG {
29
47class FactoryBase: public Interfaced {
48
49public:
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
81public:
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
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
137public:
138
145
150
154 virtual ~FactoryBase();
156
157public:
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
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
396protected:
397
406 void analysisFactory(AIDA::IAnalysisFactory * x) {
408 }
409
414 void clear();
415
416
417public:
418
426
432 void persistentInput(PersistentIStream & is, int version);
434
441 static void Init();
442
443protected:
444
451 virtual void doinitrun();
452
457 virtual void dofinish();
459
460private:
461
468
473 string theSuffix;
474
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
506private:
507
513
518 FactoryBase & operator=(const FactoryBase &) = delete;
519
520};
521
522}
523
524#include "ThePEG/Utilities/ClassTraits.h"
525
526namespace ThePEG {
527
532template <>
533struct BaseClassTrait<FactoryBase,1> {
535 typedef Interfaced NthBase;
536};
537
540template <>
541struct ClassTraits<FactoryBase>
542 : public ClassTraitsBase<FactoryBase> {
544 static string className() { return "ThePEG::FactoryBase"; }
545};
546
549}
550
551#endif /* THEPEG_FactoryBase_H */
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data.
DataFiller is a helper class to facilitate adding data to a DataPointSet.
Definition: FactoryBase.h:90
deque< double > v
The collected numbers to be committed to the IDataPointSet.
Definition: FactoryBase.h:133
DataFiller(const DataFiller &df)
Copy constructor.
Definition: FactoryBase.h:102
DataFiller(AIDA::IDataPointSet *dps)
The standard constructor needs a IDataPointSet as argument.
Definition: FactoryBase.h:97
DataFiller & operator<<(double x)
Add a number to measurement currently being read.
Definition: FactoryBase.h:113
AIDA::IDataPointSet * dset
The underlying IDataPointSet.
Definition: FactoryBase.h:128
Here is the documentation of the FactoryBase class.
Definition: FactoryBase.h:47
void analysisFactory(AIDA::IAnalysisFactory *x)
Set the underlying AIDA::IAnalysisFactory object.
Definition: FactoryBase.h:406
const string & storeType() const
The format in which the histograms are stored in the output file.
Definition: FactoryBase.h:177
virtual void normalizeToXSecFraction(tH1DPtr histogram) const =0
Rescale the given histogram so that the integral over the bins gives the fraction of the total cross ...
void cd(const string &path)
Set the default working directory for the underlying AIDA tree.
const string & filename() const
Together with suffix(), the name of the file where the resulting histograms will be stored.
Definition: FactoryBase.h:166
tH2DPtr createHistogram2D(const string &path, const string &title, const std::vector< double > &xedges, const std::vector< double > &yedges)
Create and return a AIDA::IHistogram2D object in the underlying AIDA histogram factory.
AIDA::ITree * theTree
A pointer to the underlying AIDA::ITree object.
Definition: FactoryBase.h:488
AIDA::IHistogram1D * tH1DPtr
Convenient typedef for pointer to AIDA::IHistogram1D.
Definition: FactoryBase.h:54
tH2DPtr createHistogram2D(const string &path, const string &title, int nbx, double xlo, double xup, int nby, double ylo, double yup)
Create and return a AIDA::IHistogram2D object in the underlying AIDA histogram factory.
AIDA::IAnalysisFactory * theAnalysisFactory
A pointer to the underlying AIDA::IAnalysisFactory object.
Definition: FactoryBase.h:483
AIDA::IAnalysisFactory & analysisFactory() const
Access the underlying AIDA::IAnalysisFactory object.
Definition: FactoryBase.h:230
FactoryBase(const FactoryBase &)
The copy constructor.
void clear()
Delete all associated AIDA objects.
set< IPtr > clients
A set of client objects which have required histograms from this factory.
Definition: FactoryBase.h:504
string theSuffix
Together with theFilename, the name of the file where the resulting histograms will be stored.
Definition: FactoryBase.h:473
static void Init()
The standard Init function used to initialize the interfaces.
AIDA::IHistogramFactory & histogramFactory() const
A pointer to the underlying AIDA::IHistogramFactory object.
virtual void normalizeToXSec(tH1DPtr histogram, CrossSection unit=picobarn) const =0
Rescale the given histogram so that the integral over the bins will give the correct integrated cross...
static AbstractClassDescription< FactoryBase > initFactoryBase
The static object used to initialize the description of this class.
Definition: FactoryBase.h:512
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
virtual void normalizeToXSec(tH2DPtr histogram, CrossSection unit=picobarn) const =0
Rescale the given histogram so that the integral over the bins will give the correct integrated cross...
void mkdirs(const string &path)
Create a new directory in the underlying AIDA tree.
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
virtual ~FactoryBase()
The destructor.
DataFiller createDataSet(const string &path, const string &title, int dim)
Create a IDataPointSet with the given path and title and containing points with the given number of d...
AIDA::ITree & tree() const
Access the underlying AIDA::ITree object.
AIDA::IDataPointSetFactory & dataSetFactory() const
A pointer to the underlying AIDA::IDataPointSetFactory object.
AIDA::IDataPointSet * tDSetPtr
Convenient typedef for pointer to AIDA::IHistogram1D.
Definition: FactoryBase.h:74
void registerClient(tIPtr client)
Used by a client object to indicate that he has required histograms from this factory.
tH1DPtr createHistogram1D(const string &path, const string &title, const std::vector< double > &edges)
Create and return a AIDA::IHistogram1D object in the underlying AIDA histogram factory.
virtual void doinitrun()
Initialize this object.
AIDA::IHistogram2D * tH2DPtr
Convenient typedef for pointer to AIDA::IHistogram2D.
Definition: FactoryBase.h:64
tH1DPtr createHistogram1D(const string &path, int nb, double lo, double up)
Create and return a AIDA::IHistogram1D object in the underlying AIDA histogram factory.
const AIDA::IHistogram2D * tcH2DPtr
Convenient typedef for pointer to const AIDA::IHistogram2D.
Definition: FactoryBase.h:69
virtual void dofinish()
Finalize this object.
FactoryBase & operator=(const FactoryBase &)=delete
The assignment operator is private and must never be called.
const AIDA::IHistogram1D * tcH1DPtr
Convenient typedef for pointer to const AIDA::IHistogram1D.
Definition: FactoryBase.h:59
virtual void normalizeToUnity(tH1DPtr histogram) const =0
Rescale the given histogram so that the integral over the bins gives one.
string theStoreType
The format in which the histograms are stored in the output file.
Definition: FactoryBase.h:478
string theFilename
Together with theSuffix, the name of the file where the resulting histograms will be stored.
Definition: FactoryBase.h:467
const AIDA::IDataPointSet * tcDSetPtr
Convenient typedef for pointer to const AIDA::IHistogram1D.
Definition: FactoryBase.h:79
tH2DPtr createHistogram2D(const string &path, int nbx, double xlo, double xup, int nby, double ylo, double yup)
Create and return a AIDA::IHistogram2D object in the underlying AIDA histogram factory.
AIDA::IDataPointSetFactory * theDataSetFactory
A pointer to the underlying AIDA::IDataPointSetFactory object.
Definition: FactoryBase.h:498
const string & suffix() const
Together with filename(), the name of the file where the resulting histograms will be stored.
Definition: FactoryBase.h:172
void mkdir(const string &path)
Create a new directory in the underlying AIDA tree.
AIDA::IHistogramFactory * theHistogramFactory
A pointer to the underlying AIDA::IHistogramFactory object.
Definition: FactoryBase.h:493
virtual void normalizeToXSecFraction(tH2DPtr histogram) const =0
Rescale the given histogram so that the integral over the bins gives the fraction of the total cross ...
tH1DPtr createHistogram1D(const string &path, const string &title, int nb, double lo, double up)
Create and return a AIDA::IHistogram1D object in the underlying AIDA histogram factory.
FactoryBase()
The default constructor.
virtual void normalizeToUnity(tH2DPtr histogram) const =0
Rescale the given histogram so that the integral over the bins gives one.
string path() const
Returns the path to this object including the trailing '/'.
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
PersistentIStream is used to read persistent objects from a stream where they were previously written...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
static string className()
Return the name of class T.
Definition: ClassTraits.h:66