CMS 3D CMS Logo

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

#include <RHStopTracer.h>

Inheritance diagram for RHStopTracer:
SimProducer Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfTrack * > SimWatcher

Classes

struct  StopPoint
 

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 RHStopTracer (edm::ParameterSet const &p)
 
void update (const BeginOfEvent *) 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 EndOfTrack *) override
 This routine will be called when the appropriate signal arrives. More...
 
 ~RHStopTracer () override
 
- Public Member Functions inherited from SimProducer
void registerProducts (edm::ProducesCollector producesCollector)
 
 SimProducer ()
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
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 BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * 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 EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 

Private Attributes

int maxPdgId
 
int minPdgId
 
std::vector< StopPointmStopPoints
 
bool mStopRegular
 
double mTraceEnergy
 
std::string mTraceParticleName
 
int otherPdgId
 
std::regex rePartName
 

Additional Inherited Members

- Protected Member Functions inherited from SimProducer
template<class T >
void produces ()
 
template<class T >
void produces (const std::string &instanceName)
 

Detailed Description

Definition at line 18 of file RHStopTracer.h.

Constructor & Destructor Documentation

◆ RHStopTracer()

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

Definition at line 20 of file RHStopTracer.cc.

20  {
21  edm::ParameterSet parameters = p.getParameter<edm::ParameterSet>("RHStopTracer");
22  mStopRegular = parameters.getUntrackedParameter<bool>("stopRegularParticles", false);
23  mTraceEnergy = parameters.getUntrackedParameter<double>("traceEnergy", 1.e20);
24  mTraceParticleName = parameters.getParameter<std::string>("traceParticle");
25  minPdgId = parameters.getUntrackedParameter<int>("minPdgId", 1000000);
26  maxPdgId = parameters.getUntrackedParameter<int>("maxPdgId", 2000000);
27  otherPdgId = parameters.getUntrackedParameter<int>("otherPdgId", 17);
28  produces<std::vector<std::string> >("StoppedParticlesName");
29  produces<std::vector<float> >("StoppedParticlesX");
30  produces<std::vector<float> >("StoppedParticlesY");
31  produces<std::vector<float> >("StoppedParticlesZ");
32  produces<std::vector<float> >("StoppedParticlesTime");
33  produces<std::vector<int> >("StoppedParticlesPdgId");
34  produces<std::vector<float> >("StoppedParticlesMass");
35  produces<std::vector<float> >("StoppedParticlesCharge");
36 
39 
40  edm::LogInfo("SimG4CoreCustomPhysics") << "RHStopTracer::RHStopTracer " << mTraceParticleName
41  << " Eth(GeV)= " << mTraceEnergy;
42 }

References GeV, maxPdgId, minPdgId, mStopRegular, mTraceEnergy, mTraceParticleName, otherPdgId, AlCaHLTBitMon_ParallelJobs::p, rePartName, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~RHStopTracer()

RHStopTracer::~RHStopTracer ( )
override

Definition at line 44 of file RHStopTracer.cc.

44 {}

Member Function Documentation

◆ produce()

void RHStopTracer::produce ( edm::Event fEvent,
const edm::EventSetup  
)
overridevirtual

Implements SimProducer.

Definition at line 105 of file RHStopTracer.cc.

