Skip to content

Commit

Permalink
Use simple errors for the tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
mpuccio authored and davidrohr committed Apr 13, 2022
1 parent b9aeffe commit fa2865b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 42 deletions.
8 changes: 5 additions & 3 deletions Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Tracker::~Tracker()
Tracker::~Tracker() = default;
#endif

void Tracker::clustersToTracks(std::function<void(std::string s)> logger, std::function<void(std::string s)> fatal)
void Tracker::clustersToTracks(std::function<void(std::string s)> logger, std::function<void(std::string s)> error)
{
double total{0};
for (int iteration = 0; iteration < mTrkParams.size(); ++iteration) {
Expand All @@ -66,11 +66,13 @@ void Tracker::clustersToTracks(std::function<void(std::string s)> logger, std::f
logger, iteration, mMemParams[iteration], mTrkParams[iteration]);
total += evaluateTask(&Tracker::computeTracklets, "Tracklet finding", logger);
if (!mTimeFrame->checkMemory(mTrkParams[iteration].MaxMemory)) {
fatal("Too much memory used during trackleting, check the detector status and/or the selections.");
error("Too much memory used during trackleting, check the detector status and/or the selections.");
break;
}
total += evaluateTask(&Tracker::computeCells, "Cell finding", logger);
if (!mTimeFrame->checkMemory(mTrkParams[iteration].MaxMemory)) {
fatal("Too much memory used during cell finding, check the detector status and/or the selections.");
error("Too much memory used during cell finding, check the detector status and/or the selections.");
break;
}
total += evaluateTask(&Tracker::findCellsNeighbours, "Neighbour finding", logger, iteration);
total += evaluateTask(&Tracker::findRoads, "Road finding", logger, iteration);
Expand Down
79 changes: 40 additions & 39 deletions Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void TrackerDPL::run(ProcessingContext& pc)
pattIt = patterns.begin();
std::vector<int> savedROF;
auto logger = [&](std::string s) { LOG(info) << s; };
auto fatalLogger = [&](std::string s) { LOG(fatal) << s; };
auto errorLogger = [&](std::string s) { LOG(error) << s; };
int nclUsed = 0;

std::vector<bool> processingMask;
Expand Down Expand Up @@ -286,51 +286,52 @@ void TrackerDPL::run(ProcessingContext& pc)
LOG(info) << fmt::format(" - Beam position computed for the TF: {}, {}", timeFrame->getBeamX(), timeFrame->getBeamY());

if (mCosmicsProcessing && nclUsed > 1500 * rofspan.size()) {
LOG(fatal) << "Cosmics processing was requested with an average detector occupancy exceeding 1.e-7, aborting.";
}
LOG(error) << "Cosmics processing was requested with an average detector occupancy exceeding 1.e-7, skipping TF processing.";
} else {

timeFrame->setMultiplicityCutMask(processingMask);
mTracker->clustersToTracks(logger, fatalLogger);
if (timeFrame->hasBogusClusters()) {
LOG(warning) << fmt::format(" - The processed timeframe had {} clusters with wild z coordinates, check the dictionaries", timeFrame->hasBogusClusters());
}
timeFrame->setMultiplicityCutMask(processingMask);
mTracker->clustersToTracks(logger, errorLogger);
if (timeFrame->hasBogusClusters()) {
LOG(warning) << fmt::format(" - The processed timeframe had {} clusters with wild z coordinates, check the dictionaries", timeFrame->hasBogusClusters());
}

for (unsigned int iROF{0}; iROF < rofs.size(); ++iROF) {
for (unsigned int iROF{0}; iROF < rofs.size(); ++iROF) {

auto& rof{rofs[iROF]};
tracks = timeFrame->getTracks(iROF);
trackLabels = timeFrame->getTracksLabel(iROF);
auto number{tracks.size()};
auto first{allTracks.size()};
int offset = -rof.getFirstEntry(); // cluster entry!!!
rof.setFirstEntry(first);
rof.setNEntries(number);
auto& rof{rofs[iROF]};
tracks = timeFrame->getTracks(iROF);
trackLabels = timeFrame->getTracksLabel(iROF);
auto number{tracks.size()};
auto first{allTracks.size()};
int offset = -rof.getFirstEntry(); // cluster entry!!!
rof.setFirstEntry(first);
rof.setNEntries(number);

if (tracks.size()) {
irFrames.emplace_back(rof.getBCData(), rof.getBCData() + nBCPerTF - 1);
}
std::copy(trackLabels.begin(), trackLabels.end(), std::back_inserter(allTrackLabels));
// Some conversions that needs to be moved in the tracker internals
for (unsigned int iTrk{0}; iTrk < tracks.size(); ++iTrk) {
auto& trc{tracks[iTrk]};
trc.setFirstClusterEntry(allClusIdx.size()); // before adding tracks, create final cluster indices
int ncl = trc.getNumberOfClusters(), nclf = 0;
for (int ic = TrackITSExt::MaxClusters; ic--;) { // track internally keeps in->out cluster indices, but we want to store the references as out->in!!!
auto clid = trc.getClusterIndex(ic);
if (clid >= 0) {
allClusIdx.push_back(clid);
nclf++;
if (tracks.size()) {
irFrames.emplace_back(rof.getBCData(), rof.getBCData() + nBCPerTF - 1);
}
std::copy(trackLabels.begin(), trackLabels.end(), std::back_inserter(allTrackLabels));
// Some conversions that needs to be moved in the tracker internals
for (unsigned int iTrk{0}; iTrk < tracks.size(); ++iTrk) {
auto& trc{tracks[iTrk]};
trc.setFirstClusterEntry(allClusIdx.size()); // before adding tracks, create final cluster indices
int ncl = trc.getNumberOfClusters(), nclf = 0;
for (int ic = TrackITSExt::MaxClusters; ic--;) { // track internally keeps in->out cluster indices, but we want to store the references as out->in!!!
auto clid = trc.getClusterIndex(ic);
if (clid >= 0) {
allClusIdx.push_back(clid);
nclf++;
}
}
assert(ncl == nclf);
allTracks.emplace_back(trc);
}
assert(ncl == nclf);
allTracks.emplace_back(trc);
}
}
LOGP(info, "ITSTracker pushed {} and {} vertices", allTracks.size(), vertices.size());
if (mIsMC) {
LOGP(info, "ITSTracker pushed {} track labels", allTrackLabels.size());
pc.outputs().snapshot(Output{"ITS", "TRACKSMCTR", 0, Lifetime::Timeframe}, allTrackLabels);
pc.outputs().snapshot(Output{"ITS", "ITSTrackMC2ROF", 0, Lifetime::Timeframe}, mc2rofs);
LOGP(info, "ITSTracker pushed {} and {} vertices", allTracks.size(), vertices.size());
if (mIsMC) {
LOGP(info, "ITSTracker pushed {} track labels", allTrackLabels.size());
pc.outputs().snapshot(Output{"ITS", "TRACKSMCTR", 0, Lifetime::Timeframe}, allTrackLabels);
pc.outputs().snapshot(Output{"ITS", "ITSTrackMC2ROF", 0, Lifetime::Timeframe}, mc2rofs);
}
}
mTimer.Stop();
}
Expand Down

0 comments on commit fa2865b

Please sign in to comment.