CMS 3D CMS Logo

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

#include <CheckSecondary.h>

Inheritance diagram for CheckSecondary:
SimWatcher Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfEvent * > Observer< const G4Step * >

Public Member Functions

 CheckSecondary (const edm::ParameterSet &p)
 
 ~CheckSecondary () override
 
- Public Member Functions inherited from SimWatcher
 SimWatcher ()
 
virtual ~SimWatcher ()
 
- 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 EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const G4Step * >
 Observer ()
 
void slotForUpdate (const G4Step * iT)
 
virtual ~Observer ()
 

Private Member Functions

TTree * bookTree (std::string)
 
 CheckSecondary (const CheckSecondary &)=delete
 
void endTree ()
 
const CheckSecondaryoperator= (const CheckSecondary &)=delete
 
void update (const BeginOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt) override
 This routine will be called when the appropriate signal arrives. More...
 

Private Attributes

std::vector< double > * deltae
 
TFile * file
 
std::vector< double > * mass
 
int nHad
 
std::vector< int > * nsec
 
std::vector< int > * procids
 
std::vector< std::string > * procs
 
std::vector< double > * px
 
std::vector< double > * py
 
std::vector< double > * pz
 
bool saveToTree
 
bool storeIt
 
TreatSecondarytreatSecondary
 
TTree * tree
 
G4ProcessTypeEnumeratortypeEnumerator
 

Additional Inherited Members

Detailed Description

Definition at line 25 of file CheckSecondary.h.

Constructor & Destructor Documentation

CheckSecondary::CheckSecondary ( const edm::ParameterSet p)

Definition at line 25 of file CheckSecondary.cc.

References bookTree(), deltae, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mass, nsec, procids, procs, px, py, pz, saveToTree, AlCaHLTBitMon_QueryRunRegistry::string, treatSecondary, and typeEnumerator.

26  : treatSecondary(nullptr),
27  typeEnumerator(nullptr),
28  nsec(nullptr),
29  procids(nullptr),
30  px(nullptr),
31  py(nullptr),
32  pz(nullptr),
33  mass(nullptr),
34  deltae(nullptr),
35  procs(nullptr),
36  file(nullptr),
37  tree(nullptr) {
38  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("CheckSecondary");
39  std::string saveFile = m_p.getUntrackedParameter<std::string>("SaveInFile", "None");
40  treatSecondary = new TreatSecondary(m_p);
42 
43  nsec = new std::vector<int>();
44  px = new std::vector<double>();
45  py = new std::vector<double>();
46  pz = new std::vector<double>();
47  mass = new std::vector<double>();
48  deltae = new std::vector<double>();
49  procids = new std::vector<int>();
50  procs = new std::vector<std::string>();
51 
52  if (saveFile != "None") {
53  saveToTree = true;
54  tree = bookTree(saveFile);
55  edm::LogInfo("CheckSecondary") << "Instantiate CheckSecondary with first"
56  << " hadronic interaction information"
57  << " to be saved in file " << saveFile;
58  } else {
59  saveToTree = false;
60  edm::LogInfo("CheckSecondary") << "Instantiate CheckSecondary with first"
61  << " hadronic interaction information"
62  << " not saved";
63  }
64 }
T getParameter(std::string const &) const
std::vector< std::string > * procs
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > * pz
std::vector< double > * deltae
std::vector< int > * nsec
G4ProcessTypeEnumerator * typeEnumerator
TTree * bookTree(std::string)
std::vector< double > * py
std::vector< int > * procids
Definition: tree.py:1
std::vector< double > * px
TreatSecondary * treatSecondary
std::vector< double > * mass
CheckSecondary::~CheckSecondary ( )
override

Definition at line 66 of file CheckSecondary.cc.

References deltae, endTree(), mass, nsec, procids, procs, px, py, pz, saveToTree, treatSecondary, and typeEnumerator.

66  {
67  if (saveToTree)
68  endTree();
69  if (nsec)
70  delete nsec;
71  if (px)
72  delete px;
73  if (py)
74  delete py;
75  if (pz)
76  delete pz;
77  if (mass)
78  delete mass;
79  if (deltae)
80  delete deltae;
81  if (procs)
82  delete procs;
83  if (procids)
84  delete procids;
85  if (typeEnumerator)
86  delete typeEnumerator;
87  if (treatSecondary)
88  delete treatSecondary;
89 }
std::vector< std::string > * procs
std::vector< double > * pz
std::vector< double > * deltae
std::vector< int > * nsec
G4ProcessTypeEnumerator * typeEnumerator
std::vector< double > * py
std::vector< int > * procids
std::vector< double > * px
TreatSecondary * treatSecondary
std::vector< double > * mass
CheckSecondary::CheckSecondary ( const CheckSecondary )
privatedelete

