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 BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *) 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::ProducerBase &iProd)
 
 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 ( edm::ParameterSet const &  p)

Definition at line 20 of file RHStopTracer.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), GeV, maxPdgId, minPdgId, mStopRegular, mTraceEnergy, mTraceParticleName, otherPdgId, metProducer_cfi::parameters, rePartName, and AlCaHLTBitMon_QueryRunRegistry::string.

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 
37  mTraceEnergy *= CLHEP::GeV;
39 
40  edm::LogInfo("SimG4CoreCustomPhysics")
41  << "RHStopTracer::RHStopTracer " << mTraceParticleName
42  << " Eth(GeV)= " << mTraceEnergy;
43 
44 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const double GeV
Definition: MathUtil.h:16
double mTraceEnergy
Definition: RHStopTracer.h:47
std::string mTraceParticleName
Definition: RHStopTracer.h:51
bool mStopRegular
Definition: RHStopTracer.h:46
std::regex rePartName
Definition: RHStopTracer.h:52
RHStopTracer::~RHStopTracer ( )
override

Definition at line 46 of file RHStopTracer.cc.

46  {
47 }

Member Function Documentation

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

Implements SimProducer.

Definition at line 115 of file RHStopTracer.cc.

References LogDebug, particleFlowDisplacedVertex_cfi::masses, eostools::move(), mStopPoints, cscdqm::h::names, and edm::Event::put().

