13 #include "art/Framework/Core/EDAnalyzer.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "art/Framework/Principal/Handle.h"
17 #include "canvas/Persistency/Common/Ptr.h"
18 #include "canvas/Persistency/Common/FindManyP.h"
19 #include "canvas/Utilities/InputTag.h"
22 #include "fhiclcpp/types/Atom.h"
23 #include "fhiclcpp/types/Table.h"
24 #include "fhiclcpp/types/Name.h"
25 #include "fhiclcpp/types/Comment.h"
26 #include "messagefacility/MessageLogger/MessageLogger.h"
63 Name(
"ClusterModuleLabel"),
64 Comment(
"input tag for the clusters to be dumped")
67 Name(
"OutputCategory"),
68 Comment(
"name of the category used for message facility output"),
73 Comment(
"number of hits per line (0 suppresses hit dumping)"),
102 template <
typename T>
103 size_t StringLength(
const T&
value) {
104 std::ostringstream sstr;
106 return sstr.str().length();
115 : EDAnalyzer (config)
116 , fClusterModuleLabel(config().ClusterModuleLabel())
117 , fOutputCategory (config().OutputCategory())
118 , fHitsPerLine (config().HitsPerLine())
129 = evt.getValidHandle<std::vector<recob::Cluster>>(ClusterInputTag);
132 art::FindManyP<recob::Hit> HitAssn(Clusters, evt, ClusterInputTag);
135 <<
"The event contains " << Clusters->size() <<
" '"
136 << ClusterInputTag.encode() <<
"' clusters";
138 unsigned int iCluster = 0;
139 std::vector<size_t> HitBuffer(
fHitsPerLine), LastBuffer;
141 decltype(
auto) ClusterHits = HitAssn.at(iCluster);
145 <<
"Cluster #" << (iCluster++) <<
" from " << ClusterHits.size()
151 std::vector<size_t> HitIndices;
152 for (art::Ptr<recob::Hit> pHit: ClusterHits)
153 HitIndices.push_back(pHit.key());
154 std::sort(HitIndices.begin(), HitIndices.end());
156 unsigned int Padding = ::StringLength(HitIndices.back());
160 std::vector<size_t>::const_iterator iHit = HitIndices.begin(),
161 hend = HitIndices.end();
162 size_t RangeStart = *iHit, RangeStop = RangeStart;
163 std::ostringstream output_line;
164 size_t nItemsInLine = 0;
165 while (++iHit != hend) {
167 if (*iHit == RangeStop + 1) {
173 if (RangeStart == RangeStop) {
174 output_line <<
" " << std::setw(Padding) << RangeStart;
178 char fill = (RangeStart + 1 == RangeStop)?
' ':
'-';
179 output_line <<
" " << std::setw(Padding) << RangeStart
181 << std::setw(Padding) << std::setfill(fill) << RangeStop
182 << std::setfill(
' ');
186 RangeStart = RangeStop = *iHit;
199 line_out <<
" " << output_line.str();
200 if (RangeStart == RangeStop)
201 line_out <<
" " << std::setw(Padding) << RangeStart;
203 char fill = (RangeStart + 1 == RangeStop)?
' ':
'-';
204 line_out <<
" " << std::setw(Padding) << RangeStart
206 << std::setw(Padding) << std::setfill(fill) << RangeStop;
Declaration of signal hit object.
Prints the content of all the clusters on screen.
Set of hits with a 2D structure.
unsigned int fHitsPerLine
hits per line in the output
fhicl::Atom< art::InputTag > ClusterModuleLabel
fhicl::Atom< unsigned int > HitsPerLine
art::InputTag fClusterModuleLabel
tag of the cluster data product
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
BEGIN_PROLOG vertical distance to the surface Name
Declaration of cluster object.
fhicl::Atom< std::string > OutputCategory
art::EDAnalyzer::Table< Config > Parameters
void analyze(const art::Event &evt)
Does the printing.
std::string fOutputCategory
category for LogInfo output
DumpClusters(Parameters const &config)
Default constructor.