Skip to content
Draft
Show file tree
Hide file tree
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
14 changes: 2 additions & 12 deletions inc/TrkCount.hh
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
#ifndef TrkCount_HH
#define TrkCount_HH
#include <string>
// root
//
// TrkCount: counts track types and track-related quantities in an event (MARKED FOR REMOVAL)
// Dave Brown, LBNL 7/8/2016
// Modified by Sam Grant, ANL 12/22/2025
namespace mu2e
{
struct TrkCount {
static const int MAX_COUNTS = 50;
// int _ncounts;
int _counts[MAX_COUNTS]; // number of tracks in collection
// int _overlaps[MAX_COUNTS]; // number of shared hits between candidate track and this track
int ntrk = 0; // number of distinct physical tracks collection

int _nde = 0; // number of downstreameMinus tracks
int _nue = 0; // number of upstreameMinus tracks
int _ndm = 0; // number of downstreammuMinus tracks
int _ndec = 0; // Number of calo clusters matched to the best dem track.
int _ndeo = 0; // number of shared hits between primary and next-best track
int _ndmo = 0; // number of shared hits between primary and muon-fit track
void reset() { *this = TrkCount(); }
};
}
Expand Down
29 changes: 19 additions & 10 deletions src/EventNtupleMaker_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,8 @@ namespace mu2e {
}
// hit counting branch
_ntuple->Branch("hitcount",&_hcnt);
// track counting branches
for (BranchIndex i_branch = 0; i_branch < _allBranches.size(); ++i_branch) {
BranchConfig i_branchConfig = _allBranches.at(i_branch);
std::string leafname = i_branchConfig.branch();
_ntuple->Branch(("tcnt.n"+leafname).c_str(),&_tcnt._counts[i_branch]);
}
// track counting branch
_ntuple->Branch("tcnt",&_tcnt);

// create all track branches
for (BranchIndex i_branch = 0; i_branch < _allBranches.size(); ++i_branch) {
Expand Down Expand Up @@ -660,9 +656,23 @@ namespace mu2e {
event.getByLabel(_conf.mcTrajectoriesTag(),_mcTrajectories);
if(_fillcalomc)event.getByLabel(_conf.caloClusterMCTag(),_ccmcch);
}
// fill track counts
for (BranchIndex i_branch = 0; i_branch < _allBranches.size(); ++i_branch) {
_tcnt._counts[i_branch] = (_allKSPCHs.at(i_branch))->size();

//
// fill track counts: count unique PDG hypotheses
//
std::map<int,int> pdgCounts;
for (BranchIndex i_branch = 0; i_branch < _allBranches.size() && i_branch < _allKSPCHs.size(); ++i_branch) {
const auto& kseedptr_coll_h = _allKSPCHs.at(i_branch);
const auto& kseedptr_coll = *kseedptr_coll_h;
for (size_t i_kseedptr = 0; i_kseedptr < kseedptr_coll.size(); ++i_kseedptr) {
const auto& kseedptr = kseedptr_coll[i_kseedptr];
pdgCounts[kseedptr->particle()]++;
}
}
// the number of tracks is the max count of any PDG hypothesis
_tcnt.ntrk = 0;
for (const auto& pair : pdgCounts) {
_tcnt.ntrk = std::max(_tcnt.ntrk, pair.second);
}

// find extra MCStep collections
Expand Down Expand Up @@ -978,7 +988,6 @@ namespace mu2e {
// calorimeter info
_infoStructHelper.fillTrkCaloHitInfo(kseed, _allTCHIs.at(i_branch)); // fillTrkCaloHitInfo handles whether there is a calo hit or not
if (kseed.hasCaloCluster()) {
_tcnt._ndec = 1; // only 1 possible calo hit at the moment FIXME: should work with the above
// test
if(_conf.debug()>0){
auto const& tch = kseed.caloHit();
Expand Down