00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #include <algorithm>
00057 #include "Riostream.h"
00058 #include "TClass.h"
00059 #include "TFile.h"
00060 #include "StVertex.h"
00061 #include "StTrack.h"
00062 #include "StG2TrackVertexMap.h"
00063 #include "TString.h"
00064 #if !defined(ST_NO_NAMESPACES)
00065 using std::fill_n;
00066 using std::copy;
00067 #endif
00068
00069 ClassImp(StVertex)
00070
00071 static const char rcsid[] = "$Id: StVertex.cxx,v 2.13 2012/05/07 14:42:58 fisyak Exp $";
00072 UInt_t StVertex::fgNoFitPointCutForGoodTrack = 15;
00073 StVertex::StVertex()
00074 {
00075 mType = kUndefinedVtxId;
00076 memset(mBeg, 0, mEnd-mBeg+1);
00077 }
00078
00079 Int_t
00080 StVertex::operator==(const StVertex& v) const
00081 {
00082 return mType == v.mType &&
00083 mFlag == v.mFlag &&
00084 mPosition == v.mPosition &&
00085 mChiSquared == v.mChiSquared;
00086 }
00087
00088 Int_t
00089 StVertex::operator!=(const StVertex& v) const
00090 {
00091 return !(v == *this);
00092 }
00093
00094 StMatrixF
00095 StVertex::covariantMatrix() const
00096 {
00097 StMatrixF m(3,3);
00098 m(1,1) = mCovariantMatrix[0];
00099 m(1,2) = m(2,1) = mCovariantMatrix[1];
00100 m(2,2) = mCovariantMatrix[2];
00101 m(1,3) = m(3,1) = mCovariantMatrix[3];
00102 m(2,3) = m(3,2) = mCovariantMatrix[4];
00103 m(3,3) = mCovariantMatrix[5];
00104 return m;
00105 }
00106
00107 StThreeVectorF
00108 StVertex::positionError() const
00109 {
00110 return StThreeVectorF(::sqrt(mCovariantMatrix[0]), ::sqrt(mCovariantMatrix[2]), ::sqrt(mCovariantMatrix[5]));
00111 }
00112
00113 void StVertex::setParent(StTrack* val) { mParent = val; }
00114 void StVertex::setCovariantMatrix(float val[6]) { copy(val, val+6, mCovariantMatrix); }
00115
00116 void StVertex::Streamer(TBuffer &R__b)
00117 {
00118
00119
00120 if (R__b.IsReading()) {
00121 UInt_t R__s, R__c;
00122 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00123 if (R__v > 1) {
00124 Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
00125 return;
00126 }
00127
00128 StMeasuredPoint::Streamer(R__b);
00129 R__b >> (Int_t&)mType;
00130 R__b >> mFlag;
00131 Int_t dumy;
00132 if (gFile && gFile->GetVersion() < 30000) {R__b >> dumy;}
00133 R__b.ReadFastArray(mCovariantMatrix,6);
00134 R__b >> mChiSquared;
00135 R__b >> mProbChiSquared;
00136
00137 R__b >> (StTrack*&)mParent;
00138
00139 R__b.CheckByteCount(R__s, R__c, Class());
00140
00141
00142 } else {
00143 Class()->WriteBuffer(R__b,this);
00144 }
00145 }
00146
00147 void StVertex::setIdTruth() {
00148 typedef std::map< Int_t,Float_t> myMap_t;
00149 typedef std::pair<Int_t,Float_t> myPair_t;
00150 typedef myMap_t::const_iterator myIter_t;
00151 myMap_t idTruths;
00152
00153 UInt_t Ntracks = numberOfDaughters();
00154 Int_t IdVx = 0;
00155 Int_t qa = 0;
00156 for (UInt_t l = 0; l < Ntracks; l++) {
00157 const StTrack *pTrack = daughter(l);
00158 if (! pTrack) continue;
00159 Int_t IdTk = pTrack->idTruth();
00160 if (IdTk <= 0) continue;
00161 IdVx = pTrack->idParentVx();
00162 if (IdVx <= 0) continue;
00163 qa = pTrack->qaTruth(); if (!qa) qa = 1;
00164 idTruths[IdVx] += qa;
00165 }
00166 if (! idTruths.size()) return;
00167 Int_t vxBest = 0;
00168 Float_t qaBest = 0, qaSum = 0;
00169 for (myIter_t it=idTruths.begin(); it!=idTruths.end(); ++it) {
00170 qaSum += (*it).second;
00171 if ((*it).second < qaBest) continue;
00172 vxBest = (*it).first; qaBest = (*it).second;
00173 }
00174 if (vxBest <= 0 || vxBest > 0xffff) return;
00175 Int_t avgQua = 100*qaBest/(qaSum+1e-10)+0.5;
00176 setIdTruth(vxBest,avgQua);
00177 Int_t IdParentTk = StG2TrackVertexMap::instance()->IdParentTrack(vxBest);
00178 setIdParent(IdParentTk);
00179 }
00180
00181 void StVertex::NotImplemented(const Char_t *method) const {
00182 cout << "StVertex::" << method << " is no implemented" << endl;
00183 }
00184
00185