49 Comment(
"data product with the collection of GENIE truth to be dumped")
53 Name(
"OutputCategory"),
54 Comment(
"name of the output stream (managed by the message facility)"),
60 Comment(
"when InputTruth is empty, allow for no truth to be found"),
85 template <
typename Handle>
86 static std::string
productName(Handle
const& handle);
110 <<
"'AllowNoTruth' is only allowed if no 'InputTruth' is specified.\n";
121 struct ProductInfo_t {
122 using Thruths_t = std::vector<simb::GTruth>;
123 Thruths_t
const* truths;
136 std::vector<ProductInfo_t> AllTruths;
138 std::vector<art::Handle<std::vector<simb::GTruth>>> handles;
139 event.getManyByType(handles);
140 std::copy(handles.begin(), handles.end(), std::back_inserter(AllTruths));
144 AllTruths.emplace_back
154 <<
"No GENIE truth found to be dumped!\n";
160 unsigned int const nTruths = std::accumulate(
161 AllTruths.begin(), AllTruths.end(), 0U,
162 [](
unsigned int total,
auto const& info)
163 {
return total + (info.truths? info.truths->size(): 0); }
168 <<
" contains " << nTruths <<
" GENIE truth blocks in " 169 << AllTruths.size() <<
" collections";
171 else if (AllTruths.size() == 1) {
176 <<
" GENIE truth blocks from " << AllTruths.size()
177 <<
" collections in event " <<
event.id();
183 for (ProductInfo_t
const& truths_info: AllTruths) {
185 auto const* truths = truths_info.truths;
190 <<
"Data product '" << productName
191 <<
"' has been dropped. No information available.";
194 if (AllTruths.size() > 1) {
196 <<
"Data product '" << productName
197 <<
"' contains " << truths->size() <<
" truth blocks:";
199 else if (truths->size() > 1) {
201 << truths->size() <<
" truth blocks:";
207 unsigned int iTruth = 0;
208 for (
auto const& truth: *truths) {
212 if (truths->size() > 1) log <<
"(#" << iTruth <<
") ";
232 template <
typename Handle>
234 auto const* prov = handle.provenance();
235 return prov->moduleLabel()
236 +
'_' + prov->productInstanceName()
237 +
'_' + 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.
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
EDAnalyzer(Table< Config > const &config)
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.