Skip to content

Commit

Permalink
Merge pull request #900 from sophiemiddleton/TEveUpdates
Browse files Browse the repository at this point in the history
Updated TEve Event Display to plot the new KKTraj options
  • Loading branch information
brownd1978 committed Dec 16, 2022
2 parents 2469285 + d73a510 commit 9b88132
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 44 deletions.
1 change: 1 addition & 0 deletions TEveEventDisplay/fcl/prolog.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ TEveEventDisplayBase : {
addClusters : true
addTrkExtTrajs : false
addMCTraj : true
addKKTracks : false
}
gdmlname : "Offline/TEveEventDisplay/src/mu2e.gdml"
particles : [11,13,2212,2112,211,22,212]
Expand Down
1 change: 1 addition & 0 deletions TEveEventDisplay/src/Collection_Filler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace mu2e{
RecoOnly_(conf.RecoOnly()),
FillAll_(conf.FillAll()),
addMCTraj_(conf.addMCTraj()),
addKKTracks_(conf.addKKTracks()),
MCOnly_(conf.MCOnly())
{}
#endif
Expand Down
2 changes: 1 addition & 1 deletion TEveEventDisplay/src/TEveEventDisplay_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace mu2e
application_ = new TApplication( "noapplication", &tmp_argc, tmp_argv );
}
//construct GUI:
const DrawOptions DrawOpts(_filler.addCrvHits_, _filler.addCosmicSeedFit_, _filler.addTracks_, _filler.addClusters_, _filler.addHits_, _filler.addTrkHits_, _filler.addTimeClusters_, false, _filler.addMCTraj_);
const DrawOptions DrawOpts(_filler.addCrvHits_, _filler.addCosmicSeedFit_, _filler.addTracks_, _filler.addClusters_, _filler.addHits_, _filler.addTrkHits_, _filler.addTimeClusters_, false, _filler.addMCTraj_, _filler.addKKTracks_);

_frame = new TEveMu2eMainWindow(gClient->GetRoot(), 1000,600, _pset, DrawOpts, _show);

Expand Down
129 changes: 89 additions & 40 deletions TEveEventDisplay/src/TEveMu2eDataInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,97 @@ namespace mu2e{
}


using LHPT = KinKal::PiecewiseTrajectory<KinKal::LoopHelix>;
using CHPT = KinKal::PiecewiseTrajectory<KinKal::CentralHelix>;
using KLPT = KinKal::PiecewiseTrajectory<KinKal::KinematicLine>;
template<class KTRAJ> void TEveMu2eDataInterface::AddKinKalTrajectory( std::unique_ptr<KTRAJ> const& trajectory, TEveMu2eCustomHelix *line, TEveMu2eCustomHelix *line_twoDXY, TEveMu2eCustomHelix *line_twoDXZ){
double t1=trajectory->range().begin();
double t2=trajectory->range().end();

double x1=trajectory->position3(t1).x();
double y1=trajectory->position3(t1).y();
double z1=trajectory->position3(t1).z();
GeomHandle<DetectorSystem> det;
XYZVectorF pos(x1,y1,z1);
CLHEP::Hep3Vector p = GenVector::Hep3Vec(pos);
CLHEP::Hep3Vector InMu2e = det->toMu2e(p);
line->SetPoint(0,pointmmTocm(InMu2e.x()), pointmmTocm(InMu2e.y()) , pointmmTocm(InMu2e.z()));
line_twoDXY->SetPoint(0,pointmmTocm(x1), pointmmTocm(y1) , pointmmTocm(z1));
line_twoDXZ->SetPoint(0,pointmmTocm(x1), pointmmTocm(y1) , pointmmTocm(z1));
for(double t=t1; t<=t2; t+=0.01)
{
const auto &p = trajectory->position3(t);
double xt=p.x();
double yt=p.y();
double zt=p.z();
XYZVectorF pos(x1,y1,z1);
CLHEP::Hep3Vector pmu2e = GenVector::Hep3Vec(pos);
CLHEP::Hep3Vector InMu2e = det->toMu2e(pmu2e);
line->SetNextPoint(pointmmTocm(InMu2e.x()), pointmmTocm(InMu2e.y()) , pointmmTocm(InMu2e.z()));
line_twoDXY->SetNextPoint(pointmmTocm(xt), pointmmTocm(yt), pointmmTocm(zt));
line_twoDXZ->SetNextPoint(pointmmTocm(xt), pointmmTocm(yt), pointmmTocm(zt));
}
}