Member Function Documentation

TTree * CheckSecondary::bookTree ( std::string  fileName)
private

Definition at line 91 of file CheckSecondary.cc.

References deltae, file, mass, nsec, procids, procs, px, py, and pz.

Referenced by CheckSecondary().

91  {
92  file = new TFile(fileName.c_str(), "RECREATE");
93  file->cd();
94 
95  TTree *t1 = new TTree("T1", "Secondary Particle Information");
96  t1->Branch("SecondaryPx", "std::vector<double>", &px);
97  t1->Branch("SecondaryPy", "std::vector<double>", &py);
98  t1->Branch("SecondaryPz", "std::vector<double>", &pz);
99  t1->Branch("SecondaryMass", "std::vector<double>", &mass);
100  t1->Branch("NumberSecondaries", "std::vector<int>", &nsec);
101  t1->Branch("DeltaEinInteract", "std::vector<double>", &deltae);
102  t1->Branch("ProcessID", "std::vector<int>", &procids);
103  t1->Branch("ProcessNames", "std::vector<std::string>", &procs);
104  return t1;
105 }
std::vector< std::string > * procs
std::vector< double > * pz
std::vector< double > * deltae
std::vector< int > * nsec
std::vector< double > * py
std::vector< int > * procids
std::vector< double > * px
std::vector< double > * mass
void CheckSecondary::endTree ( )
private

Definition at line 107 of file CheckSecondary.cc.

References file.

Referenced by ~CheckSecondary().

