Main Page | Compound List | File List | Compound Members | File Members | Related Pages

McObjectManager Class Reference

A singleton manager for handling the MC root objects. More...

#include <McObjectManager.h>

Collaboration diagram for McObjectManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~McObjectManager ()
McParticlegetNewMcParticle ()
 This method returns a "new" McParticle allocated from the local pool.

McPositionHitgetNewMcPositionHit ()
 This method returns a "new" McPositionHit allocated from the local pool.

McIntegratingHitgetNewMcIntegratingHit ()
 This method returns a "new" McIntegratingHit allocated from the local pool.

McTrajectorygetNewMcTrajectory ()
 This method returns a "new" McTrajectory allocated from the local pool.

McTrajectoryPointgetNewMcTrajectoryPoint ()
 This method returns a "new" McTrajectoryPoint allocated from the local pool.

void Delete ()
 "Delete" all objects


Static Public Member Functions

McObjectManagergetPointer ()
 The static pointer retrival method of the singleton.


Private Member Functions

 McObjectManager ()
 The constructor is private since this is a singleton.


Private Attributes

std::list< McParticlem_mcPartPool
 Define a "pool" for McParticles and an iterator for accessing them.

std::list< McParticle >::iterator m_mcPartPoolIdx
std::list< McPositionHitm_mcPosHitPool
 Define a "pool" for McParticles and an iterator for accessing them.

std::list< McPositionHit
>::iterator 
m_mcPosHitPoolIdx
std::list< McIntegratingHitm_mcIntHitPool
 Define a "pool" for McParticles and an iterator for accessing them.

std::list< McIntegratingHit
>::iterator 
m_mcIntHitPoolIdx
std::list< McTrajectorym_mcTrajectoryPool
 Define a "pool" for McTrajectory's and an iterator for accessing them.

std::list< McTrajectory
>::iterator 
m_mcTrajectoryPoolIdx
std::list< McTrajectoryPointm_mcTrajPointPool
 Define a "pool" for McTrajectoryPoint's and an iterator for accessing them.

std::list< McTrajectoryPoint
>::iterator 
m_mcTrajPointPoolIdx

Static Private Attributes

McObjectManagerm_pointer = 0
 The static pointer of the singleton.


Detailed Description

A singleton manager for handling the MC root objects.

Author:
Am. Crazy
Header
/nfs/slac/g/glast/ground/cvs/mcRootData/src/McObjectManager.h,v 1.2 2007/03/15 17:00:14 heather Exp

Definition at line 21 of file McObjectManager.h.


Constructor & Destructor Documentation

virtual McObjectManager::~McObjectManager  )  [inline, virtual]
 

Definition at line 23 of file McObjectManager.h.

References m_pointer.

00023 { m_pointer=0; };

McObjectManager::McObjectManager  )  [private]
 

The constructor is private since this is a singleton.

Definition at line 25 of file McObjectManager.cxx.

References m_mcIntHitPool, m_mcIntHitPoolIdx, m_mcPartPool, m_mcPartPoolIdx, m_mcPosHitPool, m_mcPosHitPoolIdx, m_mcTrajectoryPool, m_mcTrajectoryPoolIdx, m_mcTrajPointPool, m_mcTrajPointPoolIdx, MCHITPOOLSIZE, MCPOINTPOOLSIZE, and MCPOOLSIZE.

Referenced by getPointer().

00025                                  : m_mcPartPool(MCPOOLSIZE), 
00026                                      m_mcPosHitPool(MCHITPOOLSIZE), 
00027                                      m_mcIntHitPool(MCHITPOOLSIZE),
00028                                      m_mcTrajectoryPool(MCPOOLSIZE),
00029                                      m_mcTrajPointPool(MCPOINTPOOLSIZE)
00030 {
00031     m_mcPartPoolIdx       = m_mcPartPool.begin();
00032     m_mcPosHitPoolIdx     = m_mcPosHitPool.begin();
00033     m_mcIntHitPoolIdx     = m_mcIntHitPool.begin();
00034     m_mcTrajectoryPoolIdx = m_mcTrajectoryPool.begin();
00035     m_mcTrajPointPoolIdx  = m_mcTrajPointPool.begin();
00036 }


Member Function Documentation

void McObjectManager::Delete  ) 
 

"Delete" all objects

Definition at line 165 of file McObjectManager.cxx.

