LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DumpParticleIDs_module.cc
Go to the documentation of this file.
1 
8 // C//C++ standard libraries
9 #include <string>
10 
11 // support libraries
12 #include "fhiclcpp/types/Atom.h"
13 #include "fhiclcpp/types/Comment.h"
14 #include "fhiclcpp/types/Name.h"
15 
16 // art libraries
21 
22 // ... plus see below ...
23 
24 namespace pid {
25 
42  public:
43  struct Config {
44  using Name = fhicl::Name;
46 
48  Name("ParticleIDModuleLabel"),
49  Comment("tag of the producer used to create the anab::ParticleID collection")};
50 
52  Name("OutputCategory"),
53  Comment("the messagefacility category used for the output"),
54  "DumpParticleIDs"};
55 
56  }; // Config
57 
59 
61  explicit DumpParticleIDs(Parameters const& config);
62 
64  void analyze(const art::Event& evt) override;
65 
66  private:
68  std::string const fOutputCategory;
69 
70  }; // class DumpParticleIDs
71 
72 } // namespace pid
73 
74 //------------------------------------------------------------------------------
75 //--- module implementation
76 //---
77 // C//C++ standard libraries
78 #include <memory> // std::unique_ptr<>
79 
80 // support libraries
82 
83 // art libraries
85 
86 // LArSoft includes
88 
89 namespace pid {
90 
91  //-------------------------------------------------
93  : EDAnalyzer(config)
95  , fOutputCategory(config().OutputCategory())
96  {}
97 
98  //-------------------------------------------------
100  {
101 
102  // fetch the data to be dumped on screen
103  auto const& ParticleIDs =
104  evt.getProduct<std::vector<anab::ParticleID>>(fParticleIDsModuleLabel);
105 
106  mf::LogInfo(fOutputCategory) << "The event contains " << ParticleIDs.size() << " '"
107  << fParticleIDsModuleLabel.encode() << "' particle IDs";
108 
109  unsigned int ipid = 0;
110  for (const anab::ParticleID& pid : ParticleIDs) {
111 
112  // print a header for the cluster
114  log << "ParticleID #" << ipid << '\n';
115  log << "Plane ID = " << pid.PlaneID() << '\n';
116  auto scores = pid.ParticleIDAlgScores();
117  log << "Number of algorithms = " << scores.size() << '\n';
118  int ialg = 0;
119  for (const anab::sParticleIDAlgScores& score : scores) {
120  log << " ParticleID #" << ipid << ", Algorithm " << ialg << '\n'
121  << " Algorithm name = " << score.fAlgName << '\n'
122  << " Variable type = " << score.fVariableType << '\n'
123  << " TrackDirection = " << score.fTrackDir << '\n'
124  << " NDF = " << score.fNdf << '\n'
125  << " Assumed PDG = " << score.fAssumedPdg << '\n'
126  << " Value = " << score.fValue << '\n'
127  << " Plane Mask = " << score.fPlaneMask << '\n';
128  ++ialg;
129  }
130 
131  ++ipid;
132  } // for pids
133 
134  } // DumpParticleIDs::analyze()
135 
137 
138 } // namespace pid
fhicl::Atom< art::InputTag > ParticleIDModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void analyze(const art::Event &evt) override
Does the printing.
Prints the content of all the partidle IDs on screen.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
std::string encode() const
Definition: InputTag.cc:97
std::string const fOutputCategory
category for LogInfo output
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
art::InputTag const fParticleIDsModuleLabel
name of module that produced the pids
fhicl::Atom< std::string > OutputCategory
TCEvent evt
Definition: DataStructs.cxx:8
DumpParticleIDs(Parameters const &config)
Default constructor.
PROD const & getProduct(InputTag const &tag) const