106 #include "StHbtMaker/Infrastructure/StHbtParticle.hh"
107 #include "math_constants.h"
114 double StHbtParticle::mPrimPimPar0= 9.05632e-01;
115 double StHbtParticle::mPrimPimPar1= -2.26737e-01;
116 double StHbtParticle::mPrimPimPar2= -1.03922e-01;
117 double StHbtParticle::mPrimPipPar0= 9.09616e-01;
118 double StHbtParticle::mPrimPipPar1= -9.00511e-02;
119 double StHbtParticle::mPrimPipPar2= -6.02940e-02;
120 double StHbtParticle::mPrimPmPar0= 0.;
121 double StHbtParticle::mPrimPmPar1= 0.;
122 double StHbtParticle::mPrimPmPar2= 0.;
123 double StHbtParticle::mPrimPpPar0= 0.;
124 double StHbtParticle::mPrimPpPar1= 0.;
125 double StHbtParticle::mPrimPpPar2= 0.;
135 StHbtParticle::StHbtParticle() : mTrack(0), mV0(0), mKink(0), mHiddenInfo(0) {
139 StHbtParticle::~StHbtParticle(){
142 if (mTrack)
delete mTrack;
144 delete[] mTpcV0NegPosSample;
150 if (mKink)
delete mKink;
159 StHbtParticle::StHbtParticle(
const StHbtTrack*
const hbtTrack,
const double& mass) : mTrack(0), mV0(0), mKink(0), mHiddenInfo(0) {
165 mFourMomentum.setVect(temp);
166 double ener = ::sqrt(temp.mag2()+mass*mass);
167 mFourMomentum.setE(ener);
168 mMap[0] = hbtTrack->TopologyMap(0);
169 mMap[1] = hbtTrack->TopologyMap(1);
170 mNhits = hbtTrack->NHits();
171 mHelix = hbtTrack->Helix();
175 mPrimaryVertex.setX(0.);
176 mPrimaryVertex.setY(0.);
177 mPrimaryVertex.setZ(0.);
178 mSecondaryVertex.setX(0.);
179 mSecondaryVertex.setY(0.);
180 mSecondaryVertex.setZ(0.);
182 CalculateTpcExitAndEntrancePoints(&mHelix,&mPrimaryVertex,
184 &mNominalTpcEntrancePoint,
185 &mNominalTpcExitPoint,
186 &mNominalPosSample[0],
194 if(hbtTrack->ValidHiddenInfo()){
195 mHiddenInfo= hbtTrack->getHiddenInfo()->getParticleHiddenInfo();
201 StHbtParticle::StHbtParticle(
const StHbtV0*
const hbtV0,
const double& mass) : mTrack(0), mV0(0), mKink(0), mHiddenInfo(0) {
207 mFourMomentum.setVect(temp);
208 double ener = ::sqrt(temp.mag2()+mass*mass);
209 mFourMomentum.setE(ener);
211 mPrimaryVertex = hbtV0->primaryVertex();
212 mSecondaryVertex = hbtV0->decayVertexV0();
213 mHelixV0Pos = hbtV0->HelixPos();
216 mV0NegZ =
new float[45];
217 mV0NegU =
new float[45];
218 mV0NegSect =
new int[45];
220 CalculateTpcExitAndEntrancePoints(&mHelixV0Pos,&mPrimaryVertex,
222 &mTpcV0PosEntrancePoint,
224 &mNominalPosSample[0],
228 mHelixV0Neg = hbtV0->HelixNeg();
230 CalculateTpcExitAndEntrancePoints(&mHelixV0Neg,
233 &mTpcV0NegEntrancePoint,
235 &mTpcV0NegPosSample[0],
237 &mV0NegU[0],&mV0NegSect[0]);
241 if(hbtV0->ValidHiddenInfo()){
242 mHiddenInfo= hbtV0->getHiddenInfo()->clone();
247 StHbtParticle::StHbtParticle(
const StHbtKink*
const hbtKink,
const double& mass) : mTrack(0), mV0(0), mHiddenInfo(0) {
253 mFourMomentum.setVect(temp);
254 double ener = ::sqrt(temp.mag2()+mass*mass);
255 mFourMomentum.setE(ener);
259 StHbtParticle::StHbtParticle(
const StHbtXi*
const hbtXi,
const double& mass) {
264 mFourMomentum.setVect(temp);
265 double ener = ::sqrt(temp.mag2()+mass*mass);
266 mFourMomentum.setE(ener);
273 return mNominalTpcExitPoint;
279 return mNominalTpcEntrancePoint;
459 void StHbtParticle::CalculatePurity(){
460 double tPt = mFourMomentum.perp();
462 mPurity[0] = mPrimPimPar0*(1.-exp((tPt-mPrimPimPar1)/mPrimPimPar2));
463 mPurity[0] *= mTrack->PidProbPion();
465 mPurity[1] = mPrimPipPar0*(1.-exp((tPt-mPrimPipPar1)/mPrimPipPar2));
466 mPurity[1] *= mTrack->PidProbPion();
468 mPurity[2] = mTrack->PidProbKaon();
470 mPurity[3] = mTrack->PidProbKaon();
472 mPurity[4] = mTrack->PidProbProton();
474 mPurity[5] = mTrack->PidProbProton();
477 double StHbtParticle::GetPionPurity()
479 if (mTrack->Charge()>0)
484 double StHbtParticle::GetKaonPurity()
486 if (mTrack->Charge()>0)
491 double StHbtParticle::GetProtonPurity()
493 if (mTrack->Charge()>0)
499 void StHbtParticle::CalculateTpcExitAndEntrancePoints(
StPhysicalHelixD* tHelix,
519 ZeroVec.setX(SecVert->x()-PrimVert->x());
520 ZeroVec.setY(SecVert->y()-PrimVert->y());
521 ZeroVec.setZ(SecVert->z()-PrimVert->z());
522 double dip, curv, phase;
524 curv = tHelix->curvature();
525 dip = tHelix->dipAngle();
526 phase= tHelix->
phase();
529 StHelixD hel(curv,dip,phase,ZeroVec,h);
535 candidates = hel.pathLength(200.0);
536 sideLength = (candidates.first > 0) ? candidates.first : candidates.second;
542 endLength = hel.pathLength(WestEnd,EndCapNormal);
543 if (endLength < 0.0) endLength = hel.pathLength(EastEnd,EndCapNormal);
545 if (endLength < 0.0) cout <<
546 "StHbtParticle::CalculateTpcExitAndEntrancePoints(): "
547 <<
"Hey -- I cannot find an exit point out endcaps" << endl;
549 double firstExitLength = (endLength < sideLength) ? endLength : sideLength;
551 *tmpTpcExitPoint = hel.at(firstExitLength);
553 candidates = hel.pathLength(50.0);
555 sideLength = (candidates.first > 0) ? candidates.first : candidates.second;
557 *tmpTpcEntrancePoint = hel.at(sideLength);
559 if (::isnan(tmpTpcEntrancePoint->x()) ||
560 ::isnan(tmpTpcEntrancePoint->y()) ||
561 ::isnan(tmpTpcEntrancePoint->z()) ){
562 cout <<
"tmpTpcEntrancePoint NAN"<< endl;
563 cout <<
"tmpNominalTpcEntrancePoint = " <<tmpTpcEntrancePoint<< endl;
564 tmpTpcEntrancePoint->setX(-9999.);
565 tmpTpcEntrancePoint->setY(-9999.);
566 tmpTpcEntrancePoint->setZ(-9999.);
569 if (::isnan(tmpTpcExitPoint->x()) ||
570 ::isnan(tmpTpcExitPoint->y()) ||
571 ::isnan(tmpTpcExitPoint->z()) ) {
576 tmpTpcExitPoint->setX(-9999.);
577 tmpTpcExitPoint->setY(-9999.);
578 tmpTpcExitPoint->setZ(-9999.);
592 candidates = hel.pathLength(50.0);
593 sideLength = (candidates.first > 0) ? candidates.first : candidates.second;
594 while (irad<11 && !::isnan(sideLength)){
595 float radius = 50.0 + irad*15.0;
596 candidates = hel.pathLength(radius);
597 sideLength = (candidates.first > 0) ? candidates.first : candidates.second;
598 tmpPosSample[irad] = hel.at(sideLength);
599 if(::isnan(tmpPosSample[irad].x()) ||
600 ::isnan(tmpPosSample[irad].y()) ||
601 ::isnan(tmpPosSample[irad].z())
603 cout <<
"tmpPosSample for radius=" << radius <<
" NAN"<< endl;
604 cout <<
"tmpPosSample=(" <<tmpPosSample[irad]<<
")"<< endl;
609 float radius = 50.0 + irad*15.0;
610 candidates = hel.pathLength(radius);
611 sideLength = (candidates.first > 0) ? candidates.first : candidates.second;
614 for (
int i = irad; i<11; i++)
619 static float tRowRadius[45] = {60,64.8,69.6,74.4,79.2,84,88.8,93.6,98.8,
620 104,109.2,114.4,119.6,127.195,129.195,131.195,
621 133.195,135.195,137.195,139.195,141.195,
622 143.195,145.195,147.195,149.195,151.195,
623 153.195,155.195,157.195,159.195,161.195,
624 163.195,165.195,167.195,169.195,171.195,
625 173.195,175.195,177.195,179.195,181.195,
626 183.195,185.195,187.195,189.195};
627 int tRow,tSect,tOutOfBound;
635 candidates = hel.pathLength(tRowRadius[ti]);
636 tLength = (candidates.first > 0) ? candidates.first : candidates.second;
637 if (::isnan(tLength)){
638 cout <<
"tLength Init tmp NAN" << endl;
639 cout <<
"padrow number= "<<ti <<
"not reached" << endl;
640 cout <<
"*** DO NOT ENTER THE LOOP***" << endl;
644 while(ti<45 && !::isnan(tLength)){
645 candidates = hel.pathLength(tRowRadius[ti]);
646 tLength = (candidates.first > 0) ? candidates.first : candidates.second;
647 if (::isnan(tLength)){
648 cout <<
"tLength loop 1st NAN" << endl;
649 cout <<
"padrow number= " << ti <<
" not reached" << endl;
650 cout <<
"*** THIS IS AN ERROR SHOULDN'T LOOP ***" << endl;
653 tPoint = hel.at(tLength);
655 TpcLocalTransform(tPoint,tmpSect[ti],tRow,tU,tPhi);
656 if (::isnan(tmpSect[ti])){
657 cout <<
"***ERROR tmpSect"<< endl;
660 cout <<
"***ERROR tRow"<< endl;
663 cout <<
"***ERROR tU"<< endl;
666 cout <<
"***ERROR tPhi"<< endl;
671 tr.setX(tRowRadius[ti]*cos(tPhi));
672 tr.setY(tRowRadius[ti]*sin(tPhi));
674 tLength = hel.pathLength(tr,tn);
675 if (::isnan(tLength)){
676 cout <<
"tLength loop 2nd NAN" << endl;
677 cout <<
"padrow number= " << ti <<
" not reached" << endl;
680 tPoint = hel.at(tLength);
681 tmpZ[ti] = tPoint.z();
682 tOutOfBound = TpcLocalTransform(tPoint,tSect,tRow,tmpU[ti],tPhi);
684 cout <<
"***ERROR tSect 2"<< endl;
687 cout <<
"***ERROR tRow 2"<< endl;
689 if (::isnan(tmpU[ti])){
690 cout <<
"***ERROR tmpU[ti] 2"<< endl;
693 cout <<
"***ERROR tPhi 2 "<< endl;
695 if(tOutOfBound || (tmpSect[ti] == tSect && tRow!=(ti+1))){
700 if(tmpSect[ti] != tSect){
704 tr.setX(tRowRadius[ti]*cos(tPhi));
705 tr.setY(tRowRadius[ti]*sin(tPhi));
707 tLength = hel.pathLength(tr,tn);
708 tPoint = hel.at(tLength);
709 if (::isnan(tLength)){
710 cout <<
"tLength loop 3rd NAN" << endl;
711 cout <<
"padrow number= "<< ti <<
" not reached" << endl;
714 tmpZ[ti] = tPoint.z();
716 tOutOfBound = TpcLocalTransform(tPoint,tSect,tRow,tmpU[ti],tPhi);
718 cout <<
"***ERROR tSect 3"<< endl;
721 cout <<
"***ERROR tRow 3"<< endl;
723 if (::isnan(tmpU[ti])){
724 cout <<
"***ERROR tmpU[ti] 3"<< endl;
727 cout <<
"***ERROR tPhi 3 "<< endl;
729 if(tOutOfBound || tSect!= tmpSect[ti] || tRow!=(ti+1)){
734 if (::isnan(tmpSect[ti])){
735 cout <<
"*******************ERROR***************************" << endl;
736 cout <<
"StHbtParticle--Fctn tmpSect=" << tmpSect[ti] << endl;
737 cout <<
"*******************ERROR***************************" << endl;
739 if (::isnan(tmpU[ti])){
740 cout <<
"*******************ERROR***************************" << endl;
741 cout <<
"StHbtParticle--Fctn tmpU=" << tmpU[ti] << endl;
742 cout <<
"*******************ERROR***************************" << endl;
744 if (::isnan(tmpZ[ti])){
745 cout <<
"*******************ERROR***************************" << endl;
746 cout <<
"StHbtParticle--Fctn tmpZ=" << tmpZ[ti] << endl;
747 cout <<
"*******************ERROR***************************" << endl;
751 if (tmpSect[ti]==-1){
752 for (
int tj=ti; tj<45;tj++){
759 candidates = hel.pathLength(tRowRadius[ti]);
760 tLength = (candidates.first > 0) ? candidates.first : candidates.second;}
765 return mTpcV0PosExitPoint;
769 return mTpcV0PosEntrancePoint;
773 return mTpcV0NegExitPoint;
777 return mTpcV0NegEntrancePoint;
int h() const
y-center of circle in xy-plane
double phase() const
1/R in xy-plane