35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
// vis_helpers.h (or paste into anasenMS.cpp)
|
|
#include <TEvePointSet.h>
|
|
#include <TFile.h>
|
|
#include <TTree.h>
|
|
#include <vector>
|
|
#include <mutex>
|
|
|
|
static TEvePointSet* gVisPts = nullptr;
|
|
static std::mutex gVisMutex;
|
|
|
|
// Call from your ROOT session after creating TEve objects:
|
|
void SetVisPointSet(TEvePointSet* pts){ gVisPts = pts; }
|
|
|
|
// Call this from your sim loop to update visualization and optionally write data:
|
|
void PushEventAndRecord(const std::vector<double>& x,
|
|
const std::vector<double>& y,
|
|
const std::vector<double>& z,
|
|
TTree* outTree = nullptr)
|
|
{
|
|
if(outTree){
|
|
outTree->SetBranchAddress("x",(void*)&x);
|
|
outTree->SetBranchAddress("y",(void*)&y);
|
|
outTree->SetBranchAddress("z",(void*)&z);
|
|
outTree->Fill();
|
|
outTree->GetCurrentFile()->Flush();
|
|
}
|
|
|
|
if(!gVisPts) return;
|
|
std::lock_guard<std::mutex> lk(gVisMutex);
|
|
gVisPts->Reset();
|
|
for(size_t i=0;i<x.size(); ++i) gVisPts->SetNextPoint(x[i], y[i], z[i]);
|
|
gEve->Redraw3D();
|
|
gSystem->ProcessEvents();
|
|
}
|