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