105  {
106  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer::produce->";
107 
108  std::unique_ptr<std::vector<std::string> > names(new std::vector<std::string>);
109  std::unique_ptr<std::vector<float> > xs(new std::vector<float>);
110  std::unique_ptr<std::vector<float> > ys(new std::vector<float>);
111  std::unique_ptr<std::vector<float> > zs(new std::vector<float>);
112  std::unique_ptr<std::vector<float> > ts(new std::vector<float>);
113  std::unique_ptr<std::vector<int> > ids(new std::vector<int>);
114  std::unique_ptr<std::vector<float> > masses(new std::vector<float>);
115  std::unique_ptr<std::vector<float> > charges(new std::vector<float>);
116 
117  std::vector<StopPoint>::const_iterator stopPoint = mStopPoints.begin();
118  for (; stopPoint != mStopPoints.end(); ++stopPoint) {
119  names->push_back(stopPoint->name);
120  xs->push_back(stopPoint->x);
121  ys->push_back(stopPoint->y);
122  zs->push_back(stopPoint->z);
123  ts->push_back(stopPoint->t);
124  ids->push_back(stopPoint->id);
125  masses->push_back(stopPoint->mass);
126  charges->push_back(stopPoint->charge);
127  }
128  fEvent.put(std::move(names), "StoppedParticlesName");
129  fEvent.put(std::move(xs), "StoppedParticlesX");
130  fEvent.put(std::move(ys), "StoppedParticlesY");
131  fEvent.put(std::move(zs), "StoppedParticlesZ");
132  fEvent.put(std::move(ts), "StoppedParticlesTime");
133  fEvent.put(std::move(ids), "StoppedParticlesPdgId");
134  fEvent.put(std::move(masses), "StoppedParticlesMass");
135  fEvent.put(std::move(charges), "StoppedParticlesCharge");
136  mStopPoints.clear();
137 }

References CosmicGenFilterHelix_cfi::charges, hcaldqm::fEvent, LogDebug, particleFlowDisplacedVertex_cfi::masses, eostools::move(), mStopPoints, and names.

◆ update() [1/4]

void RHStopTracer::update ( const BeginOfEvent )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 50 of file RHStopTracer.cc.

50  {
51  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer::update-> begin of the event " << (*fEvent)()->GetEventID();
52 }

References LogDebug.

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

◆ update() [2/4]

void RHStopTracer::update ( const BeginOfRun )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 46 of file RHStopTracer.cc.

46  {
47  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer::update-> begin of the run " << (*fRun)()->GetRunID();
48 }

References LogDebug.

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

◆ update() [3/4]

void RHStopTracer::update ( const BeginOfTrack )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 54 of file RHStopTracer.cc.

54  {
55  const G4Track* track = (*fTrack)();
56  const G4ParticleDefinition* part = track->GetDefinition();
57  const std::string& stringPartName = part->GetParticleName();
58  bool matched = false;
59  int pdgid = std::abs(part->GetPDGEncoding());
60  if ((pdgid > minPdgId && pdgid < maxPdgId) || pdgid == otherPdgId)
61  matched = std::regex_match(stringPartName, rePartName);
62  if (matched || track->GetKineticEnergy() > mTraceEnergy) {
63  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer::update-> new track: ID/Name/pdgId/mass/charge/Parent: "
64  << track->GetTrackID() << '/' << part->GetParticleName() << '/'
65  << part->GetPDGEncoding() << '/' << part->GetPDGMass() / GeV << " GeV/"
66  << part->GetPDGCharge() << '/' << track->GetParentID()
67  << " Position: " << track->GetPosition() << ' '
68  << " R/phi: " << track->GetPosition().perp() << '/' << track->GetPosition().phi()
69  << " 4vec " << track->GetMomentum();
70  } else if (mStopRegular) { // kill regular particles
71  const_cast<G4Track*>(track)->SetTrackStatus(fStopAndKill);
72  }
73 }

References funct::abs(), GeV, LogDebug, muonTagProbeFilters_cff::matched, maxPdgId, minPdgId, mStopRegular, mTraceEnergy, otherPdgId, EgammaValidation_cff::pdgid, rePartName, AlCaHLTBitMon_QueryRunRegistry::string, and HLT_2018_cff::track.

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

◆ update() [4/4]

void RHStopTracer::update ( const EndOfTrack )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 75 of file RHStopTracer.cc.

