/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Types | Private Attributes
DybModifyProperties Class Reference

#include <DybModifyProperties.h>

List of all members.

Public Member Functions

 DybModifyProperties (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()

Private Types

typedef std::vector< std::string > PropVector
typedef std::map< std::string,
PropVector
PropMap

Private Attributes

PropMap m_PropMap

Detailed Description

Definition at line 15 of file DybModifyProperties.h.


Member Typedef Documentation

typedef std::vector<std::string> DybModifyProperties::PropVector [private]

Definition at line 30 of file DybModifyProperties.h.

typedef std::map<std::string,PropVector> DybModifyProperties::PropMap [private]

Definition at line 32 of file DybModifyProperties.h.


Constructor & Destructor Documentation

DybModifyProperties::DybModifyProperties ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 32 of file DybModifyProperties.cc.

                                                                                       :
  GaudiAlgorithm(name, pSvcLocator),
  m_PropMap ()
{

  // note that PropVector is vector of strings so parameter(s) are in quotes
  PropVector v;
  v.push_back("ABSLENGTH");
  v.push_back("0.007");
  m_PropMap[ "/dd/Materials/Water" ] = v;

   // here is an example of how to change the Acrylic index of refraction to a new, constant value of 1.234
   // v.push_back("RINDEX");
   // v.push_back("NEWCONSTANT");
   // v.push_back("1.234")
   // m_PropMap[ "/dd/Materials/Acrylic" ] = v;

  // Note that you cannot simultaneously change two properties of one material. 

   declareProperty("ModifyPropertyMap", 
                   m_PropMap,
                   "Material, Property and parameter(s)");
 } 

Member Function Documentation

StatusCode DybModifyProperties::initialize ( )

Definition at line 157 of file DybModifyProperties.cc.

{ return StatusCode::SUCCESS; }
StatusCode DybModifyProperties::execute ( )

Definition at line 58 of file DybModifyProperties.cc.

{
  // only want to do this once
  static bool doneit = false;
  if ( doneit ) return StatusCode::SUCCESS;
  doneit = true;

  debug() << " Hello from DybModifyProperties......" << endreq;
  for ( PropMap::iterator it = m_PropMap.begin(); it != m_PropMap.end() ; ++it )
    {
      const std::string Name = (*it).first;
      debug() << " Name of material is " << Name << endreq;

      DataObject* object;
      StatusCode sc =  detSvc()->retrieveObject(Name, object);
      if ( !object ) {
        error() << "Failed to find DataObject with Name " << Name << endreq;
        return StatusCode::FAILURE;
      }

      Material* mat = dynamic_cast<Material*>( &*object);
      if ( !mat ) {
        error() << "No material for object made from " << Name << endreq;
        return StatusCode::FAILURE;
      }

      debug() << "+++++ Original contents of table for " << Name << endreq;
      mat->fillStream( debug() ); 

      PropVector pv = (*it).second;
      

      for ( SmartRefVector<TabulatedProperty>::const_iterator CIT = mat->tabulatedProperties().begin() ;
            CIT != mat->tabulatedProperties().end() ; ++CIT )   
        {  if ( pv[0] == (*CIT)->type() )  // change this property
            // 
            // There are currently two ways to change the property.
            // All values in the table can be changed to a new constant 
            // or, if the property is ABSLENGTH, the water attenuation algorithm will be applied.
            // 
            { 
              if ( pv[1] == "NEWCONSTANT" ) 
                {

                  double newc = atof(pv[2].c_str()); // should handle units correctly
                  
                  for ( TabulatedProperty::Table::const_iterator j = ((*CIT)->table()).begin(); j != ((*CIT)->table()).end(); ++j )
                    { 
                      const double* V = &((*j).second);
                      double* val = const_cast<double*> (V);
                      *val = newc;
                    }
                  info() << "For " << Name << " changed all values of " << (*CIT)->type() << " to a constant = " << newc << endreq;

                }
              else
                {
                  // Apply the water attenuation algorithm of doc992

                  double a_at_200nm = atof(pv[1].c_str())/cm; // convert string to double
                  double defa_at_200nm = 0.007/cm; //  absorbance at 200nm used to construct table in xml file
                  
                  double lmax = ((*CIT)->table())[0].second; // keep track of max absorption length before, after
                  double lmax0 = lmax;
                  double wlmax, wlmax0;
                  for ( TabulatedProperty::Table::const_iterator j = ((*CIT)->table()).begin();
                        j != ((*CIT)->table()).end() ; ++j) // loop over table of (absorption length,photon energy)
                    { const double* energy = &((*j).first);
                      double wl = twopi * hbarc / (*energy);
                      const double* L = &((*j).second);
                      double* abslen = const_cast<double*> (L);
                      if ( (*abslen)>lmax0 ) { lmax0 = *abslen; wlmax0 = wl;}
                      double adef = defa_at_200nm/pow( (wl/(200.*nm)),4 );
                      double b = a_at_200nm/pow( (wl/(200.*nm)), 4 );
                      
                      double anew = 1./(*abslen) - adef + b;
                      double ltot = 1./anew;
                      if ( ltot > lmax ) { lmax = ltot; wlmax = wl ;}
                      *abslen = ltot;
                    }
                  info() << "For " << Name 
                         << " Original max abs. len. "<< lmax0/m << " (m) at " << wlmax0/nm 
                         << " (nm) for absorbance(200nm) " << defa_at_200nm*cm 
                         << " (1/cm). "<< endreq;
                  info() << "For " << Name 
                         << " New max abs. len. "<< lmax/m << " (m) at " << wlmax/nm
                         << " (nm) for absorbance(200nm) "  << a_at_200nm*cm << " (1/cm)" << endreq;
                }
            }
        }
      debug() << " ++++++ New contents of the table for " << Name << endreq;
      mat->fillStream( debug() ); // correct output stream???
      
    }
  return StatusCode::SUCCESS; 
}
StatusCode DybModifyProperties::finalize ( )

Definition at line 162 of file DybModifyProperties.cc.

{ return StatusCode::SUCCESS; }

Member Data Documentation

Definition at line 33 of file DybModifyProperties.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:09:44 for DybAlg by doxygen 1.7.4