References m_mcIntHitPool, m_mcIntHitPoolIdx, m_mcPartPool, m_mcPartPoolIdx, m_mcPosHitPool, m_mcPosHitPoolIdx, m_mcTrajectoryPool, m_mcTrajectoryPoolIdx, m_mcTrajPointPool, m_mcTrajPointPoolIdx, MCHITPOOLSIZE, MCPOINTPOOLSIZE, and MCPOOLSIZE.

Referenced by McEvent::Clear().

00166 {
00167     // Keep all of the pools down to a reasonable size...
00168     // Start with McParticle pool
00169     if (m_mcPartPool.size() > 5*MCPOOLSIZE)
00170     {
00171         m_mcPartPool.resize(5*MCPOOLSIZE);
00172     }
00173 
00174     // Now the with McPositionHit pool
00175     if (m_mcPosHitPool.size() > 5*MCHITPOOLSIZE)
00176     {
00177         m_mcPosHitPool.resize(5*MCHITPOOLSIZE);
00178     }
00179 
00180     // Now the with McIntegratingHit pool
00181     if (m_mcIntHitPool.size() > 5*MCHITPOOLSIZE)
00182     {
00183         m_mcIntHitPool.resize(5*MCHITPOOLSIZE);
00184     }
00185 
00186     // Now the with McTrajectory pool
00187     if (m_mcTrajectoryPool.size() > 5*MCPOOLSIZE)
00188     {
00189         m_mcTrajectoryPool.resize(5*MCPOOLSIZE);
00190     }
00191 
00192     // Now the with McTrajectoryPoint pool
00193     if (m_mcTrajPointPool.size() > 5*MCPOINTPOOLSIZE)
00194     {
00195         m_mcTrajPointPool.resize(5*MCPOINTPOOLSIZE);
00196     }
00197 
00198     // Ok, reset iterators to first element of our pools
00199     m_mcPartPoolIdx       = m_mcPartPool.begin();
00200     m_mcPosHitPoolIdx     = m_mcPosHitPool.begin();
00201     m_mcIntHitPoolIdx     = m_mcIntHitPool.begin();
00202     m_mcTrajectoryPoolIdx = m_mcTrajectoryPool.begin();
00203     m_mcTrajPointPoolIdx  = m_mcTrajPointPool.begin();
00204 
00205     return;
00206 }

McIntegratingHit * McObjectManager::getNewMcIntegratingHit  ) 
 

This method returns a "new" McIntegratingHit allocated from the local pool.

Definition at line 93 of file McObjectManager.cxx.

References m_mcIntHitPool, m_mcIntHitPoolIdx, and MCHITMAXPOOLGROW.

Referenced by McIntegratingHit::operator new().

00094 {
00095     McIntegratingHit* intHit = 0;
00096 
00097     // If we have exceeded our pre-allocated list of McIntegratingHits then expand
00098     if (m_mcIntHitPoolIdx == m_mcIntHitPool.end())
00099     {
00100         // Add one more McIntegratingHit just before the end... this is really a 
00101         // trick to get a valid iterator at the end of the list
00102         m_mcIntHitPoolIdx = m_mcIntHitPool.insert(m_mcIntHitPoolIdx, McIntegratingHit());
00103 
00104         // Expand the pool by some reasonable amount
00105         int newSize = std::max((int)(2 * m_mcIntHitPool.size()), (int)MCHITMAXPOOLGROW);
00106 
00107         // For good measure expand the pool by our starting poolsize
00108         m_mcIntHitPool.insert(m_mcIntHitPool.end(), newSize, McIntegratingHit());
00109     }
00110 
00111     // Get the pointer to an available McParticle
00112     intHit = &*m_mcIntHitPoolIdx++;
00113 
00114     return intHit;
00115 }

McParticle * McObjectManager::getNewMcParticle  ) 
 

This method returns a "new" McParticle allocated from the local pool.

Definition at line 45 of file McObjectManager.cxx.

References m_mcPartPool, m_mcPartPoolIdx, and MCMAXPOOLGROW.

Referenced by McParticle::operator new().

