00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00033
00034
00044
00045
00046 #include <iostream>
00047
00048 #include "database/MJDatabase.hh"
00049 using namespace std;
00050
00051
00052 #include "database/MJDatabaseSimple800g.hh"
00053 #include "database/MJDatabaseUtil.hh"
00054
00055
00056 MJDatabaseSimple800g::MJDatabaseSimple800g()
00057 {
00058
00059 }
00060
00061 MJDatabaseSimple800g::MJDatabaseSimple800g(const MJDatabaseSimple800g & other)
00062 :fCrystalMat(other.fCrystalMat),
00063 fInnerContactMat(other.fInnerContactMat)
00064 {
00065 fSerialNo = other.fSerialNo;
00066 fHeight = other.fHeight;
00067 fRadius = other.fRadius;
00068 fCoreRadius = other.fCoreRadius;
00069 fCornerR = other.fCornerR;
00070 fCoreDepth = other.fCoreDepth;
00071 fInnerContactW = other.fInnerContactW;
00072 fInnerDeadThickness = other.fInnerDeadThickness;
00073 fOuterDeadThickness = other.fOuterDeadThickness;
00074 fDiodType = other.fDiodType;
00075 fDepletionVolt = other.fDepletionVolt;
00076 fResolution = other.fResolution;
00077 fEfficiencies= other.fEfficiencies;
00078 fInnerBkgModel = other.fInnerBkgModel;
00079 fBkgModel = other.fBkgModel;
00080 }
00081
00082 MJDatabaseSimple800g::~MJDatabaseSimple800g()
00083 {
00084 }
00085 MJDatabaseSimple800g*
00086 MJDatabaseSimple800g::createCrystal(PGresult * res){
00087
00088 MJDatabaseUtil dbutil;
00089 for (int i = 0; i < PQntuples(res); i++)
00090 {
00091 fSerialNo = PQgetvalue(res, i, 0);
00092 string matName = PQgetvalue(res, i, 1);
00093 fHeight = dbutil.c_Float(PQgetvalue(res, i, 2));
00094 fRadius = dbutil.c_Float(PQgetvalue(res, i, 3));
00095
00096 fBkgModel = PQgetvalue(res, i, 4);
00097 fCoreRadius = dbutil.c_Float(PQgetvalue(res, i, 5));
00098 fCoreDepth = dbutil.c_Float(PQgetvalue(res, i, 6));
00099 fCornerR = dbutil.c_Float(PQgetvalue(res, i, 7));
00100
00101 fInnerContactW = dbutil.c_Float(PQgetvalue(res, i, 8));
00102
00103 string innerMat = PQgetvalue(res, i, 9);
00104 fInnerDeadThickness = dbutil.c_Float(PQgetvalue(res, i, 10));
00105 fOuterDeadThickness = dbutil.c_Float(PQgetvalue(res, i, 11));
00106 fInnerBkgModel = PQgetvalue(res, i, 12);
00107 fDiodType = *(char*)PQgetvalue(res, i, 13);
00108 fDepletionVolt = dbutil.c_Float(PQgetvalue(res, i, 14));
00109
00110
00111 fCrystalMat = *(MJDatabase::GetMaterial(matName));
00112 fInnerContactMat = *(MJDatabase::GetMaterial(innerMat));
00113
00114
00115 int len = PQgetlength(res,i, 15);
00116 float * ener ;
00117 if( len > 0) dbutil.fillArray(ener, PQgetvalue(res, i, 15));
00118 len = PQgetlength(res,i, 16);
00119 float * resol;
00120 if( len > 0) dbutil.fillArray(resol, PQgetvalue(res, i, 16));
00121
00122 int num =dbutil.getNoEle(PQgetvalue(res, i, 15));
00123 for (int j=0; j< num; j++){
00124 fResolution.push_back(CrystalRes(ener[j], resol[j]));
00125 }
00126
00127
00128
00129 len = PQgetlength(res,i, 17);
00130 if( len > 0) dbutil.fillArray(ener, PQgetvalue(res, i, 17));
00131 len = PQgetlength(res,i, 18);
00132 float * eff;
00133 if( len > 0) dbutil.fillArray(eff, PQgetvalue(res, i, 18));
00134
00135 num =dbutil.getNoEle(PQgetvalue(res, i, 17));
00136 for (int j=0; j< num; j++){
00137 fEfficiencies.push_back(CrystalEff(ener[j], eff[j]));
00138 }
00139
00140 fcomment = PQgetvalue(res, i, 19);
00141
00142
00143 }
00144 return this;
00145 }
00146 void
00147 MJDatabaseSimple800g::print(ostream &os){
00148
00149 os << '\n'
00150 << "******* Simple 800g Crystal: " << GetCrystalSerialNo()
00151 << " ******" << '\n'
00152 << "Radius : " << GetCrystalRadius() << '\n'
00153 << "Height : " << GetCrystalHeight() <<'\n'
00154 << "Core Radius : " << GetCoreRadius() << '\n'
00155 << "Corner Radius: " << GetCornerRadius() << '\n'
00156 << "Core Depth : " << GetCoreDepth() << '\n';
00157
00158 vector<CrystalRes>::iterator itr;
00159 os<< "Resolution : " ;
00160 for(itr = fResolution.begin(); itr != fResolution.end(); itr++)
00161 os << itr->resolution() << "(" << itr->energy() << ") ";
00162 os << '\n';
00163
00164 vector<CrystalEff>::iterator it;
00165 os<< "Efficiencies : " ;
00166 for(it = fEfficiencies.begin(); it != fEfficiencies.end(); it++)
00167 os << it->efficiency () << "(" << it->energy() << ") ";
00168 os <<endl;
00169
00170 fCrystalMat.print(os);
00171 fInnerContactMat.print(os);
00172
00173 }
00174 ostream&
00175 operator << (ostream& os, MJDatabaseSimple800g& crys){
00176
00177 os << '\n'
00178 << "******* Simple 800g Crystal: " << crys.GetCrystalSerialNo()
00179 << " ******" << '\n'
00180 << "Radius : " << crys.GetCrystalRadius() << '\n'
00181 << "Height : " << crys.GetCrystalHeight() <<'\n'
00182 << "Core Radius : " << crys.GetCoreRadius() << '\n'
00183 << "Corner Radius: " << crys.GetCornerRadius() << '\n'
00184 << "Core Depth : " << crys.GetCoreDepth() << '\n';
00185
00186 vector<CrystalRes>::iterator itr;
00187 os<< "Resolution : " ;
00188 for(itr = crys.fResolution.begin(); itr != crys.fResolution.end(); itr++)
00189 os << itr->resolution() << "(" << itr->energy() << ") ";
00190 os << '\n';
00191
00192 vector<CrystalEff>::iterator it;
00193 os<< "Efficiencies : " ;
00194 for(it = crys.fEfficiencies.begin(); it != crys.fEfficiencies.end(); it++)
00195 os << it->efficiency () << "(" << it->energy() << ") ";
00196 os <<endl;
00197
00198 os << crys.fCrystalMat;
00199 os << crys.fInnerContactMat;
00200
00201 return os;
00202 }