Geant4  10.00.p03
G4CascadeHistory.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 // $Id: G4CascadeHistory.hh 67796 2013-03-08 06:18:39Z mkelsey $
27 //
28 // G4CascadeHistory: Container to record all particles produced during
29 // cascade, with daughters; printout is formatted hierarchically.
30 
31 #ifndef G4CASCADE_HISTORY_HH
32 #define G4CASCADE_HISTORY_HH
33 
34 #include "globals.hh"
35 #include "G4CascadParticle.hh"
36 #include <iosfwd>
37 #include <set>
38 #include <vector>
39 
40 
42 public:
43  G4CascadeHistory(G4int verbose=0) : verboseLevel(verbose) {;}
44  ~G4CascadeHistory() {;} // *** Do not want subclasses ***
45 
46  void setVerboseLevel(G4int verbose=0) { verboseLevel = verbose; }
47 
48  // Reset buffers for new event
49  void Clear();
50 
51  // Add particle to history list, assigning ID number (non-const input)
53 
54  // Record full interaction vertex (non-const input)
55  G4int AddVertex(G4CascadParticle& cpart, std::vector<G4CascadParticle>& daug);
56 
57  // Discard particle reabsorbed during cascade
58  void DropEntry(const G4CascadParticle& cpart);
59 
60  // Report cascade structure hierarchically
61  void Print(std::ostream& os) const;
62 
63 protected:
64  struct HistoryEntry {
67  G4int dId[10]; // Must be fixed size for allocation in vector
68 
69  HistoryEntry() { clear(); };
70  HistoryEntry(const G4CascadParticle& cp) : cpart(cp) { clear(); }
71  void clear();
72  };
73 
74  // Assign ID number to particle (non-const input)
75  void AssignHistoryID(G4CascadParticle& cpart);
76 
77  // Populate list of daughters in interaction, adding them to history list
78  void FillDaughters(G4int iEntry, std::vector<G4CascadParticle>& daug);
79 
80  // Add single-line report for particle, along with daughters
81  void PrintEntry(std::ostream& os, G4int iEntry) const;
82  void PrintParticle(std::ostream& os, const G4CascadParticle& cpart) const;
83  G4bool PrintingDone(G4int iEntry) const {
84  return (entryPrinted.find(iEntry) != entryPrinted.end());
85  }
86 
87  // Derive target of cascade step from particle and daughters
88  const char* GuessTarget(const HistoryEntry& entry) const;
89 
90  G4int size() const { return (G4int)theHistory.size(); }
91 
92 private:
94 
95  std::vector<HistoryEntry> theHistory; // List of particles and daughters
96  mutable std::set<G4int> entryPrinted; // Particle indices already reported
97 
98  // No copying allowed
101 };
102 
103 // Inline reporting
104 std::ostream& operator<<(std::ostream& os, const G4CascadeHistory& history);
105 
106 #endif /* G4CASCADE_HISTORY_HH */
void PrintParticle(std::ostream &os, const G4CascadParticle &cpart) const
G4bool PrintingDone(G4int iEntry) const
G4int dId[10]
void Print(std::ostream &os) const
void AssignHistoryID(G4CascadParticle &cpart)
std::ostream & operator<<(std::ostream &os, const G4CascadeHistory &history)
int G4int
Definition: G4Types.hh:78
G4CascadeHistory(G4int verbose=0)
void PrintEntry(std::ostream &os, G4int iEntry) const
std::vector< HistoryEntry > theHistory
bool G4bool
Definition: G4Types.hh:79
void DropEntry(const G4CascadParticle &cpart)
G4int AddEntry(G4CascadParticle &cpart)
G4int n
HistoryEntry(const G4CascadParticle &cp)
G4CascadeHistory & operator=(const G4CascadeHistory &rhs)
HistoryEntry()
void setVerboseLevel(G4int verbose=0)
G4int size() const
void clear()
const char * GuessTarget(const HistoryEntry &entry) const
G4int AddVertex(G4CascadParticle &cpart, std::vector< G4CascadParticle > &daug)
std::set< G4int > entryPrinted
G4CascadParticle cpart
static const G4double cp
void FillDaughters(G4int iEntry, std::vector< G4CascadParticle > &daug)