26 #include "canvas/Persistency/Common/FindManyP.h" 43 size_t StringLength(
const T&
value) {
44 std::ostringstream sstr;
46 return sstr.str().length();
57 template <
typename STREAM,
typename CONT>
58 void PrintCompactIndexTable(
59 STREAM& log,
const CONT& Indices,
unsigned int IndicesPerLine,
62 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) {
77 if (nItemsInLine) output_line <<
" ";
78 if (RangeStart == RangeStop) {
79 output_line <<
std::setw(Padding) << RangeStart;
83 char fill = (RangeStart + 1 == RangeStop)?
' ':
'-';
84 output_line <<
std::setw(Padding) << RangeStart
91 RangeStart = RangeStop = *iIndex;
95 if (nItemsInLine >= IndicesPerLine) {
97 log << IndentStr << output_line.str() <<
"\n";
104 log << IndentStr << output_line.str();
106 if (nItemsInLine) log <<
" ";
107 if (RangeStart == RangeStop)
110 char fill = (RangeStart + 1 == RangeStop)?
' ':
'-';
132 template <
typename STREAM,
typename CONT,
typename GETINDEX>
133 void PrintCompactIndexTable(
134 STREAM& log,
const CONT& Objects,
unsigned int IndicesPerLine,
137 if ((IndicesPerLine == 0) || Objects.empty())
return;
139 std::vector<size_t> Indices;
140 Indices.reserve(Objects.size());
141 std::transform(Objects.begin(), Objects.end(), std::back_inserter(Indices),
143 std::sort(Indices.begin(), Indices.end());
144 PrintCompactIndexTable(log, Indices, IndicesPerLine, IndentStr);
159 template <
typename STREAM,
typename T>
160 inline void PrintAssociatedIndexTable(
162 unsigned int IndicesPerLine,
std::string IndentStr =
"" 164 PrintCompactIndexTable(
182 template <
typename STREAM,
typename T>
183 inline void PrintAssociatedIDTable(
185 unsigned int IndicesPerLine,
std::string IndentStr =
"" 187 PrintCompactIndexTable(
188 log, Objects, IndicesPerLine,
237 Name(
"TrackModuleLabel"),
238 Comment(
"input tag for the tracks to be dumped")
241 Name(
"OutputCategory"),
242 Comment(
"name of the category used for message facility output"),
247 Comment(
"number of points along the trajectory printed"),
251 Name(
"SpacePointAssociations"),
252 Comment(
"prints the number of space points associated to the track"),
256 Name(
"PrintSpacePoints"),
257 Comment(
"prints the index of all space points associated to the track"),
261 Name(
"HitAssociations"),
262 Comment(
"prints the number of hits associated to the track"),
267 Comment(
"prints the index of all hits associated to the track"),
271 Name(
"ParticleAssociations"),
272 Comment(
"prints the number of PF particles associated to the track"),
333 <<
"The event contains " << Tracks->size() <<
" '" 336 std::unique_ptr<art::FindManyP<recob::Hit>> pHits(
341 if (pHits && !pHits->isValid()) {
347 std::unique_ptr<art::FindManyP<recob::SpacePoint>> pSpacePoints(
352 if (pSpacePoints && !pSpacePoints->isValid()) {
358 std::unique_ptr<art::FindManyP<recob::PFParticle>> pPFParticles(
363 if (pPFParticles && !pPFParticles->isValid()) {
365 <<
"No particle-flow particle associated with '" 369 for (
unsigned int iTrack = 0; iTrack < Tracks->size(); ++iTrack) {
376 if (pHits || pSpacePoints || pPFParticles) {
377 log <<
"\n associated with:";
379 log <<
" " << pHits->at(iTrack).size() <<
" hits;";
381 log <<
" " << pSpacePoints->at(iTrack).size() <<
" space points;";
383 log <<
" " << pPFParticles->at(iTrack).size() <<
" PF particles;";
387 const auto&
Hits = pHits->at(iTrack);
388 log <<
"\n hit indices (" <<
Hits.
size() <<
"):\n";
389 PrintAssociatedIndexTable(log,
Hits, 10 ,
" ");
393 const auto& SpacePoints = pSpacePoints->at(iTrack);
394 log <<
"\n space point IDs (" << SpacePoints.size() <<
"):\n";
395 PrintAssociatedIDTable
396 (log, SpacePoints, 10 ,
" ");
400 const auto& PFParticles = pPFParticles->at(iTrack);
401 log <<
"\n particle indices (" << PFParticles.size() <<
"):\n";
403 PrintAssociatedIndexTable
404 (log, PFParticles, 10 ,
" ");
418 <<
"Track #" << iTrack <<
" ID: " << track.
ID()
420 <<
" theta: " << track.
Theta() <<
" rad, phi: " << track.
Phi()
421 <<
" rad, length: " << track.
Length() <<
" cm" 422 <<
"\n start at: ( " << track.
Vertex().X()
423 <<
" ; " << track.
Vertex().Y()
424 <<
" ; " << track.
Vertex().Z()
428 <<
"\n end at: ( " << track.
End().X()
429 <<
" ; " << track.
End().Y()
430 <<
" ; " << track.
End().Z()
436 << nPoints <<
" trajectory points";
440 log <<
"\n passes through:";
442 unsigned int iPoint = 0;
443 while ((iPoint += skip) < nPoints) {
445 log <<
"\n [#" << iPoint <<
"] (" 446 << 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
Point_t const & LocationAtPoint(size_t i) const
ChannelGroupService::Name Name
fhicl::Atom< bool > PrintHits
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Vector_t VertexDirection() const
void analyze(const art::Event &evt)
Does the printing.
EDAnalyzer(fhicl::ParameterSet const &pset)
fhicl::Atom< bool > ParticleAssociations
Q_EXPORT QTSManip setprecision(int p)
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
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
fhicl::Atom< art::InputTag > TrackModuleLabel
static int max(int a, int b)
bool fPrintHits
prints the index of associated hits
Q_EXPORT QTSManip setw(int w)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
art::PtrVector< recob::Hit > Hits
Prints the content of all the tracks on screen.
Declaration of signal hit object.
DumpTracks(Parameters const &config)
Default constructor.
Vector_t EndDirection() const
bool fPrintNParticles
prints the number of associated PFParticles
std::string fOutputCategory
category for LogInfo output
Provides recob::Track data product.
Point_t const & End() const
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
Q_EXPORT QTSManip setfill(int f)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
QTextStream & endl(QTextStream &s)