Anaphe Home Page Reference Documentation

Main Page     Namespaces     Classes     Source Code    

AIDAHistogramFactory.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // 
00004 // Copyright (C) CERN, Geneva 
00005 // 
00006 
00007 // implementation file for class AIDAHistogramFactory 
00008 // 
00009 // Created by: Andreas Pfeiffer
00010 // 
00011 // Last update: 
00012 // 
00013 
00014 
00015 
00016 #include "AIDAHistogramFactory.h"
00017 #if defined __i386__ || defined __sun
00018 # include <strstream>
00019 #else
00020 # include <sstream>
00021 #endif
00022 #include <assert.h>
00023 #include <stdlib.h>
00024 #include "Interfaces/IAnnotation.h"
00025 #include "Interfaces/IAnnotationFactory.h"
00026 #include "Interfaces/IHistogram1D.h"
00027 #include "Interfaces/IHistogram2D.h"
00028 #include "CHBook/CHBook.h"
00029 #include "AIDAHistogram1D.h"
00030 #include "AIDAHistogram2D.h"
00031 
00032 
00033 using Anaphe::IAnnotation;
00034 using Anaphe::IAnnotationFactory;
00035 using Anaphe::IHistogramFactory;
00036 using Anaphe::IHistogram1D;
00037 using Anaphe::IHistogram2D;
00038 using Anaphe::AIDA_HBook::AIDAAxis;
00039 using Anaphe::AIDA_HBook::AIDAHistogram1D;
00040 using Anaphe::AIDA_HBook::AIDAHistogram2D;
00041 using Anaphe::AIDA_HBook::AIDAHistogramFactory;
00042 
00044 //                     //
00045 // Pseudo-new function //
00046 //                     //
00048 
00049 IHistogramFactory* createIHistogramFactory() 
00050 { 
00051   return new AIDAHistogramFactory(); 
00052 }
00053 
00054 
00055 
00056 
00058 //                 //
00059 // Con/Destructors //
00060 //                 //
00062 
00063 AIDAHistogramFactory::AIDAHistogramFactory()
00064 {
00065   // nop
00066 }
00067 
00068 
00069 
00070 
00071 AIDAHistogramFactory::~AIDAHistogramFactory() 
00072 {
00073   // nop
00074 }
00075 
00076 
00077 
00078 
00080 //                 //
00081 // Public Methods  //
00082 //                 //
00084 
00085 IHistogram1D* 
00086 AIDAHistogramFactory::create1D(AIDA_STD::string title, 
00087                                int nBinsx, double xmin, double xmax, const int ID)
00088 {
00089   IAnnotationFactory* aFact = createIAnnotationFactory();
00090   assert(aFact);
00091   IAnnotation* ann = aFact->create();
00092   ann->add("ID", intToString(ID));
00093   AIDAHistogram1D* h = 
00094     new AIDAHistogram1D(title.c_str(), nBinsx, xmin, xmax, ann, this);
00095   delete ann;
00096   delete aFact;
00097   return h;
00098 }
00099 
00100 
00101 
00102 
00103 IHistogram2D* 
00104 AIDAHistogramFactory::create2D(AIDA_STD::string title,
00105                                int nBinsx, double xmin, double xmax,
00106                                int nBinsy, double ymin, double ymax,
00107                                const int ID)
00108 {
00109   IAnnotationFactory* aFact = createIAnnotationFactory();
00110   assert(aFact);
00111   IAnnotation* ann = aFact->create();
00112   ann->add("ID", intToString(ID));
00113   AIDAHistogram2D* h =
00114     new AIDAHistogram2D(title.c_str(), nBinsx, xmin, xmax, 
00115                         nBinsy, ymin, ymax, ann, this);
00116   delete ann;
00117   delete aFact;
00118   return h;
00119 }
00120 
00121 
00122 
00123 
00124 void AIDAHistogramFactory::unregister(IHistogram* h)
00125 {
00126   hlist.remove(h);
00127 }
00128 
00129 
00130 
00131 
00132 void AIDAHistogramFactory::destroy(IHistogram* h)
00133 {
00134   delete h;
00135 }
00136 
00137 
00139 //                 //
00140 // Private Methods //
00141 //                 //
00143 
00144 AIDA_STD::string AIDAHistogramFactory::intToString(int i) 
00145 {
00146   std::ostrstream ostr;
00147   ostr << i << std::ends;
00148   return ostr.str();
00149 }
00150 


Anaphe documentation generated by Doxygen (www.doxygen.org)