2 #include "StKFVertex.h"
8 #define PrPP(A,B) if (Debug()) {cout << "StKFVertex::" << (#A) << "\t" << (#B) << " = \t" << (B) << endl;}
13 Int_t StKFVertex::_debug = 0;
14 const Char_t *StKFVertex::GeNames[52] = {
17 "gamma" ,
"e+" ,
"e-" ,
"nu" ,
"mu+" ,
"mu-" ,
"pi0" ,
"pi+" ,
"pi-" ,
"K0L",
18 "K+" ,
"K-" ,
"N" ,
"P" ,
"Pbar" ,
"K0S" ,
"eta" ,
"Lambda",
"Sigma+" ,
"Sigma0",
19 "S-" ,
"Xi0" ,
"Xi-" ,
"Omega",
"Nbar" ,
"LamBar",
"SBar-",
"SBar0" ,
"SBar+" ,
"XiBar0",
20 "XiBar+" ,
"OmBar",
"tau+",
"tau-" ,
"D+" ,
"D-" ,
"D0" ,
"Dbar0" ,
"Ds+" ,
"Ds-" ,
21 "LambC+" ,
"W+" ,
"W-" ,
"Z0" ,
"H2" ,
"H3" ,
"alpha",
"geanti",
"He3" ,
"Cerenk",
24 ostream& operator<<(ostream& os,
const StKFVertex& v) {
25 Int_t iWest = v.MultW();
26 Int_t iEast = v.MultE();
27 os << Form(
" with %4i tracks Q:%3i W/E = %3i/%3i",v.NoTracks(),v.Charge(),iWest,iEast);
28 for (Int_t i = 0; i < 3; i++) {
29 os << Form(
"%9.3f +/- %5.3f",v.Vertex().GetParameter(i),TMath::Sqrt(v.Vertex().GetCovariance(i,i)));
31 Double_t prob = TMath::Prob(v.Vertex().GetChi2(),v.Vertex().GetNDF());
32 os << Form(
"\tchi2/NDF = %8.2f/%4i",v.Vertex().GetChi2(),v.Vertex().GetNDF())
33 << Form(
" prob = %6.4f",prob);
35 if (! v.Vertex().GetMass(M,dM)) {
36 os <<
" M = " << Form(
"%7.3f +/- %5.3f",M,dM);
38 Int_t kv = v.IdTruth();
40 os << Form(
" Mc/QA/t:%4i/%3i/%6.0f xyz: %8.3f%8.3f%8.3f m:%4i %6s",kv, v.QaTruth(),
41 v.TimeMc(), v.XyzMc().X(), v.XyzMc().Y(), v.XyzMc().Z(),
42 v.NoDaughtersMc(),StKFVertex::StKFVertex::GeNames[v.gePidMc()]);
47 void StKFVertex::Fit() {
52 for (Int_t i = 0; i < N; i++) {
54 particles[i] = &(
Track(i)->Particle());
58 (Bool_t*) Flag.GetArray(),TMath::Sqrt(StAnneling::Chi2Cut()/2));
62 if (CL[0] <= 0 || CL[2] <= 0 || CL[5] <= 0) {
63 for (Int_t i = N-1; i >= 0; i--)
delete Remove(i);
65 for (Int_t i = N-1; i >= 0; i--)
if (! Flag[i])
delete Remove(i);
75 static vertexPing candidates[20];
76 memset(candidates,0,
sizeof(candidates));
78 for (Int_t i = 0; i < N; i++) {
80 if (! pTrack)
continue;
81 Int_t IdVx = pTrack->Particle().IdParentVx();
82 if (IdVx <= 0)
continue;
84 for (Int_t j = 0; j < NC; j++)
if (candidates[j].Id == IdVx) {J = j;
break;}
85 if (J < 0) {J = NC;
if (NC < 18) NC++;}
86 candidates[J].Id = IdVx;
87 candidates[J].nPings++;
91 for (Int_t j = 0; j < NC; j++)
if (candidates[j].nPings > dominant) {dominant = candidates[j].nPings; J = j;}
93 Int_t Id = candidates[J].Id;
94 Int_t QA = (100*dominant)/N;
97 for (Int_t i = 0; i < N; i++) {
103 Int_t k2 = track->K()%100000;
104 Int_t N1 = NoTracks();
105 for (Int_t j = 0; j < N1; j++) {
107 Int_t k1 = t1->K()%100000;
113 fKFTracks.AddLast((TObject *)track);
116 Double_t StKFVertex::UpdateVertex2TrackChi2() {
117 Int_t Ntracks = NoTracks();
119 PrPP(UpdateVertex2TrackChi2,fVertex);
120 if (_debug) PrintW(
"old Weghts ");
121 for (Int_t k = Ntracks - 1; k >= 0; k--) {
126 vTmp -= track.Particle();
129 if (! particle)
continue;
131 Double_t chi2il = particle->GetDeviationFromVertex(vTmp);
133 if (chi2il > StAnneling::Chi2Cut()) {
137 track.SetChi2(chi2il);
138 chi2Vx += track.Chi2()/2 + TMath::Log(track.Weight() + StAnneling::Weight());
141 if (_debug) PrintW(
"new Weights ");
146 Int_t N = NoTracks();
147 for (Int_t k = 0; k < N; k++)
if (particle ==
Track(k)->OrigParticle())
return Remove(k);
151 Int_t StKFVertex::MultWE(Int_t k)
const {
152 Int_t N = NoTracks();
154 for (Int_t i = 0; i < N; i++) {
157 Int_t
id = (t->OrigParticle()->GetID()/100000)%10;
164 Int_t StKFVertex::Q()
const {
166 Int_t N = NoTracks();
167 for (Int_t i = 0; i < N; i++) {
169 if (t) {iQ += t->OrigParticle()->GetQ();}
174 void StKFVertex::operator +=(
StKFVertex &vtx) {
176 PrintW(
"Before Merge 1");
177 vtx.PrintW(
"Before Merge 2");
179 Int_t N2 = vtx.NoTracks();
180 for (Int_t i = N2-1; i >= 0; i--) {
182 Int_t k2 = t2->K()%100000;
183 Int_t N1 = NoTracks();
184 for (Int_t j = 0; j < N1; j++) {
186 Int_t k1 = t1->K()%100000;
187 if (k1 == k2) {SafeDelete(t2);
break;}
189 if (t2) fKFTracks.AddLast(t2);
193 PrintW(
"After Merge 1");
194 vtx.PrintW(
"After Merge 2");
198 void StKFVertex::PrintW(Option_t *option)
const {
199 Int_t N = NoTracks();
200 cout << Form(
"Vertex %5i with %5i tracks\t",fID,N);
202 cout << Form(
" i k Weight W Z chi2") << endl;
203 for (Int_t i = 0; i < N; i++) {
205 cout << Form(
"%6i",i) << *t << endl;
209 void StKFVertex::SetMc(Float_t time, Float_t x, Float_t y, Float_t z, Int_t NoDaughters, Int_t gePid) {
211 fXyzMc = TVector3(x,y,z);
212 fNoDaughtersMc = NoDaughters;
213 fgePidMc = StKFTrack::CorrectGePid(gePid);