void TEveMu2eDataInterface::FillKinKalTrajectory(bool firstloop, std::tuple<std::vector<std::string>, std::vector<const KalSeedCollection*>> track_tuple, TEveMu2e2DProjection *tracker2Dproj, TEveProjectionManager *TXYMgr, TEveProjectionManager *TRZMgr, TEveScene *scene1, TEveScene *scene2){
std::cout<<"[REveMu2eDataInterface] AddKinKalTracks "<<std::endl;
std::vector<const KalSeedCollection*> track_list = std::get<1>(track_tuple);
std::vector<std::string> names = std::get<0>(track_tuple);
std::vector<int> colour;

for(unsigned int j=0; j< track_list.size(); j++){
const KalSeedCollection* seedcol = track_list[j];
colour.push_back(j+3);
if(seedcol!=0){
for(unsigned int k = 0; k < seedcol->size(); k++){
mu2e::KalSeed kseed = (*seedcol)[k];
TEveMu2eCustomHelix *line = new TEveMu2eCustomHelix();
TEveMu2eCustomHelix *line_twoDXY = new TEveMu2eCustomHelix();
TEveMu2eCustomHelix *line_twoDXZ = new TEveMu2eCustomHelix();
line->fKalSeed_ = kseed;
line->SetSeedInfo(kseed);

if(kseed.loopHelixFit())
{
auto trajectory=kseed.loopHelixFitTrajectory();
AddKinKalTrajectory<LHPT>(trajectory, line, line_twoDXY,line_twoDXZ);
}
else if(kseed.centralHelixFit())
{
auto trajectory=kseed.centralHelixFitTrajectory();
AddKinKalTrajectory<CHPT>(trajectory,line,line_twoDXY,line_twoDXZ);
}
else if(kseed.kinematicLineFit())
{
auto trajectory=kseed.kinematicLineFitTrajectory();
AddKinKalTrajectory<KLPT>(trajectory,line,line_twoDXY,line_twoDXZ);
}

line_twoDXY->SetLineColor(kOrange);
line_twoDXY->SetLineWidth(3);
fTrackList2DXY->AddElement(line_twoDXY);

line_twoDXZ->SetLineColor(kOrange);
line_twoDXZ->SetLineWidth(3);
fTrackList2DXZ->AddElement(line_twoDXZ);

line->SetPickable(kTRUE);
line->SetLineColor(kOrange);
line->SetLineWidth(3);
fTrackList3D->AddElement(line);
}
tracker2Dproj->fXYMgr->ImportElements(fTrackList2DXY, tracker2Dproj->fEvtXYScene);
tracker2Dproj->fRZMgr->ImportElements(fTrackList2DXZ, tracker2Dproj->fEvtRZScene);
gEve->AddElement(fTrackList3D);
gEve->Redraw3D(kTRUE);
}
}
}



/*------------Function to color code the Tracker hits in 3D and 2D displays:-------------*/
void TEveMu2eDataInterface::AddTrkHits(bool firstloop, const ComboHitCollection *chcol,std::tuple<std::vector<std::string>, std::vector<const KalSeedCollection*>> track_tuple, TEveMu2e2DProjection *tracker2Dproj,
bool Redraw, double min_energy, double max_energy, double min_time, double max_time, bool accumulate, TEveProjectionManager *TXYMgr, TEveProjectionManager *TRZMgr, TEveScene *scene1, TEveScene *scene2){
void TEveMu2eDataInterface::AddTrkHits(bool firstloop, const ComboHitCollection *chcol,std::tuple<std::vector<std::string>, std::vector<const KalSeedCollection*>> track_tuple, TEveMu2e2DProjection *tracker2Dproj,bool Redraw, double min_energy, double max_energy, double min_time, double max_time, bool accumulate, TEveProjectionManager *TXYMgr, TEveProjectionManager *TRZMgr, TEveScene *scene1, TEveScene *scene2){
std::vector<const KalSeedCollection*> track_list = std::get<1>(track_tuple);
std::vector<std::string> names = std::get<0>(track_tuple);
GeomHandle<DetectorSystem> det;
Expand Down Expand Up @@ -487,7 +574,6 @@ namespace mu2e{
calo2Dproj->fRZMgr->ImportElements(fClusterList2D_disk1, calo2Dproj->fDetRZScene);
//CfRZMgr->ImportElements(fClusterList2D_disk1, scene2); For MultiView
}

}
}
gEve->AddElement(fClusterList3D);
Expand Down Expand Up @@ -659,50 +745,13 @@ namespace mu2e{
line->SetLineColor(kGreen);
line->SetLineWidth(3);
fTrackList3D->AddElement(line);

}

tracker2Dproj->fXYMgr->ImportElements(fTrackList2DXY, tracker2Dproj->fEvtXYScene);
tracker2Dproj->fRZMgr->ImportElements(fTrackList2DXZ, tracker2Dproj->fEvtRZScene);

/*TXYMgr->ImportElements(fTrackList2D, scene1);
TRZMgr->ImportElements(fTrackList2D, scene2);*/
gEve->AddElement(fTrackList3D);
gEve->Redraw3D(kTRUE);
}
}

/*TODO - Note this function is untested and awaits compatibility in current Offline. We made it for future upgrades.
void TEveMu2eDataInterface::AddTrackExitTrajectories(bool firstloop, const TrkExtTrajCollection *trkextcol, double min_time, double max_time, bool Redraw, bool accumulate) {
DataLists<const TrkExtTrajCollection*, TEveMu2e2DProjection*>(trkextcol, Redraw, accumulate, "TrackExitTraj", &fExtTrackList3D);
if(trkextcol!=0){
for(unsigned int i = 0; i < trkextcol->size(); i++){
TrkExtTraj trkext = (*trkextcol)[i];
TEveMu2eCustomHelix *line = new TEveMu2eCustomHelix();
line->fTrkExtTraj_ = trkext;
line->SetMomentumExt();
line->SetParticleExt();
line->SetPoint(0,trkext.front().x(),trkext.front().y(),trkext.front().z());
for(unsigned int k = 0 ; k< trkext.size(); k+=10){
const mu2e::TrkExtTrajPoint &trkextpoint = trkext[k];
line->SetNextPoint(trkextpoint.x(), trkextpoint.y(), trkextpoint.z()); //TODO accurate translation
}
// fExtTrackList2D->AddElement(line);
// tracker2Dproj->fXYMgr->ImportElements(fExtTrackList2D, tracker2Dproj->fDetXYScene);
// tracker2Dproj->fRZMgr->ImportElements(fExtTrackList2D, tracker2Dproj->fDetRZScene);
line->SetPickable(kTRUE);
const std::string title = "Helix #" + to_string(i + 1) + ", Momentum = " + to_string(line->Momentum_);
line->SetTitle(Form(title.c_str()));
line->SetLineColor(kRed);
line->SetLineWidth(3);
fExtTrackList3D->AddElement(line);
}
gEve->AddElement(fExtTrackList3D);
gEve->Redraw3D(kTRUE);
}
}*/
}
2 changes: 2 additions & 0 deletions TEveEventDisplay/src/TEveMu2eMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,8 @@ namespace mu2e{
if (DrawOpts.addCryHits) pass_data->AddCrystalHits(firstLoop, data.cryHitcol, calo2Dproj, ftimemin, ftimemax, false, _accumulate, CfXYMgr, CfRZMgr, proj0, proj1);

if (DrawOpts.addTracks) pass_data->AddHelixPieceWise3D(firstLoop, data.track_tuple, tracker2Dproj, ftimemin, ftimemax, false, _accumulate, TfXYMgr, TfRZMgr, proj2, proj3);
if (DrawOpts.addTracks) pass_data->FillKinKalTrajectory(firstLoop, data.track_tuple, tracker2Dproj, TfXYMgr, TfRZMgr, proj2, proj3);


if(DrawOpts.addCosmicTracks) pass_data->AddCosmicTrack(firstLoop, data.cosmiccol, tracker2Dproj, ftimemin, ftimemax, false, _accumulate, TfXYMgr, TfRZMgr, proj2, proj3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ namespace mu2e{

void AddTrkHits(bool firstloop, const ComboHitCollection *chcol, std::tuple<std::vector<std::string>, std::vector<const KalSeedCollection*>> track_tuple, TEveMu2e2DProjection *tracker2Dproj, bool Redraw, double min_energy, double max_energy, double min_time, double max_time, bool accumulate, TEveProjectionManager *TXYMgr, TEveProjectionManager *TRZMgr, TEveScene *scene1, TEveScene *scene2);
void AddTimeClusters(bool firstloop, const TimeClusterCollection *tccol, TEveMu2e2DProjection *tracker2Dproj, bool Redraw, bool accumulate, TEveProjectionManager *TXYMgr, TEveProjectionManager *TRZMgr, TEveScene *scene1, TEveScene *scene2);
template<class KTRAJ> void AddKinKalTrajectory( std::unique_ptr<KTRAJ> const& trajectory, TEveMu2eCustomHelix *line, TEveMu2eCustomHelix *line_twoDXY, TEveMu2eCustomHelix *line_twoDXZ);
void FillKinKalTrajectory(bool firstloop, std::tuple<std::vector<std::string>, std::vector<const KalSeedCollection*>> track_tuple, TEveMu2e2DProjection *tracker2Dproj, TEveProjectionManager *TXYMgr, TEveProjectionManager *TRZMgr, TEveScene *scene1, TEveScene *scene2);

std::vector<double> AddCaloClusters(bool firstloop, const CaloClusterCollection *clustercol,TEveMu2e2DProjection *calo2Dproj, bool Redraw, double min_energy, double max_energy, double min_time, double max_time, bool accumulate, TEveProjectionManager *CfXYMgr, TEveProjectionManager *CfRZMgr, TEveScene *scene1, TEveScene *scene2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ namespace mu2e{
bool addTimeClusters = false;
bool addCryHits = false;
bool addMCTraj = false;
bool addKKTracks = false;
DrawOptions(){};
DrawOptions(bool crv, bool cosmictracks, bool tracks, bool clusters, bool combohits, bool trkhits, bool timeclusters, bool cryhits, bool mctraj)
: addCRVInfo(crv), addCosmicTracks(cosmictracks), addTracks(tracks), addClusters(clusters), addComboHits(combohits), addTrkHits(trkhits), addTimeClusters(timeclusters), addCryHits(cryhits), addMCTraj(mctraj) {};
DrawOptions(bool crv, bool cosmictracks, bool tracks, bool clusters, bool combohits, bool trkhits, bool timeclusters, bool cryhits, bool mctraj, bool kktracks)
: addCRVInfo(crv), addCosmicTracks(cosmictracks), addTracks(tracks), addClusters(clusters), addComboHits(combohits), addTrkHits(trkhits), addTimeClusters(timeclusters), addCryHits(cryhits), addMCTraj(mctraj), addKKTracks(kktracks) {};
};


Expand Down
3 changes: 2 additions & 1 deletion TEveEventDisplay/src/dict_classes/Collection_Filler.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace mu2e{
fhicl::Atom<bool> RecoOnly{Name("RecoOnly"), Comment("set to see only Reco Data Products"), false};
fhicl::Atom<bool> FillAll{Name("FillAll"), Comment("to see all available products"), false};
fhicl::Atom<bool> addMCTraj{Name("addMCTraj"), Comment("set to add MC trajectories"), false};
fhicl::Atom<bool> addKKTracks{Name("addKKTracks"), Comment("set to add KinKal traj"), false};
fhicl::Atom<bool> MCOnly{Name("MCOnly"), Comment("set to see only MC Data Products"), false};
};

Expand All @@ -104,7 +105,7 @@ namespace mu2e{

art::Event *_event;
art::Run *_run;
bool addHits_, addTimeClusters_, addTrkHits_, addTracks_, addClusters_, addCrvHits_, addCosmicSeedFit_, isCosmic_, addTrkExtTrajs_, RecoOnly_, FillAll_, addMCCaloDigis_, addMCTraj_, MCOnly_;
bool addHits_, addTimeClusters_, addTrkHits_, addTracks_, addClusters_, addCrvHits_, addCosmicSeedFit_, isCosmic_, addTrkExtTrajs_, RecoOnly_, FillAll_, addMCCaloDigis_, addMCTraj_, addKKTracks_, MCOnly_;
void FillRecoCollections(const art::Event& evt, Data_Collections &data, RecoDataProductName code);
void FillMCCollections(const art::Event& evt, Data_Collections &data, MCDataProductName code);
virtual ~Collection_Filler(){};
Expand Down

0 comments on commit 9b88132

Please sign in to comment.