Skip to content

Commit

Permalink
fixed a logical error for the PicoVtxMod::Mtd in StPicoDstMaker.cxx (s…
Browse files Browse the repository at this point in the history
…tar-bnl#163)

I fixed a logical error for the PicoVtxMod::Mtd in StPicoDstMaker.cxx

Origianl:
1. Select default vertex first
2. Select each vertex in the vertex loop in order to find the vertex with at least 2 MTD matched primary tracks
3. Select MTD vertex if it is found
-> If the MTD vertex is not found (most of the cases), the vertex loop will continue to the end and the last one is selected.

Fixed:
1. Instead of selecting the vertex directly, I store the default vertex index in a variable VtxIndex.
2. VtxIndex will be changed if MTD vertex is found in the vertex loop.
3. Select the vertex after the vertex loop.
-> Default vertex will be selected if no MTD vertex is found in the loop.

Detail can be found at: https://drupal.star.bnl.gov/STAR/system/files/TeChuan_Run17_SL21c_vtxQA.pdf

Co-authored-by: Te-Chuan Huang <tchuang@Te-Chuans-Air.Dlink>
Co-authored-by: Te-Chuan Huang <tchuang@Te-Chuans-MacBook-Air.local>
  • Loading branch information
3 people authored and plexoos committed Oct 8, 2021
1 parent d874770 commit 6389740
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions StRoot/StPicoDstMaker/StPicoDstMaker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2574,11 +2574,9 @@ bool StPicoDstMaker::selectVertex() {
} //if (mBTofHeader && fabs(mBTofHeader->vpdVz()) < 200)
} //else if (mVtxMode == PicoVtxMode::Vpd || mVtxMode == PicoVtxMode::VpdOrDefault)
else if ( mVtxMode == PicoVtxMode::Mtd ) {

// Set the first primary vertex as a default vertex
mMuDst->setVertexIndex(0);
// Set pointer to the first primary vertex
selectedVertex = mMuDst->primaryVertex();
int VtxIndex = 0;

// Loop over primary vertices
for(unsigned int iVtx=0; iVtx<mMuDst->numberOfPrimaryVertices(); iVtx++) {
Expand All @@ -2592,30 +2590,33 @@ bool StPicoDstMaker::selectVertex() {
// Loop over primary tracks
for(unsigned int iTrk=0; iTrk<mMuDst->numberOfPrimaryTracks(); iTrk++) {

// Retrieve i-th primary track from that belongs
// to the current primary vertex
StMuTrack* pTrack = mMuDst->primaryTracks( iTrk );
// Track must exist
if( !pTrack ) continue;
// Retrieve i-th primary track from that belongs
// to the current primary vertex
StMuTrack* pTrack = mMuDst->primaryTracks( iTrk );
// Track must exist
if( !pTrack ) continue;

// Check if track matches MTD
if( pTrack->index2MtdHit()<0 ) continue;
// Increment number of tracks that matched MTD
nMtdMatched++;

// Check if track matches MTD
if( pTrack->index2MtdHit()<0 ) continue;
// Increment number of tracks that matched MTD
nMtdMatched++;

} // for(unsigned int iTrk=0; iTrk<mMuDst->numberOfPrimaryTracks(); iTrk++)

// Take the first primary vertex that has at least 2 tracks
// that matched MTD
// Take the first primary vertex that has at least 2 tracks
// that matched MTD
if( nMtdMatched >= 2 ) {
// Reset vertex index
mMuDst->setVertexIndex( iVtx );
// Reset pointer to the primary vertex
selectedVertex = mMuDst->primaryVertex();
// Quit vertex loop
break;
// Change vertex index
VtxIndex = iVtx;
// Quit vertex loop
break;
} // if( nMtdMatched >= 2 )
} // for(unsigned int iVtx=0; iVtx<mMuDst->numberOfPrimaryVertices(); iVtx++)

// Set the vertex index
mMuDst->setVertexIndex(VtxIndex);
// Set pointer to the primary vertex
selectedVertex = mMuDst->primaryVertex();
} // else if ( mVtxMode == PicoVtxMode::Mtd )
else { // default case
LOG_ERROR << "Pico Vtx Mode not set!" << endm;
Expand Down

0 comments on commit 6389740

Please # to comment.