From 78665a1e0509d74bbb0bac2f3b8089be530d90ef Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 15:06:51 -0400 Subject: [PATCH 01/10] StPicoDstMaker: Place part of selectVertex() into separate function Refactor selectVertex() by extracting search for VPD vertex into findVpdVertex() --- StPicoDstMaker/StPicoDstMaker.cxx | 44 ++++++++++++++++++------------- StPicoDstMaker/StPicoDstMaker.h | 5 ++++ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index e5c67bb..317ba23 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -1158,25 +1158,9 @@ bool StPicoDstMaker::selectVertex() mMuDst->setVertexIndex(0); } - StBTofHeader const* mBTofHeader = mMuDst->btofHeader(); + selectedVertex = findVpdVertex(*mMuDst); - if (mBTofHeader && fabs(mBTofHeader->vpdVz()) < 200) - { - float vzVpd = mBTofHeader->vpdVz(); - - for (unsigned int iVtx = 0; iVtx < mMuDst->numberOfPrimaryVertices(); ++iVtx) - { - StMuPrimaryVertex* vtx = mMuDst->primaryVertex(iVtx); - if (!vtx) continue; - - if (fabs(vzVpd - vtx->position().z()) < 3.) - { - mMuDst->setVertexIndex(iVtx); - selectedVertex = mMuDst->primaryVertex(); - break; - } - } - } + mMuDst->setVertexIndex( mMuDst->primaryVertices()->IndexOf(selectedVertex) ); } else // default case { @@ -1186,3 +1170,27 @@ bool StPicoDstMaker::selectVertex() // Retrun false if selected vertex is not valid return selectedVertex ? true : false; } + + +StMuPrimaryVertex* StPicoDstMaker::findVpdVertex(const StMuDst& muDst) const +{ + StBTofHeader const* mBTofHeader = muDst.btofHeader(); + + if (mBTofHeader && fabs(mBTofHeader->vpdVz()) < 200) + { + float vzVpd = mBTofHeader->vpdVz(); + + for (unsigned int iVtx = 0; iVtx < muDst.numberOfPrimaryVertices(); ++iVtx) + { + StMuPrimaryVertex* vtx = muDst.primaryVertex(iVtx); + if (!vtx) continue; + + if (fabs(vzVpd - vtx->position().z()) < 3.) + { + return vtx; + } + } + } + + return nullptr; +} diff --git a/StPicoDstMaker/StPicoDstMaker.h b/StPicoDstMaker/StPicoDstMaker.h index a73cb44..5727273 100644 --- a/StPicoDstMaker/StPicoDstMaker.h +++ b/StPicoDstMaker/StPicoDstMaker.h @@ -15,6 +15,7 @@ class TFile; class TTree; class StMuDst; class StMuTrack; +class StMuPrimaryVertex; class StEmcCollection; class StEmcPosition; class StEmcGeom; @@ -128,6 +129,10 @@ class StPicoDstMaker : public StMaker /// A pointer to the main input/outpur picoDst structure containing all `TObjArray`s StPicoDst* mPicoDst; + /// Finds a primary vertex in the list of muDst vertices that matches the VPD + /// vertex + StMuPrimaryVertex* findVpdVertex(const StMuDst& muDst) const; + StEmcCollection* mEmcCollection; StEmcPosition* mEmcPosition; StEmcGeom* mEmcGeom[4]; From ed54e3297d05d7ba195bea21507de018ffc23434 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 15:18:52 -0400 Subject: [PATCH 02/10] [Cosmetic] StPicoDstMaker: Revert conditions to save indentation in findVpdVertex() --- StPicoDstMaker/StPicoDstMaker.cxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index 317ba23..cfe2c48 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -1176,20 +1176,18 @@ StMuPrimaryVertex* StPicoDstMaker::findVpdVertex(const StMuDst& muDst) const { StBTofHeader const* mBTofHeader = muDst.btofHeader(); - if (mBTofHeader && fabs(mBTofHeader->vpdVz()) < 200) + if (!mBTofHeader || fabs(mBTofHeader->vpdVz()) >= 200) + return nullptr; + + float vzVpd = mBTofHeader->vpdVz(); + + for (unsigned int iVtx = 0; iVtx < muDst.numberOfPrimaryVertices(); ++iVtx) { - float vzVpd = mBTofHeader->vpdVz(); + StMuPrimaryVertex* vtx = muDst.primaryVertex(iVtx); - for (unsigned int iVtx = 0; iVtx < muDst.numberOfPrimaryVertices(); ++iVtx) - { - StMuPrimaryVertex* vtx = muDst.primaryVertex(iVtx); - if (!vtx) continue; + if (!vtx || fabs(vzVpd - vtx->position().z()) >= 3.) continue; - if (fabs(vzVpd - vtx->position().z()) < 3.) - { - return vtx; - } - } + return vtx; } return nullptr; From d4a966ce315dffd4846236977c632423dcb87c3c Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 16:15:22 -0400 Subject: [PATCH 03/10] StPicoDstMaker: Consider each VtxMode individually in selectVertex() --- StPicoDstMaker/StPicoDstMaker.cxx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index cfe2c48..4fd1a89 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -1151,17 +1151,26 @@ bool StPicoDstMaker::selectVertex() mMuDst->setVertexIndex(0); selectedVertex = mMuDst->primaryVertex(); } - else if (mVtxMode == PicoVtxMode::Vpd || mVtxMode == PicoVtxMode::VpdOrDefault) + else if (mVtxMode == PicoVtxMode::Vpd) { - if(mVtxMode == PicoVtxMode::VpdOrDefault) - { - mMuDst->setVertexIndex(0); - } - selectedVertex = findVpdVertex(*mMuDst); mMuDst->setVertexIndex( mMuDst->primaryVertices()->IndexOf(selectedVertex) ); } + else if (mVtxMode == PicoVtxMode::VpdOrDefault) + { + selectedVertex = findVpdVertex(*mMuDst); + + if (selectedVertex) + { + mMuDst->setVertexIndex( mMuDst->primaryVertices()->IndexOf(selectedVertex) ); + } + else + { + mMuDst->setVertexIndex(0); + selectedVertex = mMuDst->primaryVertex(); + } + } else // default case { LOG_ERROR << "Pico Vtx Mode not set!" << endm; From eeb235a2cdbb85336b8a683f833d5eda423c73fc Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 17:47:53 -0400 Subject: [PATCH 04/10] StPicoDstMaker: Use switch instead of if-else-if --- StPicoDstMaker/StPicoDstMaker.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index 4fd1a89..f3e573f 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -1145,20 +1145,20 @@ bool StPicoDstMaker::selectVertex() { StMuPrimaryVertex* selectedVertex = nullptr; - if (mVtxMode == PicoVtxMode::Default) + switch (mVtxMode) { + case PicoVtxMode::Default: // choose the default vertex, i.e. the first vertex mMuDst->setVertexIndex(0); selectedVertex = mMuDst->primaryVertex(); - } - else if (mVtxMode == PicoVtxMode::Vpd) - { - selectedVertex = findVpdVertex(*mMuDst); + break; + case PicoVtxMode::Vpd: + selectedVertex = findVpdVertex(*mMuDst); mMuDst->setVertexIndex( mMuDst->primaryVertices()->IndexOf(selectedVertex) ); - } - else if (mVtxMode == PicoVtxMode::VpdOrDefault) - { + break; + + case PicoVtxMode::VpdOrDefault: selectedVertex = findVpdVertex(*mMuDst); if (selectedVertex) @@ -1170,9 +1170,9 @@ bool StPicoDstMaker::selectVertex() mMuDst->setVertexIndex(0); selectedVertex = mMuDst->primaryVertex(); } - } - else // default case - { + break; + + default: LOG_ERROR << "Pico Vtx Mode not set!" << endm; } From 6ad640ba942d868b3ad2989a2c3515403ca58353 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 17:56:36 -0400 Subject: [PATCH 05/10] StPicoDstMaker: Use new helper functions in StMuDst --- StPicoDstMaker/StPicoDstMaker.cxx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index f3e573f..c1973a1 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -1149,27 +1149,22 @@ bool StPicoDstMaker::selectVertex() { case PicoVtxMode::Default: // choose the default vertex, i.e. the first vertex - mMuDst->setVertexIndex(0); - selectedVertex = mMuDst->primaryVertex(); + selectedVertex = StMuDst::setCurrentVertex(0); break; case PicoVtxMode::Vpd: selectedVertex = findVpdVertex(*mMuDst); - mMuDst->setVertexIndex( mMuDst->primaryVertices()->IndexOf(selectedVertex) ); + StMuDst::setCurrentVertex(selectedVertex); break; case PicoVtxMode::VpdOrDefault: selectedVertex = findVpdVertex(*mMuDst); if (selectedVertex) - { - mMuDst->setVertexIndex( mMuDst->primaryVertices()->IndexOf(selectedVertex) ); - } + StMuDst::setCurrentVertex(selectedVertex); else - { - mMuDst->setVertexIndex(0); - selectedVertex = mMuDst->primaryVertex(); - } + selectedVertex = StMuDst::setCurrentVertex(0); + break; default: From 15045d667600239f4b132e024d71aa7e4705c3d6 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 16:40:23 -0400 Subject: [PATCH 06/10] StPicoTrack: Make vertex optional in constructor --- StPicoDstMaker/StPicoDstMaker.cxx | 2 +- StPicoEvent/StPicoTrack.cxx | 17 +++++++++++------ StPicoEvent/StPicoTrack.h | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index c1973a1..f8ad081 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -677,7 +677,7 @@ void StPicoDstMaker::fillTracks() } int counter = mPicoArrays[StPicoArrays::Track]->GetEntries(); - new((*(mPicoArrays[StPicoArrays::Track]))[counter]) StPicoTrack(gTrk, pTrk, mBField, mMuDst->primaryVertex()->position(), *dcaG); + new((*(mPicoArrays[StPicoArrays::Track]))[counter]) StPicoTrack(gTrk, pTrk, mBField, mMuDst->primaryVertex(), *dcaG); StPicoTrack* picoTrk = (StPicoTrack*)mPicoArrays[StPicoArrays::Track]->At(counter); diff --git a/StPicoEvent/StPicoTrack.cxx b/StPicoEvent/StPicoTrack.cxx index 46889e7..4361a76 100644 --- a/StPicoEvent/StPicoTrack.cxx +++ b/StPicoEvent/StPicoTrack.cxx @@ -6,6 +6,7 @@ #include "StPicoEvent/StPicoTrack.h" #include "St_base/StMessMgr.h" #include "StMuDSTMaker/COMMON/StMuTrack.h" +#include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h" //---------------------------------------------------------------------------------- @@ -23,7 +24,7 @@ StPicoTrack::StPicoTrack() : TObject(), } //---------------------------------------------------------------------------------- -StPicoTrack::StPicoTrack(StMuTrack const* const gTrk, StMuTrack const* const pTrk, double const B, StThreeVectorD const& pVtx, StDcaGeometry const& dcaG) +StPicoTrack::StPicoTrack(StMuTrack const* const gTrk, StMuTrack const* const pTrk, double const B, const StMuPrimaryVertex* pVtx, StDcaGeometry const& dcaG) : StPicoTrack() { if (!gTrk || gTrk->type() != global || (pTrk && (pTrk->type() != primary || pTrk->id() != gTrk->id()))) @@ -41,11 +42,15 @@ StPicoTrack::StPicoTrack(StMuTrack const* const gTrk, StMuTrack const* const pTr mPMomentum = pTrk->p(); } - // Calculate global momentum and position at point of DCA to the pVtx - StPhysicalHelixD gHelix = dcaG.helix(); - gHelix.moveOrigin(gHelix.pathLength(pVtx)); - mGMomentum = gHelix.momentum(B * kilogauss); - mOrigin = gHelix.origin(); + // Calculate global momentum and position at point of DCA to the pVtx if the + // vertex is valid + if (pVtx) + { + StPhysicalHelixD gHelix = dcaG.helix(); + gHelix.moveOrigin(gHelix.pathLength( pVtx->position() )); + mGMomentum = gHelix.momentum(B * kilogauss); + mOrigin = gHelix.origin(); + } mDedx = gTrk->dEdx() * 1.e6; mDnDx = gTrk->probPidTraits().dNdxFit(); diff --git a/StPicoEvent/StPicoTrack.h b/StPicoEvent/StPicoTrack.h index 62ae834..72e3b4c 100644 --- a/StPicoEvent/StPicoTrack.h +++ b/StPicoEvent/StPicoTrack.h @@ -9,6 +9,7 @@ #include "StarClassLibrary/SystemOfUnits.h" +class StMuPrimaryVertex; class StMuTrack; class StDcaGeometry; @@ -21,7 +22,7 @@ class StPicoTrack : public TObject /// ctor. Note: primary track should be associated with the StPicoEvent::mPrimaryVertex StPicoTrack(StMuTrack const* globalTrack, StMuTrack const* primaryTrack, - double magField, StThreeVectorD const& pVtx, StDcaGeometry const& dcaG); + double magField, const StMuPrimaryVertex* pVtx, StDcaGeometry const& dcaG); virtual ~StPicoTrack() {} From 6be44cbec47f3e782657f78130ef0ddc69fc5f6e Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 16:44:15 -0400 Subject: [PATCH 07/10] StPicoEvent: Do not update vertex position/uncertainties if vertex not available --- StPicoEvent/StPicoEvent.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/StPicoEvent/StPicoEvent.cxx b/StPicoEvent/StPicoEvent.cxx index 81b7d89..d0e4dfd 100644 --- a/StPicoEvent/StPicoEvent.cxx +++ b/StPicoEvent/StPicoEvent.cxx @@ -42,11 +42,11 @@ StPicoEvent::StPicoEvent(StMuDst const& muDst) : StPicoEvent() mFillId = ev->runInfo().beamFillNumber(blue); mBField = ev->magneticField(); - mPrimaryVertex = ev->primaryVertexPosition(); - mPrimaryVertexError = ev->primaryVertexErrors(); - if (StMuPrimaryVertex* pv = muDst.primaryVertex()) { + mPrimaryVertex = ev->primaryVertexPosition(); + mPrimaryVertexError = ev->primaryVertexErrors(); + mRanking = pv->ranking(); mNBEMCMatch = pv->nBEMCMatch(); mNBTOFMatch = pv->nBTOFMatch(); From 8635fe9e3b604e9ada7765c74d447f6612759e6d Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 16:50:59 -0400 Subject: [PATCH 08/10] [Cosmetic] Changes in whitespace, Cleaned up includes --- StPicoEvent/StPicoTrack.h | 1 + 1 file changed, 1 insertion(+) diff --git a/StPicoEvent/StPicoTrack.h b/StPicoEvent/StPicoTrack.h index 72e3b4c..390dc6c 100644 --- a/StPicoEvent/StPicoTrack.h +++ b/StPicoEvent/StPicoTrack.h @@ -9,6 +9,7 @@ #include "StarClassLibrary/SystemOfUnits.h" +class StDcaGeometry; class StMuPrimaryVertex; class StMuTrack; class StDcaGeometry; From 0596e9c34920d46c3114e11fcd459f32b47342a3 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 7 Jul 2017 19:17:18 -0400 Subject: [PATCH 09/10] [Cosmetic] Combined nested conditions --- StPicoDstMaker/StPicoDstMaker.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/StPicoDstMaker/StPicoDstMaker.cxx b/StPicoDstMaker/StPicoDstMaker.cxx index f8ad081..c3b93ef 100644 --- a/StPicoDstMaker/StPicoDstMaker.cxx +++ b/StPicoDstMaker/StPicoDstMaker.cxx @@ -204,13 +204,10 @@ Int_t StPicoDstMaker::Init() { case PicoIoMode::IoWrite: - if (mVtxMode == PicoVtxMode::NotSet) + if (mVtxMode == PicoVtxMode::NotSet && setVtxModeAttr() != kStOK) { - if (setVtxModeAttr() != kStOK) - { - LOG_ERROR << "Pico Vertex Mode is not set ... " << endm; - return kStErr; - } + LOG_ERROR << "Pico Vertex Mode is not set ... " << endm; + return kStErr; } if (mInputFileName.Length() == 0) { From 4c02e333a64ab8784c190c920b17a6743164b24a Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Sat, 8 Jul 2017 11:45:20 -0400 Subject: [PATCH 10/10] Added doxygen comments for StPicoDstMaker::PicoVtxMode --- StPicoDstMaker/StPicoDstMaker.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/StPicoDstMaker/StPicoDstMaker.h b/StPicoDstMaker/StPicoDstMaker.h index 5727273..df2b5a0 100644 --- a/StPicoDstMaker/StPicoDstMaker.h +++ b/StPicoDstMaker/StPicoDstMaker.h @@ -29,7 +29,21 @@ class StPicoDstMaker : public StMaker { public: enum PicoIoMode {IoWrite=1, IoRead=2}; - enum PicoVtxMode {NotSet=0, Default=1, Vpd=2, VpdOrDefault=3}; + + /// Various selection criteria for picking a vertex from the list of available + /// vertices in muDst. If requested vertex not found the event is skipped + enum PicoVtxMode + { + /// Default "unspecified" mode to force user pick one of the modes below + NotSet = 0, + /// Select the first vertex in the muDst vertex collection + Default = 1, + /// Select first available vertex within a window around the VPD one + Vpd = 2, + /// If a vertex matching the VPD one is not found pick the first one from + /// the muDst collection + VpdOrDefault = 3 + }; StPicoDstMaker(char const* name = "PicoDst"); StPicoDstMaker(PicoIoMode ioMode, char const* fileName = "", char const* name = "PicoDst");