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 24 of file CheckSecondary.h.

Constructor & Destructor Documentation

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

Definition at line 23 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.

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

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

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

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

Referenced by CheckSecondary().

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

References file, and tree.

Referenced by ~CheckSecondary().

90  {
91 
92  edm::LogInfo("CheckSecondary") << "Save the Secondary Tree "
93  << tree->GetName() << " (" << tree
94  << ") in file " << file->GetName() << " ("
95  << file << ")";
96  file->cd();
97  tree->Write();
98  file->Close();
99  delete file;
100 }
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 102 of file CheckSecondary.cc.

References LogDebug.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.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().

102  {
103 
104  int iev = (*evt)()->GetEventID();
105  LogDebug("CheckSecondary") << "CheckSecondary::=====> Begin of event = "
106  << iev;
107 
108  (*nsec).clear();
109  (*procs).clear();
110  (*procids).clear();
111  (*deltae).clear();
112  (*px).clear();
113  (*py).clear();
114  (*pz).clear();
115  (*mass).clear();
116 }
#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 118 of file CheckSecondary.cc.

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

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.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().

118  {
119 
120  const G4Track * thTk = (*trk)();
121  treatSecondary->initTrack(thTk);
122  if (thTk->GetParentID() <= 0) storeIt = true;
123  else storeIt = false;
124  nHad = 0;
125  LogDebug("CheckSecondary") << "CheckSecondary:: Track " << thTk->GetTrackID()
126  << " Parent " << thTk->GetParentID() << " Flag "
127  << storeIt;
128 }
#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 130 of file CheckSecondary.cc.

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

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

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.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().

170  {
171 
172  LogDebug("CheckSecondary") << "CheckSecondary::EndofEvent =====> Event "
173  << (*evt)()->GetEventID() << " with "
174  << (*nsec).size() << " hadronic collisions with"
175  << " secondaries produced in each step";
176  for (unsigned int i= 0; i < (*nsec).size(); i++)
177  LogDebug("CheckSecondary") << " " << (*nsec)[i] << " from " << (*procs)[i]
178  << " ID " << (*procids)[i] << " ("
180  << ") deltaE = " << (*deltae)[i] << " MeV";
181  LogDebug("CheckSecondary") << "And " << (*mass).size() << " secondaries "
182  << "produced in the first interactions";
183  for (unsigned int i= 0; i < (*mass).size(); i++)
184  LogDebug("CheckSecondary") << "Secondary " << i << " (" << (*px)[i] << ", "
185  << (*py)[i] << ", " << (*pz)[i] << ", "
186  << (*mass)[i] << ")";
187 
188  if (saveToTree) tree->Fill();
189 }
#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 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().