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

MJDatabaseMaterial.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: MJDatabaseMaterial.cc,v 1.2 2004/11/09 13:42:39 xliu Exp $ 
00024 //      
00025 // CLASS IMPLEMENTATION:  MJDatabaseMaterial.cc
00026 //
00027 //---------------------------------------------------------------------------//
00033 // 
00034 //---------------------------------------------------------------------------//
00044 //---------------------------------------------------------------------------//
00045 //
00046 
00047 #include "io/MJLogger.hh"
00048 
00049 //---------------------------------------------------------------------------//
00050 
00051 #include "database/MJDatabaseMaterial.hh"      //Present MJ Class Headers 
00052 #include "database/MJDatabaseUtil.hh"
00053 //---------------------------------------------------------------------------//
00054 
00055 MJDatabaseMaterial::MJDatabaseMaterial()
00056 {
00057 }
00058 MJDatabaseMaterial::MJDatabaseMaterial(string name, double den, 
00059                                        double temp, double pres, int nc,
00060                                        string defbkg, string com)
00061   :fName(name),
00062    fDensity (den),
00063    fTemperature(temp),
00064    fPressure (pres),
00065    fNumOfComponents (nc),
00066    fDefaultBKG (defbkg),
00067    fComment (com)
00068 {
00069 }
00070 
00071 MJDatabaseMaterial::MJDatabaseMaterial(const MJDatabaseMaterial & other)
00072 {
00073 
00074   fName = other.fName;
00075   fDensity = other.fDensity;
00076   fTemperature = other.fTemperature;
00077   fPressure = other.fPressure;
00078   fNumOfComponents = other.fNumOfComponents;
00079   fDefaultBKG = other.fDefaultBKG;
00080   fComment = other.fComment;
00081   fComponents = other.fComponents;
00082   fNumAtoms = other.fNumAtoms;
00083   fFracMass = other.fFracMass;
00084 }
00085 
00086 MJDatabaseMaterial::~MJDatabaseMaterial()
00087 {
00088 }
00089 MJDatabaseMaterial*
00090 MJDatabaseMaterial::createMaterial(PGresult * res, int n){
00091 
00092   MJDatabaseUtil dbutil;
00093   // for (int i = 0; i < n; i++){
00094     fName = PQgetvalue(res, n, 0);
00095     fDensity = dbutil.c_Float(PQgetvalue(res, n, 1));
00096     fTemperature = dbutil.c_Float(PQgetvalue(res, n, 2));
00097     fPressure = dbutil.c_Float(PQgetvalue(res, n, 3));
00098     
00099     fNumOfComponents = dbutil.c_Int(PQgetvalue(res, n, 4));
00100     
00101     fDefaultBKG = PQgetvalue(res, n, 6);
00102     
00103     //get the time stamp
00104     
00105     //get the comments
00106    for (int i = 0; i < fNumOfComponents; i++){
00107    
00108     fComment = PQgetvalue(res, i+n, 8);
00109     fComponents.push_back(PQgetvalue(res, i+n, 9));
00110     
00111     fNumAtoms.push_back(dbutil.c_Int(PQgetvalue(res, i+n, 10)));
00112     fFracMass.push_back(dbutil.c_Float(PQgetvalue(res, i+n, 11)));
00113   }
00114   return this;
00115 }
00116 void 
00117 MJDatabaseMaterial::print(ostream & os){
00118   
00119  os << '\n' 
00120     << "******* Material: " << GetName() << " ******" << '\n'
00121     << "Density: " << GetDensity() << '\n'
00122     << "Temperature: " << GetTemperature() <<'\n'
00123     << "Pressure:    " << GetPressure() << '\n'
00124     << "Number of components: " << GetNoComponents() << '\n'
00125     <<endlog;
00126  
00127   
00128 }
00129 ostream& 
00130 operator << (ostream& os, MJDatabaseMaterial & mat){
00131   os << '\n' 
00132      << "******* Material: " << mat.GetName() << " ******" << '\n'
00133      << "Density     : " << mat.GetDensity() << '\n'
00134      << "Temperature : " << mat.GetTemperature() <<'\n'
00135      << "Pressure    : " << mat.GetPressure() << '\n'
00136      << "Number of components: " << mat.GetNoComponents() << '\n';
00137   vector<string>::iterator itr1;
00138   os << "Components  : { ";
00139   for (itr1 = mat.fComponents.begin(); itr1 != mat.fComponents.end(); itr1++)
00140     os << *itr1 << " ";
00141   os << "}\n";
00142 
00143   vector<int>::iterator itr2;
00144   os << "No of atoms  : { ";
00145   for (itr2 = mat.fNumAtoms.begin(); itr2 != mat.fNumAtoms.end(); itr2++)
00146     os << *itr2 << " ";
00147   os << "}\n";
00148 
00149   vector<double>::iterator itr3;
00150   os << "Fractional mass: { ";
00151   for (itr3 = mat.fFracMass.begin(); itr3 != mat.fFracMass.end(); itr3++)
00152     os << *itr3 << " ";
00153   os << "}\n";
00154 
00155 
00156   os<<endl;
00157  
00158   return os;
00159 }

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