107  {
108  edm::LogInfo("CheckSecondary") << "Save the Secondary Tree " << tree->GetName() << " (" << tree << ") in file "
109  << file->GetName() << " (" << file << ")";
110  file->cd();
111  tree->Write();
112  file->Close();
113  delete file;
114 }
Definition: tree.py:1
const CheckSecondary& CheckSecondary::operator= ( const CheckSecondary )
privatedelete
void CheckSecondary::update ( const BeginOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 116 of file CheckSecondary.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().

116  {
117  int iev = (*evt)()->GetEventID();
118  LogDebug("CheckSecondary") << "CheckSecondary::=====> Begin of event = " << iev;
119 
120  (*nsec).clear();
121  (*procs).clear();
122  (*procids).clear();
123  (*deltae).clear();
124  (*px).clear();
125  (*py).clear();
126  (*pz).clear();
127  (*mass).clear();
128 }
#define LogDebug(id)
void CheckSecondary::update ( const BeginOfTrack )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 130 of file CheckSecondary.cc.

References TreatSecondary::initTrack(), LogDebug, nHad, storeIt, and treatSecondary.

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

130  {
131  const G4Track *thTk = (*trk)();
132  treatSecondary->initTrack(thTk);
133  if (thTk->GetParentID() <= 0)
134  storeIt = true;
135  else
136  storeIt = false;
137  nHad = 0;
138  LogDebug("CheckSecondary") << "CheckSecondary:: Track " << thTk->GetTrackID() << " Parent " << thTk->GetParentID()
139  << " Flag " << storeIt;
140 }
#define LogDebug(id)
void initTrack(const G4Track *trk)
TreatSecondary * treatSecondary
void CheckSecondary::update ( const G4Step *  )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 142 of file CheckSecondary.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, mps_fire::i, createfilelist::int, LogDebug, funct::m, mag(), dataset::name, nHad, storeIt, AlCaHLTBitMon_QueryRunRegistry::string, l1t::tracks, TreatSecondary::tracks(), and treatSecondary.

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

142  {
144  int procID;
145  bool hadrInt;
146  double deltaE;
147  std::vector<int> charge;
148  std::vector<math::XYZTLorentzVector> tracks = treatSecondary->tracks(aStep, name, procID, hadrInt, deltaE, charge);
149  if (storeIt && hadrInt) {
150  double pInit = (aStep->GetPreStepPoint()->GetMomentum()).mag();
151  double pEnd = (aStep->GetPostStepPoint()->GetMomentum()).mag();
152  nHad++;
153  int sec = (int)(tracks.size());
154  LogDebug("CheckSecondary") << "CheckSecondary:: Hadronic Interaction " << nHad << " of type " << name << " ID "
155  << procID << " with " << sec << " secondaries "
156  << " and Momentum (MeV/c) at start " << pInit << " and at end " << pEnd;
157  (*nsec).push_back(sec);
158  (*procs).push_back(name);
159  (*procids).push_back(procID);
160  (*deltae).push_back(deltaE);
161  if (nHad == 1) {
162  for (int i = 0; i < sec; i++) {
163  double m = tracks[i].M();
164  if (charge[i] < 0)
165  m = -m;
166  (*px).push_back(tracks[i].Px());
167  (*py).push_back(tracks[i].Py());
168  (*pz).push_back(tracks[i].Pz());
169  (*mass).push_back(m);
170  }
171  }
172  }
173 }
#define LogDebug(id)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
std::vector< math::XYZTLorentzVector > tracks(const G4Step *step, std::string &procName, int &procID, bool &intr, double &deltaE, std::vector< int > &charges)
TreatSecondary * treatSecondary
void CheckSecondary::update ( const EndOfEvent )
overrideprivatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 175 of file CheckSecondary.cc.

References mps_fire::i, LogDebug, G4ProcessTypeEnumerator::processG4Name(), procids, saveToTree, and typeEnumerator.

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

175  {
176  LogDebug("CheckSecondary") << "CheckSecondary::EndofEvent =====> Event " << (*evt)()->GetEventID() << " with "
177  << (*nsec).size() << " hadronic collisions with"
178  << " secondaries produced in each step";
179  for (unsigned int i = 0; i < (*nsec).size(); i++)
180  LogDebug("CheckSecondary") << " " << (*nsec)[i] << " from " << (*procs)[i] << " ID " << (*procids)[i] << " ("
181  << typeEnumerator->processG4Name((*procids)[i]) << ") deltaE = " << (*deltae)[i]
182  << " MeV";
183  LogDebug("CheckSecondary") << "And " << (*mass).size() << " secondaries "
184  << "produced in the first interactions";
185  for (unsigned int i = 0; i < (*mass).size(); i++)
186  LogDebug("CheckSecondary") << "Secondary " << i << " (" << (*px)[i] << ", " << (*py)[i] << ", " << (*pz)[i] << ", "
187  << (*mass)[i] << ")";
188 
189  if (saveToTree)
190  tree->Fill();
191 }
#define LogDebug(id)
std::string processG4Name(int) const
G4ProcessTypeEnumerator * typeEnumerator
std::vector< int > * procids
Definition: tree.py:1

Member Data Documentation

std::vector<double> * CheckSecondary::deltae
private

Definition at line 52 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), and ~CheckSecondary().

TFile* CheckSecondary::file
private

Definition at line 54 of file CheckSecondary.h.

Referenced by bookTree(), and endTree().

std::vector<double> * CheckSecondary::mass
private
int CheckSecondary::nHad
private

Definition at line 50 of file CheckSecondary.h.

Referenced by update().

std::vector<int>* CheckSecondary::nsec
private

Definition at line 51 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), and ~CheckSecondary().

std::vector<int> * CheckSecondary::procids
private

Definition at line 51 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), update(), and ~CheckSecondary().

std::vector<std::string>* CheckSecondary::procs
private

Definition at line 53 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), and ~CheckSecondary().

std::vector<double>* CheckSecondary::px
private

Definition at line 52 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), and ~CheckSecondary().

std::vector<double> * CheckSecondary::py
private

Definition at line 52 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), and ~CheckSecondary().

std::vector<double> * CheckSecondary::pz
private

Definition at line 52 of file CheckSecondary.h.

Referenced by bookTree(), CheckSecondary(), and ~CheckSecondary().

bool CheckSecondary::saveToTree
private

Definition at line 49 of file CheckSecondary.h.

Referenced by CheckSecondary(), update(), and ~CheckSecondary().

bool CheckSecondary::storeIt
private

Definition at line 49 of file CheckSecondary.h.

Referenced by update().

TreatSecondary* CheckSecondary::treatSecondary
private

Definition at line 47 of file CheckSecondary.h.

Referenced by CheckSecondary(), update(), and ~CheckSecondary().

TTree* CheckSecondary::tree
private
G4ProcessTypeEnumerator* CheckSecondary::typeEnumerator
private

Definition at line 48 of file CheckSecondary.h.

Referenced by CheckSecondary(), update(), and ~CheckSecondary().