DumpParticleIDs_module.cc
Go to the documentation of this file.
1 /**
2  * @file DumpParticleIDs_module.cc
3  * @brief Dump ParticleID objects.
4  * @author H. Greenlee
5  * @date Oct. 14, 2021
6  */
7 
8 // C//C++ standard libraries
9 #include <string>
10 
11 // support libraries
12 #include "fhiclcpp/types/Atom.h"
13 #include "fhiclcpp/types/Name.h"
14 #include "fhiclcpp/types/Comment.h"
15 
16 // art libraries
21 
22 // ... plus see below ...
23 
24 namespace pid {
25 
26  /**
27  * @brief Prints the content of all the partidle IDs on screen
28  *
29  * This analyser prints the content of all the particle IDs into the
30  * LogInfo/LogVerbatim stream.
31  *
32  * Configuration parameters
33  * =========================
34  *
35  * - *ParticleIDModuleLabel* (string): label of the producer used to create the
36  * anab::ParticleID collection
37  * - *OutputCategory* (string, default: "DumpParticleIDs"): the category
38  * used for the output (useful for filtering)
39  *
40  */
42  public:
43 
44  struct Config {
45  using Name = fhicl::Name;
47 
49  Name("ParticleIDModuleLabel"),
50  Comment("tag of the producer used to create the anab::ParticleID collection")
51  };
52 
54  Name("OutputCategory"),
55  Comment("the messagefacility category used for the output"),
56  "DumpParticleIDs"
57  };
58 
59  }; // Config
60 
62 
63 
64  /// Default constructor
65  explicit DumpParticleIDs(Parameters const& config);
66 
67  /// Does the printing
68  void analyze (const art::Event& evt) override;
69 
70  private:
71 
72  art::InputTag const fParticleIDsModuleLabel; ///< name of module that produced the pids
73  std::string const fOutputCategory; ///< category for LogInfo output
74 
75  }; // class DumpParticleIDs
76 
77 } // namespace pid
78 
79 
80 //------------------------------------------------------------------------------
81 //--- module implementation
82 //---
83 // C//C++ standard libraries
84 #include <memory> // std::unique_ptr<>
85 
86 // support libraries
88 
89 // art libraries
91 
92 // LArSoft includes
94 
95 
96 namespace pid {
97 
98  //-------------------------------------------------
100  : EDAnalyzer (config)
102  , fOutputCategory (config().OutputCategory())
103  {}
104 
105 
106  //-------------------------------------------------
108 
109  // fetch the data to be dumped on screen
110  auto const& ParticleIDs = evt.getProduct<std::vector<anab::ParticleID>>(fParticleIDsModuleLabel);
111 
113  << "The event contains " << ParticleIDs.size() << " '"
114  << fParticleIDsModuleLabel.encode() << "' particle IDs";
115 
116  unsigned int ipid = 0;
117  for (const anab::ParticleID& pid: ParticleIDs) {
118 
119  // print a header for the cluster
121  log << "ParticleID #" << ipid << '\n';
122  log << "Plane ID = " << pid.PlaneID() << '\n';
123  auto scores = pid.ParticleIDAlgScores();
124  log << "Number of algorithms = " << scores.size() << '\n';
125  int ialg = 0;
126  for(const anab::sParticleIDAlgScores score: scores) {
127  log << " ParticleID #" << ipid << ", Algorithm " << ialg << '\n'
128  << " Algorithm name = " << score.fAlgName << '\n'
129  << " Variable type = " << score.fVariableType << '\n'
130  << " TrackDirection = " << score.fTrackDir << '\n'
131  << " NDF = " << score.fNdf << '\n'
132  << " Assumed PDG = " << score.fAssumedPdg << '\n'
133  << " Value = " << score.fValue << '\n'
134  << " Plane Mask = " << score.fPlaneMask << '\n';
135  ++ialg;
136  }
137 
138  ++ipid;
139  } // for pids
140 
141  } // DumpParticleIDs::analyze()
142 
144 
145 } // namespace pid
fhicl::Atom< art::InputTag > ParticleIDModuleLabel
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void analyze(const art::Event &evt) override
Does the printing.
ChannelGroupService::Name Name
Prints the content of all the partidle IDs on screen.
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string encode() const
Definition: InputTag.cc:97
std::string const fOutputCategory
category for LogInfo output
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
static Config * config
Definition: config.cpp:1054
art::InputTag const fParticleIDsModuleLabel
name of module that produced the pids
#define Comment
fhicl::Atom< std::string > OutputCategory
TCEvent evt
Definition: DataStructs.cxx:7
PROD const & getProduct(InputTag const &tag) const
Definition: DataViewImpl.h:367
DumpParticleIDs(Parameters const &config)
Default constructor.