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>
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 auto handles =
event.getMany<std::vector<simb::GTruth> >();
139 std::copy(handles.begin(), handles.end(), std::back_inserter(AllTruths));
143 AllTruths.emplace_back
153 <<
"No GENIE truth found to be dumped!\n";
159 unsigned int const nTruths = std::accumulate(
160 AllTruths.begin(), AllTruths.end(), 0U,
162 {
return total + (
info.truths?
info.truths->size(): 0); }
167 <<
" contains " << nTruths <<
" GENIE truth blocks in " 168 << AllTruths.size() <<
" collections";
170 else if (AllTruths.size() == 1) {
175 <<
" GENIE truth blocks from " << AllTruths.size()
176 <<
" collections in event " <<
event.id();
182 for (ProductInfo_t
const& truths_info: AllTruths) {
184 auto const* truths = truths_info.truths;
189 <<
"Data product '" << productName
190 <<
"' has been dropped. No information available.";
193 if (AllTruths.size() > 1) {
195 <<
"Data product '" << productName
196 <<
"' contains " << truths->size() <<
" truth blocks:";
198 else if (truths->size() > 1) {
200 << truths->size() <<
" truth blocks:";
206 unsigned int iTruth = 0;
207 for (
auto const& truth: *truths) {
211 if (truths->size() > 1) log <<
"(#" << iTruth <<
") ";
231 template <
typename Handle>
233 auto const* prov = handle.provenance();
234 return prov->moduleLabel()
235 +
'_' + prov->productInstanceName()
236 +
'_' + prov->processName()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Collection of configuration parameters for the module.
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.
ChannelGroupService::Name Name
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
#define DEFINE_ART_MODULE(klass)
Provenance const * provenance() const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool bAllTruth
Whether to process all GTruth collections.
Code to link reconstructed objects back to the MC truth information.
DumpGTruth(Parameters const &config)
Configuration-checking constructor.
fhicl::OptionalSequence< art::InputTag > InputTruth
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< art::InputTag > fInputTruth
Name of GTruth data products.
fhicl::Atom< bool > AllowNoTruth
fhicl::Atom< std::string > OutputCategory
bool bAllowNoTruth
Whether to forgive when no truth is present.
DumpGTruth & operator=(DumpGTruth const &)=delete
Event finding and building.