47 Comment(
"data product with the collection of GENIE truth to be dumped")};
50 Name(
"OutputCategory"),
51 Comment(
"name of the output stream (managed by the message facility)"),
57 Comment(
"when InputTruth is empty, allow for no truth to be found"),
79 template <
typename Handle>
80 static std::string
productName(Handle
const& handle);
102 <<
"'AllowNoTruth' is only allowed if no 'InputTruth' is specified.\n";
113 struct ProductInfo_t {
114 using Thruths_t = std::vector<simb::GTruth>;
115 Thruths_t
const* truths;
128 std::vector<ProductInfo_t> AllTruths;
132 auto handles =
event.getMany<std::vector<simb::GTruth>>();
133 std::copy(handles.begin(), handles.end(), std::back_inserter(AllTruths));
137 AllTruths.emplace_back(event.
getValidHandle<std::vector<simb::GTruth>>(inputTag));
151 unsigned int const nTruths = std::accumulate(
152 AllTruths.begin(), AllTruths.end(), 0U, [](
unsigned int total,
auto const& info) {
153 return total + (info.truths ? info.truths->size() : 0);
158 <<
"Event " <<
event.id() <<
" contains " << nTruths <<
" GENIE truth blocks in " 159 << AllTruths.size() <<
" collections";
161 else if (AllTruths.size() == 1) {
166 << AllTruths.size() <<
" collections in event " <<
event.id();
172 for (ProductInfo_t
const& truths_info : AllTruths) {
174 auto const* truths = truths_info.truths;
179 <<
"Data product '" << productName <<
"' has been dropped. No information available.";
182 if (AllTruths.size() > 1) {
184 <<
"Data product '" << productName <<
"' contains " << truths->size() <<
" truth blocks:";
186 else if (truths->size() > 1) {
193 unsigned int iTruth = 0;
194 for (
auto const& truth : *truths) {
198 if (truths->size() > 1) log <<
"(#" << iTruth <<
") ";
217 template <
typename Handle>
220 auto const* prov = handle.provenance();
221 return prov->moduleLabel() +
'_' + prov->productInstanceName() +
'_' + prov->processName();
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Collection of configuration parameters for the module.
fhicl::OptionalSequence< art::InputTag > InputTruth
void DumpGTruth(Stream &&out, simb::GTruth const &truth, std::string indent, std::string firstIndent)
Dumps the content of the GENIE truth in the output stream.
EDAnalyzer(fhicl::ParameterSet const &pset)
static std::string productName(Handle const &handle)
Returns the name of the product in the form "module_instance_process".
virtual void analyze(art::Event const &event) override
T const * product() const
std::string fOutputCategory
Name of the stream for output.
T const * product() const
Utility functions to print MC truth information.
#define DEFINE_ART_MODULE(klass)
Provenance const * provenance() const
bool bAllTruth
Whether to process all GTruth collections.
fhicl::Atom< std::string > OutputCategory
DumpGTruth(Parameters const &config)
Configuration-checking constructor.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
fhicl::Atom< bool > AllowNoTruth
std::vector< art::InputTag > fInputTruth
Name of GTruth data products.
bool bAllowNoTruth
Whether to forgive when no truth is present.
DumpGTruth & operator=(DumpGTruth const &)=delete
Event finding and building.