NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcTrack.cxx
Go to the documentation of this file.
1
31
33
113
114#include "NcTrack.h"
115#include "Riostream.h"
116
117ClassImp(NcTrack); // Class implementation to enable ROOT I/O
118
121{
128
129 Init();
130 Reset();
131}
132
134{
140
141 fDecays=0;
142 fSignals=0;
143 fHypotheses=0;
144 fBegin=0;
145 fEnd=0;
146 fRef=0;
147 fImpactXY=0;
148 fImpactXZ=0;
149 fImpactYZ=0;
150 fClosest=0;
151 fParent=0;
152 fFit=0;
153 fTstamp=0;
154 fEscale=1;
155 fTemp=0;
156 fHypCopy=1;
157}
158
160{
169
170 Int_t nsig=GetNsignals();
171 for (Int_t i=1; i<=nsig; i++)
172 {
173 NcSignal* s=GetSignal(i);
174 if (s) s->RemoveTrack(*this,0);
175 }
176
177 Int_t nhyp=GetNhypotheses();
178 for (Int_t j=1; j<=nhyp; j++)
179 {
181 if (tx)
182 {
183 NcTrack* parent=tx->GetParentTrack();
184 if (parent==this) tx->SetParentTrack(0);
185 }
186 }
187
188 NcTrack* parent=GetParentTrack();
189 if (parent) parent->RemoveTrackHypothesis(*this);
190
191 if (fDecays)
192 {
193 delete fDecays;
194 fDecays=0;
195 }
196 if (fSignals)
197 {
198 delete fSignals;
199 fSignals=0;
200 }
201 if (fHypotheses)
202 {
203 delete fHypotheses;
204 fHypotheses=0;
205 }
206 if (fBegin)
207 {
208 delete fBegin;
209 fBegin=0;
210 }
211 if (fEnd)
212 {
213 delete fEnd;
214 fEnd=0;
215 }
216 if (fRef)
217 {
218 delete fRef;
219 fRef=0;
220 }
221 if (fImpactXY)
222 {
223 delete fImpactXY;
224 fImpactXY=0;
225 }
226 if (fImpactXZ)
227 {
228 delete fImpactXZ;
229 fImpactXZ=0;
230 }
231 if (fImpactYZ)
232 {
233 delete fImpactYZ;
234 fImpactYZ=0;
235 }
236 if (fClosest)
237 {
238 delete fClosest;
239 fClosest=0;
240 }
241 if (fFit)
242 {
243 delete fFit;
244 fFit=0;
245 }
246 if (fTstamp)
247 {
248 delete fTstamp;
249 fTstamp=0;
250 }
251 if (fTemp)
252 {
253 delete fTemp;
254 fTemp=0;
255 }
256}
257
258NcTrack::NcTrack(const NcTrack& t) : TNamed(t),Nc4Vector(t)
259{
265
266 Init();
267
268 fQ=t.fQ;
269 fProb=t.fProb;
270 if (t.fBegin) fBegin=new NcPositionObj(*(t.fBegin));
271 if (t.fEnd) fEnd=new NcPositionObj(*(t.fEnd));
272 if (t.fRef) fRef=new NcPositionObj(*(t.fRef));
276 if (t.fClosest) fClosest=new NcPositionObj(*(t.fClosest));
277 if (t.fFit) fFit=t.fFit->Clone();
278 if (t.fTstamp) fTstamp=new NcTimestamp(*(t.fTstamp));
281 fCode=t.fCode;
284
285 Int_t ndec=t.GetNdecay();
286 if (ndec)
287 {
288 fDecays=new TObjArray(ndec);
289 fDecays->SetOwner();
290 for (Int_t it=1; it<=ndec; it++)
291 {
292 NcTrack* tx=t.GetDecayTrack(it);
293 fDecays->Add(new NcTrack(*tx));
294 }
295 }
296
297 Int_t nsig=t.GetNsignals();
298 if (nsig)
299 {
300 fSignals=new TObjArray(nsig);
301 for (Int_t is=1; is<=nsig; is++)
302 {
303 NcSignal* sx=t.GetSignal(is);
304 fSignals->Add(sx);
305 }
306 }
307
308 Int_t nhyp=t.GetNhypotheses();
309 if (nhyp)
310 {
311 fHypotheses=new TObjArray(nhyp);
312 if (fHypCopy) fHypotheses->SetOwner();
313 for (Int_t ih=1; ih<=nhyp; ih++)
314 {
315 NcTrack* tx=t.GetTrackHypothesis(ih);
316 if (tx) AddTrackHypothesis(*tx);
317 }
318 }
319}
320
322{
332
333 fQ=0;
334 fUserId=0;
335 fCode=0;
336 fProb=0;
337 SetZero();
338 fParent=0;
339 if (fDecays)
340 {
341 delete fDecays;
342 fDecays=0;
343 }
344 if (fSignals)
345 {
346 delete fSignals;
347 fSignals=0;
348 }
349 if (fHypotheses)
350 {
351 delete fHypotheses;
352 fHypotheses=0;
353 }
354 if (fBegin)
355 {
356 delete fBegin;
357 fBegin=0;
358 }
359 if (fEnd)
360 {
361 delete fEnd;
362 fEnd=0;
363 }
364 if (fRef)
365 {
366 delete fRef;
367 fRef=0;
368 }
369 if (fImpactXY)
370 {
371 delete fImpactXY;
372 fImpactXY=0;
373 }
374 if (fImpactXZ)
375 {
376 delete fImpactXZ;
377 fImpactXZ=0;
378 }
379 if (fImpactYZ)
380 {
381 delete fImpactYZ;
382 fImpactYZ=0;
383 }
384 if (fClosest)
385 {
386 delete fClosest;
387 fClosest=0;
388 }
389 if (fFit)
390 {
391 delete fFit;
392 fFit=0;
393 }
394 if (fTstamp)
395 {
396 delete fTstamp;
397 fTstamp=0;
398 }
399}
400
402{
409
410 Set3Vector(p);
411 Double_t inv=GetInvariant();
412 if (inv<0) SetMass(0.);
413}
414
416{
422
423 Double_t E=p.GetScalar();
424 Double_t dE=p.GetResultError();
425 Nc3Vector pv=p.Get3Vector();
426 SetVector(E,pv);
427 SetScalarError(dE);
428}
429
430void NcTrack::SetMass(Double_t m,Double_t dm)
431{
438
439 Double_t inv=pow(m,2);
440 Double_t dinv=fabs(2.*m*dm);
441 SetInvariant(inv,dinv);
442}
443
444void NcTrack::SetCharge(Float_t q)
445{
451
452 fQ=q;
453}
454
455void NcTrack::Data(TString f,TString u)
456{
469
470 Double_t m=GetMass();
471 Double_t dm=GetResultError();
472 const char* name=GetName();
473 const char* title=GetTitle();
474
475 cout << " *" << ClassName() << "::Data*";
476 if (strlen(name)) cout << " Name : " << name;
477 if (strlen(title)) cout << " Title : " << title;
478 cout << endl;
479 if (fTstamp) fTstamp->Date(1);
480 cout << " Id : " << fUserId << " Code : " << fCode
481 << " m : " << m << " dm : " << dm << " Charge : " << fQ
482 << " p : " << GetMomentum() << endl;
483 cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
484 << " Nsignals : " << GetNsignals() << " Energy scale : " << fEscale << " GeV" << endl;
485 if (fParent)
486 {
487 cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode()
488 << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge()
489 << " p : " << fParent->GetMomentum();
490 const char* pname=fParent->GetName();
491 const char* ptitle=fParent->GetTitle();
492 if (strlen(pname)) cout << " Name : " << pname;
493 if (strlen(ptitle)) cout << " Title : " << ptitle;
494 cout << endl;
495 }
496 if (fFit)
497 {
498 cout << " Fit details present in object of class " << fFit->ClassName() << endl;
499 if (fFit->InheritsFrom("NcSignal")) ((NcSignal*)fFit)->List(-1);
500 }
501 Nc4Vector::Data(f,u);
502}
503
504void NcTrack::List(TString f,TString u)
505{
518
519 Data(f,u); // Information of the current track
520 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
521 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
522 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
523
524 // Decay products of this track
525 NcTrack* td;
526 for (Int_t id=1; id<=GetNdecay(); id++)
527 {
528 td=GetDecayTrack(id);
529 if (td)
530 {
531 cout << " ---Level 1 sec. track no. " << id << endl;
532 td->Data(f,u);
533 }
534 else
535 {
536 cout << " *NcTrack::List* Error : Empty decay track slot." << endl;
537 }
538 }
539}
540
541void NcTrack::ListAll(TString f,TString u)
542{
555
556 Data(f,u); // Information of the current track
557 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
558 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
559 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
560
561 Int_t nhyp=GetNhypotheses();
562 if (nhyp)
563 {
564 cout << " List of the " << nhyp << " track hypotheses : " << endl;
565 for (Int_t ih=1; ih<=nhyp; ih++)
566 {
568 if (tx) tx->Data(f,u);
569 }
570 }
571
572 ShowSignals("TObject",2,2,f,u);
573
574 NcTrack* t=this;
575 Dumps(t,1,f,u); // Information of all decay products
576}
577
578void NcTrack::Dumps(NcTrack* t,Int_t n,TString f,TString u)
579{
585
586 NcTrack* td;
587 for (Int_t id=1; id<=t->GetNdecay(); id++)
588 {
589 td=t->GetDecayTrack(id);
590 if (td)
591 {
592 cout << " ---Level " << n << " sec. track no. " << id << endl;
593 td->Data(f,u);
594
595 Int_t nhyp=td->GetNhypotheses();
596 if (nhyp)
597 {
598 cout << " List of the " << nhyp << " track hypotheses : " << endl;
599 for (Int_t ih=1; ih<=nhyp; ih++)
600 {
601 NcTrack* tx=td->GetTrackHypothesis(ih);
602 if (tx) tx->Data(f,u);
603 }
604 }
605
606 Int_t nsig=td->GetNsignals();
607 if (nsig)
608 {
609 cout << " List of the " << nsig << " related signals : " << endl;
610 for (Int_t is=1; is<=nsig; is++)
611 {
612 NcSignal* sx=td->GetSignal(is);
613 if (sx) sx->Data(f,u);
614 }
615 }
616
617 // Go for next decay level of this decay track recursively
618 Dumps(td,n+1,f,u);
619 }
620 else
621 {
622 cout << " *NcTrack::Dumps* Error : Empty decay track slot." << endl;
623 }
624 }
625}
626
627Double_t NcTrack::GetMomentum(Float_t scale)
628{
641
642 Double_t norm=fV.GetNorm();
643 fDresult=fV.GetResultError();
644 if (scale>0)
645 {
646 norm*=fEscale/scale;
647 fDresult*=fEscale/scale;
648 }
649 return norm;
650}
651
653{
665
667 if (scale>0) p*=fEscale/scale;
668 return p;
669}
670
671Double_t NcTrack::GetMass(Float_t scale)
672{
685
686 Double_t inv=GetInvariant();
687 Double_t dinv=GetResultError();
688 Double_t dm=0;
689 if (inv >= 0)
690 {
691 Double_t m=sqrt(inv);
692 if (m) dm=dinv/(2.*m);
693 if (scale>0)
694 {
695 m*=fEscale/scale;
696 dm*=fEscale/scale;
697 }
698 fDresult=dm;
699 return m;
700 }
701 else
702 {
703 cout << "*NcTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
704 cout << " Value 0 will be returned." << endl;
705 fDresult=dm;
706 return 0;
707 }
708}
709
710Float_t NcTrack::GetCharge() const
711{
717
718 return fQ;
719}
720
721Double_t NcTrack::GetEnergy(Float_t scale)
722{
735
736 Double_t E=GetScalar();
737 if (E>0)
738 {
739 if (scale>0)
740 {
741 E*=fEscale/scale;
742 fDresult*=fEscale/scale;
743 }
744 return E;
745 }
746 else
747 {
748 cout << "*NcTrack::GetEnergy* Unphysical situation E = " << E << endl;
749 cout << " Value 0 will be returned." << endl;
750 return 0;
751 }
752}
753
754void NcTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
755{
765
766 Double_t M=GetMass();
767
768// Compute the 4-momenta of the decay products in the cms
769// Note : p2=p1=pnorm for a 2-body decay
770 Double_t e1=0;
771 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
772 Double_t e2=0;
773 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
774 Double_t pnorm=(e1*e1)-(m1*m1);
775 if (pnorm>0.)
776 {
777 pnorm=sqrt(pnorm);
778 }
779 else
780 {
781 pnorm=0;
782 }
783
784 Double_t a[3];
785 a[0]=pnorm;
786 a[1]=thcms;
787 a[2]=phicms;
788 Nc3Vector p;
789 p.SetVector(a,"sph");
790
791 Nc4Vector pprim1;
792 pprim1.SetVector(e1,p);
793 pprim1.SetInvariant(m1*m1);
794
795 Nc4Vector pprim2;
796 p*=-1;
797 pprim2.SetVector(e2,p);
798 pprim2.SetInvariant(m2*m2);
799
800 // Determine boost parameters from the parent particle
801 Double_t E=GetEnergy();
802 p=Get3Vector();
803 Nc4Vector pmu;
804 pmu.SetVector(E,p);
805
806 NcBoost q;
807 q.Set4Momentum(pmu);
808
809 Nc4Vector p1=q.Inverse(pprim1); // Boost decay product 1
810 Nc4Vector p2=q.Inverse(pprim2); // Boost decay product 2
811
812 // Enter the boosted data into the decay tracks array
813 if (fDecays)
814 {
815 delete fDecays;
816 fDecays=0;
817 }
818 fDecays=new TObjArray(2);
819 fDecays->SetOwner();
820
821 fDecays->Add(new NcTrack);
822 ((NcTrack*)fDecays->At(0))->Set4Momentum(p1);
823 ((NcTrack*)fDecays->At(0))->SetMass(m1);
824 fDecays->Add(new NcTrack);
825 ((NcTrack*)fDecays->At(1))->Set4Momentum(p2);
826 ((NcTrack*)fDecays->At(1))->SetMass(m2);
827}
828
830{
836
837 Int_t ndec=0;
838 if (fDecays) ndec=fDecays->GetEntries();
839 return ndec;
840}
841
843{
850
851 if (!fDecays)
852 {
853 cout << " *NcTrack::GetDecayTrack* No tracks present." << endl;
854 return 0;
855 }
856 else
857 {
858 if ((j >= 1) && (j <= GetNdecay()))
859 {
860 return (NcTrack*)fDecays->At(j-1);
861 }
862 else
863 {
864 cout << " *NcTrack* decay track number : " << j << " out of range."
865 << " Ndec = " << GetNdecay() << endl;
866 return 0;
867 }
868 }
869}
870
872{
878
879 if (fDecays)
880 {
881 delete fDecays;
882 fDecays=0;
883 }
884}
885
886void NcTrack::AddSignal(NcSignal& s,Int_t mode)
887{
902
903 if (!fSignals) fSignals=new TObjArray(1);
904
905 // Check if this signal is already stored for this track
906 Int_t nsig=GetNsignals();
907 for (Int_t i=0; i<nsig; i++)
908 {
909 if (&s==fSignals->At(i)) return;
910 }
911
912 fSignals->Add(&s);
913 if (mode==1) s.AddTrack(*this,0);
914}
915
917{
932
933 if (fSignals)
934 {
935 NcSignal* test=(NcSignal*)fSignals->Remove(&s);
936 if (test) fSignals->Compress();
937 }
938 if (mode==1) s.RemoveTrack(*this,0);
939}
940
942{
956
957 if (!fSignals) return;
958
959 Int_t ns=GetNsignals();
960 for (Int_t i=0; i<ns; i++)
961 {
962 NcSignal* sx=(NcSignal*)fSignals->At(i);
963 if (sx && mode==1) sx->RemoveTrack(*this,0);
964 }
965
966 delete fSignals;
967 fSignals=0;
968}
969
971{
977
978 Int_t nsig=0;
979 if (fSignals) nsig=fSignals->GetEntries();
980 return nsig;
981}
982
983Int_t NcTrack::GetNsignals(const char* classname,Int_t par) const
984{
996
997 Int_t nsigs=0;
998 for (Int_t isig=1; isig<=GetNsignals(); isig++)
999 {
1000 NcSignal* sx=GetSignal(isig);
1001 if (!sx) continue;
1002
1003 if ((par==0 || par==2) && sx->InheritsFrom(classname))
1004 {
1005 nsigs++;
1006 continue;
1007 }
1008
1009 NcDevice* parent=sx->GetDevice();
1010 if (!parent) continue;
1011
1012 if ((par==1 || par==2) && parent->InheritsFrom(classname)) nsigs++;
1013 }
1014 return nsigs;
1015}
1016
1018{
1025
1026 if (!fSignals)
1027 {
1028 cout << " *NcTrack::GetSignal* No signals present." << endl;
1029 return 0;
1030 }
1031 else
1032 {
1033 if ((j >= 1) && (j <= GetNsignals()))
1034 {
1035 return (NcSignal*)fSignals->At(j-1);
1036 }
1037 else
1038 {
1039 cout << " *NcTrack* signal number : " << j << " out of range."
1040 << " Nsig = " << GetNsignals() << endl;
1041 return 0;
1042 }
1043 }
1044}
1045
1046TObjArray* NcTrack::GetSignals(const char* classname,Int_t par,TObjArray* signals)
1047{
1071
1072 if (signals)
1073 {
1074 signals->Clear();
1075 }
1076 else
1077 {
1078 if (fTemp)
1079 {
1080 fTemp->Clear();
1081 }
1082 else
1083 {
1084 fTemp=new TObjArray();
1085 }
1086 }
1087
1088 // Generic array pointer to be used in the logic below
1089 TObjArray* arr=0;
1090 if (signals)
1091 {
1092 arr=signals;
1093 }
1094 else
1095 {
1096 arr=fTemp;
1097 }
1098
1099 for (Int_t isig=1; isig<=GetNsignals(); isig++)
1100 {
1101 NcSignal* sx=GetSignal(isig);
1102 if (!sx) continue;
1103
1104 if ((par==0 || par==2) && sx->InheritsFrom(classname))
1105 {
1106 arr->Add(sx);
1107 continue;
1108 }
1109
1110 NcDevice* parent=sx->GetDevice();
1111 if (!parent) continue;
1112
1113 if ((par==1 || par==2) && parent->InheritsFrom(classname)) arr->Add(sx);
1114 }
1115
1116 if (signals)
1117 {
1118 return 0;
1119 }
1120 else
1121 {
1122 return fTemp;
1123 }
1124}
1125
1126void NcTrack::ShowSignals(const char* classname,Int_t par,Int_t mode,TString f,TString u)
1127{
1145
1146 TObjArray hits;
1147 GetSignals(classname,par,&hits);
1148
1149 Int_t nhits=hits.GetEntries();
1150
1151 cout << " *NcTrack::ShowSignals* There are " << nhits
1152 << " signals recorded for (device) class " << classname << endl;
1153
1154 if (!nhits || !mode) return;
1155
1156 NcPosition r;
1157 for (Int_t i=0; i<nhits; i++)
1158 {
1159 NcSignal* sx=(NcSignal*)hits.At(i);
1160 if (sx) sx->Data(f,u);
1161 if (mode==2)
1162 {
1163 NcDevice* dev=(NcDevice*)sx->GetDevice();
1164 if (!dev) continue;
1165 r=dev->GetPosition();
1166 cout << " Device Position";
1167 r.Data(f,u);
1168 }
1169 }
1170}
1171
1172Double_t NcTrack::GetSignalValue(TString classname,TString varname,Int_t mode,Int_t par)
1173{
1190
1191 TObjArray hits;
1192 GetSignals(classname.Data(),par,&hits);
1193
1194 Int_t nhits=hits.GetEntries();
1195
1196 if (!nhits) return 0;
1197
1198 Double_t val=0;
1199 for (Int_t i=0; i<nhits; i++)
1200 {
1201 NcSignal* sx=(NcSignal*)hits.At(i);
1202 if (!sx) continue;
1203 val+=sx->GetSignal(varname,mode);
1204 }
1205
1206 return val;
1207}
1208
1209void NcTrack::SetHypCopy(Int_t flag)
1210{
1232
1233 if (!fHypotheses)
1234 {
1235 if (flag==0 || flag==1)
1236 {
1237 fHypCopy=flag;
1238 }
1239 else
1240 {
1241 cout << " *" << ClassName() << "::SetHypCopy* Invalid argument : " << flag << endl;
1242 }
1243 }
1244}
1245
1247{
1265
1266 return fHypCopy;
1267}
1268
1270{
1282
1283 if (!fHypotheses)
1284 {
1285 fHypotheses=new TObjArray(1);
1286 if (fHypCopy) fHypotheses->SetOwner();
1287 }
1288
1289 t.SetParentTrack(this);
1290
1291 if (fHypCopy)
1292 {
1293 fHypotheses->Add(t.Clone());
1294 }
1295 else
1296 {
1297 fHypotheses->Add(&t);
1298 }
1299}
1300
1301void NcTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
1302{
1317
1318 NcTrack* t=new NcTrack(*this);
1319 t->RemoveDecays();
1321 t->RemoveSignals();
1322 t->SetTitle("Mass hypothesis");
1323 t->SetMass(m,dm);
1324 t->SetProb(prob);
1326 if (fHypCopy) delete t;
1327}
1328
1330{
1336
1337 if (fHypotheses)
1338 {
1339 NcTrack* test=(NcTrack*)fHypotheses->Remove(&t);
1340 if (test)
1341 {
1342 if (fHypCopy) delete test;
1343 fHypotheses->Compress();
1344 }
1345 }
1346}
1347
1349{
1355
1356 if (fHypotheses)
1357 {
1358 delete fHypotheses;
1359 fHypotheses=0;
1360 }
1361}
1362
1364{
1370
1371 Int_t nhyp=0;
1372 if (fHypotheses) nhyp=fHypotheses->GetEntries();
1373 return nhyp;
1374}
1375
1377{
1385
1386 if (!fHypotheses) return 0;
1387
1388 Int_t nhyp=GetNhypotheses();
1389
1390 // Check validity of index j
1391 if (j<0 || j>nhyp)
1392 {
1393 cout << " *NcTrack* hypothesis number : " << j << " out of range."
1394 << " Nhyp = " << nhyp << endl;
1395 return 0;
1396 }
1397
1398 NcTrack* t=0;
1399
1400 if (j==0) // Provide track hypothesis with highest probability
1401 {
1402 Float_t prob=0;
1403 t=(NcTrack*)fHypotheses->At(0);
1404 if (t) prob=t->GetProb();
1405 Float_t probx=0;
1406 for (Int_t ih=1; ih<nhyp; ih++)
1407 {
1408 NcTrack* tx=(NcTrack*)fHypotheses->At(ih);
1409 if (tx)
1410 {
1411 probx=tx->GetProb();
1412 if (probx > prob) t=tx;
1413 }
1414 }
1415 return t;
1416 }
1417 else // Provide requested j-th track hypothesis
1418 {
1419 return (NcTrack*)fHypotheses->At(j-1);
1420 }
1421}
1422
1424{
1430
1431 if (fBegin) delete fBegin;
1432 fBegin=new NcPositionObj(p);
1433}
1434
1436{
1442
1443 return fBegin;
1444}
1445
1447{
1453
1454 if (fEnd) delete fEnd;
1455 fEnd=new NcPositionObj(p);
1456}
1457
1459{
1465
1466 return fEnd;
1467}
1468
1470{
1480
1481 if (fRef) delete fRef;
1482 fRef=new NcPositionObj(p);
1483}
1484
1486{
1496
1497 return fRef;
1498}
1499
1501{
1507
1508 Double_t m=0,dm=0;
1509
1510 // Select mass hypothesis with highest probability
1512 if (t)
1513 {
1514 m=t->GetMass();
1515 dm=t->GetResultError();
1516 SetMass(m,dm);
1517 }
1518 else
1519 {
1520 cout << " *NcTrack::SetMass()* No hypothesis present => No action." << endl;
1521 }
1522}
1523
1524Double_t NcTrack::GetPt(Float_t scale)
1525{
1538
1539 Nc3Vector v;
1540 v=GetVecTrans();
1541 Double_t norm=v.GetNorm();
1543 if (scale>0)
1544 {
1545 norm*=fEscale/scale;
1546 fDresult*=fEscale/scale;
1547 }
1548
1549 return norm;
1550}
1551
1552Double_t NcTrack::GetPl(Float_t scale)
1553{
1567
1568 Nc3Vector v;
1569 v=GetVecLong();
1570
1571 Double_t pl=v.GetNorm();
1573
1574 Double_t a[3];
1575 v.GetVector(a,"sph");
1576 if (cos(a[1])<0) pl=-pl;
1577 if (scale>0)
1578 {
1579 pl*=fEscale/scale;
1580 fDresult*=fEscale/scale;
1581 }
1582
1583 return pl;
1584}
1585
1586Double_t NcTrack::GetEt(Float_t scale)
1587{
1600
1601 Double_t et=GetScaTrans();
1602 if (scale>0)
1603 {
1604 et*=fEscale/scale;
1605 fDresult*=fEscale/scale;
1606 }
1607
1608 return et;
1609}
1610
1611Double_t NcTrack::GetEl(Float_t scale)
1612{
1626
1627 Double_t el=GetScaLong();
1628 if (scale>0)
1629 {
1630 el*=fEscale/scale;
1631 fDresult*=fEscale/scale;
1632 }
1633
1634 return el;
1635}
1636
1637Double_t NcTrack::GetMt(Float_t scale)
1638{
1651
1652 Double_t pt=GetPt();
1653 Double_t dpt=GetResultError();
1654 Double_t m=GetMass();
1655 Double_t dm=GetResultError();
1656
1657 Double_t mt=sqrt(pt*pt+m*m);
1658 Double_t dmt2=0;
1659 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1660
1661 fDresult=sqrt(dmt2);
1662 if (scale>0)
1663 {
1664 mt*=fEscale/scale;
1665 fDresult*=fEscale/scale;
1666 }
1667 return mt;
1668}
1669
1671{
1681
1682 Double_t e=GetEnergy();
1683 Double_t de=GetResultError();
1684 Double_t pl=GetPl();
1685 Double_t dpl=GetResultError();
1686 Double_t sum=e+pl;
1687 Double_t dif=e-pl;
1688
1689 Double_t y=9999,dy2=0;
1690 if (sum && dif) y=0.5*log(sum/dif);
1691
1692 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1693
1694 fDresult=sqrt(dy2);
1695 return y;
1696}
1697
1699{
1708
1709 Int_t axis=0;
1710 if (q=="x" || q=="X") axis=1;
1711 if (q=="y" || q=="Y") axis=2;
1712 if (q=="z" || q=="Z") axis=3;
1713
1714 switch (axis)
1715 {
1716 case 1: // Impact-point in the plane X=0
1717 if (fImpactYZ) delete fImpactYZ;
1718 fImpactYZ=new NcPositionObj(p);
1719 break;
1720
1721 case 2: // Impact-point in the plane Y=0
1722 if (fImpactXZ) delete fImpactXZ;
1723 fImpactXZ=new NcPositionObj(p);
1724 break;
1725
1726 case 3: // Impact-point in the plane Z=0
1727 if (fImpactXY) delete fImpactXY;
1728 fImpactXY=new NcPositionObj(p);
1729 break;
1730
1731 default: // Unsupported axis
1732 cout << "*NcTrack::SetImpactPoint* Unsupported axis : " << q << endl
1733 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1734 break;
1735 }
1736}
1737
1739{
1748
1749 Int_t axis=0;
1750 if (q=="x" || q=="X") axis=1;
1751 if (q=="y" || q=="Y") axis=2;
1752 if (q=="z" || q=="Z") axis=3;
1753
1754 switch (axis)
1755 {
1756 case 1: // Impact-point in the plane X=0
1757 return fImpactYZ;
1758
1759 case 2: // Impact-point in the plane Y=0
1760 return fImpactXZ;
1761
1762 case 3: // Impact-point in the plane Z=0
1763 return fImpactXY;
1764
1765 default: // Unsupported axis
1766 cout << "*NcTrack::GetImpactPoint* Unsupported axis : " << q << endl
1767 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1768 return 0;
1769 }
1770}
1771
1772void NcTrack::SetId(Int_t id)
1773{
1779
1780 fUserId=id;
1781}
1782
1783Int_t NcTrack::GetId() const
1784{
1790
1791 return fUserId;
1792}
1793
1795{
1801
1802 if (fClosest) delete fClosest;
1803 fClosest=new NcPositionObj(p);
1804}
1805
1807{
1813
1814 return fClosest;
1815}
1816
1817void NcTrack::SetEscale(Float_t scale)
1818{
1830
1831 if (scale>0)
1832 {
1833 fEscale=scale;
1834 }
1835 else
1836 {
1837 cout << " *NcTrack::SetEscale* Invalid scale value : " << scale << endl;
1838 }
1839}
1840
1841Float_t NcTrack::GetEscale() const
1842{
1852
1853 return fEscale;
1854}
1855
1857{
1863
1864 fCode=code;
1865}
1866
1868{
1874
1875 return fCode;
1876}
1877
1879{
1885
1886 fParent=t;
1887}
1888
1890{
1896
1897 return fParent;
1898}
1899
1900void NcTrack::SetProb(Double_t prob)
1901{
1907
1908 fProb=prob;
1909}
1910
1911Float_t NcTrack::GetProb() const
1912{
1918
1919 return fProb;
1920}
1921
1922void NcTrack::SetFitDetails(TObject* obj)
1923{
1952
1953 if (fFit)
1954 {
1955 delete fFit;
1956 fFit=0;
1957 }
1958
1959 if (obj) fFit=obj->Clone();
1960}
1961
1963{
1969
1970 return fFit;
1971}
1972
1974{
1980
1981 if (fTstamp) delete fTstamp;
1982 fTstamp=new NcTimestamp(t);
1983}
1984
1986{
1992
1993 return fTstamp;
1994}
1995
1997{
2003
2004 if (fTstamp)
2005 {
2006 delete fTstamp;
2007 fTstamp=0;
2008 }
2009}
2010
2011Double_t NcTrack::GetDistance(NcPosition* p,Float_t scale)
2012{
2033
2034 Double_t dist=-1.;
2035 fDresult=0.;
2036
2037 if (!p) return dist;
2038
2039 // Obtain a defined position on this track
2040 NcPosition* rx=fRef;
2041 if (!rx) rx=fBegin;
2042 if (!rx) rx=fEnd;
2043
2044 if (!rx) return dist;
2045
2047
2048 if (p1.GetNorm() <= 0.) return dist;
2049
2050 Nc3Vector r0=(Nc3Vector)(*rx);
2051
2052 Float_t tscale=rx->GetUnitScale();
2053 Float_t pscale=p->GetUnitScale();
2054 if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
2055
2056 // Obtain the direction unit vector of this track
2057 Double_t vec[3];
2058 Double_t err[3];
2059 p1.GetVector(vec,"sph");
2060 p1.GetErrors(err,"sph");
2061 vec[0]=1.;
2062 err[0]=0.;
2063 p1.SetVector(vec,"sph");
2064 p1.SetErrors(err,"sph");
2065
2066 Nc3Vector q=(Nc3Vector)(*p);
2067 Nc3Vector r=q-r0;
2068 Nc3Vector d=r.Cross(p1);
2069 dist=d.GetNorm();
2071 if (scale>0)
2072 {
2073 dist*=pscale/scale;
2074 fDresult*=pscale/scale;
2075 }
2076 return dist;
2077}
2078
2079Double_t NcTrack::GetDistance(NcTrack* t,Float_t scale)
2080{
2103
2104 Double_t dist=-1.;
2105 fDresult=0.;
2106
2107 if (!t) return dist;
2108
2109 // Obtain a defined position on this track
2110 NcPosition* rx=fRef;
2111 if (!rx) rx=fBegin;
2112 if (!rx) rx=fEnd;
2113
2114 if (!rx) return dist;
2115
2116 // Obtain a defined position on track t
2118 if (!ry) ry=t->GetBeginPoint();
2119 if (!ry) ry=t->GetEndPoint();
2120
2121 if (!ry) return dist;
2122
2124 Nc3Vector p2=t->Get3Momentum();
2125
2126 if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
2127
2128 // The vector normal to both track directions
2129 Nc3Vector n=p1.Cross(p2);
2130
2131 Float_t scalex=rx->GetUnitScale();
2132 Float_t scaley=ry->GetUnitScale();
2133
2134 if (n.GetNorm() > 1.e-10)
2135 {
2136 // Normalise n to a unit vector
2137 Double_t vec[3];
2138 Double_t err[3];
2139 n.GetVector(vec,"sph");
2140 n.GetErrors(err,"sph");
2141 vec[0]=1.;
2142 err[0]=0.;
2143 n.SetVector(vec,"sph");
2144 n.SetErrors(err,"sph");
2145 Nc3Vector r1=(Nc3Vector)(*rx);
2146 Nc3Vector r2=(Nc3Vector)(*ry);
2147 // Correct components of r2 in case of different unit scales
2148 if ((scaley/scalex > 1.1) || (scalex/scaley > 1.1)) r2=r2*(scaley/scalex);
2149 Nc3Vector r=r1-r2;
2150 dist=fabs(r.Dot(n));
2151 fDresult=r.GetResultError();
2152 }
2153 else // Parallel tracks
2154 {
2155 dist=t->GetDistance(rx);
2157 }
2158
2159 if (scale>0)
2160 {
2161 dist*=scalex/scale;
2162 fDresult*=scalex/scale;
2163 }
2164 return dist;
2165}
2166
2167TObject* NcTrack::Clone(const char* name) const
2168{
2180
2181 NcTrack* trk=new NcTrack(*this);
2182 if (name)
2183 {
2184 if (strlen(name)) trk->SetName(name);
2185 }
2186 return trk;
2187}
2188
ClassImp(NcTrack)
Handling of 3-vectors in various reference frames.
Definition Nc3Vector.h:15
void GetErrors(Double_t *e, TString f, TString u="rad") const
void SetVector(Double_t *v, TString f, TString u="rad")
Nc3Vector Cross(Nc3Vector &q) const
void SetErrors(Double_t *e, TString f, TString u="rad")
Double_t GetResultError() const
void GetVector(Double_t *v, TString f, TString u="rad") const
Double_t GetNorm()
void SetInvariant(Double_t v2, Double_t dv2=0)
Double_t GetScaTrans()
virtual void SetZero()
Double_t GetScaLong()
void SetVector(Double_t v0, Nc3Vector &v)
Nc3Vector GetVecLong() const
Double_t GetResultError() const
Double_t GetInvariant()
virtual void Data(TString f="car", TString u="rad")
void Set3Vector(Nc3Vector &v)
Double_t GetScalar()
Nc3Vector GetVecTrans() const
Nc3Vector Get3Vector() const
Nc3Vector fV
Definition Nc4Vector.h:74
void SetScalarError(Double_t dv0)
Double32_t fDresult
! The error on the scalar result of an operation (e.g. dotproduct)
Definition Nc4Vector.h:77
Perform various Lorentz transformations.
Definition NcBoost.h:17
Nc4Vector Inverse(Nc4Vector &v)
Definition NcBoost.cxx:325
void Set4Momentum(Nc4Vector &p)
Definition NcBoost.cxx:154
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
Handling of positions (with timestamps) in various reference frames.
Definition NcPosition.h:18
void GetPosition(Double_t *r, TString f, TString u="rad", Float_t s=-1) const
Float_t GetUnitScale() const
virtual void Data(TString f="car", TString u="rad") const
Handling of positions in various reference frames.
Generic handling of (extrapolated) detector signals.
Definition NcSignal.h:23
NcDevice * GetDevice() const
void RemoveTrack(NcTrack &t, Int_t mode=1)
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
void AddTrack(NcTrack &t, Int_t mode=1)
virtual void Data(TString f="car", TString u="rad") const
Definition NcSignal.cxx:959
Handling of timestamps for (astro)particle physics research.
Definition NcTimestamp.h:20
Handling of the attributes of a reconstructed particle track.
Definition NcTrack.h:19
Int_t GetHypCopy() const
Definition NcTrack.cxx:1246
NcPosition * GetEndPoint()
Definition NcTrack.cxx:1458
NcPosition * GetBeginPoint()
Definition NcTrack.cxx:1435
void Set4Momentum(Nc4Vector &p)
Definition NcTrack.cxx:415
Double_t GetEt(Float_t scale=-1)
Definition NcTrack.cxx:1586
void RemoveSignals(Int_t mode=1)
Definition NcTrack.cxx:941
TObjArray * fTemp
! Temporary storage for exchange of object pointers
Definition NcTrack.h:117
virtual void ListAll(TString f="car", TString u="rad")
Definition NcTrack.cxx:541
NcTrack * GetTrackHypothesis(Int_t j=0) const
Definition NcTrack.cxx:1376
NcTrack * GetDecayTrack(Int_t j) const
Definition NcTrack.cxx:842
virtual void List(TString f="car", TString u="rad")
Definition NcTrack.cxx:504
void SetCharge(Float_t q)
Definition NcTrack.cxx:444
void SetBeginPoint(NcPosition &p)
Definition NcTrack.cxx:1423
NcPosition * GetImpactPoint(TString q)
Definition NcTrack.cxx:1738
void AddTrackHypothesis(NcTrack &t)
Definition NcTrack.cxx:1269
NcPositionObj * fImpactYZ
Definition NcTrack.h:108
TObjArray * fHypotheses
Definition NcTrack.h:102
NcPositionObj * fImpactXZ
Definition NcTrack.h:107
Double_t GetRapidity()
Definition NcTrack.cxx:1670
void RemoveDecays()
Definition NcTrack.cxx:871
TObjArray * fSignals
Definition NcTrack.h:101
NcTimestamp * GetTimestamp()
Definition NcTrack.cxx:1985
Float_t fProb
Definition NcTrack.h:113
void SetEndPoint(NcPosition &p)
Definition NcTrack.cxx:1446
NcPositionObj * fImpactXY
Definition NcTrack.h:106
NcTrack * GetParentTrack()
Definition NcTrack.cxx:1889
void SetReferencePoint(NcPosition &p)
Definition NcTrack.cxx:1469
NcTrack * fParent
Definition NcTrack.h:112
Int_t fHypCopy
Definition NcTrack.h:118
void SetMass(Double_t m, Double_t dm=0)
Definition NcTrack.cxx:430
virtual TObject * Clone(const char *name="") const
Definition NcTrack.cxx:2167
Int_t GetId() const
Definition NcTrack.cxx:1783
Double_t GetPl(Float_t scale=-1)
Definition NcTrack.cxx:1552
NcSignal * GetSignal(Int_t j) const
Definition NcTrack.cxx:1017
Int_t GetNdecay() const
Definition NcTrack.cxx:829
void RemoveTimestamp()
Definition NcTrack.cxx:1996
Int_t GetParticleCode() const
Definition NcTrack.cxx:1867
Int_t GetNsignals() const
Definition NcTrack.cxx:970
void Decay(Double_t m1, Double_t m2, Double_t thcms, Double_t phicms)
Definition NcTrack.cxx:754
TObjArray * fDecays
Definition NcTrack.h:100
NcPositionObj * fBegin
Definition NcTrack.h:103
Double_t GetDistance(NcPosition *p, Float_t scale=-1)
Definition NcTrack.cxx:2011
void SetParticleCode(Int_t code)
Definition NcTrack.cxx:1856
Double_t GetEl(Float_t scale=-1)
Definition NcTrack.cxx:1611
void Dumps(NcTrack *t, Int_t n, TString f, TString u)
Definition NcTrack.cxx:578
virtual void Data(TString f="car", TString u="rad")
Definition NcTrack.cxx:455
NcPosition * GetClosestPoint()
Definition NcTrack.cxx:1806
void RemoveTrackHypothesis(NcTrack &t)
Definition NcTrack.cxx:1329
void AddSignal(NcSignal &s, Int_t mode=0)
Definition NcTrack.cxx:886
NcPositionObj * fClosest
Definition NcTrack.h:110
void Set3Momentum(Nc3Vector &p)
Definition NcTrack.cxx:401
void SetProb(Double_t prob)
Definition NcTrack.cxx:1900
Float_t GetProb() const
Definition NcTrack.cxx:1911
Double_t GetEnergy(Float_t scale=-1)
Definition NcTrack.cxx:721
NcPositionObj * fEnd
Definition NcTrack.h:104
void SetFitDetails(TObject *obj)
Definition NcTrack.cxx:1922
NcPosition * GetReferencePoint()
Definition NcTrack.cxx:1485
Double_t GetMass(Float_t scale=-1)
Definition NcTrack.cxx:671
void SetMass()
Definition NcTrack.cxx:1500
void Init()
Definition NcTrack.cxx:133
Int_t fUserId
Definition NcTrack.h:109
Int_t fCode
Definition NcTrack.h:111
void ShowSignals(const char *classname, Int_t par=0, Int_t mode=1, TString f="car", TString u="rad")
Definition NcTrack.cxx:1126
Int_t GetNhypotheses() const
Definition NcTrack.cxx:1363
virtual void Reset()
Definition NcTrack.cxx:321
Nc3Vector Get3Momentum(Float_t scale=-1) const
Definition NcTrack.cxx:652
Double_t GetSignalValue(TString classname, TString varname, Int_t mode=0, Int_t par=2)
Definition NcTrack.cxx:1172
virtual ~NcTrack()
Definition NcTrack.cxx:159
Double_t GetMt(Float_t scale=-1)
Definition NcTrack.cxx:1637
Float_t GetEscale() const
Definition NcTrack.cxx:1841
TObject * GetFitDetails()
Definition NcTrack.cxx:1962
Float_t fQ
Definition NcTrack.h:99
NcPositionObj * fRef
Definition NcTrack.h:105
NcTimestamp * fTstamp
Definition NcTrack.h:115
TObjArray * GetSignals(const char *classname, Int_t par=0, TObjArray *signals=0)
Definition NcTrack.cxx:1046
Float_t fEscale
Definition NcTrack.h:116
void SetHypCopy(Int_t flag)
Definition NcTrack.cxx:1209
Float_t GetCharge() const
Definition NcTrack.cxx:710
Double_t GetPt(Float_t scale=-1)
Definition NcTrack.cxx:1524
void RemoveTrackHypotheses()
Definition NcTrack.cxx:1348
void SetClosestPoint(NcPosition &p)
Definition NcTrack.cxx:1794
void SetImpactPoint(NcPosition &p, TString q)
Definition NcTrack.cxx:1698
void SetId(Int_t id)
Definition NcTrack.cxx:1772
void RemoveSignal(NcSignal &s, Int_t mode=1)
Definition NcTrack.cxx:916
Double_t GetMomentum(Float_t scale=-1)
Definition NcTrack.cxx:627
TObject * fFit
Definition NcTrack.h:114
void SetParentTrack(NcTrack *t)
Definition NcTrack.cxx:1878
void SetTimestamp(NcTimestamp &t)
Definition NcTrack.cxx:1973
void SetEscale(Float_t scale)
Definition NcTrack.cxx:1817