Public Types | List of all members
proxy::ChargedSpacePoints Struct Reference

Proxy tag for a recob::SpacePoint collection with charge. More...

#include <ChargedSpacePoints.h>

Public Types

using SpacePointDataProduct_t = std::vector< recob::SpacePoint >
 Type of the main collection. More...
 
using ChargeTag = recob::PointCharge
 Tag used for the "standard" charge information. More...
 

Detailed Description

Proxy tag for a recob::SpacePoint collection with charge.

See also
proxy::getChargedSpacePoints(), proxy::SpacePointWithCharge, proxy::ChargedSpacePointsCollectionProxy

This type can be used to get a proxy for recob::SpacePoint collection with charge. Normally, you want to use proxy::getChargedSpacePoints() directly instead:

auto spacePoints = proxy::getChargedSpacePoints(event, pointsTag);

An example of usage for a simple space point processing loop:

auto points = proxy::getChargedSpacePoints(event, pointsTag);
if (points.empty()) {
mf::LogVerbatim("ProxyTest")
<< "No points in '" << pointsTag.encode() << "'";
return;
}
mf::LogVerbatim log("ProxyTest");
for (auto point: points) {
log << "\nPoint at " << point.position() << " (ID=" << point.ID()
<< ") has ";
if (point.hasCharge()) log << "charge " << point.charge();
else log << "no charge";
} // for point
mf::LogVerbatim("ProxyTest") << "Collection '" << pointsTag.encode()
<< "' contains " << points.size() << " points.";
} // MyAnalyzer::analyze()

In this example, the charged space point proxy accesses the information exclusively via its specific interface. The complete documentation of the interface is split between proxy::ChargedSpacePointsCollectionProxy (treating the collection as a whole) and proxy::SpacePointWithCharge (accessing the individual element of the collection).

Unfortunately, the proxy object (point in the example) can be of a different class depending on which data is merged into it (via optional arguments after the tag argument). 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 point (a point proxy):

template <typename Point>
void MyAnalyzer::processPoint(Point const& point) const {
mf::LogVerbatim log("ProxyTest");
log << "\nPoint at " << point.position() << " (ID=" << point.ID()
<< ") has ";
if (point.hasCharge()) log << "charge " << point.charge();
else log << "no charge";
} // MyAnalyzer::processPoint()
void MyAnalyzer::proxyUsageExample(art::Event const& event) {
auto points = proxy::getChargedSpacePoints(event, pointsTag);
if (points.empty()) {
mf::LogVerbatim("ProxyTest")
<< "No points in '" << pointsTag.encode() << "'";
return;
}
mf::LogVerbatim("ProxyTest") << "Collection '" << pointsTag.encode()
<< "' contains " << points.size() << " points.";
for (auto point: points) {
processPoint(point);
} // for point
} // MyAnalyzer::proxyUsageExample()

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

std::vector<decltype(points)::element_proxy_t> strongPoints;
for (auto point: points) {
if (point.charge() >= 30.0) strongPoints.push_back(point);
}

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

Note
proxy::ChargedSpacePoints is not the type of the collection proxy returned by proxy::getChargedSpacePoints().

Definition at line 222 of file ChargedSpacePoints.h.

Member Typedef Documentation

Tag used for the "standard" charge information.

Definition at line 228 of file ChargedSpacePoints.h.

Type of the main collection.

Definition at line 225 of file ChargedSpacePoints.h.


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