CMS 3D CMS Logo

LocalFieldManager.cc
Go to the documentation of this file.
1 
4 
5 #include "G4ChordFinder.hh"
6 #include "G4Track.hh"
7 
8 #include "CLHEP/Units/SystemOfUnits.h"
9 
10 #include <iostream>
11 
12 using namespace sim;
13 
14 LocalFieldManager::LocalFieldManager(G4Field *commonField, G4FieldManager *priFM, G4FieldManager *altFM)
15  : G4FieldManager(commonField, nullptr, false),
16  fPrimaryFM(priFM),
17  fAlternativeFM(altFM),
18  fCurrentFM(nullptr),
19  fVerbosity(false) {
20  this->CopyValuesAndChordFinder(priFM);
21  fCurrentFM = priFM;
22 }
23 
24 void LocalFieldManager::ConfigureForTrack(const G4Track *trk) {
25  int PID = trk->GetDynamicParticle()->GetDefinition()->GetPDGEncoding();
26 
27  if (std::abs(PID) != 13) // maybe also high energy pions ?... what else ?
28  {
29  if (fCurrentFM != fAlternativeFM) {
32  if (fVerbosity)
33  print(trk);
34  }
35  } else {
36  if (fCurrentFM != fPrimaryFM) {
39  if (fVerbosity)
40  print(trk);
41  }
42  }
43 }
44 
45 const G4FieldManager *LocalFieldManager::CopyValuesAndChordFinder(G4FieldManager *fm) {
46  SetDeltaIntersection(fm->GetDeltaIntersection());
47  SetDeltaOneStep(fm->GetDeltaOneStep());
48  G4ChordFinder *cf = fm->GetChordFinder();
49  cf->SetDeltaChord(cf->GetDeltaChord());
50  SetChordFinder(cf);
51 
52  return fm;
53 }
54 
55 void LocalFieldManager::print(const G4Track *trk) {
56  std::string ss = (fCurrentFM == fAlternativeFM) ? "Alternative field manager with" : "Global field manager with";
57 
58  edm::LogVerbatim("SimG4CoreMagneticField")
59  << ss << " DeltaIntersection= " << G4FieldManager::GetDeltaIntersection()
60  << ", DeltaOneStep= " << G4FieldManager::GetDeltaOneStep()
61  << ", DeltaChord= " << G4FieldManager::GetChordFinder()->GetDeltaChord() << " for "
62  << trk->GetDynamicParticle()->GetDefinition()->GetPDGEncoding() << " with "
63  << trk->GetKineticEnergy() / CLHEP::GeV << " GeV in " << trk->GetVolume()->GetName();
64 }
sim::LocalFieldManager::fAlternativeFM
G4FieldManager * fAlternativeFM
Definition: LocalFieldManager.h:27
MessageLogger.h
funct::false
false
Definition: Factorize.h:34
sim::LocalFieldManager::CopyValuesAndChordFinder
const G4FieldManager * CopyValuesAndChordFinder(G4FieldManager *fm)
Definition: LocalFieldManager.cc:45
sim::LocalFieldManager::fVerbosity
bool fVerbosity
Definition: LocalFieldManager.h:29
sim::LocalFieldManager::fPrimaryFM
G4FieldManager * fPrimaryFM
Definition: LocalFieldManager.h:26
sim::LocalFieldManager::print
void print(const G4Track *trk)
Definition: LocalFieldManager.cc:55
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
PID
PID
Definition: data.h:16
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
sim
Definition: GeometryProducer.h:20
GeV
const double GeV
Definition: MathUtil.h:16
sim::LocalFieldManager::fCurrentFM
G4FieldManager * fCurrentFM
Definition: LocalFieldManager.h:28
sim::LocalFieldManager::ConfigureForTrack
void ConfigureForTrack(const G4Track *trk) override
Definition: LocalFieldManager.cc:24
edm::LogVerbatim
Definition: MessageLogger.h:297
sim::LocalFieldManager::LocalFieldManager
LocalFieldManager()
Definition: LocalFieldManager.h:11
LocalFieldManager.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22