Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
recob::DumpPFParticles Class Reference

Prints the content of all the ParticleFlow particles on screen. More...

Inheritance diagram for recob::DumpPFParticles:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

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

Public Member Functions

 DumpPFParticles (Parameters const &config)
 Default constructor. More...
 
virtual void analyze (const art::Event &evt) override
 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 Member Functions

void MakePFParticleGraph (art::Event const &event, art::ValidHandle< std::vector< recob::PFParticle >> const &handle) const
 

Static Private Member Functions

static std::string DotFileName (art::EventID const &evtID, art::Provenance const &prodInfo)
 

Private Attributes

art::InputTag fInputTag
 input tag of the PFParticle product More...
 
std::string fOutputCategory
 category for LogInfo output More...
 
bool fPrintHexFloats
 whether to print floats in base 16 More...
 
unsigned int fMaxDepth
 maximum generation to print (0: only primaries) More...
 
bool fMakeEventGraphs
 whether to create one DOT file per event 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 ParticleFlow particles on screen.

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

Configuration parameters

Particle connection graphs

When MakeParticleGraphs configuration option is activated, a file is created for each event, that contains the particle flow tree in GraphViz format. The GraphViz dot command can be used to render it into a PDF, SVG, EPS or one of the many supported bitmap formats. The typical command to use is:

dot -Tpdf -oPMTrk.pdf PMTrk.dot

A bash command to convert all files into a OutputFormat format:

OutputFormat='pdf'
for DotFile in *.dot ; do
  OutputFile="${DotFile%.dot}.${OutputFormat}"
  [[ "$OutputFile" -ot "$DotFile" ]] || continue # up to date already
  echo "${DotFile} => ${OutputFile} ..."
  dot -T"$OutputFormat" -o"$OutputFile" "$DotFile" || break
done

which will also skip files already converted.

The output shows one cell ("node") per particle. The format of the node follows these prescriptions:

The relations between particles in the flow are represented by connecting lines ("edges"). Connection information is redundant: the parent particle should have the daughter in the daughter list, and the daughter should have the parent particle referenced as such. Since the connection is usually from two sources, there are usually two arrow heads, each one close to the particle that provides information on that connection; all arrow heads point from parent to daughter.

If you are trying to interpret an existing diagram, the following list is more direct to the point. Nodes: represent particles (see above for the label content)

Connecting lines ("edges"):

Definition at line 131 of file DumpPFParticles_module.cc.

Member Typedef Documentation

Definition at line 168 of file DumpPFParticles_module.cc.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 1118 of file DumpPFParticles_module.cc.

1119  : EDAnalyzer(config)
1120  , fInputTag(config().PFModuleLabel())
1121  , fOutputCategory(config().OutputCategory())
1122  , fPrintHexFloats(config().PrintHexFloats())
1124  , fMakeEventGraphs(config().MakeParticleGraphs())
1125  {
1126  // here we are handling the optional configuration key as it had just a
1127  // default value
1128  if (!config().MaxDepth(fMaxDepth))
1130  }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string fOutputCategory
category for LogInfo output
unsigned int fMaxDepth
maximum generation to print (0: only primaries)
static Config * config
Definition: config.cpp:1054
static int max(int a, int b)
bool fMakeEventGraphs
whether to create one DOT file per event
art::InputTag fInputTag
input tag of the PFParticle product
bool fPrintHexFloats
whether to print floats in base 16

Member Function Documentation

void recob::DumpPFParticles::analyze ( const art::Event evt)
overridevirtual

Does the printing.

Definition at line 1174 of file DumpPFParticles_module.cc.

