CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual ~CheckSecondary ()
 
- 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 &)
 
void endTree ()
 
const CheckSecondaryoperator= (const CheckSecondary &)
 
void update (const BeginOfEvent *evt)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *trk)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const G4Step *step)
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfEvent *evt)
 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, tree, and typeEnumerator.

25  : treatSecondary(0),
26  typeEnumerator(0),
27  nsec(0),procids(0),
28  px(0),py(0),pz(0),
29  mass(0),deltae(0),
30  procs(0),file(0),
31  tree(0) {
32 
33  edm::ParameterSet m_p = p.getParameter<edm::ParameterSet>("CheckSecondary");
34  std::string saveFile = m_p.getUntrackedParameter<std::string>("SaveInFile", "None");
35  treatSecondary = new TreatSecondary(m_p);
37 
38  nsec = new std::vector<int>();
39  px = new std::vector<double>();
40  py = new std::vector<double>();
41  pz = new std::vector<double>();
42  mass = new std::vector<double>();
43  deltae = new std::vector<double>();
44  procids = new std::vector<int>();
45  procs = new std::vector<std::string>();
46 
47  if (saveFile != "None") {
48  saveToTree = true;
49  tree = bookTree (saveFile);
50  edm::LogInfo("CheckSecondary") << "Instantiate CheckSecondary with first"
51  << " hadronic interaction information"
52  << " to be saved in file " << saveFile;
53  } else {
54  saveToTree = false;
55  edm::LogInfo("CheckSecondary") << "Instantiate CheckSecondary with first"
56  << " hadronic interaction information"
57  << " not saved";
58  }
59 }
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
std::vector< double > * px
TreatSecondary * treatSecondary
std::vector< double > * mass
CheckSecondary::~CheckSecondary ( )
virtual

Definition at line 61 of file CheckSecondary.cc.

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

61  {
62  if (saveToTree) endTree();
63  if (nsec) delete nsec;
64  if (px) delete px;
65  if (py) delete py;
66  if (pz) delete pz;
67  if (mass) delete mass;
68  if (deltae) delete deltae;
69  if (procs) delete procs;
70  if (procids) delete procids;
71  if (typeEnumerator) delete typeEnumerator;
72  if (treatSecondary) delete treatSecondary;
73 }
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 )
private

Member Function Documentation

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

Definition at line 75 of file CheckSecondary.cc.

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

Referenced by CheckSecondary().

75  {
76 
77  file = new TFile (fileName.c_str(), "RECREATE");
78  file->cd();
79 
80  TTree * t1 = new TTree("T1", "Secondary Particle Information");
81  t1->Branch("SecondaryPx", "std::vector<double>", &px);
82  t1->Branch("SecondaryPy", "std::vector<double>", &py);
83  t1->Branch("SecondaryPz", "std::vector<double>", &pz);
84  t1->Branch("SecondaryMass", "std::vector<double>", &mass);
85  t1->Branch("NumberSecondaries", "std::vector<int>", &nsec);
86  t1->Branch("DeltaEinInteract", "std::vector<double>", &deltae);
87  t1->Branch("ProcessID", "std::vector<int>", &procids);
88  t1->Branch("ProcessNames", "std::vector<std::string>", &procs);
89  return t1;
90 }
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 92 of file CheckSecondary.cc.

References file, and tree.

Referenced by ~CheckSecondary().

