StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StV0Vertex.cxx
1 /***************************************************************************
2  *
3  * $Id: StV0Vertex.cxx,v 2.11 2009/11/23 16:34:08 fisyak Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StV0Vertex.cxx,v $
13  * Revision 2.11 2009/11/23 16:34:08 fisyak
14  * Cleanup, remove dependence on dst tables, clean up software monitors
15  *
16  * Revision 2.10 2008/03/13 16:57:27 ullrich
17  * Add include to comply with ROOT.
18  *
19  * Revision 2.9 2004/07/15 16:36:26 ullrich
20  * Removed all clone() declerations and definitions. Use StObject::clone() only.
21  *
22  * Revision 2.8 2003/04/30 20:37:08 perev
23  * Warnings cleanup. Modified lines marked VP
24  *
25  * Revision 2.7 2002/11/26 02:19:11 perev
26  * StEventMaker ITTF modif
27  *
28  * Revision 2.6 2002/03/08 22:16:20 jeromel
29  * Extra version needed to be read (Thomas)
30  *
31  * Revision 2.5 2002/03/08 20:28:36 ullrich
32  * Custom Streamer written.
33  *
34  * Revision 2.4 2001/04/05 04:00:59 ullrich
35  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
36  *
37  * Revision 2.3 2001/03/24 03:35:00 perev
38  * clone() -> clone() const
39  *
40  * Revision 2.2 1999/12/21 15:09:21 ullrich
41  * Modified to cope with new compiler version on Sun (CC5.0).
42  *
43  * Revision 2.1 1999/10/28 22:28:01 ullrich
44  * Adapted new StArray version. First version to compile on Linux and Sun.
45  *
46  * Revision 2.0 1999/10/12 18:43:23 ullrich
47  * Completely Revised for New Version
48  *
49  **************************************************************************/
50 #include <algorithm>
51 #include "StV0Vertex.h"
52 #include "StTrack.h"
53 #include "StTrackGeometry.h"
54 #include "TClass.h"
55 #if !defined(ST_NO_NAMESPACES)
56 using std::fill_n;
57 using std::copy;
58 #endif
59 
60 ClassImp(StV0Vertex)
61 
62 static const char rcsid[] = "$Id: StV0Vertex.cxx,v 2.11 2009/11/23 16:34:08 fisyak Exp $";
63 
65 {
66  mType = kV0VtxId;
67  mDaughters.resize(2);
68  mDaughters[negative] = 0;
69  mDaughters[positive] = 0;
70  fill_n(mDcaDaughtersToPrimaryVertex, 2, 0);
71  mDcaDaughters = 0;
72  mDcaParentToPrimaryVertex = 0;
73 }
74 
75 
76 StV0Vertex::~StV0Vertex() { /* noop */ }
77 
78 StVertexId
79 StV0Vertex::type() const { return kV0VtxId; }
80 
81 unsigned int
82 StV0Vertex::numberOfDaughters() const { return 2; }
83 
84 StTrack*
85 StV0Vertex::daughter(unsigned int i)
86 {
87  return i < 2 ? mDaughters[i] : 0;
88 }
89 
90 const StTrack*
91 StV0Vertex::daughter(unsigned int i) const
92 {
93  return i < 2 ? mDaughters[i] : 0;
94 }
95 
96 StPtrVecTrack
97 StV0Vertex::daughters(StTrackFilter& filter)
98 {
99  StPtrVecTrack vec;
100  for (int i=0; i<2; i++)
101  if (filter(mDaughters[i])) vec.push_back(mDaughters[i]);
102  return vec;
103 }
104 
105 void
106 StV0Vertex::addDaughter(StTrack* track)
107 {
108  if (track) {
109  if (track->geometry()->charge() > 0)
110  mDaughters[positive] = track;
111  else
112  mDaughters[negative] = track;
113  }
114 }
115 
116 void
117 StV0Vertex::removeDaughter(StTrack* t)
118 {
119  if (t == mDaughters[positive]) mDaughters[positive] = 0;
120  if (t == mDaughters[negative]) mDaughters[negative] = 0;
121 }
122 
123 StTrack*
124 StV0Vertex::daughter(StChargeSign sign)
125 {
126  return mDaughters[sign];
127 }
128 
129 const StTrack*
130 StV0Vertex::daughter(StChargeSign sign) const
131 {
132  return mDaughters[sign];
133 }
134 
135 float
136 StV0Vertex::dcaDaughterToPrimaryVertex(StChargeSign sign) const
137 {
138  return mDcaDaughtersToPrimaryVertex[sign];
139 }
140 
141 const StThreeVectorF&
142 StV0Vertex::momentumOfDaughter(StChargeSign sign) const
143 {
144  return (sign == negative ? mMomentumOfDaughters[0] : mMomentumOfDaughters[1]);
145 }
146 
148 StV0Vertex::momentum() const
149 {
150  return (mMomentumOfDaughters[0] +
151  mMomentumOfDaughters[1]);
152 }
153 
154 float
155 StV0Vertex::dcaDaughters() const { return mDcaDaughters; }
156 
157 float
158 StV0Vertex::dcaParentToPrimaryVertex() const { return mDcaParentToPrimaryVertex; }
159 
160 void
161 StV0Vertex::setDcaDaughterToPrimaryVertex(StChargeSign sign, float val)
162 {
163  mDcaDaughtersToPrimaryVertex[sign] = val;
164 }
165 
166 void
167 StV0Vertex::setMomentumOfDaughter(StChargeSign sign, const StThreeVectorF& v)
168 {
169  if (sign == negative)
170  mMomentumOfDaughters[0] = v;
171  else
172  mMomentumOfDaughters[1] = v;
173 }
174 
175 void
176 StV0Vertex::setDcaDaughters(float val) { mDcaDaughters = val; }
177 
178 void
179 StV0Vertex::setDcaParentToPrimaryVertex(float val) { mDcaParentToPrimaryVertex = val; }
180 
182 void StV0Vertex::Streamer(TBuffer &R__b)
183 {
184  // Stream an object of class .
185 
186  if (R__b.IsReading()) {
187  UInt_t R__s, R__c;
188  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
189  if (R__v > 2) {
190  Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
191  return;
192  }
193 
194  // *** HACK ***
195  //==== process old versions which were saved properly
196  // by sheer luck.
197  StVertex::Streamer(R__b);
198  mDaughters.Streamer(R__b);
199  R__b >> mDcaDaughtersToPrimaryVertex[0];
200  R__b >> mDcaDaughtersToPrimaryVertex[1];
201 
202  // Old format : had an extra version saved.
203  // Was previously saved as StThreeVectorF mMomentumOfDaughters[2];
204  // with StThreeVectorF having a custom streamer (therefore the
205  // extra version).
206  UInt_t R__s2, R__c2;
207  if (R__v==1) {R__b.ReadVersion(&R__s2, &R__c2);}
208  mMomentumOfDaughters[0].Streamer(R__b);
209  mMomentumOfDaughters[1].Streamer(R__b);
210 
211 
212  // Come back to other data members
213  R__b >> mDcaDaughters;
214  R__b >> mDcaParentToPrimaryVertex;
215  R__b.CheckByteCount(R__s, R__c, Class());
216  //====end of old versions
217  }
218  else {
219  Class()->WriteBuffer(R__b,this);
220  }
221 }
222 
223 
224 
225 
226 
227 
228