CMS 3D CMS Logo

LocalFieldManager.cc
Go to the documentation of this file.
1 
3 
4 #include "G4ChordFinder.hh"
5 #include "G4Track.hh"
6 
7 #include "G4PhysicalConstants.hh"
8 #include "G4SystemOfUnits.hh"
9 
10 #include <iostream>
11 
12 using namespace sim;
13 
15  G4FieldManager* priFM,
16  G4FieldManager* altFM)
17  : G4FieldManager(commonField,0,false),
18  fPrimaryFM(priFM), fAlternativeFM(altFM),
19  fCurrentFM(0),
20  fVerbosity(false)
21 {
22  this->CopyValuesAndChordFinder(priFM);
23  fCurrentFM = priFM ;
24 }
25 
26 void LocalFieldManager::ConfigureForTrack(const G4Track* trk)
27 {
28 
29  int PID = trk->GetDynamicParticle()->GetDefinition()->GetPDGEncoding();
30 
31  if ( abs(PID)!=13 ) // maybe also high energy pions ?... what else ?
32  {
33  if ( fCurrentFM != fAlternativeFM )
34  {
37  if ( fVerbosity) print(trk);
38  }
39  }
40  else
41  {
42  if ( fCurrentFM != fPrimaryFM )
43  {
46  if ( fVerbosity) print(trk);
47  }
48  }
49 
50  return ;
51 
52 }
53 
54 const G4FieldManager* LocalFieldManager::CopyValuesAndChordFinder(G4FieldManager * fm)
55 {
56 
57  SetDeltaIntersection(fm->GetDeltaIntersection());
58  SetDeltaOneStep(fm->GetDeltaOneStep());
59  G4ChordFinder* cf = fm->GetChordFinder();
60  cf->SetDeltaChord(cf->GetDeltaChord());
61  SetChordFinder(cf);
62 
63  return fm;
64 
65 }
66 
67 void LocalFieldManager::print(const G4Track* trk)
68 {
69 
71  {
72  std::cout << " Alternative field manager with";
73  }
74  else
75  {
76  std::cout << " Global field manager with";
77  }
78  std::cout << " DeltaIntersection " << G4FieldManager::GetDeltaIntersection()
79  << ", DeltaOneStep " << G4FieldManager::GetDeltaOneStep()
80  << " and DeltaChord " << G4FieldManager::GetChordFinder()->GetDeltaChord()
81  << " for " << trk->GetDynamicParticle()->GetDefinition()->GetPDGEncoding()
82  << " with " << trk->GetKineticEnergy()/MeV << " MeV in "
83  << trk->GetVolume()->GetName() << std::endl;
84 
85  return ;
86 
87 }
G4FieldManager * fCurrentFM
G4FieldManager * fAlternativeFM
const double MeV
virtual void ConfigureForTrack(const G4Track *trk)
const G4FieldManager * CopyValuesAndChordFinder(G4FieldManager *fm)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: RunManager.h:28
void print(const G4Track *trk)
return(e1-e2)*(e1-e2)+dp *dp
G4FieldManager * fPrimaryFM