All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
recob::DumpClusters Class Reference

Prints the content of all the clusters on screen. More...

Inheritance diagram for recob::DumpClusters:

Classes

struct  Config
 Configuration object. More...
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 

Public Member Functions

 DumpClusters (Parameters const &config)
 Default constructor. More...
 
void analyze (const art::Event &evt)
 Does the printing. More...
 

Private Attributes

art::InputTag fClusterModuleLabel
 tag of the cluster data product More...
 
std::string fOutputCategory
 category for LogInfo output More...
 
unsigned int fHitsPerLine
 hits per line in the output More...
 

Detailed Description

Prints the content of all the clusters on screen.

This analyser prints the content of all the clusters into the LogInfo/LogVerbatim stream.

Configuration parameters

Definition at line 54 of file DumpClusters_module.cc.

Member Typedef Documentation

using recob::DumpClusters::Parameters = art::EDAnalyzer::Table<Config>

Definition at line 79 of file DumpClusters_module.cc.

Constructor & Destructor Documentation

recob::DumpClusters::DumpClusters ( Parameters const &  config)
explicit

Default constructor.

Definition at line 114 of file DumpClusters_module.cc.

115  : EDAnalyzer (config)
116  , fClusterModuleLabel(config().ClusterModuleLabel())
117  , fOutputCategory (config().OutputCategory())
118  , fHitsPerLine (config().HitsPerLine())
119  {}
unsigned int fHitsPerLine
hits per line in the output
art::InputTag fClusterModuleLabel
tag of the cluster data product
std::string fOutputCategory
category for LogInfo output

Member Function Documentation

void recob::DumpClusters::analyze ( const art::Event &  evt)

Does the printing.

Definition at line 123 of file DumpClusters_module.cc.

123  {
124 
125  // fetch the data to be dumped on screen
126  art::InputTag ClusterInputTag(fClusterModuleLabel);
127 
128  auto Clusters
129  = evt.getValidHandle<std::vector<recob::Cluster>>(ClusterInputTag);
130 
131  // get cluster-hit associations
132  art::FindManyP<recob::Hit> HitAssn(Clusters, evt, ClusterInputTag);
133 
134  mf::LogInfo(fOutputCategory)
135  << "The event contains " << Clusters->size() << " '"
136  << ClusterInputTag.encode() << "' clusters";
137 
138  unsigned int iCluster = 0;
139  std::vector<size_t> HitBuffer(fHitsPerLine), LastBuffer;
140  for (const recob::Cluster& cluster: *Clusters) {
141  decltype(auto) ClusterHits = HitAssn.at(iCluster);
142 
143  // print a header for the cluster
144  mf::LogVerbatim(fOutputCategory)
145  << "Cluster #" << (iCluster++) << " from " << ClusterHits.size()
146  << " hits: " << cluster;
147 
148 
149  // print the hits of the cluster
150  if ((fHitsPerLine > 0) && !ClusterHits.empty()) {
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());
155 
156  unsigned int Padding = ::StringLength(HitIndices.back());
157 
158  mf::LogVerbatim(fOutputCategory) << " hit indices:";
159 
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) {
166 
167  if (*iHit == RangeStop + 1) {
168  ++RangeStop;
169  }
170  else {
171  // the new item does not belong to the current range:
172  // - print the current range
173  if (RangeStart == RangeStop) {
174  output_line << " " << std::setw(Padding) << RangeStart;
175  ++nItemsInLine;
176  }
177  else {
178  char fill = (RangeStart + 1 == RangeStop)? ' ': '-';
179  output_line << " " << std::setw(Padding) << RangeStart
180  << fill << fill
181  << std::setw(Padding) << std::setfill(fill) << RangeStop
182  << std::setfill(' ');
183  nItemsInLine += 2;
184  }
185  // - start a new one
186  RangeStart = RangeStop = *iHit;
187  } // if ... else
188 
189  // if we have enough stuff in the buffer, let's print it
190  if (nItemsInLine >= fHitsPerLine) {
191  nItemsInLine = 0;
192  mf::LogVerbatim(fOutputCategory) << " " << output_line.str();
193  output_line.str("");
194  }
195 
196  } // while
197 
198  mf::LogVerbatim line_out(fOutputCategory);
199  line_out << " " << output_line.str();
200  if (RangeStart == RangeStop)
201  line_out << " " << std::setw(Padding) << RangeStart;
202  else {
203  char fill = (RangeStart + 1 == RangeStop)? ' ': '-';
204  line_out << " " << std::setw(Padding) << RangeStart
205  << fill << fill
206  << std::setw(Padding) << std::setfill(fill) << RangeStop;
207  }
208  } // if dumping the hits
209 
210  } // for clusters
211 
212  } // DumpClusters::analyze()
process_name cluster
Definition: cheaterreco.fcl:51
Set of hits with a 2D structure.
Definition: Cluster.h:71
unsigned int fHitsPerLine
hits per line in the output
art::InputTag fClusterModuleLabel
tag of the cluster data product
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
TCEvent evt
Definition: DataStructs.cxx:8
std::string fOutputCategory
category for LogInfo output

Member Data Documentation

art::InputTag recob::DumpClusters::fClusterModuleLabel
private

tag of the cluster data product

Definition at line 89 of file DumpClusters_module.cc.

unsigned int recob::DumpClusters::fHitsPerLine
private

hits per line in the output

Definition at line 91 of file DumpClusters_module.cc.

std::string recob::DumpClusters::fOutputCategory
private

category for LogInfo output

Definition at line 90 of file DumpClusters_module.cc.


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