Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MoleculeCounter.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 #ifndef G4MoleculeCounter_h
27 #define G4MoleculeCounter_h
28 
29 #include "G4Molecule.hh"
30 #include <map>
31 #include "G4ParticleDefinition.hh"
32 #include <memory>
33 
34 using namespace std;
35 
37 {
38  bool operator() (const double& a, const double& b) const
39  {
40  if(fabs(a - b) < fPrecision)
41  {
42  return false;
43  }
44  else
45  {
46  return a < b;
47  }
48  }
49 
50  static double fPrecision ;
51 };
52 
53 typedef map<G4double, G4int, compDoubleWithPrecision> NbMoleculeAgainstTime;
54 
56 {
57 protected:
59  virtual ~G4MoleculeCounter(){;}
61  typedef std::map<G4Molecule, NbMoleculeAgainstTime> CounterMapType;
62 
64 
65  std::map<const G4MoleculeDefinition*, G4bool> fDontRegister ;
67 
69 
70 public:
71  static void DeleteInstance();
72 
73  static G4MoleculeCounter* GetMoleculeCounter();
74  inline const NbMoleculeAgainstTime& GetNbMoleculeAgainstTime(const G4Molecule &molecule);
75  std::auto_ptr<vector<G4Molecule> > GetRecordedMolecules();
76  virtual void AddAMoleculeAtTime(const G4Molecule&, G4double);
77  virtual void RemoveAMoleculeAtTime(const G4Molecule&, G4double);
78 
79  // inline void DontRegister(G4MoleculeID);
80  inline virtual void DontRegister(const G4MoleculeDefinition*);
81  inline virtual void ResetDontRegister();
82 
83  void Use(G4bool flag = true)
84  {
85  fUse=flag;
86  }
88  {
89  return fUse;
90  }
91 
92  inline void SetVerbose(G4int);
93  inline G4int GetVerbose();
94 
95  virtual void ResetCounter();
96 };
97 
99 {
100  fCounterMap.clear();
101 }
102 
104 {
105  return fCounterMap[molecule];
106 }
107 
109 {
110  fVerbose = level;
111 }
112 
114 {
115  return fVerbose ;
116 }
117 
119 {
120  fDontRegister[molDef] = true ;
121 }
122 
124 {
125  fDontRegister.clear();
126 }
127 
128 #endif