10 #include "StMuException.hh"
11 #include "StEvent/StEventTypes.h"
12 #include "StEvent/StTrackGeometry.h"
13 #include "StEvent/StPrimaryVertex.h"
14 #include "StEvent/StDcaGeometry.h"
16 #include "StEvent/StBTofHit.h"
17 #include "StEvent/StBTofPidTraits.h"
18 #include "StEvent/StETofHit.h"
19 #include "StEvent/StETofPidTraits.h"
20 #include "StEvent/StMtdHit.h"
21 #include "StEvent/StMtdPidTraits.h"
22 #include "StarClassLibrary/SystemOfUnits.h"
23 #include "StEvent/StTpcDedxPidAlgorithm.h"
24 #include "StarClassLibrary/StThreeVectorD.hh"
25 #include "StarClassLibrary/StPhysicalHelixD.hh"
26 #include "StarClassLibrary/StParticleTypes.hh"
27 #include "StEventUtilities/StuProbabilityPidAlgorithm.h"
28 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
29 #include "StEmcUtil/projection/StEmcPosition.h"
30 #include "StEmcUtil/geometry/StEmcGeom.h"
31 #include "StBichsel/Bichsel.h"
32 #include "StBichsel/StdEdxModel.h"
33 #include "THelixTrack.h"
47 mId(0), mType(0), mFlag(0), mFlagExtension(0), mIndex2Global(index2Global), mIndex2RichSpectra(index2RichSpectra), mNHits(0), mNHitsPoss(0), mNHitsDedx(0),mNHitsFit(0),
48 mPidProbElectron(0), mPidProbPion(0),mPidProbKaon(0),mPidProbProton(0),
50 mdEdx(0.), mPt(0.), mEta(0.), mPhi(0.), mIndex2Cov(-1), mIdTruth(0), mQuality(0), mIdParentVx(0)
55 mType = track->type();
56 mFlag = track->flag();
57 mFlagExtension = track->flagExtension();
58 mTopologyMap = track->topologyMap();
59 mIdTruth = track->idTruth();
60 mQuality = track->qaTruth();
61 mIdParentVx = track->idParentVx();
66 static StElectron* Electron = StElectron::instance();
67 static StPionPlus* Pion = StPionPlus::instance();
68 static StKaonPlus* Kaon = StKaonPlus::instance();
69 static StProton* Proton = StProton::instance();
72 mNSigmaElectron = pack2Int( fabsMin(PidAlgorithm.numberOfSigma(Electron),__SIGMA_SCALE__), __SIGMA_SCALE__ );
73 mNSigmaPion = pack2Int( fabsMin(PidAlgorithm.numberOfSigma(Pion),__SIGMA_SCALE__), __SIGMA_SCALE__ );
74 mNSigmaKaon = pack2Int( fabsMin(PidAlgorithm.numberOfSigma(Kaon),__SIGMA_SCALE__), __SIGMA_SCALE__ );
75 mNSigmaProton = pack2Int( fabsMin(PidAlgorithm.numberOfSigma(Proton),__SIGMA_SCALE__), __SIGMA_SCALE__ );
80 mNSigmaElectron = int(__NOVALUE__*__SIGMA_SCALE__);
81 mNSigmaPion = int(__NOVALUE__*__SIGMA_SCALE__);
82 mNSigmaKaon = int(__NOVALUE__*__SIGMA_SCALE__);
83 mNSigmaProton = int(__NOVALUE__*__SIGMA_SCALE__);
87 if ( PidAlgorithm.traits() ) {
88 mdEdx = PidAlgorithm.traits()->mean();
89 mNHitsDedx = PidAlgorithm.traits()->numberOfPoints();
93 if ( track->detectorInfo() ) {
94 mFirstPoint = track->detectorInfo()->firstPoint();
95 mLastPoint = track->detectorInfo()->lastPoint();
96 mNHits = track->detectorInfo()->numberOfPoints();
99 mNHitsPoss = track->numberOfPossiblePoints();
103 if (track->numberOfPossiblePoints(kTpcId)==track->numberOfPossiblePoints(kFtpcEastId)) {
105 if (track->topologyMap().hasHitInDetector(kTpcId))
106 mNHitsPossTpc=track->numberOfPossiblePoints(kTpcId);
107 else if (track->topologyMap().hasHitInDetector(kFtpcEastId))
108 mNHitsPossTpc=(1 << 6) + track->numberOfPossiblePoints(kFtpcEastId);
109 else if (track->topologyMap().hasHitInDetector(kFtpcWestId))
110 mNHitsPossTpc=(2 << 6) + track->numberOfPossiblePoints(kFtpcWestId);
113 if ( (tpc_hits=track->numberOfPossiblePoints(kTpcId)) )
114 mNHitsPossTpc=tpc_hits;
115 else if ( (tpc_hits=track->numberOfPossiblePoints(kFtpcEastId)) )
116 mNHitsPossTpc=(1 << 6) + tpc_hits;
117 else if ( (tpc_hits=track->numberOfPossiblePoints(kFtpcWestId)) )
118 mNHitsPossTpc=(2 << 6) + tpc_hits;
121 mNHitsPossInner=track->numberOfPossiblePoints(kSvtId) & 0x7;
122 if (! mNHitsPossInner) mNHitsPossInner=track->numberOfPossiblePoints(kIstId) & 0x7;
123 mNHitsPossInner|=(track->numberOfPossiblePoints(kSsdId) & 0x3) << 3;
124 mNHitsPossInner|=(track->numberOfPossiblePoints(kPxlId) & 0x7) << 5;
126 mNHitsFit = track->fitTraits().numberOfFitPoints();
128 if (track->numberOfPossiblePoints(kTpcId)==track->numberOfPossiblePoints(kFtpcEastId)) {
130 if (track->topologyMap().hasHitInDetector(kTpcId))
131 mNHitsFitTpc=track->fitTraits().numberOfFitPoints(kTpcId);
132 else if (track->topologyMap().hasHitInDetector(kFtpcEastId))
133 mNHitsFitTpc=(1 << 6) + track->fitTraits().numberOfFitPoints(kFtpcEastId);
134 else if (track->topologyMap().hasHitInDetector(kFtpcWestId))
135 mNHitsFitTpc=(2 << 6) + track->fitTraits().numberOfFitPoints(kFtpcWestId);
138 if ( (tpc_hits=track->fitTraits().numberOfFitPoints(kTpcId)) )
139 mNHitsFitTpc=tpc_hits;
140 else if ( (tpc_hits=track->fitTraits().numberOfFitPoints(kFtpcEastId)) )
141 mNHitsFitTpc=(1 << 6) + tpc_hits;
142 else if ( (tpc_hits=track->fitTraits().numberOfFitPoints(kFtpcWestId)) )
143 mNHitsFitTpc=(2 << 6) + tpc_hits;
145 mNHitsFitInner=track->fitTraits().numberOfFitPoints(kSvtId) & 0x7;
146 if (! mNHitsFitInner) mNHitsFitInner=track->fitTraits().numberOfFitPoints(kIstId) & 0x7;
147 mNHitsFitInner|=(track->fitTraits().numberOfFitPoints(kSsdId) & 0x3) << 3;
148 mNHitsFitInner|=(track->fitTraits().numberOfFitPoints(kPxlId) & 0x7) << 5;
150 mChiSqXY = track->fitTraits().chi2(0);
151 mChiSqZ = track->fitTraits().chi2(1);
153 if ( track->geometry() && track->geometry()->charge()) {
154 mHelix =
StMuHelix(track->geometry()->helix(),
event->runInfo()->magneticField());
158 Int_t vtx_id=vtxList->IndexOf(vertex);
163 gMessMgr->Warning() <<
"Track does not point to a primary vertex" << endm;
168 mDCA =
dca(track, vertex);
170 if (globalTrack->dcaGeometry()) {
171 const StDcaGeometry *dcaGeometry = globalTrack->dcaGeometry();
173 Double_t vtx[3] = {pvert[0],pvert[1],pvert[2]};
175 thelix.
Move(thelix.Path(vtx));
176 const Double_t *pos = thelix.Pos();
177 const Double_t *mom = thelix.Dir();
178 mDCAGlobal =
StThreeVectorF(pos[0],pos[1],pos[2]) - vertex->position();
179 if (track->type() == global) {
182 mP *= dcaGeometry->momentum().mag();
186 mDCAGlobal =
dca(globalTrack, vertex);
195 mEta = mP.pseudoRapidity();
198 Int_t
charge = track->geometry()->charge();
212 if (globalTrack->dcaGeometry()) {
213 const StDcaGeometry *dcaGeometry = globalTrack->dcaGeometry();
215 const Double_t *mom = thelix.Dir();
216 if (track->type() == global) {
218 mP *= dcaGeometry->momentum().mag();
224 mEta = mP.pseudoRapidity();
230 fillMuBTofPidTraits(track);
236 fillMuMtdPidTraits(track);
238 if ( track->outerGeometry() )
239 mOuterHelix =
StMuHelix(track->outerGeometry()->helix(),
event->runInfo()->magneticField());
244 if (mNHitsPossTpc==255 &&
type()==primary)
253 if (mNHitsPossTpc==255) {
254 if (det==kFtpcEastId || det==kFtpcWestId)
255 return mTopologyMap.hasHitInDetector(det)*mNHitsPoss;
256 else if (det==kTpcId)
257 return (mTopologyMap.hasHitInDetector(det) || mTopologyMap.hasHitInDetector(kiTpcId) ? mNHitsPoss : 0);
265 return mNHitsPossTpc;
271 return ((mNHitsPossTpc & 0xC0)==0x40)*(mNHitsPossTpc & 0x3F);
274 return ((mNHitsPossTpc & 0xC0)==0x80)*(mNHitsPossTpc & 0x3F);
278 return (mNHitsPossInner & 0x7);
281 return ((mNHitsPossInner >> 3) & 0x3);
284 return ((mNHitsPossInner >> 5) & 0x7);
294 if (mNHitsFitTpc==255) {
295 if (det==kFtpcEastId || det==kFtpcWestId)
296 return mTopologyMap.hasHitInDetector(det)*mNHitsFit;
297 else if (det==kTpcId)
298 return (mTopologyMap.hasHitInDetector(det) || mTopologyMap.hasHitInDetector(kiTpcId) ? mNHitsFit : 0);
312 return ((mNHitsFitTpc & 0xC0)==0x40)*(mNHitsFitTpc & 0x3F);
315 return ((mNHitsFitTpc & 0xC0)==0x80)*(mNHitsFitTpc & 0x3F);
319 return (mNHitsFitInner & 0x7);
322 return ((mNHitsFitInner >> 3) & 0x3);
325 return ((mNHitsFitInner >> 5) & 0x7);
334 vtx_id == mVertexIndex) {
345 Float_t cosl = dir.perp();
346 return -dir[1]/cosl * mDCAGlobal[0] + dir[0]/cosl * mDCAGlobal[1];
353 vtx_id == mVertexIndex) {
354 return mDCAGlobal.z();
362 if (vtx_id==mVertexIndex)
364 else if (mVertexIndex == -1)
374 if (vtx_id==mVertexIndex) {
377 else if (mVertexIndex == -1) {
393 double pathlength = hlx.
pathLength(pos,
false);
394 return hlx.at(pathlength)-pos;
398 double pathlength = track->geometry()->helix().
pathLength( vertex->position(), false );
399 return track->geometry()->helix().at(pathlength)-vertex->position();
403 double pathlength = track->geometry()->helix().
pathLength( vertex->position() );
404 return track->geometry()->helix().momentumAt(pathlength,event->runInfo()->magneticField()*kilogauss);
409 return StPhysicalHelixD(mHelix.p(),mHelix.origin(), mHelix.b()*kilogauss, mHelix.q());
413 return StPhysicalHelixD(mOuterHelix.p(),mOuterHelix.origin(), mOuterHelix.b()*kilogauss, mOuterHelix.q());
421 Int_t StMuTrack::bad()
const
423 if (mFlag <= 0 )
return 10;
424 if (mHelix.bad())
return 20;
425 if (mOuterHelix.bad())
return 30;
428 #include "StEvent/StProbPidTraits.h"
431 StPtrVecTrackPidTraits traits = t->pidTraits(kTpcId);
434 UInt_t size = traits.size();
437 cout <<
" dedxPidTraits->method() ";
439 for (UInt_t i = 0; i < size; i++) {
440 if ( !(dedxPidTraits=dynamic_cast<StDedxPidTraits*>(traits[i])) )
continue;
442 cout <<
" " << dedxPidTraits->method();
444 if (dedxPidTraits->method() == kTruncatedMeanIdentifier) {
449 if (dedxPidTraits->method() == kLikelihoodFitIdentifier) {
455 if (dedxPidTraits->method() == kOtherMethodIdentifier) {
468 size = traits.size();
469 for (UInt_t i = 0; i < size; i++) {
470 if ( (probPidTraits=dynamic_cast<StProbPidTraits*>(traits[i])) ) {
478 void StMuTrack::fillMuBTofPidTraits(
const StTrack* t) {
480 StPtrVecTrackPidTraits traits = t->pidTraits(kTofId);
481 UInt_t size = traits.size();
482 for (UInt_t i = 0; i < size; i++) {
483 if ( (btofPidTraits=dynamic_cast<StBTofPidTraits*>(traits[i])) ) {
484 mBTofPidTraits.setBTofPidTraits(btofPidTraits);
495 StPtrVecTrackPidTraits traits = t->pidTraits( kETofId );
496 UInt_t size = traits.size();
497 for( UInt_t i = 0; i < size; i++ ) {
498 if( ( etofPidTraits = dynamic_cast< StETofPidTraits* >( traits[ i ] ) ) ) {
505 void StMuTrack::fillMuMtdPidTraits(
const StTrack* t) {
507 StPtrVecTrackPidTraits traits = t->pidTraits(kMtdId);
508 UInt_t size = traits.size();
509 for (UInt_t i = 0; i < size; i++) {
510 if ( (mtdPidTraits=dynamic_cast<StMtdPidTraits*>(traits[i])) ) {
527 else if (mType == primary)
530 cout <<
"Other type ";
531 cout <<
"track, id " << mId <<
", flag " << mFlag <<
" (>0 is OK)" << endl;
533 if (mVertexIndex != 0)
534 cout <<
"Not assigned to primary vertex ( vertex Index " << mVertexIndex <<
" )" << endl;
536 cout <<
"momentum " << mP << endl;
537 cout <<
"eta " << mEta <<
", phi " << mPhi <<
", pt " << mPt << endl;
538 cout <<
"DCA " << mDCA << endl;
539 cout <<
"\t radial " <<
dcaD() <<
", z " <<
dcaZ() << endl;
540 cout <<
"global DCA " << mDCAGlobal << endl;
541 cout <<
"Total hits: " <<
nHits() <<
", fitted " <<
nHitsFit()
546 <<
nHitsFit(kSsdId) <<
" ) " << endl;
548 cout <<
"Possible points: " <<
nHitsPoss() <<
" \t( TPC "
554 cout <<
"\t first point " << mFirstPoint << endl;
555 cout <<
"\t last point " << mLastPoint << endl;
560 ostream& operator<<(ostream& os,
const StMuTrack& v) {
561 if (v.
type() == global) os <<
"Gl ";
562 else if (v.
type() == primary) os <<
"Pr ";
564 os << Form(
"id:%5i fl:%5i vx:%3i p:%8.3f %8.3f %8.3f",v.
id(),v.
flag(),v.
vertexIndex(), v.
p().x(), v.
p().y(), v.
p().z());
565 os << Form(
" q:%2i eta:%6.3f phi:%6.3f pT: %6.3f",v.
charge(),v.
eta(),v.
phi(),v.
pt());
566 os << Form(
" DCA [%d]:%6.3f %6.3f %6.3f", v.index2Cov(), v.
dca().x(),v.
dca().y(),v.
dca().z());
568 os << Form(
" Points F: %6.3f %6.3f %6.3f L: %6.3f %6.3f %6.3f",
571 os << Form(
" idT %4i qa %2i",v.idTruth(), v.qaTruth());
572 os << Form(
" idParentVx %d", v.idParentVx());
580 if(mType==1)
return this;
586 if(mIndex2Global==-1){
587 Int_t nVer = StMuDst::numberOfPrimaryVertices();
590 if(mIndex2Global < 0 )
return prim;
603 if (StMuDst::numberOfPrimaryVertices()==0){
609 if(this->
type()==1)
return mVertexIndex;
617 TArrayI StMuTrack::getTower(Bool_t useExitRadius,Int_t det)
const{
629 StEmcGeom* mEmcGeom = StEmcGeom::instance(
"bemc");
630 StEmcGeom* mSmdEGeom= StEmcGeom::instance(
"bsmde");
631 StEmcGeom* mSmdPGeom= StEmcGeom::instance(
"bsmdp");
633 if(det==1) radius = mEmcGeom->Radius();
634 if(det==2) radius = mEmcGeom->Radius();
635 if(det==3) radius = mSmdEGeom->Radius();
636 if(det==4) radius = mSmdPGeom->Radius();
639 Double_t mField = evtSummary.magneticField()/10;
642 if(useExitRadius) radius += 30.0;
645 Bool_t goodProjection;
646 if(
this) goodProjection = mEmcPosition.
trackOnEmc(&position,&momentum,
this,mField,radius);
650 Float_t
eta=position.pseudoRapidity();
651 Float_t
phi=position.phi();
653 mEmcGeom->
getBin(phi,eta,m,e,s);
655 if(mEmcGeom->getId(m,e,s,
id)==0){
663 Int_t check=mSmdEGeom->
getBin(phi,eta,m,e,s);
666 if(mSmdEGeom->getId(m,e,s,
id)==0){
674 Int_t check=mSmdPGeom->
getBin(phi,eta,m,e,s);
677 if(mSmdPGeom->getId(m,e,s,
id)==0){
688 double StMuTrack::energyBEMC()
const {
691 TArrayI tower = getTower();
692 UInt_t iMod = tower[0];
693 UInt_t iEta = tower[1];
694 Int_t iSub = tower[2];
695 if(iMod < 1 ||iMod > 120)
return -100.0;
700 StSPtrVecEmcRawHit& hits = mod->hits();
701 for(UInt_t i=0; i<hits.size();i++){
703 if((hits[i]->
eta() == iEta) && (hits[i]->sub() == iSub)) {
704 hitEnergy = hits[i]->energy();
705 if(hitEnergy > 0)
return hitEnergy;
714 Bool_t StMuTrack::matchBEMC()
const {
715 double mEmcThres = 0.15;
716 if (energyBEMC() > mEmcThres)
return true;
720 Double_t StMuTrack::dEdxPull(Double_t mass, Bool_t fit, Int_t charge)
const {
724 Double_t momentum = mh.p().mag();
726 if (log2dX <= 0) log2dX = 1;
727 Double_t dedx_measured, dedx_expected, dedx_resolution = -1;
730 dedx_expected = 1.e-6*charge*charge*Bichsel::Instance()->GetI70M(TMath::Log10(momentum*TMath::Abs(charge)/mass));
732 }
else if ( fit == 1) {
734 dedx_expected = 1.e-6*charge*charge*TMath::Exp(Bichsel::Instance()->GetMostProbableZ(TMath::Log10(momentum*TMath::Abs(charge)/mass)));
738 dedx_expected = StdEdxModel::instance()->dNdx(momentum*TMath::Abs(charge)/mass,charge);
741 if (dedx_resolution > 0)
742 z = TMath::Log(dedx_measured/dedx_expected)/dedx_resolution;
Double_t lengthMeasured() const
Returns length of track (cm) from first to last measured point.
const StMuHelix & muHelix() const
Returns inner helix (first measured point)
short type() const
Returns the track type: 0=global, 1=primary, etc (see StEvent manual for type information) ...
Bool_t trackOnEmc(StThreeVectorD *position, StThreeVectorD *momentum, const StTrack *const track, Double_t magField, Double_t emcRadius=225.405) const
Track projection utility.
Int_t vertexIndex() const
Returns index of associated primary vertex.
void setdEdxTrackLength(double dedx)
sets the track length in TPC used for dE/dx calculations
void fillMuProbPidTraits(const StEvent *, const StTrack *)
Helper function to fill all the different pid values.
void setdEdxTruncated(double dedx)
sets the truncated dEdx value;
Double_t pt() const
Returns pT at point of dca to primary vertex.
short id() const
Returns the track id(or key), is unique for a track node, i.e. global and primary tracks have the sam...
void setdEdxErrorFit(double dedx)
sets the fitted dEdx error value;
Double_t length() const
Returns length of track (cm) from primary vertex to last measured point.
Float_t dcaZ(Int_t vtx_id=-1) const
Z component of global DCA.
double dEdxFit() const
returns the fitted dEdx value
void setETofPidTraits(const StETofPidTraits *)
PID functions – to be added (?)
const StMuETofPidTraits & etofPidTraits() const
dongx
void setdNdxErrorFit(double dedx)
sets the fitted dNdx error value;
static void fixTrackIndicesG(int mult=1)
StMuMtdPidTraits mMtdPidTraits
dongx
void fillMuETofPidTraits(const StTrack *)
dongx
static StuProbabilityPidAlgorithm * mProbabilityPidAlgorithm
Bingchu.
int numberOfParticles() const
returns the number of particles avaiable
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
void setMtdPidTraits(const StMtdPidTraits *)
Setters.
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
UShort_t nHitsFit() const
Return total number of hits used in fit.
short flag() const
Returns flag, (see StEvent manual for type information)
Short_t charge() const
Returns charge.
void setdEdxErrorTruncated(double dedx)
sets the truncated dEdx error value;
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
double dNdxErrorFit() const
returns the fitted dNdx resolution value
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
const StThreeVectorF & firstPoint() const
Returns positions of first measured point.
const StMuProbPidTraits & probPidTraits() const
Returns Yuri Fisyak new pid probabilities.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
virtual void Print(Option_t *option="") const
Print track info.
StThreeVectorD momentumAtPrimaryVertex(const StEvent *event, const StTrack *track, const StVertex *vertex) const
Helper function: Calculates the momentum at dca a given StTrack and the primary vertex taken from StE...
void setProbability(unsigned int, double)
set the probability for particle i
UShort_t nHitsPoss() const
Return number of possible hits on track.
void setNdf(unsigned int)
set number of degrees of freedom
static Double_t mProbabilityPidCentrality
Centrality for Aihong's pid prob calculations. Will set when new StMuEvent is made from StEvent...
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
static int level()
returns debug level
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
UShort_t nHits() const
Bingchu.
StThreeVectorF dca(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex.
StMuProbPidTraits mProbPidTraits
Class holding the new Yuri Fisyak pid probabilities.
const StThreeVectorF & lastPoint() const
Returns positions of last measured point.
double dEdxErrorFit() const
returns the fitted dEdx resolution value
double dEdxErrorTruncated() const
returns the truncated 70% dEdx resolution value
void setdNdxFit(double dedx)
sets the fitted dNdx value;
static TClonesArray * array(int type)
returns pointer to the n-th TClonesArray
Double_t phi() const
Returns phi at point of dca to primary vertex.
const StMuTrack * primaryTrack() const
Returns pointer to associated primary track. Null pointer if no global track available.
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const
static StEmcCollection * emcCollection()
returns pointer to current StEmcCollection
double dNdxFit() const
returns the fitted dNdx value
Float_t dcaD(Int_t vtx_id=-1) const
Signed radial component of global DCA (projected)
static Int_t currentVertexIndex()
Get the index number of the current primary vertex.
const StMuTrack * globalTrack() const
Returns pointer to associated global track. Null pointer if no global track available.
double dEdxTruncated() const
returns the truncated 70% dEdx value
StThreeVectorF dcaGlobal(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex of associated global track.
double Move(double step)
Move along helix.
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
void setdEdxFit(double dedx)
sets the fitted dEdx value;