92  {
93 
94  edm::LogInfo("CheckSecondary") << "Save the Secondary Tree "
95  << tree->GetName() << " (" << tree
96  << ") in file " << file->GetName() << " ("
97  << file << ")";
98  file->cd();
99  tree->Write();
100  file->Close();
101  delete file;
102 }
const CheckSecondary& CheckSecondary::operator= ( const CheckSecondary )
private
void CheckSecondary::update ( const BeginOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 104 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().

104  {
105 
106  int iev = (*evt)()->GetEventID();
107  LogDebug("CheckSecondary") << "CheckSecondary::=====> Begin of event = "
108  << iev;
109 
110  (*nsec).clear();
111  (*procs).clear();
112  (*procids).clear();
113  (*deltae).clear();
114  (*px).clear();
115  (*py).clear();
116  (*pz).clear();
117  (*mass).clear();
118 }
#define LogDebug(id)
void CheckSecondary::update ( const BeginOfTrack )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfTrack * >.

Definition at line 120 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().

120  {
121 
122  const G4Track * thTk = (*trk)();
123  treatSecondary->initTrack(thTk);
124  if (thTk->GetParentID() <= 0) storeIt = true;
125  else storeIt = false;
126  nHad = 0;
127  LogDebug("CheckSecondary") << "CheckSecondary:: Track " << thTk->GetTrackID()
128  << " Parent " << thTk->GetParentID() << " Flag "
129  << storeIt;
130 }
#define LogDebug(id)
void initTrack(const G4Track *trk)
TreatSecondary * treatSecondary
void CheckSecondary::update ( const G4Step *  )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 132 of file CheckSecondary.cc.

References RecoTauCleanerPlugins::charge, i, LogDebug, visualization-live-secondInstance_cfg::m, mag(), mergeVDriftHistosByStation::name, nHad, storeIt, AlCaHLTBitMon_QueryRunRegistry::string, TreatSecondary::tracks(), testEve_cfg::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().

132  {
133 
135  int procID;
136  bool hadrInt;
137  double deltaE;
138  std::vector<int> charge;
139  std::vector<math::XYZTLorentzVector> tracks = treatSecondary->tracks(aStep,
140  name,
141  procID,
142  hadrInt,
143  deltaE,
144  charge);
145  if (storeIt && hadrInt) {
146  double pInit = (aStep->GetPreStepPoint()->GetMomentum()).mag();
147  double pEnd = (aStep->GetPostStepPoint()->GetMomentum()).mag();
148  nHad++;
149  int sec = (int)(tracks.size());
150  LogDebug("CheckSecondary") << "CheckSecondary:: Hadronic Interaction "
151  << nHad << " of type " << name << " ID "
152  << procID << " with " << sec << " secondaries "
153  << " and Momentum (MeV/c) at start " << pInit
154  << " and at end " << pEnd;
155  (*nsec).push_back(sec);
156  (*procs).push_back(name);
157  (*procids).push_back(procID);
158  (*deltae).push_back(deltaE);
159  if (nHad == 1) {
160  for (int i=0; i<sec; i++) {
161  double m = tracks[i].M();
162  if (charge[i]<0) m = -m;
163  (*px).push_back(tracks[i].Px());
164  (*py).push_back(tracks[i].Py());
165  (*pz).push_back(tracks[i].Pz());
166  (*mass).push_back(m);
167  }
168  }
169  }
170 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
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)
tuple tracks
Definition: testEve_cfg.py:39
TreatSecondary * treatSecondary
void CheckSecondary::update ( const EndOfEvent )
privatevirtual

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 172 of file CheckSecondary.cc.

References i, LogDebug, G4ProcessTypeEnumerator::processG4Name(), procids, saveToTree, tree, 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().

172  {
173 
174  LogDebug("CheckSecondary") << "CheckSecondary::EndofEvent =====> Event "
175  << (*evt)()->GetEventID() << " with "
176  << (*nsec).size() << " hadronic collisions with"
177  << " secondaries produced in each step";
178  for (unsigned int i= 0; i < (*nsec).size(); i++)
179  LogDebug("CheckSecondary") << " " << (*nsec)[i] << " from " << (*procs)[i]
180  << " ID " << (*procids)[i] << " ("
182  << ") deltaE = " << (*deltae)[i] << " 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] << ", "
187  << (*py)[i] << ", " << (*pz)[i] << ", "
188  << (*mass)[i] << ")";
189 
190  if (saveToTree) tree->Fill();
191 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
G4ProcessTypeEnumerator * typeEnumerator
std::vector< int > * procids

Member Data Documentation

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

Definition at line 53 of file CheckSecondary.h.

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

TFile* CheckSecondary::file
private

Definition at line 55 of file CheckSecondary.h.

Referenced by bookTree(), and endTree().

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

Definition at line 51 of file CheckSecondary.h.

Referenced by update().

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

Definition at line 52 of file CheckSecondary.h.

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

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

Definition at line 52 of file CheckSecondary.h.

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

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

Definition at line 54 of file CheckSecondary.h.

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

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

Definition at line 53 of file CheckSecondary.h.

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

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

Definition at line 53 of file CheckSecondary.h.

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

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

Definition at line 53 of file CheckSecondary.h.

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

bool CheckSecondary::saveToTree
private

Definition at line 50 of file CheckSecondary.h.

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

bool CheckSecondary::storeIt
private

Definition at line 50 of file CheckSecondary.h.

Referenced by update().

TreatSecondary* CheckSecondary::treatSecondary
private

Definition at line 48 of file CheckSecondary.h.

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

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

Definition at line 49 of file CheckSecondary.h.

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