G4MoleculeCounter.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 #ifndef G4MoleculeCounter_h
00027 #define G4MoleculeCounter_h
00028 
00029 #include "G4Molecule.hh"
00030 #include <map>
00031 #include "G4ParticleDefinition.hh"
00032 #include <memory>
00033 
00034 using namespace std;
00035 
00036 struct compDoubleWithPrecision
00037 {
00038     bool operator() (const double& a, const double& b) const
00039     {
00040         if(fabs(a - b) < fPrecision)
00041         {
00042             return false;
00043         }
00044         else
00045         {
00046             return a < b;
00047         }
00048     }
00049 
00050     static double fPrecision ;
00051 };
00052 
00053 typedef map<G4double, G4int, compDoubleWithPrecision> NbMoleculeAgainstTime;
00054 
00055 class G4MoleculeCounter
00056 {
00057 protected:
00058     G4MoleculeCounter();
00059     virtual ~G4MoleculeCounter(){;}
00060     static G4MoleculeCounter* fpInstance;
00061     typedef std::map<G4Molecule, NbMoleculeAgainstTime> CounterMapType;
00062 
00063     CounterMapType fCounterMap;
00064 
00065     std::map<const G4MoleculeDefinition*, G4bool> fDontRegister ;
00066     G4bool fUse;
00067 
00068     G4int fVerbose ;
00069 
00070 public:
00071     static void DeleteInstance();
00072 
00073     static  G4MoleculeCounter* GetMoleculeCounter();
00074     inline const NbMoleculeAgainstTime& GetNbMoleculeAgainstTime(const G4Molecule &molecule);
00075     std::auto_ptr<vector<G4Molecule> > GetRecordedMolecules();
00076     virtual void AddAMoleculeAtTime(const G4Molecule&, G4double);
00077     virtual void RemoveAMoleculeAtTime(const G4Molecule&, G4double);
00078 
00079     // inline void DontRegister(G4MoleculeID);
00080     inline virtual void DontRegister(const G4MoleculeDefinition*);
00081     inline virtual void ResetDontRegister();
00082 
00083     void Use(G4bool flag = true)
00084     {
00085         fUse=flag;
00086     }
00087     G4bool InUse()
00088     {
00089         return fUse;
00090     }
00091 
00092     inline void SetVerbose(G4int);
00093     inline G4int GetVerbose();
00094 
00095     virtual void ResetCounter();
00096 };
00097 
00098 inline void G4MoleculeCounter::ResetCounter()
00099 {
00100     fCounterMap.clear();
00101 }
00102 
00103 inline const NbMoleculeAgainstTime& G4MoleculeCounter::GetNbMoleculeAgainstTime(const G4Molecule& molecule)
00104 {
00105     return fCounterMap[molecule];
00106 }
00107 
00108 inline void G4MoleculeCounter::SetVerbose(G4int level)
00109 {
00110     fVerbose = level;
00111 }
00112 
00113 inline G4int G4MoleculeCounter::GetVerbose()
00114 {
00115     return fVerbose ;
00116 }
00117 
00118 inline void G4MoleculeCounter::DontRegister(const G4MoleculeDefinition* molDef)
00119 {
00120     fDontRegister[molDef] = true ;
00121 }
00122 
00123 inline void G4MoleculeCounter::ResetDontRegister()
00124 {
00125     fDontRegister.clear();
00126 }
00127 
00128 #endif

Generated on Mon May 27 17:48:53 2013 for Geant4 by  doxygen 1.4.7