75  {
76  const G4Track* track = (*fTrack)();
77  const G4ParticleDefinition* part = track->GetDefinition();
78  const std::string& stringPartName = part->GetParticleName();
79  bool matched = false;
80  int pdgid = std::abs(part->GetPDGEncoding());
81  if ((pdgid > minPdgId && pdgid < maxPdgId) || pdgid == otherPdgId)
82  matched = std::regex_match(stringPartName, rePartName);
83  if (matched || track->GetKineticEnergy() > mTraceEnergy) {
84  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer::update-> stop track: ID/Name/pdgId/mass/charge/Parent: "
85  << track->GetTrackID() << '/' << part->GetParticleName() << '/'
86  << part->GetPDGEncoding() << '/' << part->GetPDGMass() / GeV << " GeV/"
87  << part->GetPDGCharge() << '/' << track->GetParentID()
88  << " Position: " << track->GetPosition() << ' '
89  << " R/phi: " << track->GetPosition().perp() << '/' << track->GetPosition().phi()
90  << " 4vec " << track->GetMomentum();
91  if (track->GetMomentum().mag() < 0.001) {
92  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer:: track has stopped, so making StopPoint";
93  mStopPoints.push_back(StopPoint(track->GetDefinition()->GetParticleName(),
94  track->GetPosition().x(),
95  track->GetPosition().y(),
96  track->GetPosition().z(),
97  track->GetGlobalTime(),
98  track->GetDefinition()->GetPDGEncoding(),
99  track->GetDefinition()->GetPDGMass() / GeV,
100  track->GetDefinition()->GetPDGCharge()));
101  }
102  }
103 }

References funct::abs(), GeV, LogDebug, muonTagProbeFilters_cff::matched, maxPdgId, minPdgId, mStopPoints, mTraceEnergy, otherPdgId, EgammaValidation_cff::pdgid, rePartName, AlCaHLTBitMon_QueryRunRegistry::string, and HLT_2018_cff::track.

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

Member Data Documentation

◆ maxPdgId

int RHStopTracer::maxPdgId
private

Definition at line 49 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

◆ minPdgId

int RHStopTracer::minPdgId
private

Definition at line 48 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

◆ mStopPoints

std::vector<StopPoint> RHStopTracer::mStopPoints
private

Definition at line 53 of file RHStopTracer.h.

Referenced by produce(), and update().

◆ mStopRegular

bool RHStopTracer::mStopRegular
private

Definition at line 46 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

◆ mTraceEnergy

double RHStopTracer::mTraceEnergy
private

Definition at line 47 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

◆ mTraceParticleName

std::string RHStopTracer::mTraceParticleName
private

Definition at line 51 of file RHStopTracer.h.

Referenced by RHStopTracer().

◆ otherPdgId

int RHStopTracer::otherPdgId
private

Definition at line 50 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

◆ rePartName

std::regex RHStopTracer::rePartName
private

Definition at line 52 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
CosmicGenFilterHelix_cfi.charges
charges
only generated particles of these IDs are considered
Definition: CosmicGenFilterHelix_cfi.py:6
RHStopTracer::mTraceParticleName
std::string mTraceParticleName
Definition: RHStopTracer.h:51
RHStopTracer::minPdgId
int minPdgId
Definition: RHStopTracer.h:48
RHStopTracer::rePartName
std::regex rePartName
Definition: RHStopTracer.h:52
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
RHStopTracer::mStopRegular
bool mStopRegular
Definition: RHStopTracer.h:46
edm::LogInfo
Definition: MessageLogger.h:254
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
RHStopTracer::maxPdgId
int maxPdgId
Definition: RHStopTracer.h:49
RHStopTracer::mTraceEnergy
double mTraceEnergy
Definition: RHStopTracer.h:47
part
part
Definition: HCALResponse.h:20
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
RHStopTracer::mStopPoints
std::vector< StopPoint > mStopPoints
Definition: RHStopTracer.h:53
RHStopTracer::otherPdgId
int otherPdgId
Definition: RHStopTracer.h:50
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
GeV
const double GeV
Definition: MathUtil.h:16
particleFlowDisplacedVertex_cfi.masses
masses
Definition: particleFlowDisplacedVertex_cfi.py:80
hcaldqm::fEvent
Definition: DQTask.h:32
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:30