00001 #include "H_Factory.h"
00002
00003 int H_Factory::init (HepDbApplication *app, char *dbname,
00004 char *contname) {
00005 HepRef(ooDBObj) db_h = 0;
00006 int retval = 0;
00007 dbApp = app;
00008
00009 if (!db_h.exist(dbApp->fd(),dbname,oocUpdate)) {
00010 db_h = new (dbApp->fd()) ooDBObj(dbname);
00011 if (db_h == 0)
00012 HTL_ERR("Could not create the database" )
00013 }
00014
00015
00016 if (db_h != 0) {
00017 if (contname == 0)
00018 contname = (char *)("Histograms");
00019 if (histoCont.exist(db_h,contname,oocUpdate)) {
00020 retval = 1;
00021 } else {
00022 histoCont = new (contname,1,10,40,db_h) ooContObj ();
00023 if (histoCont != 0)
00024 retval = 1;
00025 else
00026 HTL_ERR("Could not create the container" )
00027 }
00028 }
00029 return retval;
00030 }
00031
00032 int H_Factory::hintSet () {
00033 if (histoCont != 0)
00034 return 1;
00035 else {
00036 HTL_ERR("Clustering hint used before setting it" )
00037 return 0;
00038 }
00039 }
00040
00041 HepRef(P_Histo1D) H_Factory::Histo1D (const char *a_title,
00042 Size n, double x1, double x2,
00043 End_Point_Convention epc) {
00044 HepRef(P_Histo1D) hhh = 0;
00045 if (hintSet())
00046 hhh = new (histoCont) P_Histo1D(a_title, n, x1, x2, epc);
00047 return hhh;
00048 }
00049
00050 HepRef(P_Histo1DVar) H_Factory::Histo1DVar (const char *a_title,
00051 HTL_STD::vector<float> &pts,
00052 End_Point_Convention epc) {
00053 HepRef(P_Histo1DVar) hhh = 0;
00054 if (hintSet())
00055 hhh = new (histoCont) P_Histo1DVar(a_title,pts,epc);
00056 return hhh;
00057 }
00058
00059 HepRef(P_Histo1DVar) H_Factory::Histo1DVar (const char *a_title,
00060 HTL_STD::vector<double> &pts,
00061 End_Point_Convention epc) {
00062 HepRef(P_Histo1DVar) hhh = 0;
00063 if (hintSet())
00064 hhh = new (histoCont) P_Histo1DVar(a_title,pts,epc);
00065 return hhh;
00066 }
00067
00068 HepRef(P_ProfileHisto1D) H_Factory::ProfileHisto (const char *a_title,
00069 Size n, double x1, double x2,
00070 End_Point_Convention epc) {
00071 HepRef(P_ProfileHisto1D) hhh = 0;
00072 if (hintSet())
00073 hhh = new (histoCont) P_ProfileHisto1D(a_title, n, x1, x2, epc);
00074 return hhh;
00075 }
00076
00077 HepRef(P_ProfileHisto1DVar) H_Factory::ProfileHistoVar (const char *a_title,
00078 HTL_STD::vector<float>&pts,
00079 End_Point_Convention epc) {
00080 HepRef(P_ProfileHisto1DVar) hhh = 0;
00081 if (hintSet())
00082 hhh = new (histoCont) P_ProfileHisto1DVar(a_title,pts,epc);
00083 return hhh;
00084 }
00085
00086 HepRef(P_ProfileHisto1DVar) H_Factory::ProfileHistoVar (const char *a_title,
00087 HTL_STD::vector<double>&pts,
00088 End_Point_Convention epc) {
00089 HepRef(P_ProfileHisto1DVar) hhh = 0;
00090 if (hintSet())
00091 hhh = new (histoCont) P_ProfileHisto1DVar(a_title,pts,epc);
00092 return hhh;
00093 }
00094
00095 HepRef(P_Histo2D) H_Factory::Histo2D (const char *a_title, Size n1,
00096 double x1 , double x2, Size n2,
00097 double y1 , double y2,
00098 End_Point_Convention epc1 ,
00099 End_Point_Convention epc2 ) {
00100 HepRef(P_Histo2D) hhh = 0;
00101 if (hintSet())
00102 hhh = new (histoCont) P_Histo2D(a_title,n1,x1,x2,n2,y1,y2,epc1,epc2);
00103 return hhh;
00104 }
00105
00106 HepRef(P_Histo2DVar) H_Factory::Histo2DVar(const char *a_title,
00107 HTL_STD::vector<double> &pts1,
00108 HTL_STD::vector<double> &pts2,
00109 End_Point_Convention epc1,
00110 End_Point_Convention epc2) {
00111 HepRef(P_Histo2DVar) hhh = 0;
00112 if (hintSet())
00113 hhh = new (histoCont) P_Histo2DVar (a_title, pts1, pts2, epc1, epc2 );
00114 return hhh;
00115 }
00116
00117 HepRef(P_Histo2DVar) H_Factory::Histo2DVar(const char *a_title,
00118 HTL_STD::vector<float> &pts1,
00119 HTL_STD::vector<float> &pts2,
00120 End_Point_Convention epc1,
00121 End_Point_Convention epc2) {
00122 HepRef(P_Histo2DVar) hhh = 0;
00123 if (hintSet())
00124 hhh = new (histoCont) P_Histo2DVar (a_title, pts1, pts2, epc1, epc2 );
00125 return hhh;
00126 }