00046 {
00047     McParticle* mcPart = 0;
00048 
00049     // If we have exceeded our pre-allocated list of McParticles then expand
00050     if (m_mcPartPoolIdx == m_mcPartPool.end())
00051     {
00052         // Add one more McParticle just before the end... this is really a 
00053         // trick to get a valid iterator at the end of the list
00054         m_mcPartPoolIdx = m_mcPartPool.insert(m_mcPartPoolIdx, McParticle());
00055 
00056         // Expand the pool by some reasonable amount
00057         int newSize = std::max((int)(2 * m_mcPartPool.size()), (int)MCMAXPOOLGROW);
00058 
00059         // For good measure expand the pool by our starting poolsize
00060         m_mcPartPool.insert(m_mcPartPool.end(), newSize, McParticle());
00061     }
00062 
00063     // Get the pointer to an available McParticle
00064     mcPart = &*m_mcPartPoolIdx++;
00065 
00066     return mcPart;
00067 }

McPositionHit * McObjectManager::getNewMcPositionHit  ) 
 

This method returns a "new" McPositionHit allocated from the local pool.

Definition at line 69 of file McObjectManager.cxx.

References m_mcPosHitPool, m_mcPosHitPoolIdx, and MCHITMAXPOOLGROW.

Referenced by McPositionHit::operator new().

00070 {
00071     McPositionHit* posHit = 0;
00072 
00073     // If we have exceeded our pre-allocated list of McParticles then expand
00074     if (m_mcPosHitPoolIdx == m_mcPosHitPool.end())
00075     {
00076         // Add one more McPositionHit just before the end... this is really a 
00077         // trick to get a valid iterator at the end of the list
00078         m_mcPosHitPoolIdx = m_mcPosHitPool.insert(m_mcPosHitPoolIdx, McPositionHit());
00079 
00080         // Expand the pool by some reasonable amount
00081         int newSize = std::max((int)(2 * m_mcPosHitPool.size()), (int)MCHITMAXPOOLGROW);
00082 
00083         // For good measure expand the pool by our starting poolsize
00084         m_mcPosHitPool.insert(m_mcPosHitPool.end(), newSize, McPositionHit());
00085     }
00086 
00087     // Get the pointer to an available McParticle
00088     posHit = &*m_mcPosHitPoolIdx++;
00089 
00090     return posHit;
00091 }

McTrajectory * McObjectManager::getNewMcTrajectory  ) 
 

This method returns a "new" McTrajectory allocated from the local pool.

Definition at line 117 of file McObjectManager.cxx.

References m_mcTrajectoryPool, m_mcTrajectoryPoolIdx, and MCMAXPOOLGROW.

Referenced by McTrajectory::operator new().

00118 {
00119     McTrajectory* traj = 0;
00120 
00121     // If we have exceeded our pre-allocated list of McIntegratingHits then expand
00122     if (m_mcTrajectoryPoolIdx == m_mcTrajectoryPool.end())
00123     {
00124         // Add one more McTrajectory just before the end... this is really a 
00125         // trick to get a valid iterator at the end of the list
00126         m_mcTrajectoryPoolIdx = m_mcTrajectoryPool.insert(m_mcTrajectoryPoolIdx, McTrajectory());
00127 
00128         // Expand the pool by some reasonable amount
00129         int newSize = std::max((int)(2 * m_mcTrajectoryPool.size()), (int)MCMAXPOOLGROW);
00130 
00131         // For good measure expand the pool by our starting poolsize
00132         m_mcTrajectoryPool.insert(m_mcTrajectoryPool.end(), newSize, McTrajectory());
00133     }
00134 
00135     // Get the pointer to an available McTrajectory
00136     traj = &*m_mcTrajectoryPoolIdx++;
00137 
00138     return traj;
00139 }

McTrajectoryPoint * McObjectManager::getNewMcTrajectoryPoint  ) 
 

This method returns a "new" McTrajectoryPoint allocated from the local pool.

Definition at line 141 of file McObjectManager.cxx.

References m_mcTrajPointPool, m_mcTrajPointPoolIdx, and MCPOINTMAXPOOLGROW.

Referenced by McTrajectoryPoint::operator new().

