42 size_t StringLength(
const T&
value)
44 std::ostringstream sstr;
46 return sstr.str().length();
57 template <
typename STREAM,
typename CONT>
58 void PrintCompactIndexTable(STREAM& log,
60 unsigned int IndicesPerLine,
61 std::string IndentStr =
"")
63 unsigned int Padding = StringLength(Indices.back());
66 size_t RangeStart = *iIndex, RangeStop = RangeStart;
67 std::ostringstream output_line;
68 size_t nItemsInLine = 0;
69 while (++iIndex != iend) {
71 if (*iIndex == RangeStop + 1) { ++RangeStop; }
75 if (nItemsInLine) output_line <<
" ";
76 if (RangeStart == RangeStop) {
77 output_line << std::setw(Padding) << RangeStart;
81 char fill = (RangeStart + 1 == RangeStop) ?
' ' :
'-';
82 output_line << std::setw(Padding) << RangeStart << fill << fill << std::setw(Padding)
83 << std::setfill(fill) << RangeStop << std::setfill(
' ');
87 RangeStart = RangeStop = *iIndex;
91 if (nItemsInLine >= IndicesPerLine) {
93 log << IndentStr << output_line.str() <<
"\n";
100 log << IndentStr << output_line.str();
102 if (nItemsInLine) log <<
" ";
103 if (RangeStart == RangeStop)
104 log << std::setw(Padding) << RangeStart;
106 char fill = (RangeStart + 1 == RangeStop) ?
' ' :
'-';
107 log << std::setw(Padding) << RangeStart << fill << fill << std::setw(Padding)
108 << std::setfill(fill) << RangeStop << std::setfill(
' ');
124 template <
typename STREAM,
typename CONT,
typename GETINDEX>
125 void PrintCompactIndexTable(STREAM& log,
127 unsigned int IndicesPerLine,
128 GETINDEX IndexExtractor,
129 std::string IndentStr)
131 if ((IndicesPerLine == 0) || Objects.empty())
return;
133 std::vector<size_t> Indices;
134 Indices.reserve(Objects.size());
135 std::transform(Objects.begin(), Objects.end(), std::back_inserter(Indices), IndexExtractor);
136 std::sort(Indices.begin(), Indices.end());
137 PrintCompactIndexTable(log, Indices, IndicesPerLine, IndentStr);
152 template <
typename STREAM,
typename T>
153 inline void PrintAssociatedIndexTable(STREAM& log,
155 unsigned int IndicesPerLine,
156 std::string IndentStr =
"")
158 PrintCompactIndexTable(log, Objects, IndicesPerLine, std::mem_fn(&
art::Ptr<T>::key), IndentStr);
172 template <
typename STREAM,
typename T>
173 inline void PrintAssociatedIDTable(STREAM& log,
175 unsigned int IndicesPerLine,
176 std::string IndentStr =
"")
178 PrintCompactIndexTable(
179 log, Objects, IndicesPerLine, [](
const art::Ptr<T>& ptr) {
return ptr->ID(); }, IndentStr);
223 Comment(
"input tag for the tracks to be dumped")};
225 Name(
"OutputCategory"),
226 Comment(
"name of the category used for message facility output"),
229 Comment(
"number of points along the trajectory printed"),
232 Name(
"SpacePointAssociations"),
233 Comment(
"prints the number of space points associated to the track"),
236 Name(
"PrintSpacePoints"),
237 Comment(
"prints the index of all space points associated to the track"),
240 Name(
"HitAssociations"),
241 Comment(
"prints the number of hits associated to the track"),
244 Comment(
"prints the index of all hits associated to the track"),
247 Name(
"ParticleAssociations"),
248 Comment(
"prints the number of PF particles associated to the track"),
308 std::unique_ptr<art::FindManyP<recob::Hit>> pHits(
310 if (pHits && !pHits->isValid()) {
315 std::unique_ptr<art::FindManyP<recob::SpacePoint>> pSpacePoints(
318 if (pSpacePoints && !pSpacePoints->isValid()) {
323 std::unique_ptr<art::FindManyP<recob::PFParticle>> pPFParticles(
326 if (pPFParticles && !pPFParticles->isValid()) {
332 for (
unsigned int iTrack = 0; iTrack < Tracks->size(); ++iTrack) {
339 if (pHits || pSpacePoints || pPFParticles) {
340 log <<
"\n associated with:";
341 if (pHits) log <<
" " << pHits->at(iTrack).size() <<
" hits;";
342 if (pSpacePoints) log <<
" " << pSpacePoints->at(iTrack).size() <<
" space points;";
343 if (pPFParticles) log <<
" " << pPFParticles->at(iTrack).size() <<
" PF particles;";
347 const auto&
Hits = pHits->at(iTrack);
348 log <<
"\n hit indices (" <<
Hits.
size() <<
"):\n";
349 PrintAssociatedIndexTable(log,
Hits, 10 ,
" ");
353 const auto& SpacePoints = pSpacePoints->at(iTrack);
354 log <<
"\n space point IDs (" << SpacePoints.size() <<
"):\n";
355 PrintAssociatedIDTable(log, SpacePoints, 10 ,
" ");
359 const auto& PFParticles = pPFParticles->at(iTrack);
360 log <<
"\n particle indices (" << PFParticles.size() <<
"):\n";
362 PrintAssociatedIndexTable(log, PFParticles, 10 ,
" ");
373 log <<
"Track #" << iTrack <<
" ID: " << track.
ID() << std::fixed << std::setprecision(3)
374 <<
" theta: " << track.
Theta() <<
" rad, phi: " << track.
Phi()
375 <<
" rad, length: " << track.
Length() <<
" cm" 376 <<
"\n start at: ( " << track.
Vertex().X() <<
" ; " << track.
Vertex().Y() <<
" ; " 379 <<
"\n end at: ( " << track.
End().X() <<
" ; " << track.
End().Y() <<
" ; " 380 << track.
End().Z() <<
" ), direction: ( " << track.
EndDirection().X() <<
" ; " 382 <<
"\n with " << nPoints <<
" trajectory points";
386 log <<
"\n passes through:";
388 unsigned int iPoint = 0;
389 while ((iPoint += skip) < nPoints) {
391 log <<
"\n [#" << iPoint <<
"] (" << point.X() <<
", " << point.Y() <<
", " << point.Z()
void DumpTrack(unsigned int iTrack, recob::Track const &track) const
Dumps information about the specified track.
fhicl::Atom< unsigned int > WayPoints
bool fPrintNSpacePoints
prints the number of associated space points
Reconstruction base classes.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
fhicl::Atom< std::string > OutputCategory
Declaration of signal hit object.
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
fhicl::Atom< bool > PrintHits
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Vector_t VertexDirection() const
Access to track direction at different points.
void analyze(const art::Event &evt)
Does the printing.
EDAnalyzer(fhicl::ParameterSet const &pset)
fhicl::Atom< bool > ParticleAssociations
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double Phi() const
Access to spherical or geographical angles at vertex or at any point.
double Length(size_t p=0) const
Access to various track properties.
art::InputTag fTrackModuleLabel
name of module that produced the tracks
fhicl::Atom< bool > PrintSpacePoints
#define DEFINE_ART_MODULE(klass)
bool fPrintNHits
prints the number of associated hits
double Theta() const
Access to spherical or geographical angles at vertex or at any point.
fhicl::Atom< bool > SpacePointAssociations
fhicl::Atom< bool > HitAssociations
Point_t const & Vertex() const
Access to track position at different points.
Provides recob::Track data product.
fhicl::Atom< art::InputTag > TrackModuleLabel
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
bool fPrintHits
prints the index of associated hits
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
art::PtrVector< recob::Hit > Hits
Prints the content of all the tracks on screen.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
DumpTracks(Parameters const &config)
Default constructor.
Vector_t EndDirection() const
Access to track direction at different points.
bool fPrintNParticles
prints the number of associated PFParticles
std::string fOutputCategory
category for LogInfo output
Point_t const & End() const
Access to track position at different points.
bool fPrintParticles
prints the index of associated PFParticles
bool fPrintSpacePoints
prints the index of associated space points
unsigned int fPrintWayPoints
number of printed way points
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: