Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

MJDatabaseCloverCrystal.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00003 //                                                                           //
00004 //                         MAJORANA Simulation                               //
00005 //                                                                           //
00006 //      This code implementation is the intellectual property of the         //
00007 //      MAJORANA Collaboration. It is based on Geant4, an intellectual       //
00008 //      property of the RD44 GEANT4 collaboration.                           //
00009 //                                                                           //
00010 //                        *********************                              //
00011 //                                                                           //
00012 //    Neither the authors of this software system, nor their employing       //
00013 //    institutes, nor the agencies providing financial support for this      //
00014 //    work  make  any representation or  warranty, express or implied,       //
00015 //    regarding this software system or assume any liability for its use.    //
00016 //    By copying, distributing or modifying the Program (or any work based   //
00017 //    on on the Program) you indicate your acceptance of this statement,     //
00018 //    and all its terms.                                                     //
00019 //                                                                           //
00020 //bb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nubb0nu//
00021 //---------------------------------------------------------------------------//
00022 //                                                          
00023 // $Id: MJDatabaseCloverCrystal.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJDatabaseCloverCrystal.cc
00026 //
00027 //---------------------------------------------------------------------------//
00033 // 
00034 //---------------------------------------------------------------------------//
00044 //---------------------------------------------------------------------------//
00045 //
00046 #include <iostream>
00047 
00048 #include "database/MJDatabase.hh"
00049 using namespace std;
00050 //---------------------------------------------------------------------------//
00051 
00052 #include "database/MJDatabaseCloverCrystal.hh"      //Present MJ Class Headers 
00053 #include "database/MJDatabaseUtil.hh"
00054 //---------------------------------------------------------------------------//
00055 
00056 MJDatabaseCloverCrystal::MJDatabaseCloverCrystal()
00057 {
00058 
00059 }
00060 MJDatabaseCloverCrystal::MJDatabaseCloverCrystal(string serN, double rad, double h,
00061                                                  double coreR, double coreD, double topDef,
00062                                                  double bottDef, double rightDef, 
00063                                                  double leftDef, MJDatabaseMaterial& cMat,
00064                                                  double innerCW, MJDatabaseMaterial& contMat,
00065                                                  double innerDeadT, double outerDeadT)
00066   :fSerialNo(serN),
00067    fHeight(h),
00068    fRadius (rad),
00069    fCoreRadius(coreR),
00070    fCoreDepth(coreD),
00071    fTopDeficit(topDef),
00072    fBottomDeficit(bottDef),
00073    fRightDeficit(rightDef),
00074    fLeftDeficit(leftDef),
00075    fInnerContactW(innerCW),
00076    fInnerDeadThickness(innerDeadT),
00077    fOuterDeadThickness(outerDeadT)
00078 {
00079   //construct material here
00080 }
00081 MJDatabaseCloverCrystal::MJDatabaseCloverCrystal(const MJDatabaseCloverCrystal & other)
00082   :fCrystalMat(other.fCrystalMat),
00083    fInnerContactMat(other.fInnerContactMat)
00084 {
00085   fSerialNo = other.fSerialNo;
00086   fHeight = other.fHeight;
00087   fRadius = other.fRadius;
00088   fCoreRadius = other.fCoreRadius;
00089   fCoreDepth = other.fCoreDepth;
00090   fTopDeficit = other.fTopDeficit;
00091   fBottomDeficit = other.fBottomDeficit;
00092   fRightDeficit= other.fRightDeficit;
00093   fLeftDeficit = other.fLeftDeficit;
00094   fInnerContactW = other.fInnerContactW;
00095   fInnerDeadThickness = other.fInnerDeadThickness;
00096   fOuterDeadThickness = other.fOuterDeadThickness;
00097   fCornerR = other.fCornerR;
00098   fCoreBubble = other.fCoreBubble;
00099   fOrient = other.fOrient;
00100   fDiodType = other.fDiodType;
00101   fDepletionVolt = other.fDepletionVolt;
00102   fResolution = other.fResolution;
00103   fEfficiencies= other.fEfficiencies;
00104   fRatios = other.fRatios;
00105   fInnerBkgModel = other.fInnerBkgModel;
00106   fBkgModel = other.fBkgModel;
00107 }
00108 
00109 MJDatabaseCloverCrystal::~MJDatabaseCloverCrystal()
00110 {
00111 }
00112 MJDatabaseCloverCrystal*
00113 MJDatabaseCloverCrystal::createCrystal(PGresult * res){
00114 
00115   MJDatabaseUtil dbutil;
00116   for (int i = 0; i < PQntuples(res); i++)
00117     {
00118       fSerialNo = PQgetvalue(res, i, 0);
00119       string matName =  PQgetvalue(res, i, 1);
00120       fHeight = dbutil.c_Float(PQgetvalue(res, i, 2));
00121       fCornerR = dbutil.c_Float(PQgetvalue(res, i, 3));
00122 
00123       fBkgModel = PQgetvalue(res, i, 4);
00124       fRadius = dbutil.c_Float(PQgetvalue(res, i, 5));
00125       fCoreRadius = dbutil.c_Float(PQgetvalue(res, i, 6));
00126       fCoreDepth = dbutil.c_Float(PQgetvalue(res, i, 7));
00127 
00128       fCoreBubble = dbutil.c_Float(PQgetvalue(res, i, 8));
00129       fTopDeficit = dbutil.c_Float(PQgetvalue(res, i, 9));
00130       fBottomDeficit = dbutil.c_Float(PQgetvalue(res, i, 10));
00131       fRightDeficit = dbutil.c_Float(PQgetvalue(res, i, 11));
00132       fLeftDeficit = dbutil.c_Float(PQgetvalue(res, i, 12));
00133 
00134       int len = PQgetlength(res,i, 13);
00135       float *ao;
00136       if(len>0 )dbutil.fillArray( ao, PQgetvalue(res, i, 13)); 
00137       int num =dbutil.getNoEle(PQgetvalue(res, i, 13));  
00138       for (int j=0; j< num; j++){
00139         fOrient.push_back(ao[j]);
00140       }
00141       fInnerContactW = dbutil.c_Float(PQgetvalue(res, i, 14));
00142 
00143 
00144       string innerMat = PQgetvalue(res, i, 15);
00145       fInnerDeadThickness = dbutil.c_Float(PQgetvalue(res, i, 16));
00146       fOuterDeadThickness = dbutil.c_Float(PQgetvalue(res, i, 17));
00147       fInnerBkgModel = PQgetvalue(res, i, 18);
00148       fDiodType = *(char*)PQgetvalue(res, i, 19);
00149       fDepletionVolt = dbutil.c_Int(PQgetvalue(res, i, 20));
00150 
00151       //get the matrials
00152       fCrystalMat = *(MJDatabase::GetMaterial(matName));
00153       fInnerContactMat = *(MJDatabase::GetMaterial(innerMat));
00154 
00155       //get resolution at different energies
00156       len = PQgetlength(res,i, 21);
00157       float * ener ;
00158       if( len > 0) dbutil.fillArray(ener, PQgetvalue(res, i, 21));
00159       len = PQgetlength(res,i, 22);
00160       float * resol;
00161       if( len > 0) dbutil.fillArray(resol, PQgetvalue(res, i, 22));
00162       //create the vector of resolutions
00163       num =dbutil.getNoEle(PQgetvalue(res, i, 21));  
00164       for (int j=0; j< num; j++){
00165         fResolution.push_back(CrystalRes(ener[j], resol[j]));
00166       }
00167 
00168       //get efficiencies at different energies
00169 
00170       len = PQgetlength(res,i, 23);
00171       if( len > 0) dbutil.fillArray(ener, PQgetvalue(res, i, 23));
00172       len = PQgetlength(res,i, 24);
00173       float * eff;
00174       if( len > 0) dbutil.fillArray(eff, PQgetvalue(res, i, 24));
00175       //create the vector of efficiencies
00176       num =dbutil.getNoEle(PQgetvalue(res, i, 23));
00177       for (int j=0; j< num; j++){
00178         fEfficiencies.push_back(CrystalEff(ener[j], eff[j]));
00179       }
00180       //get the peak ratios
00181       len = PQgetlength(res,i, 25);
00182       float * ratios;
00183       if( len > 0) dbutil.fillArray(ratios, PQgetvalue(res, i, 25));
00184       num =dbutil.getNoEle(PQgetvalue(res, i, 25));
00185       for (int j=0; j< num; j++){
00186         fRatios.push_back(ratios[j]);
00187       }
00188 
00189 
00190     }
00191   return this;
00192 } 
00193 void 
00194 MJDatabaseCloverCrystal::print(ostream &os){
00195 
00196   vector<double>::iterator iter;
00197   os << '\n' 
00198      << "******* Clover Crystal: " << GetCrystalSerialNo() 
00199      << " ******" << '\n'
00200      << "Radius       : " << GetCrystalRadius() << '\n'
00201      << "Height       : " << GetCrystalHeight() <<'\n'
00202      << "Core Radius  : " << GetCoreRadius() << '\n'
00203      << "Corner Radius: " << GetCornerRadius() << '\n'
00204      << "Core Bubble  : " << GetCoreBubbleRadius() << '\n'
00205      << "Core Depth   : " << GetCoreDepth() << '\n'
00206      << "Orientation  : " << "{ ";
00207   for(iter = fOrient.begin(); iter != fOrient.end(); iter++)
00208     os <<  *iter << " "; 
00209   os << "}\n";
00210 
00211   vector<CrystalRes>::iterator itr;
00212   os<< "Resolution   : " ;
00213   for(itr = fResolution.begin(); itr != fResolution.end(); itr++)
00214     os <<  itr->resolution() << "(" << itr->energy() << ") "; 
00215   os << '\n';
00216 
00217   vector<CrystalEff>::iterator it;
00218   os<< "Efficiencies   : " ;
00219   for(it = fEfficiencies.begin(); it != fEfficiencies.end(); it++)
00220     os <<  it->efficiency () << "(" << it->energy() << ") "; 
00221   os <<endl;
00222   os<< "Peak ratios    : { " ;
00223   for(iter = fRatios.begin(); iter != fRatios.end(); iter++)
00224     os <<  *iter << " "; 
00225    os << "}\n";
00226 
00227   fCrystalMat.print(os);
00228   fInnerContactMat.print(os);
00229 
00230 }
00231 ostream& 
00232 operator << (ostream& os, MJDatabaseCloverCrystal& crys){
00233  
00234   vector<double>::iterator iter;
00235   os << '\n' 
00236      << "******* Clover Crystal: " << crys.GetCrystalSerialNo() 
00237      << " ******" << '\n'
00238      << "Radius       : " << crys.GetCrystalRadius() << '\n'
00239      << "Height       : " << crys.GetCrystalHeight() <<'\n'
00240      << "Core Radius  : " << crys.GetCoreRadius() << '\n'
00241      << "Corner Radius: " << crys.GetCornerRadius() << '\n'
00242      << "Core Bubble  : " << crys.GetCoreBubbleRadius() << '\n'
00243      << "Core Depth   : " << crys.GetCoreDepth() << '\n'
00244      << "Orientation  : " << "{ ";
00245   for(iter =crys.fOrient.begin(); iter != crys.fOrient.end(); iter++)
00246     os <<  *iter << " "; 
00247   os << "}\n";
00248 
00249   vector<CrystalRes>::iterator itr;
00250   os<< "Resolution   : " ;
00251   for(itr = crys.fResolution.begin(); itr != crys.fResolution.end(); itr++)
00252     os <<  itr->resolution() << "(" << itr->energy() << ") "; 
00253   os << '\n';
00254 
00255   vector<CrystalEff>::iterator it;
00256   os<< "Efficiencies   : " ;
00257   for(it = crys.fEfficiencies.begin(); it != crys.fEfficiencies.end(); it++)
00258     os <<  it->efficiency () << "(" << it->energy() << ") "; 
00259   os <<endl;
00260   os<< "Peak ratios    : { " ;
00261   for(iter = crys.fRatios.begin(); iter != crys.fRatios.end(); iter++)
00262     os <<  *iter << " "; 
00263    os << "}\n";
00264 
00265   os << crys.fCrystalMat;
00266   os << crys.fInnerContactMat;
00267  
00268   return os;
00269 }

Generated on Mon Nov 29 16:58:49 2004 for Majorana Simulation by  doxygen 1.3.9.1