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:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 Configuration object. More...
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 DumpClusters (Parameters const &config)
 Default constructor. More...
 
void analyze (const art::Event &evt)
 Does the printing. More...
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

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

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  {}
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
unsigned int fHitsPerLine
hits per line in the output
static Config * config
Definition: config.cpp:1054
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 
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
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 
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()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void cluster(In first, In last, Out result, Pred *pred)
Definition: NNClusters.h:41
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Set of hits with a 2D structure.
Definition: Cluster.h:71
intermediate_table::const_iterator const_iterator
Cluster finding and building.
unsigned int fHitsPerLine
hits per line in the output
art::InputTag fClusterModuleLabel
tag of the cluster data product
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
def fill(s)
Definition: translator.py:93
std::string fOutputCategory
category for LogInfo output
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337

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: