Skip to content

Commit d2d68df

Browse files
Merge pull request #241 from NamithaChitrazee/main
Addition of time cluster and background cluster hits
2 parents 7509ccc + 42a84be commit d2d68df

File tree

4 files changed

+71
-88
lines changed

4 files changed

+71
-88
lines changed

examples/nominal_MDC2020_withBkgClusters.fcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ physics.analyzers.Mu2eEventDisplay.addCRVBars : false
2828

2929
physics.analyzers.Mu2eEventDisplay.addKalInter : true
3030
physics.analyzers.Mu2eEventDisplay.addCrystalHits : false
31-
physics.analyzers.Mu2eEventDisplay.filler.addHelixSeeds : false
32-
physics.analyzers.Mu2eEventDisplay.filler.addKalSeeds : false
31+
physics.analyzers.Mu2eEventDisplay.filler.addHelixSeeds : true
32+
physics.analyzers.Mu2eEventDisplay.filler.addKalSeeds : true
3333
physics.analyzers.Mu2eEventDisplay.filler.addClusters : false
3434
physics.analyzers.Mu2eEventDisplay.filler.addHits : true # adds ComboHits
35-
physics.analyzers.Mu2eEventDisplay.filler.addBkgClusters : true
35+
physics.analyzers.Mu2eEventDisplay.filler.addBkgClusters : false
3636
physics.analyzers.Mu2eEventDisplay.filler.addCrvClusters : false
3737
physics.analyzers.Mu2eEventDisplay.filler.addCrvHits : false
3838
physics.analyzers.Mu2eEventDisplay.filler.addTimeClusters : false
3939
physics.analyzers.Mu2eEventDisplay.filler.addSimParts : false
4040
physics.analyzers.Mu2eEventDisplay.addTrkStrawHits : false
4141
physics.analyzers.Mu2eEventDisplay.filler.addCosmicTrackSeeds : false
42-
physics.analyzers.Mu2eEventDisplay.filler.addMCTraj : false
43-
physics.analyzers.Mu2eEventDisplay.specifyTag : false
42+
physics.analyzers.Mu2eEventDisplay.filler.addMCTraj : true
43+
physics.analyzers.Mu2eEventDisplay.specifyTag : true
4444

4545
# allows movement through events in sequential order
4646
physics.analyzers.Mu2eEventDisplay.seqMode : true

inc/DataInterface.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace mu2e{
6060
inline constexpr double pointmmTocm(double mm){ return mm/10; };
6161
void AddBkgClusters(REX::REveManager *&eveMng, bool firstLoop_, std::tuple<std::vector<std::string>, std::vector<const BkgClusterCollection*>> bkgcluster_tuple, REX::REveElement* &scene);
6262
void AddComboHits(REX::REveManager *&eveMng, bool firstLoop_, std::tuple<std::vector<std::string>, std::vector<const ComboHitCollection*>> combohit_tuple, REX::REveElement* &scene, bool strawdisplay, bool AddErrBar);
63-
void AddTimeClusters(REX::REveManager *&eveMng, bool firstloop, std::tuple<std::vector<std::string>, std::vector<const TimeClusterCollection*>> timecluster_tuple, REX::REveElement* &scene);
63+
void AddTimeClusters(REX::REveManager *&eveMng, bool firstloop, std::tuple<std::vector<std::string>, std::vector<const TimeClusterCollection*>> timecluster_tuple, std::tuple<std::vector<std::string>, std::vector<const ComboHitCollection*>> combohit_tuple, REX::REveElement* &scene);
6464
void AddCaloDigis(REX::REveManager *&eveMng, bool firstLoop_, std::tuple<std::vector<std::string>, std::vector<const CaloDigiCollection*>> calodigi_tuple, REX::REveElement* &scene);
6565
void AddCaloClusterLegend(REX::REveElement* scene, double t_ref);
6666
void AddCaloClusters(REX::REveManager *&eveMng, bool firstLoop_, std::tuple<std::vector<std::string>, std::vector<const CaloClusterCollection*>> calocluster_tuple, REX::REveElement* &scene, bool addCrystalDraw);

src/DataInterface.cc

Lines changed: 64 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -372,34 +372,44 @@ void DataInterface::AddCaloClusters(REX::REveManager *&eveMng, bool firstLoop_,
372372
}
373373

374374
/*
375-
Enables the visualization of cluster of hits flagged as background by the FlagBkgHits module. This is work in progress. More features coming soon.
375+
Enables the visualization of cluster of hits flagged as background by the FlagBkgHits module.
376376
*/
377377
void DataInterface::AddBkgClusters(REX::REveManager *&eveMng, bool firstLoop_, std::tuple<std::vector<std::string>, std::vector<const BkgClusterCollection*>> bkgcluster_tuple, REX::REveElement* &scene){
378378
std::cout<<"BkgClusterCollection "<<std::endl;
379379
std::vector<const BkgClusterCollection*> bkgcluster_list = std::get<1>(bkgcluster_tuple);
380380
// std::vector<std::string> names = std::get<0>(bkgcluster_tuple);
381381
std::cout<<"BkgClusterCollection size = "<<bkgcluster_list.size()<<std::endl;
382+
std::string bctitle = "BkgCluster";
383+
auto ps1 = new REX::REvePointSet(bctitle, bctitle,0);
384+
int colour = 6; //Magenta
382385
for(unsigned int j = 0; j < bkgcluster_list.size(); j++){
383386
const BkgClusterCollection* bccol = bkgcluster_list[j];
384387
if(bccol->size() !=0 ){
385388
// Loop over hits
386389
for(unsigned int i=0; i< bccol->size(); i++){
387390
mu2e::BkgCluster const &bkgcluster= (*bccol)[i];
388-
int colour = (i+3);
389-
std::cout<<"BkgCluster ="<<bkgcluster.hits().size()<<std::endl;
391+
std::string bchtitle = "BkgClusterHits";
392+
auto ps2 = new REX::REvePointSet(bchtitle, bchtitle,0);
393+
for (size_t j = 0; j < bkgcluster.hitposition().size(); ++j) {
394+
auto const& p = bkgcluster.hitposition()[j];
395+
ps2->SetNextPoint(pointmmTocm(p.x()), pointmmTocm(p.y()) , pointmmTocm(p.z()));
396+
}
397+
ps2->SetMarkerColor(i);
398+
ps2->SetMarkerStyle(DataInterface::mstyle);
399+
ps2->SetMarkerSize(DataInterface::msize);
400+
if(ps2->GetSize() !=0 ) scene->AddElement(ps2);
401+
//int colour = (i+3);
402+
//std::cout<<"BkgCluster ="<<bkgcluster.hits().size()<<std::endl;
390403
CLHEP::Hep3Vector ClusterPos(pointmmTocm(bkgcluster.pos().x()), pointmmTocm(bkgcluster.pos().y()), pointmmTocm(bkgcluster.pos().z()));
391-
std::string bctitle = "BkgCluster";
392-
auto ps1 = new REX::REvePointSet(bctitle, bctitle,0);
393404
ps1->SetNextPoint(ClusterPos.x(), ClusterPos.y() , ClusterPos.z());
394-
ps1->SetMarkerColor(colour);
395-
ps1->SetMarkerStyle(DataInterface::mstyle);
396-
ps1->SetMarkerSize(DataInterface::msize);
397-
if(ps1->GetSize() !=0 ) scene->AddElement(ps1);
398405
}
399406
}
400407
}
408+
ps1->SetMarkerColor(colour);
409+
ps1->SetMarkerStyle(DataInterface::mstyle);
410+
ps1->SetMarkerSize(DataInterface::msize);
411+
if(ps1->GetSize() !=0 ) scene->AddElement(ps1);
401412
}
402-
403413
/*
404414
* Adds reconstructed ComboHits data products to the REve visualization scene.
405415
* Hits are visualized as points with optional error bars
@@ -463,6 +473,10 @@ void DataInterface::AddComboHits(REX::REveManager *&eveMng, bool firstLoop_,
463473
std::string master_name = "ComboHits_" + names[j];
464474
auto master_compound = new REX::REveCompound(master_name.c_str(), master_name.c_str(), true);
465475
master_compound->SetRnrSelf(false); // Only render children (hits/errors)
476+
477+
std::string bkghit = "FlgBkgHit";
478+
auto ps2 = new REX::REvePointSet(bkghit, bkghit,0);
479+
ps2->SetMarkerColor(2);
466480

467481
mu2e::GeomHandle<mu2e::Tracker> tracker;
468482
const auto& allStraws = tracker->getStraws();
@@ -564,15 +578,20 @@ void DataInterface::AddComboHits(REX::REveManager *&eveMng, bool firstLoop_,
564578
+ " energy dep : " + std::to_string(hit.energyDep()) + "MeV";
565579

566580
auto ps1 = new REX::REvePointSet(chtitle.c_str(), chtitle.c_str(), 0);
567-
ps1->SetNextPoint(HitPos.x(), HitPos.y() , HitPos.z());
568-
569-
ps1->SetMarkerColor(hit_color); // Time-based color
570-
ps1->SetMarkerStyle(DataInterface::mstyle);
571-
ps1->SetMarkerSize(DataInterface::msize);
572-
573-
master_compound->AddElement(ps1);
581+
if (!hit.flag().hasAnyProperty(StrawHitFlagDetail::bkg)){
582+
ps1->SetNextPoint(HitPos.x(), HitPos.y() , HitPos.z());
583+
ps1->SetMarkerColor(hit_color); // Time-based color
584+
ps1->SetMarkerStyle(DataInterface::mstyle);
585+
ps1->SetMarkerSize(DataInterface::msize);
586+
master_compound->AddElement(ps1);
587+
}
588+
else{
589+
ps2->SetNextPoint(HitPos.x(), HitPos.y() , HitPos.z());
590+
}
574591
}
575-
592+
ps2->SetMarkerStyle(DataInterface::mstyle);
593+
ps2->SetMarkerSize(DataInterface::msize);
594+
if(ps2->GetSize() !=0) scene->AddElement(ps2);
576595
// Add the Master Compound to the Scene
577596
scene->AddElement(master_compound);
578597
}
@@ -1055,76 +1074,41 @@ void DataInterface::AddCrvClusters(REX::REveManager *&eveMng, bool firstLoop_,
10551074
}
10561075
}
10571076

1058-
/*
1059-
* Adds reconstructed TimeClusers data products to the REve visualization scene.
1060-
* visualized as points
1061-
*/
1062-
// FIXME - do we ever use this? What is the purpose?
1063-
void DataInterface::AddTimeClusters(REX::REveManager *&eveMng, bool firstLoop_,
1064-
std::tuple<std::vector<std::string>,
1065-
std::vector<const TimeClusterCollection*>> timecluster_tuple,
1066-
REX::REveElement* &scene){
1067-
1068-
1069-
std::vector<const TimeClusterCollection*> timecluster_list = std::get<1>(timecluster_tuple);
1070-
std::vector<std::string> names = std::get<0>(timecluster_tuple);
1077+
/*------------Function to add TimeCluster Collection in 3D and 2D displays:-------------*/
1078+
void DataInterface::AddTimeClusters(REX::REveManager *&eveMng, bool firstLoop_, std::tuple<std::vector<std::string>, std::vector<const TimeClusterCollection*>> timecluster_tuple, std::tuple<std::vector<std::string>, std::vector<const ComboHitCollection*>> combohit_tuple, REX::REveElement* &scene){
10711079

1072-
if(timecluster_list.empty()){
1073-
return;
1074-
} else {
1075-
std::cout << "[DataInterface::AddTimeClusters()]" << std::endl;
1076-
}
1077-
1078-
// Loop over TimeCluster Collections (i-loop)
1080+
std::vector<const TimeClusterCollection*> timecluster_list = std::get<1>(timecluster_tuple);
1081+
std::vector<const ComboHitCollection*> combohit_list = std::get<1>(combohit_tuple);
1082+
const ComboHitCollection* chcol = combohit_list[0];
1083+
std::vector<std::string> names = std::get<0>(timecluster_tuple);
1084+
std::cout<<"time cluster collection size = "<<timecluster_list.size()<<std::endl;
1085+
if(timecluster_list.size() !=0){
10791086
for(unsigned int i = 0; i < timecluster_list.size(); i++){
1080-
const TimeClusterCollection* tccol = timecluster_list[i];
1081-
1082-
if(tccol && tccol->size() != 0){
1083-
1084-
// Create a compound for this entire collection for better organization in the REve tree
1085-
std::string collection_title = "Time Cluster Collection: " + names[i];
1086-
auto collection_compound = new REX::REveCompound(collection_title.c_str(), collection_title.c_str(), true);
1087-
1088-
// Loop over individual TimeClusters (j-loop)
1089-
for(size_t j=0; j<tccol->size();j++){
1090-
mu2e::TimeCluster const &tclust= (*tccol)[j];
1091-
1092-
// Detailed title for mouseover
1093-
std::string tctitle = "Time Cluster tag: " + names[i] + '\n'
1094-
+ "t0: " + std::to_string(tclust.t0().t0()) + " +/- " + std::to_string(tclust.t0().t0Err()) + " ns " + '\n'
1095-
+ "Hits: " + std::to_string(tclust.hits().size()) + '\n'
1096-
+ "Position (X, Y, Z): (" + std::to_string(tclust._pos.x()) + ", " + std::to_string(tclust._pos.y()) + ", " + std::to_string(tclust._pos.z()) + ") mm";
1097-
1098-
// Create a point set for the single cluster. Naming convention improved.
1099-
std::string ps_name = "Cluster_" + std::to_string(j) + "_" + names[i];
1100-
auto ps1 = new REX::REvePointSet(ps_name.c_str(), tctitle.c_str(), 1);
1101-
1102-
// Get position and convert to cm
1103-
CLHEP::Hep3Vector clusterPos(tclust._pos.x(), tclust._pos.y(), tclust._pos.z());
1104-
ps1->SetNextPoint(pointmmTocm(clusterPos.x()), pointmmTocm(clusterPos.y()) , pointmmTocm(clusterPos.z()));
1105-
1106-
// Marker style configuration
1107-
ps1->SetMarkerColor(i + 6); // Use a color based on collection index (i)
1108-
ps1->SetMarkerStyle(kOpenCircle);
1109-
ps1->SetMarkerSize(DataInterface::msize * 1.5); // Slightly larger marker for clarity
1110-
1111-
if(ps1->GetSize() !=0 ) {
1112-
// Add the individual cluster point set to the collection compound
1113-
collection_compound->AddElement(ps1);
1114-
}
1115-
} // End of j-loop (clusters)
1116-
1117-
// Add the entire collection compound to the main scene
1118-
scene->AddElement(collection_compound);
1087+
const TimeClusterCollection* tccol = timecluster_list[i];
1088+
for(size_t j=0; j<tccol->size();j++){
1089+
mu2e::TimeCluster const &tclust= (*tccol)[j];
1090+
std::string tctitle = "Time Cluster tag: " + names[i] + '\n'
1091+
+ "t0 " + std::to_string(tclust.t0().t0()) + " +/- " + std::to_string(tclust.t0().t0Err()) + " ns " + '\n' ;
1092+
auto ps1 = new REX::REvePointSet("TimeClusters", tctitle, 0);
1093+
int tchitsize = tclust.hits().size();
1094+
for (int ih=0; ih < tchitsize; ih++) {
1095+
StrawHitIndex hit_index = tclust.hits().at(ih);
1096+
const mu2e::ComboHit* hit = &chcol->at(hit_index);
1097+
CLHEP::Hep3Vector HitPos(pointmmTocm(hit->pos().x()), pointmmTocm(hit->pos().y()), pointmmTocm(hit->pos().z()));
1098+
ps1->SetNextPoint(HitPos.x(), HitPos.y(), HitPos.z());
1099+
}
1100+
ps1->SetMarkerColor(j);
1101+
ps1->SetMarkerStyle(DataInterface::mstyle);
1102+
ps1->SetMarkerSize(DataInterface::msize);
1103+
if(ps1->GetSize() !=0) scene->AddElement(ps1);
11191104
}
1120-
} // End of i-loop (collections)
1105+
}
1106+
}
11211107
}
1122-
11231108
/*
11241109
* Adds reconstructed HelixSeed data products to the REve visualization scene.
11251110
* Visualized as series of lines
11261111
*/
1127-
//FIXME - establish a use case, if none, remove!
11281112
void DataInterface::AddHelixSeedCollection(REX::REveManager *&eveMng, bool firstloop,
11291113
std::tuple<std::vector<std::string>,
11301114
std::vector<const HelixSeedCollection*>> helix_tuple,
@@ -1679,4 +1663,3 @@ void DataInterface::AddCosmicTrackFit(REX::REveManager *&eveMng, bool firstLoop_
16791663
// Add the compound of all tracks to the scene
16801664
scene->AddElement(all_tracks_compound);
16811665
}
1682-

src/MainWindow.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ void MainWindow::showEvents(REX::REveManager *eveMng, REX::REveElement* &eventSc
794794
}
795795
if(drawOpts.addTimeClusters){
796796
std::vector<const TimeClusterCollection*> timecluster_list = std::get<1>(data.timecluster_tuple);
797-
if(timecluster_list.size() !=0) pass_data->AddTimeClusters(eveMng, firstLoop, data.timecluster_tuple, eventScene);
797+
if(timecluster_list.size() !=0) pass_data->AddTimeClusters(eveMng, firstLoop, data.timecluster_tuple, data.combohit_tuple, eventScene);
798798
}
799799

800800
//... add MC:

0 commit comments

Comments
 (0)