Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New FWD tracking mode based on FST-track finding #571

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7786bd9
FST tracking mode for high mult and data with missing sTGCs
jdbrice Dec 18, 2023
e65362f
Verify working refit (FST and FTT) in ideal sim, remove old unused tr…
jdbrice Dec 19, 2023
cf5dbe3
Logic update so that non-MC track finding (standard) works when Track…
jdbrice Dec 20, 2023
1f512ab
remove StJPSiMaker dep from sim.C, keep feature branches separate
jdbrice Dec 20, 2023
2aced37
add scripts for runnning common simulation configurations (ideal, rea…
jdbrice Dec 20, 2023
7499f20
Merge branch 'star-bnl:main' into fst-tracking-mode
jdbrice Apr 18, 2024
a04fa94
restore StBFChain doc files
jdbrice Apr 18, 2024
f243886
load hits from MuDst, allow cached geometry, and properly handle GenT…
jdbrice Apr 18, 2024
c7d2fe7
Changes to resolve severe memory leaks due to geometry navigtor, and …
jdbrice Apr 18, 2024
b7a8346
Update to StFwdTrack for MC track id and qa truth
jdbrice Apr 18, 2024
7c4aa5e
Update StMuFwdTrack to mirror StFwdTrack (Mc Id and QA)
jdbrice Apr 18, 2024
99752c4
Update macros used for sim and MuDst analysis
jdbrice Apr 18, 2024
7b03b9e
Merge branch 'main' into fst-tracking-mode
plexoos Apr 19, 2024
774a7e3
use static const TVector3 where possible
May 15, 2024
a576a44
StMuFwdTrack initialize members
May 15, 2024
f0172c9
Make FwdHits on stack, easier memory managment
May 15, 2024
a2c5548
cleanup macros for fwd mudst processing
May 15, 2024
0e9b674
Use FST z locations from geom to identify hit plane index
May 15, 2024
0241f63
Cleanup of the StFwdTrackMaker code
jdbrice Jun 28, 2024
e0dfc4d
Merge branch 'main' into fst-tracking-mode
jdbrice Jun 29, 2024
501243a
Revert "Cleanup of the StFwdTrackMaker code"
plexoos Jul 19, 2024
b90b057
Merge branch 'main' into fst-tracking-mode
plexoos Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions StRoot/StEvent/StFwdTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class StFwdTrack : public StObject {

// Number of points used in the track seed step
short numberOfSeedPoints() const;
UShort_t idTruth() const { return mIdTruth; }
UShort_t qaTruth() const { return mQATruth; }


void setPrimaryMomentum( StThreeVectorD mom ) { mPrimaryMomentum = mom; }
Expand All @@ -140,6 +142,7 @@ class StFwdTrack : public StObject {
void setNDF( float lNDF ) { mNDF = lNDF;}
void setPval( float lPval ) { mPval = lPval;}
void setCharge( short lCharge ) { mCharge = lCharge;}
void setMc( UShort_t idt, UShort_t qual ) { mIdTruth = idt; mQATruth = qual; }

// ECAL clusters
StPtrVecFcsCluster& ecalClusters();
Expand Down Expand Up @@ -168,12 +171,14 @@ class StFwdTrack : public StObject {
float mPval;
short mCharge;
StThreeVectorD mPrimaryMomentum;


StPtrVecFcsCluster mEcalClusters;
StPtrVecFcsCluster mHcalClusters;
/// MC track id
UShort_t mIdTruth;
/// MC track quality (percentage of hits coming from corresponding MC track)
UShort_t mQATruth;

ClassDef(StFwdTrack,2)
ClassDef(StFwdTrack,3)

};

Expand Down
589 changes: 375 additions & 214 deletions StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx

Large diffs are not rendered by default.

95 changes: 80 additions & 15 deletions StRoot/StFwdTrackMaker/StFwdTrackMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#ifndef __CINT__
#include "GenFit/Track.h"
#include "StFwdTrackMaker/include/Tracker/FwdHit.h"
#endif

#include "FwdTrackerConfig.h"
Expand Down Expand Up @@ -49,50 +50,54 @@ class GenfitTrackResult;
const size_t MAX_TREE_ELEMENTS = 4000;
struct FwdTreeData {

// hits;
/**@brief Ftt hit related info*/
int fttN;
vector<float> fttX, fttY, fttZ;
vector<int> fttVolumeId;
// Only avalaible for hits if MC
// Note: Below are only avalaible for hits if MC
vector<float> fttPt;
vector<int> fttTrackId, fttVertexId;

// hits;
/**@brief Fst hit related info*/
int fstN;
vector<float> fstX, fstY, fstZ;
vector<int> fstTrackId;

/**@brief Fcs hit related info*/
int fcsN;
vector<float> fcsX, fcsY, fcsZ;
vector<float> fcsX, fcsY, fcsZ, fcsE;
vector<int> fcsDet;

// RC tracks
/**@brief RC track related info*/
int rcN;
vector<float> rcPt, rcEta, rcPhi, rcQuality;
vector<int> rcTrackId, rcNumFST, rcCharge, rcNumFTT, rcNumPV;

// MC Tracks
/**@brief MC Track related info*/
int mcN;
vector<float> mcPt, mcEta, mcPhi;
vector<int> mcVertexId, mcCharge;
vector<int> mcNumFtt, mcNumFst;

// MC Level vertex info
// maybe use also for TPC vertex if available in data
/**@brief MC Vertex related info*/
int vmcN;
vector<float> vmcX, vmcY, vmcZ;

/**@brief Track Projection related info*/
int tprojN;
vector<float> tprojX, tprojY, tprojZ;
vector<float> tprojPx, tprojPy, tprojPz;
vector<int> tprojIdD, tprojIdT;

// RAVE reco vertices
/**@brief RAVE RC Vertex related info*/
int vrcN;
vector<float> vrcX, vrcY, vrcZ;

/**@brief Track-to-hit delta related info*/
int thdN;
vector<float> thdX, thdY, thaX, thaY, thaZ;
vector<float> thdX, thdY, thdP, thdR, thaX, thaY, thaZ;

/**@brief Seed finding Criteria related info*/
bool saveCrit = false;
std::map<string, std::vector<float>> Crits;
std::map<string, std::vector<int>> CritTrackIds;
Expand Down Expand Up @@ -134,8 +139,8 @@ class StFwdTrackMaker : public StMaker {


// for Wavefront OBJ export
size_t eventIndex = 0;

size_t eventIndex = 0; // counts up for processed events
size_t mEventNum = 0; // global event num (index)

bool mGenHistograms = false;
bool mGenTree = false;
Expand All @@ -156,6 +161,8 @@ class StFwdTrackMaker : public StMaker {

std::vector< genfit::GFRaveVertex * > mRaveVertices;

vector<float> mFttZFromGeom, mFstZFromGeom;

void ProcessFwdTracks();
void FillEvent();
void FillTrackDeltas();
Expand All @@ -165,6 +172,7 @@ class StFwdTrackMaker : public StMaker {
// I could not get the library generation to succeed with these.
// so I have removed them
#ifndef __CINT__
vector<FwdHit> mFwdHits;
std::shared_ptr<SiRasterizer> mSiRasterizer;
FwdTrackerConfig mFwdConfig;
std::shared_ptr<ForwardTracker> mForwardTracker;
Expand All @@ -176,9 +184,11 @@ class StFwdTrackMaker : public StMaker {
void loadFttHitsFromStEvent( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap, int count = 0 );
void loadFttHitsFromGEANT( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap, int count = 0 );

void loadFstHits( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap, int count = 0 );
void loadFstHitsFromGEANT( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap, int count = 0 );
void loadFstHitsFromStEvent( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap, int count = 0 );
int loadFstHits( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap );
int loadFstHitsFromMuDst( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap );
int loadFstHitsFromGEANT( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap );
int loadFstHitsFromStEvent( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap );
int loadFstHitsFromStEventFastSim( std::map<int, std::shared_ptr<McTrack>> &mcTrackMap, std::map<int, std::vector<KiTrack::IHit *>> &hitMap );
#endif

void FillTTree(); // if debugging ttree is turned on (mGenTree)
Expand All @@ -188,6 +198,7 @@ class StFwdTrackMaker : public StMaker {
static std::string defaultConfigData;
std::string defaultConfig;
bool configLoaded = false;
TString mGeoCache;

// Helper functions for modifying configuration
// NOTE: to override configuration, call individual functions after setConfigForXXX
Expand Down Expand Up @@ -353,6 +364,60 @@ class StFwdTrackMaker : public StMaker {
*/
void setSmearMcPrimaryVertex( bool pvs = true ) { mFwdConfig.set<bool>( "TrackFitter.Vertex:smearMcVertex", pvs ); }

/**
* @brief Sets geometry cache filename
*
*/
void setGeoCache( TString gc ) { mGeoCache = gc; }

/**
* @brief Set a generic Key Value in the Config object
*
* @param k key: any string representing absolute path e.g. `the.path.to.node:attribute`
* @param v value: value encoded as a string
*/
void setConfigKeyValue( std::string k, std::string v ){
mFwdConfig.set( k, v );
}

/** @brief Sets a criteria value in the config for 2-hit criteria
* @param string name: name of the crit2, e.g. Crit2_RZRatio
* @param double min: minimum for the criteria, meaning depends on specific crit2
* @param double max: maximum for the criteria, meaning depends on specific crit2
*/
void setCrit2( std::string name, double min, double max ){
for ( auto p : mFwdConfig.childrenOf( "TrackFinder.Iteration.SegmentBuilder" ) ){
auto nName = mFwdConfig.get<std::string>( p + ":name", "DNE" );

if (nName == name) {
LOG_DEBUG << "Setting Crit2=" << nName << " (min=" << min << ", max=" << max << ")" << endm;
mFwdConfig.set<double>(p + ":min", min );
mFwdConfig.set<double>(p + ":max", max );
return;
}
} // loop on existing crit2
// if we got here then the crit did not exist

}

/** @brief Sets a criteria value in the config for 3-hit criteria
* @param string name: name of the crit3, e.g. Crit2_RZRatio
* @param double min: minimum for the criteria, meaning depends on specific crit2
* @param double max: maximum for the criteria, meaning depends on specific crit2
*/
void setCrit3( std::string name, double min, double max ){
for ( auto p : mFwdConfig.childrenOf( "TrackFinder.Iteration.ThreeHitSegments" ) ){
auto nName = mFwdConfig.get<std::string>( p + ":name", "DNE" );
if (nName == name) {
LOG_DEBUG << "Setting Crit3=" << nName << " (min=" << min << ", max=" << max << ")" << endm;
mFwdConfig.set<double>(p + ":min", min );
mFwdConfig.set<double>(p + ":max", max );
return;
}
} // loop on existing crit3
// if we got here then the crit did not exist
}

};

#endif
26 changes: 5 additions & 21 deletions StRoot/StFwdTrackMaker/include/Tracker/FwdDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,11 @@ class FwdDataSource {

// Cleanup
void clear() {

// delete the hits from the hitmap
for ( auto kv : mFttHits ){
for ( auto h : kv.second ){
delete h;
}
kv.second.clear();
}

for ( auto kv : mFstHits ){
for ( auto h : kv.second ){
delete h;
}
kv.second.clear();
}

// the tracks are shared pointers, so they will be taken care of by clearing the map (below)

mFttHits.clear();
mFstHits.clear();
mMcTracks.clear();
// Just empty our vectors, we dont own the memory
mFttHits.clear();
mFstHits.clear();
// the tracks are shared pointers, so they will be taken care of by clearing the map (below)
mMcTracks.clear();
}

// TODO, protect and add interaface for pushing hits / tracks
Expand Down
11 changes: 9 additions & 2 deletions StRoot/StFwdTrackMaker/include/Tracker/FwdGeomUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
class FwdGeomUtils {
public:



FwdGeomUtils( TGeoManager * gMan ) {
if ( gMan != nullptr )
if ( gMan != nullptr ){
_navigator = gMan->AddNavigator();
_gMan = gMan;
}
}

~FwdGeomUtils(){

if ( _gMan != nullptr && _navigator != nullptr){
_gMan->RemoveNavigator( _navigator );
}
}

bool cd( const char* path ){
Expand Down Expand Up @@ -85,6 +91,7 @@ class FwdGeomUtils {
TGeoHMatrix *_matrix = nullptr;
TGeoIterator *_iter = nullptr;
TGeoNavigator *_navigator = nullptr;
TGeoManager *_gMan = nullptr;
};

#endif
8 changes: 4 additions & 4 deletions StRoot/StFwdTrackMaker/include/Tracker/FwdHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class McTrack {
mStartVertex = start_vertex;
}

void addHit(KiTrack::IHit *hit) { mHits.push_back(hit); }
// void addFstHit(KiTrack::IHit *hit) { mFstHits.push_back(hit); }
void addHit(KiTrack::IHit *hit) { mFttHits.push_back(hit); }
void addFstHit(KiTrack::IHit *hit) { mFstHits.push_back(hit); }

double mPt, mEta, mPhi;
int mTid, mQ, mStartVertex;

std::vector<KiTrack::IHit *> mHits;
// std::vector<KiTrack::IHit *> mFstHits;
std::vector<KiTrack::IHit *> mFttHits;
std::vector<KiTrack::IHit *> mFstHits;
};


Expand Down
Loading
Loading