StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPrimaryVertex.cxx
1 /***************************************************************************
2  *
3  * $Id: StPrimaryVertex.cxx,v 2.20 2013/01/15 23:31:05 fisyak Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StPrimaryVertex.cxx,v $
13  * Revision 2.20 2013/01/15 23:31:05 fisyak
14  * Soft requirement for matching with EMC
15  *
16  * Revision 2.19 2013/01/15 23:21:06 fisyak
17  * improve printouts
18  *
19  * Revision 2.18 2012/10/23 20:18:33 fisyak
20  * Add/modify print outs
21  *
22  * Revision 2.17 2012/09/16 21:37:13 fisyak
23  * Add no. of Tpc West Only and East only tracks
24  *
25  * Revision 2.16 2012/05/07 14:42:58 fisyak
26  * Add handlings for Track to Fast Detectors Matching
27  *
28  * Revision 2.15 2009/11/23 22:25:21 ullrich
29  * Added new member mNumMatchesWithBTOF and related access fcts.
30  *
31  * Revision 2.14 2009/11/23 16:34:06 fisyak
32  * Cleanup, remove dependence on dst tables, clean up software monitors
33  *
34  * Revision 2.13 2006/04/07 18:21:28 ullrich
35  * Added data member mMeanDip incl. access functions (Marco).
36  *
37  * Revision 2.12 2005/07/15 20:17:35 ullrich
38  * Corrected spelling in membrane
39  *
40  * Revision 2.11 2005/06/15 21:50:32 ullrich
41  * Added members and methods to identify used vertex finder and store vertex quality.
42  *
43  * Revision 2.10 2004/07/15 16:36:24 ullrich
44  * Removed all clone() declerations and definitions. Use StObject::clone() only.
45  *
46  * Revision 2.9 2003/09/02 17:58:05 perev
47  * gcc 3.2 updates + WarnOff
48  *
49  * Revision 2.8 2002/04/18 23:38:21 jeromel
50  * Implementation of the SVT 2 tables scheme ...
51  *
52  * Revision 2.7 2001/04/05 04:00:52 ullrich
53  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
54  *
55  * Revision 2.6 2001/03/24 03:34:53 perev
56  * clone() -> clone() const
57  *
58  * Revision 2.5 2000/04/03 15:30:23 ullrich
59  * addDaughter() now assigns the right vertex, i.e. this, to
60  * the primary tracks stored within this primary vertex.
61  *
62  * Revision 2.4 1999/11/09 15:44:11 ullrich
63  * Removed method unlink() and all calls to it.
64  *
65  * Revision 2.3 1999/11/04 20:36:17 ullrich
66  * New method to obtain daughter container directly
67  *
68  * Revision 2.2 1999/10/28 22:26:16 ullrich
69  * Adapted new StArray version. First version to compile on Linux and Sun.
70  *
71  * Revision 2.1 1999/10/13 19:45:02 ullrich
72  * Initial Revision
73  *
74  **************************************************************************/
75 #include <Stiostream.h>
76 #include "StPrimaryVertex.h"
77 #include "StPrimaryTrack.h"
78 #include "StTrack.h"
79 #include "StFunctional.h"
80 #include "StTrackNode.h"
81 #include "StGlobalTrack.h"
82 #include "TMath.h"
83 #include "StTrackGeometry.h"
84 ClassImp(StPrimaryVertex)
85 
86 static const char rcsid[] = "$Id: StPrimaryVertex.cxx,v 2.20 2013/01/15 23:31:05 fisyak Exp $";
87 
89 {init();}
90 
91 void StPrimaryVertex::init()
92 {
93  mType = kEventVtxId;
94  mVertexFinderId = undefinedVertexFinder;
95  memset(mBeg, 0, mEnd-mBeg+1);
96 }
97 
98 StPrimaryVertex::~StPrimaryVertex() {/* noop */};
99 
100 StVertexId
101 StPrimaryVertex::type() const { return kEventVtxId; }
102 
103 UInt_t
104 StPrimaryVertex::numberOfDaughters() const
105 {
106  return mDaughters.size();
107 }
108 UInt_t StPrimaryVertex::numberOfGoodTracks() const {
109  UInt_t no = 0;
110  for (UInt_t i=0; i<mDaughters.size(); i++) {
111  const StTrack *track = daughter(i);
112  if (track && track->flag() >= 0 && track->fitTraits().numberOfFitPoints() >= NoFitPointCutForGoodTrack()) no++;
113  }
114  return no;
115 }
116 
117 StTrack*
118 StPrimaryVertex::daughter(UInt_t i)
119 {
120  return i < mDaughters.size() ? mDaughters[i] : 0;
121 }
122 
123 const StTrack*
124 StPrimaryVertex::daughter(UInt_t i) const
125 {
126  return i < mDaughters.size() ? mDaughters[i] : 0;
127 }
128 
129 StPtrVecTrack
130 StPrimaryVertex::daughters(StTrackFilter& filter)
131 {
132  StPtrVecTrack vec;
133  for (UInt_t i=0; i<mDaughters.size(); i++)
134  if (filter(mDaughters[i])) vec.push_back(mDaughters[i]);
135  return vec;
136 }
137 
138 void
139 StPrimaryVertex::addDaughter(StTrack* t)
140 {
141  StPrimaryTrack* p = dynamic_cast<StPrimaryTrack*>(t);
142  if (p) {
143  if (p->type() == primary) {
144  mDaughters.push_back(p);
145  p->setVertex(this);
146  }
147  }
148 }
149 
150 void
151 StPrimaryVertex::removeDaughter(StTrack* t)
152 {
153  StPrimaryTrack* p = dynamic_cast<StPrimaryTrack*>(t);
154  if (!p) return;
155  StSPtrVecPrimaryTrackIterator iter;
156  if (p->type() == primary) {
157  for (iter=mDaughters.begin(); iter != mDaughters.end(); iter++)
158  if (*iter == t) {
159  mDaughters.erase(iter);
160  p->setVertex(0);
161  }
162  }
163 }
164 
165 void
166 StPrimaryVertex::setParent(StTrack*)
167 {
168  cerr << "StPrimaryVertex::setParent(): StPrimaryVertex cannot have a parent." << endl;
169 }
170 //________________________________________________________________________________
171 void StPrimaryVertex::setTrackNumbers() {
172  mNumMatchesWithTOF = 0;
173  mNumMatchesWithCTB = 0;
174  mNumMatchesWithBEMC = 0;
175  mNumMatchesWithEEMC = 0;
176  mNumNotMatchesWithTOF = 0;
177  mNumNotMatchesWithCTB = 0;
178  mNumNotMatchesWithBEMC = 0;
179  mNumNotMatchesWithEEMC = 0;
180  mNumTracksCrossingCentralMembrane = 0;
181  mNumPostXTracks = 0;
182  mNumTracksWithPromptHit = 0;
183  mNumTracksTpcWestOnly = mNumTracksTpcEastOnly = 0;
184  mMeanDip = 0;
185  mSumOfTrackPt = 0;
186  UInt_t nDaughters = numberOfDaughters();
187  UShort_t n_trk_vtx = 0;
188  for (UInt_t i = 0; i < nDaughters; i++) {
189  StPrimaryTrack* pTrack = (StPrimaryTrack*) daughter(i);
190  if (! pTrack) continue;
191  n_trk_vtx++;
192  StThreeVectorD g3 = pTrack->geometry()->momentum();
193  mMeanDip += TMath::PiOver2() - g3.theta();
194  mSumOfTrackPt += g3.perp();
195  if (! pTrack->flagExtension()) { // check consitency with global track
196  const StTrackNode* node = pTrack->node();
197  const StTrack *gTrack = node->track(global);
198  if (gTrack) pTrack->setFlagExtension(gTrack->flagExtension());
199  }
200  if (pTrack->isCtbMatched() ) mNumMatchesWithCTB++;
201  if (pTrack->isCtbNotMatched() ) mNumNotMatchesWithCTB++;
202  if (pTrack->isToFMatched() ) mNumMatchesWithTOF++;
203  if (pTrack->isToFNotMatched() ) mNumNotMatchesWithTOF++;
204  if ((pTrack->flagExtension() & 7) > 0) {
205  if (pTrack->isBemcMatched() ) mNumMatchesWithBEMC += 1;// << ((pTrack->flagExtension() & 7) - 1);
206  if (pTrack->isEemcMatched() ) mNumMatchesWithEEMC += 1;// << ((pTrack->flagExtension() & 7) - 1);
207  }
208  if (pTrack->isBemcNotMatched()) mNumNotMatchesWithBEMC++;
209  if (pTrack->isEemcNotMatched()) mNumNotMatchesWithEEMC++;
210  if (pTrack->isMembraneCrossingTrack()) mNumTracksCrossingCentralMembrane++;
211  if (pTrack->isPostXTrack()) mNumPostXTracks++;
212  if (pTrack-> isPromptTrack()) mNumTracksWithPromptHit++;
213  if (pTrack->isWestTpcOnly()) mNumTracksTpcWestOnly++;
214  if (pTrack->isEastTpcOnly()) mNumTracksTpcEastOnly++;
215  }
216  if (n_trk_vtx > 0) mMeanDip /= n_trk_vtx;
217 }
218 //________________________________________________________________________________
219 ostream& operator<<(ostream& os, const StPrimaryVertex& v) {
220  UInt_t nGoodTpcTracks = 0, nTpcTracks = 0;
221  UInt_t nDaughters = v.numberOfDaughters();
222  for (UInt_t i=0; i < nDaughters; i++) {
223  StPrimaryTrack* pTrack = (StPrimaryTrack*) v.daughter(i);
224  if (! pTrack) continue;
225  Int_t good = (pTrack->flag() > 0 && pTrack->fitTraits().numberOfFitPoints() >= StVertex::NoFitPointCutForGoodTrack()) ? 1 : 0;
226  if (pTrack->fitTraits().numberOfFitPoints(kTpcId)) {
227  nTpcTracks++; nGoodTpcTracks+=good;
228  }
229  }
230  const Char_t *beam = (v.isBeamConstrained()) ? "B" : " ";
231  // os << Form("%2s:C/P/X/T/E %i/%i/%i/%i/%i: %8.3f,%8.3f,%8.3f",
232  os << Form("%1s:",beam);
233  if (v.numPostXTracks() < 10) os << Form("%i/",v.numPostXTracks());
234  else os << "*/";
235  if (v.numTracksWithPromptHit() < 10) os << Form("%i/",v.numTracksWithPromptHit());
236  else os << "*/";
237  if (v.numTracksCrossingCentralMembrane() < 10) os << Form("%i/",v.numTracksCrossingCentralMembrane());
238  else os << "*/";
239  if ((v.numMatchesWithCTB()+v.numMatchesWithBTOF()) < 10) os << Form("%i/",(v.numMatchesWithCTB()+v.numMatchesWithBTOF()));
240  else os << "*/";
241  if ((v.numMatchesWithBEMC()+v.numMatchesWithEEMC()) < 10) os << Form("%i/",(v.numMatchesWithBEMC()+v.numMatchesWithEEMC()));
242  else os << "*/";
243  if (v.numTracksTpcWestOnly() < 10) os << Form("%i/",v.numTracksTpcWestOnly());
244  else os << "*/";
245  if (v.numTracksTpcEastOnly() < 10) os << Form("%i",v.numTracksTpcEastOnly());
246  else os << "*";
247  const Float_t *xyz = v.position().xyz();
248  const Float_t *dxyz = v.positionError().xyz();
249  for (Int_t i = 0; i < 3; i++) os << Form("%8.3f+/-%5.3f,",xyz[i],dxyz[i]);
250  os << " Prob/Chi2: " << Form("%5.3f/%7.2f",v.probChiSquared(),v.chiSquared())
251  << " Rank: " << Form("%8.1f",v.ranking())
252  << Form(" U/T/G: %4i,%4i,%4i", v.numTracksUsedInFinder(),nDaughters,v.numberOfGoodTracks());
253  if (nTpcTracks != nDaughters || nGoodTpcTracks != v.numberOfGoodTracks()) {
254  os << Form(" TPC:%4i,%4i",nTpcTracks,nGoodTpcTracks);
255  }
256  if (v.idTruth())
257  os << Form(" IdT: %5i Q: %4i", v.idTruth(), v.qaTruth());
258  return os;
259 }
260 
Definition: beam.h:43