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,
60 std::string IndentStr =
"")
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
86 << std::setw(Padding) << std::setfill(fill) << RangeStop
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)
108 log << std::setw(Padding) << RangeStart;
110 char fill = (RangeStart + 1 == RangeStop)?
' ':
'-';
111 log << std::setw(Padding) << RangeStart
113 << std::setw(Padding) << std::setfill(fill) << RangeStop
114 << std::setfill(
' ');
132 template <
typename STREAM,
typename CONT,
typename GETINDEX>
133 void PrintCompactIndexTable(
134 STREAM& log,
const CONT& Objects,
unsigned int IndicesPerLine,
135 GETINDEX IndexExtractor, std::string IndentStr)
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"),
310 template <
typename STREAM>
311 bool PrintdQdXinView(
317 catch (std::out_of_range) {
return false; }
318 log <<
" " << ViewName <<
": " << nData;
349 <<
"The event contains " << Tracks->size() <<
" '" 352 std::unique_ptr<art::FindManyP<recob::Hit>> pHits(
357 if (pHits && !pHits->isValid()) {
363 std::unique_ptr<art::FindManyP<recob::SpacePoint>> pSpacePoints(
368 if (pSpacePoints && !pSpacePoints->isValid()) {
374 std::unique_ptr<art::FindManyP<recob::PFParticle>> pPFParticles(
379 if (pPFParticles && !pPFParticles->isValid()) {
381 <<
"No particle-flow particle associated with '" 385 for (
unsigned int iTrack = 0; iTrack < Tracks->size(); ++iTrack) {
392 if (pHits || pSpacePoints || pPFParticles) {
393 log <<
"\n associated with:";
395 log <<
" " << pHits->at(iTrack).size() <<
" hits;";
397 log <<
" " << pSpacePoints->at(iTrack).size() <<
" space points;";
399 log <<
" " << pPFParticles->at(iTrack).size() <<
" PF particles;";
403 const auto&
Hits = pHits->at(iTrack);
404 log <<
"\n hit indices (" <<
Hits.
size() <<
"):\n";
405 PrintAssociatedIndexTable(log,
Hits, 10 ,
" ");
409 const auto& SpacePoints = pSpacePoints->at(iTrack);
410 log <<
"\n space point IDs (" << SpacePoints.size() <<
"):\n";
411 PrintAssociatedIDTable
412 (log, SpacePoints, 10 ,
" ");
416 const auto& PFParticles = pPFParticles->at(iTrack);
417 log <<
"\n particle indices (" << PFParticles.size() <<
"):\n";
419 PrintAssociatedIndexTable
420 (log, PFParticles, 10 ,
" ");
434 <<
"Track #" << iTrack <<
" ID: " << track.
ID()
435 << std::fixed << std::setprecision(3)
436 <<
" theta: " << track.
Theta() <<
" rad, phi: " << track.
Phi()
437 <<
" rad, length: " << track.
Length() <<
" cm" 438 <<
"\n start at: ( " << track.
Vertex().X()
439 <<
" ; " << track.
Vertex().Y()
440 <<
" ; " << track.
Vertex().Z()
444 <<
"\n end at: ( " << track.
End().X()
445 <<
" ; " << track.
End().Y()
446 <<
" ; " << track.
End().Z()
452 << nPoints <<
" trajectory points, " 454 unsigned int nViews = 0;
455 std::ostringstream sstr;
456 if (PrintdQdXinView(sstr, track,
geo::kU,
"U")) ++nViews;
457 if (PrintdQdXinView(sstr, track,
geo::kV,
"V")) ++nViews;
458 if (PrintdQdXinView(sstr, track,
geo::kZ,
"Z")) ++nViews;
459 if (PrintdQdXinView(sstr, track,
geo::k3D,
"3D")) ++nViews;
461 log <<
", dQ/dx in " << nViews <<
" views: " << sstr.str();
467 log <<
"\n passes through:";
469 unsigned int iPoint = 0;
470 while ((iPoint += skip) < nPoints) {
472 log <<
"\n [#" << iPoint <<
"] (" 473 << point.X() <<
", " << point.Y() <<
", " << point.Z()
void DumpTrack(unsigned int iTrack, recob::Track const &track) const
Dumps information about the specified track.
TVector3 LocationAtPoint(unsigned int p) const
Covariance matrices are either set or not.
fhicl::Atom< unsigned int > WayPoints
bool fPrintNSpacePoints
prints the number of associated space points
Reconstruction base classes.
TVector3 VertexDirection() const
Covariance matrices are either set or not.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
fhicl::Atom< std::string > OutputCategory
Declaration of signal hit object.
fhicl::Atom< bool > PrintHits
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Planes which measure Z direction.
void analyze(const art::Event &evt)
Does the printing.
size_t NumberdQdx(geo::View_t view=geo::kUnknown) const
Covariance matrices are either set or not.
fhicl::Atom< bool > ParticleAssociations
3-dimensional objects, potentially hits, clusters, prongs, etc.
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
fhicl::Atom< art::InputTag > TrackModuleLabel
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
EDAnalyzer(Table< Config > const &config)
Provides recob::Track data product.
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.
std::string value(boost::any const &)
DumpTracks(Parameters const &config)
Default constructor.
bool fPrintNParticles
prints the number of associated PFParticles
std::string fOutputCategory
category for LogInfo output
TVector3 Vertex() const
Covariance matrices are either set or not.
TVector3 EndDirection() const
Covariance matrices are either set or not.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool fPrintParticles
prints the index of associated PFParticles
TVector3 End() const
Covariance matrices are either set or not.
size_t NumberCovariance() const
Covariance matrices are either set or not.
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: