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

Fwd picodst integration #639

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
36 changes: 19 additions & 17 deletions StRoot/StFwdTrackMaker/StFwdTrackMaker.cxx
Original file line number Diff line number Diff line change
@@ -226,7 +226,7 @@ class ForwardTracker : public ForwardTrackMaker {
};

//________________________________________________________________________
StFwdTrackMaker::StFwdTrackMaker() : StMaker("fwdTrack"), mGenHistograms(false), mGenTree(false), mForwardTracker(nullptr), mForwardData(nullptr){
StFwdTrackMaker::StFwdTrackMaker() : StMaker("fwdTrack"), mGenHistograms(false), mGenTree(false), mForwardTracker(nullptr), mForwardData(nullptr), mGeoCache(""){
SetAttr("useFtt",1); // Default Ftt on
SetAttr("useFst",1); // Default Fst on
SetAttr("useFcs",1); // Default Fcs on
@@ -428,23 +428,21 @@ int StFwdTrackMaker::Init() {
mTree->SetAutoFlush(0);
} // gen tree

if ( mGeoCache == "" ){
/// Instantiate and cache the geometry
GetDataBase("VmcGeometry");

/// Instantiate and cache the geometry
GetDataBase("VmcGeometry");
mGeoCache = GetChainOpt()->GetFileOut();
if ( mGeoCache=="" )
mGeoCache = GetChainOpt()->GetFileIn();



TString geoCache = GetChainOpt()->GetFileOut();
if ( geoCache=="" )
geoCache = GetChainOpt()->GetFileIn();

// Strip out @ symbol
geoCache = geoCache.ReplaceAll("@","");
// Strip off the last extention in the geoCache
geoCache = geoCache( 0, geoCache.Last('.') );
// Append geom.root to the extentionless geoCache
geoCache+=".geom.root";

// Strip out @ symbol
mGeoCache = mGeoCache.ReplaceAll("@","");
// Strip off the last extention in the mGeoCache
mGeoCache = mGeoCache( 0, mGeoCache.Last('.') );
// Append geom.root to the extentionless mGeoCache
mGeoCache+=".geom.root";
}
// create an SiRasterizer in case we need it
mSiRasterizer = std::shared_ptr<SiRasterizer>( new SiRasterizer(mFwdConfig));
mForwardTracker = std::shared_ptr<ForwardTracker>(new ForwardTracker( ));
@@ -455,7 +453,7 @@ int StFwdTrackMaker::Init() {

mForwardData = std::shared_ptr<FwdDataSource>(new FwdDataSource());
mForwardTracker->setData(mForwardData);
mForwardTracker->initialize( geoCache, mGenHistograms );
mForwardTracker->initialize( mGeoCache, mGenHistograms );

if ( mGenHistograms ){
mHistograms["fwdVertexZ"] = new TH1D("fwdVertexZ", "FWD Vertex (RAVE);z", 1000, -50, 50);
@@ -739,6 +737,10 @@ void StFwdTrackMaker::loadFttHitsFromGEANT( FwdDataSource::McTrackMap_t &mcTrack

void StFwdTrackMaker::loadFstHits( FwdDataSource::McTrackMap_t &mcTrackMap, FwdDataSource::HitMap_t &hitMap, int count ){
StEvent *event = (StEvent *)GetDataSet("StEvent");
if (!event) {
LOG_ERROR << "No StEvent, cannot load FST hits" << endm;
return;
}
StFstHitCollection *fstHitCollection = event->fstHitCollection();

if ( fstHitCollection ){
1 change: 1 addition & 0 deletions StRoot/StFwdTrackMaker/StFwdTrackMaker.h
Original file line number Diff line number Diff line change
@@ -188,6 +188,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
2 changes: 1 addition & 1 deletion StRoot/StFwdTrackMaker/macro/build_geom.C
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
// that is a valid shebang to run script as executable


void build_geom( TString geomtag = "dev2022", TString output="fGeom.root" ) {
void build_geom( TString geomtag = "y2023", TString output="fGeom.root" ) {

gSystem->Load( "libStarRoot.so" );

152 changes: 152 additions & 0 deletions StRoot/StPicoDstMaker/StPicoDstMaker.cxx
Original file line number Diff line number Diff line change
@@ -40,6 +40,9 @@
#include "StEvent/StTriggerData.h"
#include "StEvent/StEnumerations.h"
#include "StEvent/StL0Trigger.h"
#include "StEvent/StFwdTrackCollection.h"
#include "StEvent/StFwdTrack.h"
#include "StEvent/StFcsCluster.h"

#include "StMuDSTMaker/COMMON/StMuDst.h"
#include "StMuDSTMaker/COMMON/StMuEvent.h"
@@ -59,6 +62,9 @@
#include "StMuDSTMaker/COMMON/StMuETofHeader.h"
#include "StMuDSTMaker/COMMON/StMuMcTrack.h"
#include "StMuDSTMaker/COMMON/StMuMcVertex.h"
#include "StMuDSTMaker/COMMON/StMuFcsCollection.h"
#include "StMuDSTMaker/COMMON/StMuFcsHit.h"
#include "StMuDSTMaker/COMMON/StMuFcsCluster.h"

#include "StTriggerUtilities/StTriggerSimuMaker.h"
#include "StTriggerUtilities/Bemc/StBemcTriggerSimu.h"
@@ -70,6 +76,7 @@
#include "StEmcRawMaker/StBemcTables.h"

#include "StFmsDbMaker/StFmsDbMaker.h"
#include "StFcsDbMaker/StFcsDb.h"

#include "tables/St_mtdModuleToQTmap_Table.h"
#include "tables/St_mtdQTSlewingCorr_Table.h"
@@ -94,6 +101,9 @@
#include "StPicoEvent/StPicoBEmcSmdPHit.h"
#include "StPicoEvent/StPicoETofHit.h"
#include "StPicoEvent/StPicoETofPidTraits.h"
#include "StPicoEvent/StPicoFwdTrack.h"
#include "StPicoEvent/StPicoFcsHit.h"
#include "StPicoEvent/StPicoFcsCluster.h"
#include "StPicoEvent/StPicoMcVertex.h"
#include "StPicoEvent/StPicoMcTrack.h"
#include "StPicoEvent/StPicoArrays.h"
@@ -245,6 +255,9 @@ void StPicoDstMaker::streamerOff() {
StPicoTrackCovMatrix::Class()->IgnoreTObjectStreamer();
StPicoETofHit::Class()->IgnoreTObjectStreamer();
StPicoETofPidTraits::Class()->IgnoreTObjectStreamer();
StPicoFwdTrack::Class()->IgnoreTObjectStreamer();
StPicoFcsHit::Class()->IgnoreTObjectStreamer();
StPicoFcsCluster::Class()->IgnoreTObjectStreamer();
StPicoMcVertex::Class()->IgnoreTObjectStreamer();
StPicoMcTrack::Class()->IgnoreTObjectStreamer();
}
@@ -893,6 +906,9 @@ Int_t StPicoDstMaker::MakeWrite() {
fillEpdHits();
fillBbcHits();
fillETofHits();
fillFcsHits();
fillFcsClusters();
fillFwdTracks();

// Could be a good idea to move this call to Init() or InitRun()
StFmsDbMaker* fmsDbMaker = static_cast<StFmsDbMaker*>(GetMaker("fmsDb"));
@@ -2502,6 +2518,142 @@ void StPicoDstMaker::fillMtdHits() {
} //while (triggerPos.size() > 0)
}

//_________________
void StPicoDstMaker::fillFwdTracks() {

StEvent *evt = (StEvent *)GetDataSet("StEvent");
if ( evt ){
StFwdTrackCollection * evc = evt->fwdTrackCollection();
if ( !evc ){
LOG_ERROR << "null FwdTrackCollection" << endm;
return;
}

// fill a map of picodst FCS clusters between index and the cluster pointer
map<UShort_t, StPicoFcsCluster*> fcsClusterMap;
for ( auto iClu = 0; iClu < mPicoArrays[StPicoArrays::FcsCluster]->GetEntries(); iClu++ ){
StPicoFcsCluster * picoFcsCluster = (StPicoFcsCluster*)mPicoArrays[StPicoArrays::FcsCluster]->At(iClu);
fcsClusterMap[picoFcsCluster->index()] = picoFcsCluster;
}

const StSPtrVecFwdTrack& evTracks = evc->tracks();
LOG_INFO << "Adding " << evc->numberOfTracks() << " StFwdTracks from StEvent to PicoDst" << endm;
for ( size_t i = 0; i < evc->numberOfTracks(); i++ ){
StFwdTrack * evTrack = evTracks[i];
StPicoFwdTrack picoFwdTrack;
picoFwdTrack.setMomentum( evTrack->momentum().x(), evTrack->momentum().y(), evTrack->momentum().z() );
picoFwdTrack.setNumberOfFitPoints( evTrack->numberOfFitPoints() * evTrack->charge() );
picoFwdTrack.setNumberOfSeedPoints( evTrack->numberOfSeedPoints() );
picoFwdTrack.setChi2( evTrack->chi2() );
picoFwdTrack.setDca( evTrack->dca().x(), evTrack->dca().y(), evTrack->dca().z() );
if ( evTrack->didFitConvergeFully())
picoFwdTrack.setStatus( 2 );
else if ( evTrack->didFitConverge())
picoFwdTrack.setStatus( 1 );
else
picoFwdTrack.setStatus( 0 );

picoFwdTrack.setMcTruth( evTrack->idTruth(), evTrack->qaTruth() );
picoFwdTrack.setVtxIndex( evTrack->vertexIndex() );

// fill matched ecal and hcal clusters for the track
// ecal
for ( auto & cluster : evTrack->ecalClusters() ){
if ( mMapFcsIdPairIndex.count( make_pair( cluster->detectorId(), cluster->id() ) ) == 0 ){
LOG_WARN << "No FCS cluster found for ecal cluster with id " << cluster->id() << " and detectorId " << cluster->detectorId() << endm;
continue;
}
int index = mMapFcsIdPairIndex[ make_pair( cluster->detectorId(), cluster->id() ) ];
picoFwdTrack.addEcalCluster( index );
}
// hcal
for ( auto & cluster : evTrack->hcalClusters() ){
if ( mMapFcsIdPairIndex.count( make_pair( cluster->detectorId(), cluster->id() ) ) == 0 ){
LOG_WARN << "No FCS cluster found for hcal cluster with id " << cluster->id() << " and detectorId " << cluster->detectorId() << endm;
continue;
}
int index = mMapFcsIdPairIndex[ make_pair( cluster->detectorId(), cluster->id() ) ];
picoFwdTrack.addHcalCluster( index );
}


int counter = mPicoArrays[StPicoArrays::FwdTrack]->GetEntries();
picoFwdTrack.setId( counter );
new((*(mPicoArrays[StPicoArrays::FwdTrack]))[counter]) StPicoFwdTrack(picoFwdTrack);
}
} else {
LOG_WARN << "Cannot get Fwd Tracks from StEvent" << endm;
}
} //fillFwdTracks

//_________________
void StPicoDstMaker::fillFcsClusters() {
StFcsDb* fcsDb = static_cast<StFcsDb*>(GetDataSet("fcsDb"));
if( !fcsDb ) {
LOG_ERROR << "Cannot get StFcsDb object" << endm;
return;
}
StMuFcsCollection * muFcs = mMuDst->muFcsCollection();
if ( !muFcs ) {
LOG_ERROR << "Cannot get Fcs Collection from MuDst" << endm;
return;
}
TIter next(muFcs->getClusterArray());
StMuFcsCluster* muCluster(NULL);
while ((muCluster = static_cast<StMuFcsCluster*>(next()))) {
int counter = mPicoArrays[StPicoArrays::FcsCluster]->GetEntries();
StPicoFcsCluster picoFcsCluster;
picoFcsCluster.setId(muCluster->id());
picoFcsCluster.setIndex(counter);
picoFcsCluster.setDetectorId(muCluster->detectorId());
picoFcsCluster.setCategory(muCluster->category());
picoFcsCluster.setNTowers(muCluster->nTowers());
picoFcsCluster.setEnergy(muCluster->energy());
picoFcsCluster.setX(muCluster->x());
picoFcsCluster.setY(muCluster->y());
picoFcsCluster.setSigmaMin(muCluster->sigmaMin());
picoFcsCluster.setSigmaMax(muCluster->sigmaMax());
picoFcsCluster.setTheta(muCluster->theta());
picoFcsCluster.setChi2Ndf1Photon(muCluster->chi2Ndf1Photon());
picoFcsCluster.setChi2Ndf2Photon(muCluster->chi2Ndf2Photon());
double zVertex=picoDst()->event()->primaryVertex().z();
StThreeVectorD xyz=fcsDb->getStarXYZ(muCluster->detectorId(), muCluster->x(), muCluster->y());
StLorentzVectorD lv = fcsDb->getLorentzVector(xyz, muCluster->energy(), zVertex);
picoFcsCluster.setFourMomentum(lv.px(),lv.py(),lv.pz(),lv.e());
new((*(mPicoArrays[StPicoArrays::FcsCluster]))[counter]) StPicoFcsCluster(picoFcsCluster);
mMapFcsIdPairIndex[ make_pair( muCluster->detectorId(), muCluster->id() ) ] = counter;
}
LOG_INFO << "StPicoDstMaker::fillFcsClusters filled " << mPicoArrays[StPicoArrays::FcsCluster]->GetEntries() << endm;
}//fillFcsClusters

//_________________
void StPicoDstMaker::fillFcsHits() {
StFcsDb* fcsDb = static_cast<StFcsDb*>(GetDataSet("fcsDb"));
if( !fcsDb ) {
LOG_ERROR << "Cannot get StFcsDb object" << endm;
return;
}
StMuFcsCollection * muFcs = mMuDst->muFcsCollection();
if ( !muFcs ) {
LOG_ERROR << "Cannot get Fcs Collection from MuDst" << endm;
return;
}
TIter next(muFcs->getHitArray());
StMuFcsHit* muHit(NULL);
while ((muHit = static_cast<StMuFcsHit*>(next()))) {
int counter = mPicoArrays[StPicoArrays::FcsHit]->GetEntries();
StPicoFcsHit picoFcsHit;
picoFcsHit.setDetectorId(muHit->detectorId());
picoFcsHit.setId(muHit->id());
double zVertex=picoDst()->event()->primaryVertex().z();
StThreeVectorD xyz = fcsDb->getStarXYZ(muHit->detectorId(), muHit->id());
StLorentzVectorD lv = fcsDb->getLorentzVector(xyz, muHit->energy(), zVertex);
picoFcsHit.setFourMomentum(lv.px(),lv.py(),lv.pz(),lv.e());
new((*(mPicoArrays[StPicoArrays::FcsHit]))[counter]) StPicoFcsHit(picoFcsHit);
}
LOG_INFO << "StPicoDstMaker::fillFcsHits filled " << mPicoArrays[StPicoArrays::FcsHit]->GetEntries() << endm;
}//fillFcsHit

#if !defined (__TFG__VERSION__)

/**
9 changes: 9 additions & 0 deletions StRoot/StPicoDstMaker/StPicoDstMaker.h
Original file line number Diff line number Diff line change
@@ -225,6 +225,12 @@ class StPicoDstMaker : public StMaker {
void fillBbcHits();
/// Fill ETOF information
void fillETofHits();
/// Fill Fwd Track information
void fillFwdTracks();
/// Fill FcsHits information
void fillFcsHits();
/// Fill FcsClusters information
void fillFcsClusters();
/// Fill MC vertex information
void fillMcVertices();
/// Fill MC track information
@@ -287,6 +293,9 @@ class StPicoDstMaker : public StMaker {
/// Pointer to the array of BEMC tower hits
StEmcRawHit* mEmcIndex[4800];

/// Map of StPicoFcsCluster detId + Id to index in the array for track matching
std::map<std::pair<int, int>, int> mMapFcsIdPairIndex;

/// Magnetic field of the current event
Float_t mBField;

21 changes: 15 additions & 6 deletions StRoot/StPicoEvent/StPicoArrays.cxx
Original file line number Diff line number Diff line change
@@ -25,8 +25,11 @@ const char* StPicoArrays::picoArrayNames [NAllPicoArrays] = { "Event",
"BEmcSmdPHit",
"ETofHit",
"ETofPidTraits",
"McVertex",
"McTrack"
"McVertex",
"McTrack",
"FwdTracks",
"FcsHits",
"FcsClusters"
};

// ARRAY TYPES
@@ -49,8 +52,11 @@ const char* StPicoArrays::picoArrayTypes [NAllPicoArrays] = { "StPicoEvent",
"StPicoBEmcSmdPHit",
"StPicoETofHit",
"StPicoETofPidTraits",
"StPicoMcVertex",
"StPicoMcTrack"
"StPicoMcVertex",
"StPicoMcTrack",
"StPicoFwdTrack",
"StPicoFcsHit",
"StPicoFcsCluster"
};

// ARRAY SIZES
@@ -76,8 +82,11 @@ int StPicoArrays::picoArraySizes [NAllPicoArrays] = { 1, // StPicoEvent
100, // StPicoBEmcSmdPHit
100, // StPicoETofHit
100, // StPicoETofPidTraits
10, // StPicoMcVertex
1000 // StPicoMcTrack
10, // StPicoMcVertex
1000, // StPicoMcTrack
10, // StPicoFwdTrack
200, // StPicoFcsHit
100 // StPicoFcsCluster
};

//_________________
7 changes: 4 additions & 3 deletions StRoot/StPicoEvent/StPicoArrays.h
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ class StPicoArrays {
StPicoArrays();

/// Should be changed to constexpr once ROOT 6 is available at STAR
enum { NAllPicoArrays = 20};
enum { NAllPicoArrays = 23};

/// Names of the TBranches in the TTree/File
static const char* picoArrayNames[NAllPicoArrays];
@@ -32,8 +32,9 @@ class StPicoArrays {
enum TypeIndex { Event=0, Track, EmcTrigger, MtdTrigger,
BTowHit, BTofHit, MtdHit, BbcHit, EpdHit, FmsHit,
BEmcPidTraits, BTofPidTraits, MtdPidTraits, TrackCovMatrix,
BEmcSmdEHit, BEmcSmdPHit, ETofHit, ETofPidTraits,
McVertex, McTrack };
BEmcSmdEHit, BEmcSmdPHit, ETofHit, ETofPidTraits,
McVertex, McTrack,
FwdTrack, FcsHit, FcsCluster };
};

#endif
17 changes: 17 additions & 0 deletions StRoot/StPicoEvent/StPicoDst.cxx
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
#include "StPicoBEmcSmdPHit.h"
#include "StPicoETofHit.h"
#include "StPicoETofPidTraits.h"
#include "StPicoFwdTrack.h"
#include "StPicoMcVertex.h"
#include "StPicoMcTrack.h"
#include "StPicoDst.h" //MUST be the last one
@@ -328,3 +329,19 @@ void StPicoDst::printETofPidTraits() {

LOG_INFO << endm;
}
//_________________
void StPicoDst::printFwdTracks() {
if(numberOfFwdTracks() == 0) {
LOG_INFO << "No Fwd tracks found!" << endm;
return;
}

LOG_INFO << "\n+++++++++ fwd track list ( " << numberOfFwdTracks() << " entries )\n\n";
for(UInt_t iTrk=0; iTrk<numberOfFwdTracks(); iTrk++) {
LOG_INFO << "+++ track " << iTrk << "\n";
fwdTrack(iTrk)->Print();
LOG_INFO << "\n";
}

LOG_INFO << endm;
}
Loading