1174  {
1175 
1176  //
1177  // collect all the available information
1178  //
1179  // fetch the data to be dumped on screen
1181  = evt.getValidHandle<std::vector<recob::PFParticle>>(fInputTag);
1182 
1183  if (fMakeEventGraphs)
1184  MakePFParticleGraph(evt, PFParticles);
1185 
1186  art::FindOne<recob::Vertex> const ParticleVertices
1187  (PFParticles, evt, fInputTag);
1188  art::FindMany<recob::Track> const ParticleTracks
1189  (PFParticles, evt, fInputTag);
1190  art::FindMany<recob::Cluster> const ParticleClusters
1191  (PFParticles, evt, fInputTag);
1192  art::FindMany<recob::Seed> const ParticleSeeds
1193  (PFParticles, evt, fInputTag);
1194  art::FindMany<recob::SpacePoint> const ParticleSpacePoints
1195  (PFParticles, evt, fInputTag);
1196  art::FindMany<recob::PCAxis> const ParticlePCAxes
1197  (PFParticles, evt, fInputTag);
1198 
1199  size_t const nParticles = PFParticles->size();
1200  mf::LogVerbatim(fOutputCategory) << "Event " << evt.id()
1201  << " contains " << nParticles << " particles from '"
1202  << fInputTag.encode() << "'";
1203 
1204  // prepare the dumper
1205  ParticleDumper::PrintOptions_t options;
1206  options.hexFloats = fPrintHexFloats;
1207  options.maxDepth = fMaxDepth;
1208  options.streamName = fOutputCategory;
1209  ParticleDumper dumper(*PFParticles, options);
1210  if (ParticleVertices.isValid()) dumper.SetVertices(&ParticleVertices);
1211  else mf::LogPrint("DumpPFParticles") << "WARNING: vertex information not available";
1212  if (ParticleTracks.isValid()) dumper.SetTracks(&ParticleTracks);
1213  else mf::LogPrint("DumpPFParticles") << "WARNING: track information not available";
1214  if (ParticleClusters.isValid()) dumper.SetClusters(&ParticleClusters);
1215  else mf::LogPrint("DumpPFParticles") << "WARNING: cluster information not available";
1216  if (ParticleSeeds.isValid()) dumper.SetSeeds(&ParticleSeeds);
1217  else mf::LogPrint("DumpPFParticles") << "WARNING: seed information not avaialble";
1218  if (ParticleSpacePoints.isValid())
1219  dumper.SetSpacePoints(&ParticleSpacePoints);
1220  else {
1221  mf::LogPrint("DumpPFParticles")
1222  << "WARNING: space point information not available";
1223  }
1224  if (ParticlePCAxes.isValid())
1225  dumper.SetPCAxes(&ParticlePCAxes);
1226  else {
1227  mf::LogPrint("DumpPFParticles")
1228  << "WARNING: principal component axis not available";
1229  }
1230  dumper.DumpAllParticles(" ");
1231 
1232  mf::LogVerbatim(fOutputCategory) << "\n"; // two empty lines
1233 
1234  } // DumpPFParticles::analyze()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string encode() const
Definition: InputTag.cc:97
std::string fOutputCategory
category for LogInfo output
unsigned int fMaxDepth
maximum generation to print (0: only primaries)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
bool fMakeEventGraphs
whether to create one DOT file per event
void MakePFParticleGraph(art::Event const &event, art::ValidHandle< std::vector< recob::PFParticle >> const &handle) const
art::InputTag fInputTag
input tag of the PFParticle product
bool fPrintHexFloats
whether to print floats in base 16
EventID id() const
Definition: Event.cc:34
MaybeLogger_< ELseverityLevel::ELsev_warning, true > LogPrint
std::string recob::DumpPFParticles::DotFileName ( art::EventID const &  evtID,
art::Provenance const &  prodInfo 
)
staticprivate

Definition at line 1135 of file DumpPFParticles_module.cc.

1136  {
1137  return prodInfo.processName()
1138  + '_' + prodInfo.moduleLabel()
1139  + '_' + prodInfo.productInstanceName()
1140  + "_Run" + std::to_string(evtID.run())
1141  + "_Subrun" + std::to_string(evtID.subRun())
1142  + "_Event" + std::to_string(evtID.event())
1143  + "_particles.dot";
1144  } // DumpPFParticles::DotFileName()
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void recob::DumpPFParticles::MakePFParticleGraph ( art::Event const &  event,
art::ValidHandle< std::vector< recob::PFParticle >> const &  handle 
) const
private

Definition at line 1148 of file DumpPFParticles_module.cc.

1151  {
1152  art::EventID const eventID = event.id();
1153  std::string fileName = DotFileName(eventID, *(handle.provenance()));
1154  std::ofstream outFile(fileName); // overwrite by default
1155 
1156  outFile
1157  << "// " << fileName
1158  << "\n// "
1159  << "\n// Created for run " << eventID.run()
1160  << " subrun " << eventID.subRun()
1161  << " event " << eventID.event()
1162  << "\n// "
1163  << "\n// dump of " << handle->size() << " particles"
1164  << "\n// "
1165  << std::endl;
1166 
1167  PFParticleGraphMaker graphMaker;
1168  graphMaker.MakeGraph(outFile, *handle);
1169 
1170  } // DumpPFParticles::MakePFParticleGraph()
std::string string
Definition: nybbler.cc:12
TFile * outFile
Definition: makeDST.cxx:36
RunNumber_t run() const
Definition: EventID.h:98
fileName
Definition: dumpTree.py:9
Provenance const * provenance() const
Definition: Handle.h:344
static std::string DotFileName(art::EventID const &evtID, art::Provenance const &prodInfo)
EventNumber_t event() const
Definition: EventID.h:116
SubRunNumber_t subRun() const
Definition: EventID.h:110
QTextStream & endl(QTextStream &s)

Member Data Documentation

art::InputTag recob::DumpPFParticles::fInputTag
private

input tag of the PFParticle product

Definition at line 178 of file DumpPFParticles_module.cc.

bool recob::DumpPFParticles::fMakeEventGraphs
private

whether to create one DOT file per event

Definition at line 182 of file DumpPFParticles_module.cc.

unsigned int recob::DumpPFParticles::fMaxDepth
private

maximum generation to print (0: only primaries)

Definition at line 181 of file DumpPFParticles_module.cc.

std::string recob::DumpPFParticles::fOutputCategory
private

category for LogInfo output

Definition at line 179 of file DumpPFParticles_module.cc.

bool recob::DumpPFParticles::fPrintHexFloats
private

whether to print floats in base 16

Definition at line 180 of file DumpPFParticles_module.cc.


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