115  {
116  LogDebug("SimG4CoreCustomPhysics") << "RHStopTracer::produce->";
117 
118  std::unique_ptr<std::vector<std::string> > names(new std::vector<std::string>);
119  std::unique_ptr<std::vector<float> > xs(new std::vector<float>);
120  std::unique_ptr<std::vector<float> > ys(new std::vector<float>);
121  std::unique_ptr<std::vector<float> > zs(new std::vector<float>);
122  std::unique_ptr<std::vector<float> > ts(new std::vector<float>);
123  std::unique_ptr<std::vector<int> > ids(new std::vector<int>);
124  std::unique_ptr<std::vector<float> > masses(new std::vector<float>);
125  std::unique_ptr<std::vector<float> > charges(new std::vector<float>);
126 
127  std::vector <StopPoint>::const_iterator stopPoint = mStopPoints.begin ();
128  for (; stopPoint != mStopPoints.end(); ++stopPoint) {
129  names->push_back (stopPoint->name);
130  xs->push_back (stopPoint->x);
131  ys->push_back (stopPoint->y);
132  zs->push_back (stopPoint->z);
133  ts->push_back (stopPoint->t);
134  ids->push_back (stopPoint->id);
135  masses->push_back (stopPoint->mass);
136  charges->push_back (stopPoint->charge);
137  }
138  fEvent.put(std::move(names), "StoppedParticlesName");
139  fEvent.put(std::move(xs), "StoppedParticlesX");
140  fEvent.put(std::move(ys), "StoppedParticlesY");
141  fEvent.put(std::move(zs), "StoppedParticlesZ");
142  fEvent.put(std::move(ts), "StoppedParticlesTime");
143  fEvent.put(std::move(ids), "StoppedParticlesPdgId");
144  fEvent.put(std::move(masses), "StoppedParticlesMass");
145  fEvent.put(std::move(charges), "StoppedParticlesCharge");
146  mStopPoints.clear ();
147 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
static const HistoName names[]
std::vector< StopPoint > mStopPoints
Definition: RHStopTracer.h:53
def move(src, dest)
Definition: eostools.py:510
void RHStopTracer::update ( const BeginOfRun )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfRun * >.

Definition at line 49 of file RHStopTracer.cc.

References LogDebug.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

49  {
50  LogDebug("SimG4CoreCustomPhysics")
51  << "RHStopTracer::update-> begin of the run " << (*fRun)()->GetRunID();
52 }
#define LogDebug(id)
void RHStopTracer::update ( const BeginOfEvent )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 54 of file RHStopTracer.cc.

References LogDebug.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

54  {
55  LogDebug("SimG4CoreCustomPhysics")
56  << "RHStopTracer::update-> begin of the event " << (*fEvent)()->GetEventID();
57 }
#define LogDebug(id)
void RHStopTracer::update ( const BeginOfTrack )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 59 of file RHStopTracer.cc.

References funct::abs(), GeV, LogDebug, electronMatch_cfi::matched, maxPdgId, minPdgId, mStopRegular, mTraceEnergy, otherPdgId, BPhysicsValidation_cfi::pdgid, rePartName, AlCaHLTBitMon_QueryRunRegistry::string, and HiIsolationCommonParameters_cff::track.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

59  {
60  const G4Track* track = (*fTrack)();
61  const G4ParticleDefinition* part = track->GetDefinition();
62  const std::string& stringPartName = part->GetParticleName();
63  bool matched = false;
64  int pdgid = std::abs(part->GetPDGEncoding());
65  if( (pdgid>minPdgId && pdgid<maxPdgId) || pdgid==otherPdgId )
66  matched = std::regex_match(stringPartName,rePartName);
67  if( matched || track->GetKineticEnergy() > mTraceEnergy) {
68  LogDebug("SimG4CoreCustomPhysics")
69  << "RHStopTracer::update-> new track: ID/Name/pdgId/mass/charge/Parent: "
70  << track->GetTrackID() << '/' << part->GetParticleName() << '/'
71  << part->GetPDGEncoding() << '/'
72  << part->GetPDGMass()/GeV <<" GeV/" << part->GetPDGCharge() << '/'
73  << track->GetParentID()
74  << " Position: " << track->GetPosition() << ' '
75  << " R/phi: " << track->GetPosition().perp() << '/' << track->GetPosition().phi()
76  << " 4vec " << track->GetMomentum();
77  } else if (mStopRegular) { // kill regular particles
78  const_cast<G4Track*>(track)->SetTrackStatus(fStopAndKill);
79  }
80 }
#define LogDebug(id)
const double GeV
Definition: MathUtil.h:16
double mTraceEnergy
Definition: RHStopTracer.h:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool mStopRegular
Definition: RHStopTracer.h:46
part
Definition: HCALResponse.h:20
std::regex rePartName
Definition: RHStopTracer.h:52
void RHStopTracer::update ( const EndOfTrack )
overridevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfTrack * >.

Definition at line 82 of file RHStopTracer.cc.

References funct::abs(), GeV, LogDebug, electronMatch_cfi::matched, maxPdgId, minPdgId, mStopPoints, mTraceEnergy, otherPdgId, BPhysicsValidation_cfi::pdgid, rePartName, AlCaHLTBitMon_QueryRunRegistry::string, and HiIsolationCommonParameters_cff::track.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

82  {
83  const G4Track* track = (*fTrack)();
84  const G4ParticleDefinition* part = track->GetDefinition();
85  const std::string& stringPartName = part->GetParticleName();
86  bool matched = false;
87  int pdgid = std::abs(part->GetPDGEncoding());
88  if( (pdgid>minPdgId && pdgid<maxPdgId) || pdgid==otherPdgId )
89  matched = std::regex_match(stringPartName,rePartName);
90  if( matched || track->GetKineticEnergy() > mTraceEnergy) {
91  LogDebug("SimG4CoreCustomPhysics")
92  << "RHStopTracer::update-> stop track: ID/Name/pdgId/mass/charge/Parent: "
93  << track->GetTrackID() << '/' << part->GetParticleName() << '/'
94  << part->GetPDGEncoding() << '/'
95  << part->GetPDGMass()/GeV <<" GeV/" << part->GetPDGCharge() << '/'
96  << track->GetParentID()
97  << " Position: " << track->GetPosition() << ' '
98  << " R/phi: " << track->GetPosition().perp() << '/' << track->GetPosition().phi()
99  << " 4vec " << track->GetMomentum();
100  if (track->GetMomentum().mag () < 0.001) {
101  LogDebug("SimG4CoreCustomPhysics") <<
102  "RHStopTracer:: track has stopped, so making StopPoint";
103  mStopPoints.push_back (StopPoint (track->GetDefinition()->GetParticleName(),
104  track->GetPosition().x(),
105  track->GetPosition().y(),
106  track->GetPosition().z(),
107  track->GetGlobalTime(),
108  track->GetDefinition()->GetPDGEncoding(),
109  track->GetDefinition()->GetPDGMass()/GeV,
110  track->GetDefinition()->GetPDGCharge() ));
111  }
112  }
113 }
#define LogDebug(id)
const double GeV
Definition: MathUtil.h:16
double mTraceEnergy
Definition: RHStopTracer.h:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
part
Definition: HCALResponse.h:20
std::regex rePartName
Definition: RHStopTracer.h:52
std::vector< StopPoint > mStopPoints
Definition: RHStopTracer.h:53

Member Data Documentation

int RHStopTracer::maxPdgId
private

Definition at line 49 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

int RHStopTracer::minPdgId
private

Definition at line 48 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

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

Definition at line 53 of file RHStopTracer.h.

Referenced by produce(), and update().

bool RHStopTracer::mStopRegular
private

Definition at line 46 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

double RHStopTracer::mTraceEnergy
private

Definition at line 47 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

std::string RHStopTracer::mTraceParticleName
private

Definition at line 51 of file RHStopTracer.h.

Referenced by RHStopTracer().

int RHStopTracer::otherPdgId
private

Definition at line 50 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().

std::regex RHStopTracer::rePartName
private

Definition at line 52 of file RHStopTracer.h.

Referenced by RHStopTracer(), and update().