Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4CascadeHistory Class Reference

#include <G4CascadeHistory.hh>

Classes

struct  HistoryEntry
 

Public Member Functions

 G4CascadeHistory (G4int verbose=0)
 
 ~G4CascadeHistory ()
 
void setVerboseLevel (G4int verbose=0)
 
void Clear ()
 
G4int AddEntry (G4CascadParticle &cpart)
 
G4int AddVertex (G4CascadParticle &cpart, std::vector< G4CascadParticle > &daug)
 
void DropEntry (const G4CascadParticle &cpart)
 
void Print (std::ostream &os) const
 

Protected Member Functions

void AssignHistoryID (G4CascadParticle &cpart)
 
void FillDaughters (G4int iEntry, std::vector< G4CascadParticle > &daug)
 
void PrintEntry (std::ostream &os, G4int iEntry) const
 
void PrintParticle (std::ostream &os, const G4CascadParticle &cpart) const
 
G4bool PrintingDone (G4int iEntry) const
 
const char * GuessTarget (const HistoryEntry &entry) const
 
G4int size () const
 

Detailed Description

Definition at line 41 of file G4CascadeHistory.hh.

Constructor & Destructor Documentation

G4CascadeHistory::G4CascadeHistory ( G4int  verbose = 0)
inline

Definition at line 43 of file G4CascadeHistory.hh.

43 : verboseLevel(verbose) {;}
G4CascadeHistory::~G4CascadeHistory ( )
inline

Definition at line 44 of file G4CascadeHistory.hh.

44 {;} // *** Do not want subclasses ***

Member Function Documentation

G4int G4CascadeHistory::AddEntry ( G4CascadParticle cpart)

Definition at line 106 of file G4CascadeHistory.cc.

106  {
107  AssignHistoryID(cpart); // Make sure particle has index
108 
109  G4int id = cpart.getHistoryId();
110  if (id < size()) {
111  if (verboseLevel>2)
112  G4cout << " AddEntry updating " << id << " " << &theHistory[id] << G4endl;
113  theHistory[id].cpart = cpart; // Copies kinematics
114  } else {
115  theHistory.push_back(HistoryEntry(cpart));
116  if (verboseLevel>2)
117  G4cout << " AddEntry creating " << id << " " << &theHistory.back() << G4endl;
118  }
119 
120  if (verboseLevel>3) G4cout << theHistory[id].cpart << G4endl; // Sanity check
121 
122  return id;
123 }
void AssignHistoryID(G4CascadParticle &cpart)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4int getHistoryId() const
G4int size() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4CascadeHistory::AddVertex ( G4CascadParticle cpart,
std::vector< G4CascadParticle > &  daug 
)

Definition at line 59 of file G4CascadeHistory.cc.

