CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
MonopoleSteppingAction Class Reference

#include <MonopoleSteppingAction.h>

Inheritance diagram for MonopoleSteppingAction:
SimWatcher Observer< const BeginOfJob * > Observer< const BeginOfRun * > Observer< const BeginOfTrack * > Observer< const G4Step * >

Public Member Functions

 MonopoleSteppingAction (edm::ParameterSet const &p)
 
void update (const BeginOfJob *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *) override
 This routine will be called when the appropriate signal arrives. More...
 
 ~MonopoleSteppingAction () override
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
virtual ~SimWatcher ()
 
- Public Member Functions inherited from Observer< const BeginOfJob * >
 Observer ()
 
void slotForUpdate (const BeginOfJob * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Attributes

bool actOnTrack
 
double bZ
 
double cInMByS
 
double cMevToJ
 
double cMeVToKgMByS
 
double dirxStart
 
double diryStart
 
double dirzStart
 
double eStart
 
double magCharge
 
bool mode
 
std::vector< int > pdgCode
 
double pxStart
 
double pyStart
 
double pzStart
 

Additional Inherited Members

Detailed Description

Definition at line 15 of file MonopoleSteppingAction.h.

Constructor & Destructor Documentation

◆ MonopoleSteppingAction()

MonopoleSteppingAction::MonopoleSteppingAction ( edm::ParameterSet const &  p)

Definition at line 23 of file MonopoleSteppingAction.cc.

23  : actOnTrack(false), bZ(0) {
24  mode = p.getUntrackedParameter<bool>("ChangeFromFirstStep", true);
25  edm::LogInfo("SimG4CoreWatcher") << "MonopoleSeppingAction set mode for"
26  << " start at first step to " << mode;
27 }

References mode, and AlCaHLTBitMon_ParallelJobs::p.

◆ ~MonopoleSteppingAction()

MonopoleSteppingAction::~MonopoleSteppingAction ( )
override

Definition at line 29 of file MonopoleSteppingAction.cc.

29 {}

Member Function Documentation

◆ update() [1/4]

void MonopoleSteppingAction::update ( const BeginOfJob )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfJob * >.

Definition at line 31 of file MonopoleSteppingAction.cc.

31  {
32  const edm::EventSetup *iSetup = (*job)();
34  iSetup->get<IdealMagneticFieldRecord>().get(bFieldH);
35  const MagneticField *bField = bFieldH.product();
36  const GlobalPoint p(0, 0, 0);
37  bZ = (bField->inTesla(p)).z();
38  edm::LogInfo("SimG4CoreWatcher") << "Magnetic Field (X): " << (bField->inTesla(p)).x()
39  << " Y: " << (bField->inTesla(p)).y() << " Z: " << bZ;
40 }

References Calorimetry_cff::bField, bZ, edm::EventSetup::get(), get, AlCaHLTBitMon_ParallelJobs::p, x, y, and z.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [2/4]

void MonopoleSteppingAction::update ( const BeginOfRun )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 42 of file MonopoleSteppingAction.cc.

42  {
43  G4ParticleTable *partTable = G4ParticleTable::GetParticleTable();
44  magCharge = CLHEP::e_SI / CLHEP::fine_structure_const * 0.5;
45  for (int ii = 0; ii < partTable->size(); ii++) {
46  G4ParticleDefinition *particle = partTable->GetParticle(ii);
47  std::string particleName = (particle->GetParticleName()).substr(0, 8);
48  if (strcmp(particleName.c_str(), "Monopole") == 0) {
49  magCharge = CLHEP::e_SI * ((Monopole *)(particle))->MagneticCharge();
50  pdgCode.push_back(particle->GetPDGEncoding());
51  }
52  }
53  edm::LogInfo("SimG4CoreWatcher") << "MonopoleSeppingAction Finds " << pdgCode.size() << " candidates";
54  for (unsigned int ii = 0; ii < pdgCode.size(); ++ii) {
55  edm::LogInfo("SimG4CoreWatcher") << "PDG Code[" << ii << "] = " << pdgCode[ii];
56  }
57  cMevToJ = CLHEP::e_SI / CLHEP::eV;
58  cMeVToKgMByS = CLHEP::e_SI * CLHEP::meter / (CLHEP::eV * CLHEP::c_light * CLHEP::second);
59  cInMByS = CLHEP::c_light * CLHEP::second / CLHEP::meter;
60  edm::LogInfo("SimG4CoreWatcher") << "MonopoleSeppingAction Constants:"
61  << " MevToJoules = " << cMevToJ << ", MevToKgm/s = " << cMeVToKgMByS
62  << ", c in m/s = " << cInMByS << ", mag. charge = " << magCharge;
63 }

References cInMByS, cMevToJ, cMeVToKgMByS, e_SI, cuy::ii, magCharge, HiggsValidation_cfi::particleName, pdgCode, edm::second(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [3/4]

void MonopoleSteppingAction::update ( const BeginOfTrack )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 65 of file MonopoleSteppingAction.cc.

65  {
66  actOnTrack = false;
67  if (!pdgCode.empty()) {
68  const G4Track *aTrack = (*trk)();
69  int code = aTrack->GetDefinition()->GetPDGEncoding();
70  if (std::count(pdgCode.begin(), pdgCode.end(), code) > 0) {
71  actOnTrack = true;
72  eStart = aTrack->GetTotalEnergy();
73  pxStart = aTrack->GetMomentum().x();
74  pyStart = aTrack->GetMomentum().y();
75  pzStart = aTrack->GetMomentum().z();
76  dirxStart = aTrack->GetMomentumDirection().x();
77  diryStart = aTrack->GetMomentumDirection().y();
78  dirzStart = aTrack->GetMomentumDirection().z();
79  LogDebug("SimG4CoreWatcher") << "MonopoleSeppingAction Track " << code << " Flag " << actOnTrack
80  << " (px,py,pz,E) = (" << pxStart / GeV << ", " << pyStart / GeV << ", "
81  << pzStart / GeV << ", " << eStart / GeV << ")";
82  }
83  }
84 }

References actOnTrack, submitPVResolutionJobs::count, dirxStart, diryStart, dirzStart, eStart, GeV, LogDebug, pdgCode, pxStart, pyStart, and pzStart.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

◆ update() [4/4]

void MonopoleSteppingAction::update ( const G4Step *  )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 86 of file MonopoleSteppingAction.cc.

86  {
87  if (actOnTrack) {
88  double eT, pT, pZ, tStep;
89  G4Track *aTrack = aStep->GetTrack();
90  G4ThreeVector initialPosition(0, 0, 0);
91  if (mode) {
92  tStep = aTrack->GetGlobalTime();
95  pZ = pzStart;
96  } else {
97  const G4ThreeVector &dirStep = aTrack->GetMomentumDirection();
98  double lStep = aTrack->GetStepLength();
99  double xStep = aTrack->GetPosition().x() - lStep * dirStep.x();
100  double yStep = aTrack->GetPosition().y() - lStep * dirStep.y();
101  double zStep = aTrack->GetPosition().z() - lStep * dirStep.z();
102  double vStep = aTrack->GetVelocity();
103  initialPosition = G4ThreeVector(xStep, yStep, zStep);
104  tStep = (vStep > 0. ? (lStep / vStep) : 0.);
105  double eStep = aTrack->GetTotalEnergy();
106  eT = eStep * dirStep.perp();
107  pT = aTrack->GetMomentum().perp();
108  pZ = aTrack->GetMomentum().z();
109  }
110  LogDebug("SimG4CoreWatcher") << "MonopoleSeppingAction: tStep " << tStep << " eT " << eT << " pT " << pT << " pZ "
111  << pZ;
112  double eT1 = eT * cMevToJ;
113  double pT1 = pT * cMeVToKgMByS;
114  double pZ1 = pZ * cMeVToKgMByS;
115  double ts1 = tStep / CLHEP::second;
116  double eT2 = (eT1 > 0. ? (1. / eT1) : 0.);
117  double fac0 = magCharge * bZ * cInMByS;
118  double fac2 = pZ1 * cInMByS * eT2;
119  double fac1 = fac0 * cInMByS * ts1 * eT2 + fac2;
120  double fact1 = (eT1 / fac0) * (std::sqrt(1 + fac1 * fac1) - std::sqrt(1 + fac2 * fac2));
121  double fact2 = (pT1 / (magCharge * bZ) * (asinh(fac1) - asinh(fac2)));
122  LogDebug("SimG4CoreWatcher") << "MonopoleSeppingAction: Factor eT = " << eT << " " << eT1 << " " << eT2
123  << ", pT = " << pT << " " << pT1 << ", pZ = " << pZ << " " << pZ1
124  << ", time = " << tStep << " " << ts1 << ", Factors " << fac0 << " " << fac1 << " "
125  << fac2 << ", Final ones " << fact1 << " " << fact2;
126  G4ThreeVector ez(0, 0, 1), et(std::sqrt(0.5), std::sqrt(0.5), 0);
127  G4ThreeVector displacement = (fact1 * ez + fact2 * et) * CLHEP::m;
128 
129  LogDebug("SimG4CoreWatcher") << "MonopoleSeppingAction: Initial " << initialPosition << " Displacement "
130  << displacement << " Final " << (initialPosition + displacement);
131  aTrack->SetPosition(initialPosition + displacement);
132  }
133 }

References actOnTrack, bZ, cInMByS, cMevToJ, cMeVToKgMByS, dirxStart, diryStart, eStart, EgHLTOffHistBins_cfi::et, isotrackTrainRegressor::fac0(), isotrackTrainRegressor::fac1(), isotrackTrainRegressor::fac2(), LogDebug, visualization-live-secondInstance_cfg::m, magCharge, mode, PVValHelper::pT, HLT_FULL_cff::pT1, pxStart, pyStart, pzStart, edm::second(), mathSSE::sqrt(), beampixel_dqm_sourceclient-live_cfg::xStep, beampixel_dqm_sourceclient-live_cfg::yStep, and beampixel_dqm_sourceclient-live_cfg::zStep.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

Member Data Documentation

◆ actOnTrack

bool MonopoleSteppingAction::actOnTrack
private

Definition at line 29 of file MonopoleSteppingAction.h.

Referenced by update().

◆ bZ

double MonopoleSteppingAction::bZ
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ cInMByS

double MonopoleSteppingAction::cInMByS
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ cMevToJ

double MonopoleSteppingAction::cMevToJ
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ cMeVToKgMByS

double MonopoleSteppingAction::cMeVToKgMByS
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ dirxStart

double MonopoleSteppingAction::dirxStart
private

Definition at line 32 of file MonopoleSteppingAction.h.

Referenced by update().

◆ diryStart

double MonopoleSteppingAction::diryStart
private

Definition at line 32 of file MonopoleSteppingAction.h.

Referenced by update().

◆ dirzStart

double MonopoleSteppingAction::dirzStart
private

Definition at line 32 of file MonopoleSteppingAction.h.

Referenced by update().

◆ eStart

double MonopoleSteppingAction::eStart
private

Definition at line 31 of file MonopoleSteppingAction.h.

Referenced by update().

◆ magCharge

double MonopoleSteppingAction::magCharge
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ mode

bool MonopoleSteppingAction::mode
private

Definition at line 29 of file MonopoleSteppingAction.h.

Referenced by MonopoleSteppingAction(), and update().

◆ pdgCode

std::vector<int> MonopoleSteppingAction::pdgCode
private

Definition at line 30 of file MonopoleSteppingAction.h.

Referenced by update().

◆ pxStart

double MonopoleSteppingAction::pxStart
private

Definition at line 31 of file MonopoleSteppingAction.h.

Referenced by update().

◆ pyStart

double MonopoleSteppingAction::pyStart
private

Definition at line 31 of file MonopoleSteppingAction.h.

Referenced by update().

◆ pzStart

double MonopoleSteppingAction::pzStart
private

Definition at line 31 of file MonopoleSteppingAction.h.

Referenced by update().

MonopoleSteppingAction::dirzStart
double dirzStart
Definition: MonopoleSteppingAction.h:32
DDAxes::y
e_SI
#define e_SI
Definition: HitDigitizerFP420.cc:24
MonopoleSteppingAction::pzStart
double pzStart
Definition: MonopoleSteppingAction.h:31
MonopoleSteppingAction::cMevToJ
double cMevToJ
Definition: MonopoleSteppingAction.h:33
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MonopoleSteppingAction::cInMByS
double cInMByS
Definition: MonopoleSteppingAction.h:33
isotrackTrainRegressor.fac2
def fac2(jeta)
Definition: isotrackTrainRegressor.py:113
MonopoleSteppingAction::mode
bool mode
Definition: MonopoleSteppingAction.h:29
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
beampixel_dqm_sourceclient-live_cfg.xStep
xStep
Definition: beampixel_dqm_sourceclient-live_cfg.py:145
beampixel_dqm_sourceclient-live_cfg.yStep
yStep
Definition: beampixel_dqm_sourceclient-live_cfg.py:147
MonopoleSteppingAction::diryStart
double diryStart
Definition: MonopoleSteppingAction.h:32
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
MonopoleSteppingAction::cMeVToKgMByS
double cMeVToKgMByS
Definition: MonopoleSteppingAction.h:33
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
MonopoleSteppingAction::pxStart
double pxStart
Definition: MonopoleSteppingAction.h:31
PVValHelper::pT
Definition: PVValidationHelpers.h:70
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
MonopoleSteppingAction::eStart
double eStart
Definition: MonopoleSteppingAction.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
edm::ESHandle< MagneticField >
HiggsValidation_cfi.particleName
particleName
Definition: HiggsValidation_cfi.py:7
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
MonopoleSteppingAction::actOnTrack
bool actOnTrack
Definition: MonopoleSteppingAction.h:29
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
MonopoleSteppingAction::dirxStart
double dirxStart
Definition: MonopoleSteppingAction.h:32
MonopoleSteppingAction::magCharge
double magCharge
Definition: MonopoleSteppingAction.h:33
Monopole
Definition: Monopole.h:12
MonopoleSteppingAction::pdgCode
std::vector< int > pdgCode
Definition: MonopoleSteppingAction.h:30
GeV
const double GeV
Definition: MathUtil.h:16
isotrackTrainRegressor.fac0
def fac0(jeta)
marinas correction form
Definition: isotrackTrainRegressor.py:101
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
MonopoleSteppingAction::pyStart
double pyStart
Definition: MonopoleSteppingAction.h:31
Calorimetry_cff.bField
bField
Definition: Calorimetry_cff.py:292
MonopoleSteppingAction::bZ
double bZ
Definition: MonopoleSteppingAction.h:33
HLT_FULL_cff.pT1
pT1
Definition: HLT_FULL_cff.py:9596
MagneticField
Definition: MagneticField.h:19
beampixel_dqm_sourceclient-live_cfg.zStep
zStep
Definition: beampixel_dqm_sourceclient-live_cfg.py:149
cuy.ii
ii
Definition: cuy.py:590
isotrackTrainRegressor.fac1
def fac1(jeta)
Definition: isotrackTrainRegressor.py:107