120 struct ProductInfo_t {
121 using Thruths_t = std::vector<simb::GTruth>;
122 Thruths_t
const* truths;
125 ProductInfo_t(art::Handle<Thruths_t>
const& handle)
126 : truths(handle.provenance()->isPresent()? handle.product(): nullptr)
129 ProductInfo_t(art::ValidHandle<Thruths_t>
const& handle)
135 std::vector<ProductInfo_t> AllTruths;
139 auto handles =
event.getMany<std::vector<simb::GTruth>>();
140 std::copy(handles.begin(), handles.end(), std::back_inserter(AllTruths));
144 AllTruths.emplace_back
145 (event.getValidHandle<std::vector<simb::GTruth>>(inputTag));
153 throw art::Exception(art::errors::ProductNotFound)
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 <<
") ";
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".
std::string fOutputCategory
Name of the stream for output.
bool bAllTruth
Whether to process all GTruth collections.
DumpGTruth(Parameters const &config)
Configuration-checking constructor.
std::vector< art::InputTag > fInputTruth
Name of GTruth data products.
bool bAllowNoTruth
Whether to forgive when no truth is present.