LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/

Proxy tag for a recob::Track collection proxy. More...

#include "Track.h"

Public Types

enum  TrackType_t { Unfitted, Fitted, NTypes }
 Types of tracks and trajectories. More...
 
using TrackDataProduct_t = std::vector< recob::Track >
 Type of the main collection. More...
 
using TrackTrajectoryTag = recob::TrackTrajectory
 Tag used for the "standard" track trajectory information. More...
 
using TrackFitHitInfoTag = recob::TrackFitHitInfo
 Tag used for the "standard" track fit information. More...
 
using HitTag = recob::Hit
 Tag used for the associated hits. More...
 

Detailed Description

Proxy tag for a recob::Track collection proxy.

See also
proxy::TrackCollectionProxyElement

This type can be used to get a proxy for recob::Track collection:

auto tracks = proxy::getCollection<proxy::Tracks>(event, tracksTag);

An example of usage for a simple track processing loop:

void MyAnalyzer::analyze(art::Event const& event) {
auto tracks = proxy::getCollection<proxy::Tracks>
(event, tracksTag, proxy::withFitHitInfo());
if (tracks.empty()) {
mf::LogVerbatim("TrackProxyTest")
<< "No tracks in '" << tracksTag.encode() << "'";
return;
}
mf::LogVerbatim("TrackProxyTest") << "Collection '" << tracksTag.encode()
<< "' contains " << tracks.size() << " tracks.";
for (auto track: tracks) {
recob::Track const& trackRef = track.track();
mf::LogVerbatim log("TrackProxyTest");
log << "[#" << track.index() << "] track " << trackRef
<< "\n with " << trackRef.NPoints() << " points and "
<< track.nHits() << " hits:";
for (auto const& point: track.points()) {
log <<
"\n [#" << point.index() << "] at " << point.position()
<< " (momentum: " << point.momentum() << "), flags: "
<< point.flags();
recob::Hit const* hit = point.hit();
if (hit) {
log << " with a Q=" << hit->Integral() << " hit on channel "
<< hit->Channel() << " at tick " << hit->PeakTime()
<< ", measured: " << point.fitInfoPtr()->hitMeas();
}
else
log << " (no associated hit)";
} // for points in track
} // for track
} // MyAnalyzer::analyze()

In this example, the track proxy accesses the track itself, its associated hits (always implicitly present) and the track fit hit information (explicitly requested). Since both those data products are produced by the same module as the track, there is no need to specify their producer module label.

Unfortunately, the proxy object (tracks in the example) can be of a different class depending on which data is merged into it: a proxy created by getCollection<proxy::Tracks>(event, tag, proxy::withFitHitInfo()) has different type than e.g. getCollection<proxy::Tracks>(event, tag). This implies than when passing proxies as arguments to functions, template types must be used. For example, the following code is equivalent to the one above, but with methods processing a single track (a track proxy) and a single trajectory point (a track point proxy):

template <typename TrackPoint>
void MyAnalyzer::processPoint(TrackPoint const& point) const {
mf::LogVerbatim log("TrackProxyTest");
log <<
" [#" << point.index() << "] at " << point.position()
<< " (momentum: " << point.momentum() << "), flags: "
<< point.flags();
recob::Hit const* hit = point.hit();
if (hit) {
log << " with a Q=" << hit->Integral() << " hit on channel "
<< hit->Channel() << " at tick " << hit->PeakTime()
<< ", measured: " << point.fitInfoPtr()->hitMeas();
}
else
log << " (no associated hit)";
} // MyAnalyzer::processPoint()
//------------------------------------------------------------------------------
template <typename Track>
void MyAnalyzer::processTrack(Track const& track) const {
recob::Track const& trackRef = track.track();
mf::LogVerbatim("TrackProxyTest")
<< "[#" << track.index() << "] track " << trackRef
<< "\n with " << trackRef.NPoints() << " points and " << track.nHits()
<< " hits:";
for (auto point: track.points()) {
processPoint(point);
} // for points in track
} // MyAnalyzer::processTrack()
//------------------------------------------------------------------------------
void MyAnalyzer::proxyUsageExample(art::Event const& event) {
auto tracks = proxy::getCollection<proxy::Tracks>
(event, tracksTag, proxy::withFitHitInfo());
if (tracks.empty()) {
mf::LogVerbatim("TrackProxyTest") << "No tracks in '"
<< tracksTag.encode() << "'";
return;
}
mf::LogVerbatim("TrackProxyTest") << "Collection '" << tracksTag.encode()
<< "' contains " << tracks.size() << " tracks.";
for (auto track: tracks) {
processTrack(track);
} // for track
} // MyAnalyzer::proxyUsageExample()

As any other proxy object, other data can be merged to the proxy, but no custom interface will be available. For example:

auto tracks = proxy::getCollection<proxy::Tracks>(
event, tracksTag,
proxy::withParallelData<recob::TrackMomentumFit>(momTag)
);

will add a data product std::vector<recob::TrackMomentumFit> expected to have one element (of type recob::TrackMomentumFit) per track, which will be accessed with the generic proxy interface:

for (auto track: tracks) {
recob::TrackMomentumFit const& momFit
= track.get<recob::TrackMomentumFit>();
// ...
}

The other common features of proxy collections are supported, like tagging of different instances of the same data types:

struct MCS {};
struct Range {};
auto tracks = proxy::getCollection<proxy::Tracks>(
event, tracksTag,
proxy::withParallelDataAs<recob::TrackMomentumFit, Range>(rangeMomTag),
proxy::withParallelDataAs<recob::TrackMomentumFit, MCS>(MCStag)
);
for (auto track: tracks) {
recob::TrackMomentumFit const& rangeMom = track.get<Range>();
recob::TrackMomentumFit const& MCSmom = track.get<MCS>();
// ...
}

A new, filtered collection of proxies can be created with obvious means and with a less-than-friendly declaration:

std::vector<decltype(tracks)::element_proxy_t> longTracks;
for (auto track: tracks) {
if (track->Length() >= 30.0) longTracks.push_back(track);
}

The collection thus created (longTracks) is valid also after the collection proxy (tracks) has fallen out of scope.

Note
proxy::Tracks is not the type of the collection proxy returned by getCollection().

Definition at line 481 of file Track.h.

Member Typedef Documentation

Tag used for the associated hits.

Definition at line 493 of file Track.h.

Type of the main collection.

Definition at line 484 of file Track.h.

Tag used for the "standard" track fit information.

Definition at line 490 of file Track.h.

Tag used for the "standard" track trajectory information.

Definition at line 487 of file Track.h.

Member Enumeration Documentation

Types of tracks and trajectories.

Enumerator
Unfitted 

Represents a track trajectory before the final fit.

Fitted 

Represents a track trajectory from the final fit.

NTypes 

Number of supported track types.

Definition at line 496 of file Track.h.

496  {
497  Unfitted,
498  Fitted,
499  NTypes
500  } TrackType_t;
Represents a track trajectory before the final fit.
Definition: Track.h:497
TrackType_t
Types of tracks and trajectories.
Definition: Track.h:496
Represents a track trajectory from the final fit.
Definition: Track.h:498
Number of supported track types.
Definition: Track.h:499

The documentation for this struct was generated from the following file: