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 BeginOfRun *> Observer< const BeginOfTrack *> Observer< const G4Step *>

Public Member Functions

void beginRun (edm::EventSetup const &) override
 
 MonopoleSteppingAction (edm::ParameterSet const &p)
 
void registerConsumes (edm::ConsumesCollector) override
 
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
bool isMT () const
 
const SimWatcheroperator= (const SimWatcher &)=delete
 
 SimWatcher ()
 
 SimWatcher (const SimWatcher &)=delete
 
virtual ~SimWatcher ()
 
- 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
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordtok_bFieldH_
 

Additional Inherited Members

- Protected Member Functions inherited from SimWatcher
void setMT (bool val)
 

Detailed Description

Definition at line 16 of file MonopoleSteppingAction.h.

Constructor & Destructor Documentation

◆ MonopoleSteppingAction()

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

Definition at line 19 of file MonopoleSteppingAction.cc.

References mode, and AlCaHLTBitMon_ParallelJobs::p.

19  : actOnTrack(false), bZ(0) {
20  mode = p.getUntrackedParameter<bool>("ChangeFromFirstStep", true);
21  edm::LogVerbatim("SimG4CoreWatcher") << "MonopoleSeppingAction set mode for"
22  << " start at first step to " << mode;
23 }
Log< level::Info, true > LogVerbatim

◆ ~MonopoleSteppingAction()

MonopoleSteppingAction::~MonopoleSteppingAction ( )
override

Definition at line 25 of file MonopoleSteppingAction.cc.

25 {}

Member Function Documentation

◆ beginRun()

void MonopoleSteppingAction::beginRun ( edm::EventSetup const &  es)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 32 of file MonopoleSteppingAction.cc.

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

32  {
33  const MagneticField *bField = &es.getData(tok_bFieldH_);
34  const GlobalPoint p(0, 0, 0);
35  bZ = (bField->inTesla(p)).z();
36  edm::LogVerbatim("SimG4CoreWatcher") << "Magnetic Field (X): " << (bField->inTesla(p)).x()
37  << " Y: " << (bField->inTesla(p)).y() << " Z: " << bZ;
38 }
Log< level::Info, true > LogVerbatim
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tok_bFieldH_

◆ registerConsumes()

void MonopoleSteppingAction::registerConsumes ( edm::ConsumesCollector  cc)
overridevirtual

Reimplemented from SimWatcher.

Definition at line 27 of file MonopoleSteppingAction.cc.

References edm::BeginRun, gpuPixelDoublets::cc, SiStripFineDelayHit_cfi::MagneticField, and tok_bFieldH_.

27  {
29  edm::LogVerbatim("SimG4CoreWatcher") << "MonopoleSteppingAction::Initialize ESGetToken for MagneticField";
30 }
Log< level::Info, true > LogVerbatim
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tok_bFieldH_
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49

◆ update() [1/3]

void MonopoleSteppingAction::update ( const BeginOfRun )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun *>.

Definition at line 40 of file MonopoleSteppingAction.cc.

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().

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

◆ update() [2/3]

void MonopoleSteppingAction::update ( const BeginOfTrack )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack *>.

Definition at line 63 of file MonopoleSteppingAction.cc.

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

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

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

◆ update() [3/3]

void MonopoleSteppingAction::update ( const G4Step *  )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step *>.

Definition at line 85 of file MonopoleSteppingAction.cc.

References actOnTrack, bZ, cInMByS, cMevToJ, cMeVToKgMByS, dirxStart, diryStart, eStart, l1tnanotables_cff::et, isotrackTrainRegressor::fac0(), isotrackTrainRegressor::fac1(), isotrackTrainRegressor::fac2(), LogDebug, visualization-live-secondInstance_cfg::m, magCharge, mode, pv::pT, HLT_2024v13_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().

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

Member Data Documentation

◆ actOnTrack

bool MonopoleSteppingAction::actOnTrack
private

Definition at line 31 of file MonopoleSteppingAction.h.

Referenced by update().

◆ bZ

double MonopoleSteppingAction::bZ
private

Definition at line 35 of file MonopoleSteppingAction.h.

Referenced by beginRun(), and update().

◆ cInMByS

double MonopoleSteppingAction::cInMByS
private

Definition at line 35 of file MonopoleSteppingAction.h.

Referenced by update().

◆ cMevToJ

double MonopoleSteppingAction::cMevToJ
private

Definition at line 35 of file MonopoleSteppingAction.h.

Referenced by update().

◆ cMeVToKgMByS

double MonopoleSteppingAction::cMeVToKgMByS
private

Definition at line 35 of file MonopoleSteppingAction.h.

Referenced by update().

◆ dirxStart

double MonopoleSteppingAction::dirxStart
private

Definition at line 34 of file MonopoleSteppingAction.h.

Referenced by update().

◆ diryStart

double MonopoleSteppingAction::diryStart
private

Definition at line 34 of file MonopoleSteppingAction.h.

Referenced by update().

◆ dirzStart

double MonopoleSteppingAction::dirzStart
private

Definition at line 34 of file MonopoleSteppingAction.h.

Referenced by update().

◆ eStart

double MonopoleSteppingAction::eStart
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ magCharge

double MonopoleSteppingAction::magCharge
private

Definition at line 35 of file MonopoleSteppingAction.h.

Referenced by update().

◆ mode

bool MonopoleSteppingAction::mode
private

Definition at line 31 of file MonopoleSteppingAction.h.

Referenced by MonopoleSteppingAction(), and update().

◆ pdgCode

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

Definition at line 32 of file MonopoleSteppingAction.h.

Referenced by update().

◆ pxStart

double MonopoleSteppingAction::pxStart
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ pyStart

double MonopoleSteppingAction::pyStart
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ pzStart

double MonopoleSteppingAction::pzStart
private

Definition at line 33 of file MonopoleSteppingAction.h.

Referenced by update().

◆ tok_bFieldH_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> MonopoleSteppingAction::tok_bFieldH_
private

Definition at line 30 of file MonopoleSteppingAction.h.

Referenced by beginRun(), and registerConsumes().