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

NonProjCalGeomParams.cc

Go to the documentation of this file.
00001 #include "NonProjCalGeomParams.hh"
00002 #include "xercesc/dom/deprecated/DOM_Element.hpp"
00003 #include "LCD_Document.hh"
00004 #include "LCD_DocumentUtil.hh"
00005 #include "globals.hh"
00006 #include <cassert>
00007 #include <iostream>
00008 using std::cerr;
00009 using std::endl;
00010 
00011 XERCES_CPP_NAMESPACE_USE
00012 
00013 // Full constructor
00014 NonProjCalGeomParams::
00015 NonProjCalGeomParams(double Rmin, double Rmax, double Zmax, int nLayers,
00016                      double preAbsThick, double postAbsThick, double sensThick,
00017                      double cell_len_Z, double cell_len_Phi )
00018   : _Rmin(0.), _Rmax(0.), _Zmax(0.)
00019     , _nLayers(0), _preAbs_thick(0.), _postAbs_thick(0.), _sens_thick(0.)
00020     , _cell_len_Z(0.), _cell_len_Phi(0.)
00021 {
00022   _Rmin = Rmin;
00023   _Rmax = Rmax;
00024   _Zmax = Zmax;
00025   _nLayers = nLayers;
00026   _preAbs_thick = preAbsThick;
00027   _postAbs_thick = postAbsThick;
00028   _sens_thick = sensThick;
00029   _cell_len_Z = cell_len_Z;
00030   _cell_len_Phi = cell_len_Phi;
00031 }
00032 
00033 NonProjCalGeomParams::NonProjCalGeomParams(const DOM_Element& voldb)
00034   : _Rmin(0.), _Rmax(0.), _Zmax(0.)
00035     , _nLayers(0), _preAbs_thick(0.), _postAbs_thick(0.), _sens_thick(0.)
00036     , _cell_len_Z(0.), _cell_len_Phi(0.)
00037 {
00038   DOM_Element celldb;    /* DOM pointer */
00039 
00040   double offset;         /* offset from 0 to 1 */
00041 
00042   /* retrieve parameters for cell calculations from volume element */
00043   if( voldb == DOM_Element() ) {
00044     cerr << "error: XML voldb is invalid" << endl;
00045     exit(1);
00046   }
00047 
00048   /* retrieve and convert number of layers from layering element */
00049   celldb = LCD_DocumentUtil::firstDesc(voldb,"layering");
00050   LCD_DocumentUtil::convertValue(celldb.getAttribute("n"),&_nLayers);
00051 
00052   /* retrieve and convert inner_r and outer_z from barrel_dimensions */
00053   celldb = LCD_DocumentUtil::firstDesc(voldb,"barrel_dimensions");
00054   LCD_DocumentUtil::convertValue(celldb.getAttribute("inner_r"),&_Rmin);
00055   LCD_DocumentUtil::convertValue(celldb.getAttribute("outer_z"),&_Zmax);
00056   _Rmin *= cm;
00057   _Zmax *= cm;
00058 
00059   /* retrieve and convert all variables from cell_info */
00060   celldb = LCD_DocumentUtil::firstDesc(voldb,"cell_info");
00061   if ( celldb == DOM_Element() ) {
00062     G4cerr <<"***** NonProjCalGeomParams Error: could not find cell_info!!!"
00063            << G4endl;
00064     exit(1);
00065   }
00066   LCD_DocumentUtil::convertValue(celldb.getAttribute("height"),&_cell_len_Z);
00067   LCD_DocumentUtil::convertValue(celldb.getAttribute("length"),&_cell_len_Phi);
00068   LCD_DocumentUtil::convertValue(celldb.getAttribute("offset"),&offset);
00069   LCD_DocumentUtil::convertValue(celldb.getAttribute("outer_r"),&_Rmax);
00070   _cell_len_Z *= cm;
00071   _cell_len_Phi *= cm;
00072   offset *= cm;
00073   _Rmax *= cm;
00074 
00075   if (_Rmax == 0) {
00076     printf("_Rmax was not set properly; defaulting to 256 cm\n");
00077     _Rmax = 256.0*cm;
00078   }
00079 
00080   /* retrieve and convert slice thickness information
00081      relies on sensitive slice being 2nd in XML */
00082   DOM_NodeList sliceList = voldb.getElementsByTagName("slice");
00083   int listLen = sliceList.getLength();
00084 
00085   // Make sure a multi-layering scheme can be used (just one of the sublayers
00086   // can be sensitive, otherwise assert(false) will crash)
00087   double temp;
00088   bool sens;
00089   bool sensRead = false;
00090   for(int iitem=0; iitem<listLen; ++iitem) {
00091     DOM_Node sliceNode = sliceList.item(iitem);
00092     celldb = (DOM_Element &)sliceNode;
00093     LCD_DocumentUtil::convertValue(celldb.getAttribute("width"),&temp);
00094     LCD_DocumentUtil::convertValue(celldb.getAttribute("sensitive"),&sens);
00095     if(sens) {
00096       if(sensRead) {
00097         G4cerr<< "*** Geometry problem: >1 sensitive layer!!"<< G4endl;
00098         assert(false);
00099       }
00100       sensRead = true;
00101       _sens_thick = temp * cm;
00102     }
00103     else {
00104       if(sensRead) _postAbs_thick += temp*cm;
00105       else         _preAbs_thick += temp*cm;
00106     }
00107   }
00108 
00109   // cross-validation of geometry
00110   double test = _Rmin + _nLayers*(_preAbs_thick+_sens_thick+_postAbs_thick);
00111   test = (test - _Rmax)/_Rmax;
00112   if( fabs(test) > 0.0001 ) {
00113     G4cout <<"***** Geometry cross-check error:\n"
00114            <<"  Please check outer_r for non-projective components"<< G4endl;
00115     assert( false );
00116   }
00117 }

Generated on Thu Oct 7 18:44:46 2004 for LCDG4 by doxygen 1.3.4