60  {
61  if (verboseLevel>1) G4cout << " >>> G4CascadeHistory::AddVertex" << G4endl;
62 
63  // Create new entry for vertex or update particle kinematics
64  G4int id = AddEntry(cpart);
65  FillDaughters(id, daug);
66 
67  if (verboseLevel>3) {
68  G4cout << " entry " << id << " " << &theHistory[id] << " got "
69  << theHistory[id].n << " daughters:";
70  for (G4int i=0; i<theHistory[id].n; i++) {
71  G4cout << " " << theHistory[id].dId[i];
72  }
73  G4cout << G4endl;
74  }
75 
76  return id;
77 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4int AddEntry(G4CascadParticle &cpart)
#define G4endl
Definition: G4ios.hh:61
void FillDaughters(G4int iEntry, std::vector< G4CascadParticle > &daug)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeHistory::AssignHistoryID ( G4CascadParticle cpart)
protected

Definition at line 137 of file G4CascadeHistory.cc.

137  {
138  if (cpart.getHistoryId() >= 0) return; // ID already assigned
139 
140  if (verboseLevel>2) {
141  G4cout << " >>> G4CascadeHistory::NewHistoryID assigning ID "
142  << size() << G4endl;
143  }
144 
145  cpart.setHistoryId(size());
146 }
void setHistoryId(G4int id)
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4int getHistoryId() const
G4int size() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeHistory::Clear ( )

Definition at line 50 of file G4CascadeHistory.cc.

50  {
51  if (verboseLevel>1) G4cout << " >>> G4CascadeHistory::Clear" << G4endl;
52  theHistory.clear();
53  entryPrinted.clear();
54 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the caller graph for this function:

void G4CascadeHistory::DropEntry ( const G4CascadParticle cpart)

Definition at line 127 of file G4CascadeHistory.cc.

127  {
128  if (verboseLevel>1) G4cout << " >>> G4CascadeHistory::DropEntry" << G4endl;
129 
130 
131  G4int id = cpart.getHistoryId(); // Particle must appear in history
132  if (id>=0) theHistory[id].n = -1; // Special flag for absorbed particle
133 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4int getHistoryId() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeHistory::FillDaughters ( G4int  iEntry,
std::vector< G4CascadParticle > &  daug 
)
protected

Definition at line 80 of file G4CascadeHistory.cc.

80  {
81  G4int nDaug = (G4int)daug.size();
82 
83  if (verboseLevel>1)
84  G4cout << " >>> G4CascadeHistory::FillDaughters " << iEntry << G4endl;
85 
86  // NOTE: Cannot use reference to element, as push_back can invalidate refs!
87  theHistory[iEntry].clear();
88 
89  theHistory[iEntry].n = nDaug;
90  for (G4int i=0; i<nDaug; i++) {
91  G4int id = AddEntry(daug[i]);
92  theHistory[iEntry].dId[i] = id;
93  }
94 
95  if (verboseLevel>3) {
96  G4cout << " got " << theHistory[iEntry].n << " daughters:";
97  for (G4int i=0; i<theHistory[iEntry].n; i++) {
98  G4cout << " " << theHistory[iEntry].dId[i];
99  }
100  G4cout << G4endl;
101  }
102 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4int AddEntry(G4CascadParticle &cpart)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

const char * G4CascadeHistory::GuessTarget ( const HistoryEntry entry) const
protected

Definition at line 205 of file G4CascadeHistory.cc.

205  {
206  if (verboseLevel>2) G4cout << " >>> G4CascadeHistory::GuessTarget" << G4endl;
207 
208  if (entry.n < 0) return "-O-"; // Exciton or trapped-decay
209  if (entry.n == 0) return "***"; // Outgoing (final state) particle
210 
211  const G4CascadParticle& cpart = entry.cpart; // For convenience
212  if (verboseLevel>3) G4cout << "cpart: " << cpart;
213 
214  // Compute baryon number and charge from daughters minus projectile
215  G4int targetB = -cpart.getParticle().baryon();
216  G4int targetQ = (G4int)-cpart.getParticle().getCharge();
217 
218  for (G4int i=0; i<entry.n; i++) {
219  const G4CascadParticle& cdaug = theHistory[entry.dId[i]].cpart;
220  if (verboseLevel>3)
221  G4cout << "cdaug " << i << " ID " << entry.dId[i] << ": " << cdaug;
222 
223  targetB += cdaug.getParticle().baryon();
224  targetQ += (G4int)cdaug.getParticle().getCharge();
225  }
226 
227  // Target possibilities are proton, neutron or dibaryon (pp, nn, pn)
228  if (targetB==1 && targetQ==0) return "n";
229  if (targetB==1 && targetQ==1) return "p";
230  if (targetB==2 && targetQ==0) return "nn";
231  if (targetB==2 && targetQ==1) return "pn";
232  if (targetB==2 && targetQ==2) return "pp";
233 
234  if (verboseLevel>2) {
235  G4cout << " ERROR identifying target: deltaB " << targetB
236  << " deltaQ " << targetQ << " from\n" << cpart << " to" << G4endl;
237  for (G4int j=0; j<entry.n; j++) {
238  G4cout << theHistory[entry.dId[j]].cpart;
239  }
240  }
241 
242  return "BAD TARGET"; // Should not get here if EPCollider worked right
243 }
int G4int
Definition: G4Types.hh:78
const G4InuclElementaryParticle & getParticle() const
G4GLOB_DLL std::ostream G4cout
G4double getCharge() const
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeHistory::Print ( std::ostream &  os) const

Definition at line 156 of file G4CascadeHistory.cc.

156  {
157  if (verboseLevel) os << " >>> G4CascadeHistory::Print" << std::endl;
158 
159  os << " Cascade structure: vertices, (-O-) exciton, (***) outgoing"
160  << std::endl;
161 
162  for (G4int i=0; i<size(); i++) {
163  if (!PrintingDone(i)) PrintEntry(os, i);
164  }
165 }
G4bool PrintingDone(G4int iEntry) const
int G4int
Definition: G4Types.hh:78
void PrintEntry(std::ostream &os, G4int iEntry) const
G4int size() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeHistory::PrintEntry ( std::ostream &  os,
G4int  iEntry 
) const
protected

Definition at line 169 of file G4CascadeHistory.cc.

169  {
170  if (iEntry >= size()) return; // Skip nonexistent entry
171  if (PrintingDone(iEntry)) return; // Skip entry already reported
172 
173  entryPrinted.insert(iEntry);
174 
175  const HistoryEntry& entry = theHistory[iEntry]; // For convenience
176  const G4CascadParticle& cpart = entry.cpart;
177 
178  G4int indent = cpart.getGeneration()*2;
179 
180  // Index and indentation of cascade vertex
181  std::ios::fmtflags osFlags = os.flags();
182  os.setf(std::ios::left); // Pushes all blanks to right end of output
183  os << "#" << std::setw(3+indent) << iEntry;
184  os.flags(osFlags);
185 
186  os << cpart.getParticle().getDefinition()->GetParticleName()
187  << " p " << cpart.getMomentum() << " (cosTh "
188  << cpart.getMomentum().vect().unit().z() << ")"
189  << " @ " << cpart.getPosition()
190  << " zone " << cpart.getCurrentZone();
191 
192  // Flag as final-state particle or report daughters iteratively
193  os << " (" << GuessTarget(entry) << ")";
194  if (entry.n > 0) {
195  os << " -> N=" << entry.n << std::endl;
196  for (G4int i=0; i<entry.n; i++) {
197  PrintEntry(os, entry.dId[i]);
198  }
199  } else os << std::endl;
200 }
G4LorentzVector getMomentum() const
G4bool PrintingDone(G4int iEntry) const
G4int getGeneration() const
const G4ParticleDefinition * getDefinition() const
int G4int
Definition: G4Types.hh:78
const G4InuclElementaryParticle & getParticle() const
const G4String & GetParticleName() const
double z() const
void PrintEntry(std::ostream &os, G4int iEntry) const
Hep3Vector vect() const
Hep3Vector unit() const
G4int getCurrentZone() const
const G4ThreeVector & getPosition() const
G4int size() const
const char * GuessTarget(const HistoryEntry &entry) const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4CascadeHistory::PrintingDone ( G4int  iEntry) const
inlineprotected

Definition at line 83 of file G4CascadeHistory.hh.

83  {
84  return (entryPrinted.find(iEntry) != entryPrinted.end());
85  }

Here is the caller graph for this function:

void G4CascadeHistory::PrintParticle ( std::ostream &  os,
const G4CascadParticle cpart 
) const
protected
void G4CascadeHistory::setVerboseLevel ( G4int  verbose = 0)
inline

Definition at line 46 of file G4CascadeHistory.hh.

46 { verboseLevel = verbose; }

Here is the caller graph for this function:

G4int G4CascadeHistory::size ( ) const
inlineprotected

Definition at line 90 of file G4CascadeHistory.hh.

90 { return (G4int)theHistory.size(); }
int G4int
Definition: G4Types.hh:78

Here is the caller graph for this function:


The documentation for this class was generated from the following files: