StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcVertex.cc
1 /***************************************************************************
2  *
3  * $Id: StMcVertex.cc,v 2.13 2016/05/16 23:47:09 perev Exp $
4  * $Log: StMcVertex.cc,v $
5  * Revision 2.13 2016/05/16 23:47:09 perev
6  * Coverity fix
7  *
8  * Revision 2.12 2005/11/22 21:44:52 fisyak
9  * Add compress Print for McEvent, add Ssd collections
10  *
11  * Revision 2.11 2005/09/29 01:01:10 calderon
12  * Fixed bugs in printing event and hit information.
13  * Format operator<< for various classes.
14  *
15  * Revision 2.10 2005/09/28 21:30:15 fisyak
16  * Persistent StMcEvent
17  *
18  * Revision 2.9 2005/01/27 23:40:49 calderon
19  * Adding persistency to StMcEvent as a step for Virtual MonteCarlo.
20  *
21  * Revision 2.8 2003/08/20 18:50:21 calderon
22  * Addition of Tof classes and Pixel classes. Modified track, event, and
23  * container code to reflect this.
24  * Fix bug in StMcVertex and in clearing of some hit collections.
25  *
26  * Revision 2.7 2000/05/05 15:25:44 calderon
27  * Reduced dependencies and made constructors more efficient
28  *
29  * Revision 2.6 2000/03/29 16:15:54 calderon
30  * Added more information from g2t_vertex table
31  *
32  * Revision 2.5 2000/03/06 18:05:24 calderon
33  * 1) Modified SVT Hits storage scheme from layer-ladder-wafer to
34  * barrel-ladder-wafer.
35  * 2) Added Rich Hit class and collection, and links to them in other
36  * classes.
37  *
38  * Revision 2.4 2000/01/18 20:52:31 calderon
39  * Works with CC5
40  *
41  * Revision 2.3 1999/12/14 07:04:50 calderon
42  * Numbering scheme as per SVT request.
43  *
44  * Revision 2.2 1999/12/03 00:51:53 calderon
45  * Tested with new StMcEventMaker. Added messages for
46  * diagnostics.
47  *
48  * Revision 2.1 1999/11/19 19:06:34 calderon
49  * Recommit after redoing the files.
50  *
51  * Revision 2.0 1999/11/17 02:12:17 calderon
52  * Completely revised for new StEvent
53  *
54  * Revision 1.4 1999/09/23 21:25:55 calderon
55  * Added Log & Id
56  * Modified includes according to Yuri
57  *
58  * Revision 1.3 1999/07/29 00:13:14 calderon
59  * Read ge_volume correctly
60  *
61  *
62  **************************************************************************/
63 #include <algorithm>
64 #ifndef ST_NO_NAMESPACES
65 using std::find;
66 #endif
67 
68 #include "StMcVertex.hh"
69 #include "StMcTrack.hh"
70 #include "tables/St_g2t_vertex_Table.h"
71 
72 static const char rcsid[] = "$Id: StMcVertex.cc,v 2.13 2016/05/16 23:47:09 perev Exp $";
73 
74 ClassImp(StMcVertex);
75 
76 StMcVertex::StMcVertex()
77 {
78 
79  mParent = 0;
80  mGeantVolume = "aaaa";
81  mTof = 0;
82  mGeantProcess = 0;
83  mGeneratorProcess = 0;
84  mKey = 0;
85  mGeantMedium = 0;
86 }
87 
88 StMcVertex::StMcVertex(g2t_vertex_st* vtx)
89 {
90 
91 
92  mPosition.setX(vtx->ge_x[0]);
93  mPosition.setY(vtx->ge_x[1]);
94  mPosition.setZ(vtx->ge_x[2]);
95  char tmp[5]; tmp[4]=0; strncpy(tmp,vtx->ge_volume,4);
96  mGeantVolume=tmp;
97  mTof = vtx->ge_tof;
98  mGeantProcess = vtx->ge_proc;
99  mGeneratorProcess = vtx->eg_proc;
100  mKey = vtx->id;
101  mGeantMedium = vtx->ge_medium;
102  mParent = 0;
103 
104 }
105 
106 StMcVertex::~StMcVertex()
107 {
108  mDaughters.clear(); //Not owner, so we don't have to delete.
109 }
110 
111 
112 int StMcVertex::operator==(const StMcVertex& v) const
113 {
114  return (mGeantProcess == v.mGeantProcess &&
115  mPosition == v.mPosition &&
116  mTof == v.mTof &&
117  mKey == v.mKey);
118 }
119 
120 int StMcVertex::operator!=(const StMcVertex& v) const
121 {
122  return !(v == *this);
123 }
124 
125 ostream& operator<<(ostream& os, const StMcVertex& v)
126 {
127  os << "Position : " << Form("%8.3f%8.3f%8.3f",v.position().x(),v.position().y(),v.position().z()) << endl;
128  os << "Geant Volume : " << v.geantVolume() << endl;
129  os << "Time of Flight: " << v.tof() << endl;
130  os << "Geant Process : " << v.geantProcess() << endl;
131  Int_t nDaughters = v.numberOfDaughters();
132  os << "N. Daughters : " << nDaughters;
133  //for (int j = 0; j < nDaughters; j++) {
134  // os << "\t" << v.daughter(j)->key();
135  //}
136 
137  return os;
138 }
139 
140 
141 void StMcVertex::setPosition(const StThreeVectorF& val) { mPosition = val; }
142 
143 void StMcVertex::setParent(StMcTrack* val) { mParent = val; }
144 
145 void StMcVertex::addDaughter(StMcTrack* val) { mDaughters.push_back(val); }
146 
147 void StMcVertex::setGeantVolume(const Char_t *val) { mGeantVolume = val; }
148 
149 void StMcVertex::setTof(float val) { mTof = val; }
150 
151 void StMcVertex::setGeantProcess(int val) { mGeantProcess = val; }
152 
153 void StMcVertex::removeDaughter(StMcTrack* trk) {
154  StMcTrackIterator iter = find(mDaughters.begin(), mDaughters.end(), trk);
155  if (iter != mDaughters.end()) mDaughters.erase(iter);
156 }
157 //________________________________________________________________________________
158 void StMcVertex::Print(Option_t *option) const {
159  cout << "StMcVertex: pos:" << Form("%8.3f%8.3f%8.3f",position().x(),position().y(),position().z())
160  << " Volume: " << geantVolume()
161  << " Time of Flight(ns): " << 1.e9*tof()
162  << " Process: " << geantProcess();
163  Int_t nDaughters = numberOfDaughters();
164  cout << " N.Daughters: " << nDaughters;
165  for (int j = 0; j < nDaughters; j++) {
166  cout << "\t" << daughter(j)->key();
167  }
168  cout << endl;
169 }
Definition: tof.h:15
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144