00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef THEPEG_FactoryBase_H
00010 #define THEPEG_FactoryBase_H
00011
00012
00013
00014
00015 #include "ThePEG/Config/LWH.h"
00016 #include "ThePEG/Interface/Interfaced.h"
00017 #include "FactoryBase.fh"
00018 #include "AIAnalysisFactory.h"
00019 #include "AITreeFactory.h"
00020 #include "AITree.h"
00021 #include "AIHistogramFactory.h"
00022 #include "AIHistogram1D.h"
00023 #include "AIAxis.h"
00024 #include "AIDataPointSetFactory.h"
00025 #include "AIDataPointSet.h"
00026 #include "AIDataPoint.h"
00027 #include "AIMeasurement.h"
00028
00029 namespace ThePEG {
00030
00048 class FactoryBase: public Interfaced {
00049
00050 public:
00051
00055 typedef AIDA::IHistogram1D * tH1DPtr;
00056
00060 typedef const AIDA::IHistogram1D * tcH1DPtr;
00061
00065 typedef AIDA::IDataPointSet * tDSetPtr;
00066
00070 typedef const AIDA::IDataPointSet * tcDSetPtr;
00071
00072 public:
00073
00081 class DataFiller {
00082
00083 public:
00084
00088 DataFiller(AIDA::IDataPointSet * dps) : dset(dps) {}
00089
00093 DataFiller(const DataFiller & df) : dset(df.dset) {}
00094
00099 ~DataFiller();
00100
00104 DataFiller & operator<<(double x) {
00105 v.push_back(x);
00106 return *this;
00107 }
00108
00112 operator AIDA::IDataPointSet * () { return dset; }
00113
00114 private:
00115
00119 AIDA::IDataPointSet * dset;
00120
00124 deque<double> v;
00125
00126 };
00127
00128 public:
00129
00135 FactoryBase();
00136
00140 FactoryBase(const FactoryBase &);
00141
00145 virtual ~FactoryBase();
00147
00148 public:
00149
00157 const string & filename() const { return theFilename; }
00158
00163 const string & suffix() const { return theSuffix; }
00164
00168 const string & storeType() const { return theStoreType; }
00170
00178 virtual void
00179 normalizeToXSec(tH1DPtr histogram, CrossSection unit = picobarn) const = 0;
00180
00186 virtual void normalizeToXSecFraction(tH1DPtr histogram) const = 0;
00187
00192 virtual void normalizeToUnity(tH1DPtr histogram) const = 0;
00194
00200 AIDA::IAnalysisFactory & analysisFactory() const {
00201 return *theAnalysisFactory;
00202 }
00203
00207 AIDA::ITree & tree() const { return *theTree; }
00208
00212 AIDA::IHistogramFactory & histogramFactory() const {
00213 return *theHistogramFactory;
00214 }
00215
00219 AIDA::IDataPointSetFactory & dataSetFactory() const {
00220 return *theDataSetFactory;
00221 }
00222
00226 void mkdir(const string & path) { tree().mkdir(path); }
00227
00231 void mkdirs(const string & path) { tree().mkdirs(path); }
00232
00236 void cd(const string & path) { tree().cd(path); }
00237
00253 tH1DPtr createHistogram1D(const string & path, int nb, double lo, double up) {
00254 return histogramFactory().createHistogram1D(path, nb, lo, up);
00255 }
00256
00272 tH1DPtr createHistogram1D(const string & path, const string & title, int nb,
00273 double lo, double up) {
00274 return histogramFactory().createHistogram1D(path, title, nb, lo, up);
00275 }
00276
00290 tH1DPtr createHistogram1D(const string & path, const string & title,
00291 const std::vector<double> & edges) {
00292 return histogramFactory().createHistogram1D(path, title, edges);
00293 }
00294
00302 DataFiller createDataSet(const string & path, const string & title, int dim) {
00303 return DataFiller(dataSetFactory().create(path, title, dim));
00304 }
00305
00313 void registerClient(tIPtr client) {
00314 initrun();
00315 clients.insert(client);
00316 }
00318
00319 protected:
00320
00329 void analysisFactory(AIDA::IAnalysisFactory * x) {
00330 theAnalysisFactory = x;
00331 }
00332
00337 void clear();
00338
00339
00340 public:
00341
00348 void persistentOutput(PersistentOStream & os) const;
00349
00355 void persistentInput(PersistentIStream & is, int version);
00357
00364 static void Init();
00365
00366 protected:
00367
00374 virtual void doinitrun();
00375
00380 virtual void dofinish();
00382
00383 private:
00384
00390 string theFilename;
00391
00396 string theSuffix;
00397
00401 string theStoreType;
00402
00406 AIDA::IAnalysisFactory * theAnalysisFactory;
00407
00411 AIDA::ITree * theTree;
00412
00416 AIDA::IHistogramFactory * theHistogramFactory;
00417
00421 AIDA::IDataPointSetFactory * theDataSetFactory;
00422
00427 set<IPtr> clients;
00428
00429 private:
00430
00435 static AbstractClassDescription<FactoryBase> initFactoryBase;
00436
00441 FactoryBase & operator=(const FactoryBase &);
00442
00443 };
00444
00445 }
00446
00447 #include "ThePEG/Utilities/ClassTraits.h"
00448
00449 namespace ThePEG {
00450
00455 template <>
00456 struct BaseClassTrait<FactoryBase,1> {
00458 typedef Interfaced NthBase;
00459 };
00460
00463 template <>
00464 struct ClassTraits<FactoryBase>
00465 : public ClassTraitsBase<FactoryBase> {
00467 static string className() { return "ThePEG::FactoryBase"; }
00468 };
00469
00472 }
00473
00474 #endif