00142 {
00143     McTrajectoryPoint* point = 0;
00144 
00145     // If we have exceeded our pre-allocated list of McIntegratingHits then expand
00146     if (m_mcTrajPointPoolIdx == m_mcTrajPointPool.end())
00147     {
00148         // Add one more McTrajectory just before the end... this is really a 
00149         // trick to get a valid iterator at the end of the list
00150         m_mcTrajPointPoolIdx = m_mcTrajPointPool.insert(m_mcTrajPointPoolIdx, McTrajectoryPoint());
00151 
00152         // Expand the pool by some reasonable amount
00153         int newSize = std::max((int)(2 * m_mcTrajPointPool.size()), (int)MCPOINTMAXPOOLGROW);
00154 
00155         // For good measure expand the pool by our starting poolsize
00156         m_mcTrajPointPool.insert(m_mcTrajPointPool.end(), newSize, McTrajectoryPoint());
00157     }
00158 
00159     // Get the pointer to an available McTrajectory
00160     point = &*m_mcTrajPointPoolIdx++;
00161 
00162     return point;
00163 }

McObjectManager * McObjectManager::getPointer  )  [static]
 

The static pointer retrival method of the singleton.

Definition at line 38 of file McObjectManager.cxx.

References m_pointer, and McObjectManager().

Referenced by McEvent::Clear(), McTrajectoryPoint::operator new(), McTrajectory::operator new(), McPositionHit::operator new(), McParticle::operator new(), McIntegratingHit::operator new(), and McEvent::~McEvent().

00039 {
00040   // Purpose and Method: standard singleton method to retrive the unique pointer
00041   if(m_pointer == 0) m_pointer = new McObjectManager();
00042   return m_pointer;
00043 }


Member Data Documentation

std::list<McIntegratingHit> McObjectManager::m_mcIntHitPool [private]
 

Define a "pool" for McParticles and an iterator for accessing them.

Definition at line 62 of file McObjectManager.h.

Referenced by Delete(), getNewMcIntegratingHit(), and McObjectManager().

std::list<McIntegratingHit>::iterator McObjectManager::m_mcIntHitPoolIdx [private]
 

Definition at line 63 of file McObjectManager.h.

Referenced by Delete(), getNewMcIntegratingHit(), and McObjectManager().

std::list<McParticle> McObjectManager::m_mcPartPool [private]
 

Define a "pool" for McParticles and an iterator for accessing them.

Definition at line 54 of file McObjectManager.h.

Referenced by Delete(), getNewMcParticle(), and McObjectManager().

std::list<McParticle>::iterator McObjectManager::m_mcPartPoolIdx [private]
 

Definition at line 55 of file McObjectManager.h.

Referenced by Delete(), getNewMcParticle(), and McObjectManager().

std::list<McPositionHit> McObjectManager::m_mcPosHitPool [private]
 

Define a "pool" for McParticles and an iterator for accessing them.

Definition at line 58 of file McObjectManager.h.

Referenced by Delete(), getNewMcPositionHit(), and McObjectManager().

std::list<McPositionHit>::iterator McObjectManager::m_mcPosHitPoolIdx [private]
 

Definition at line 59 of file McObjectManager.h.

Referenced by Delete(), getNewMcPositionHit(), and McObjectManager().

std::list<McTrajectory> McObjectManager::m_mcTrajectoryPool [private]
 

Define a "pool" for McTrajectory's and an iterator for accessing them.

Definition at line 66 of file McObjectManager.h.

Referenced by Delete(), getNewMcTrajectory(), and McObjectManager().

std::list<McTrajectory>::iterator McObjectManager::m_mcTrajectoryPoolIdx [private]
 

Definition at line 67 of file McObjectManager.h.

Referenced by Delete(), getNewMcTrajectory(), and McObjectManager().

std::list<McTrajectoryPoint> McObjectManager::m_mcTrajPointPool [private]
 

Define a "pool" for McTrajectoryPoint's and an iterator for accessing them.

Definition at line 70 of file McObjectManager.h.

Referenced by Delete(), getNewMcTrajectoryPoint(), and McObjectManager().

std::list<McTrajectoryPoint>::iterator McObjectManager::m_mcTrajPointPoolIdx [private]
 

Definition at line 71 of file McObjectManager.h.

Referenced by Delete(), getNewMcTrajectoryPoint(), and McObjectManager().

McObjectManager * McObjectManager::m_pointer = 0 [static, private]
 

The static pointer of the singleton.

Definition at line 15 of file McObjectManager.cxx.

Referenced by getPointer(), and ~McObjectManager().


The documentation for this class was generated from the following files:
Generated on Tue Dec 11 16:28:56 2007 by doxygen 1.3.3