47 Comment(
"data product with the collection of MC truth to be dumped")
51 Name(
"OutputCategory"),
52 Comment(
"name of the output stream (managed by the message facility)"),
57 Name(
"PointsPerLine"),
58 Comment(
"trajectory points printed per line (default: 2; 0 = skip them)"),
82 template <
typename Handle>
117 struct ProductInfo_t {
118 using Thruths_t = std::vector<simb::MCTruth>;
119 Thruths_t
const* truths;
132 std::vector<ProductInfo_t> AllTruths;
134 auto handles =
event.getMany<std::vector<simb::MCTruth> >();
135 std::copy(handles.begin(), handles.end(), std::back_inserter(AllTruths));
139 AllTruths.emplace_back
147 if (AllTruths.empty()) {
149 <<
"No MC truth found to be dumped!\n";
155 unsigned int const nTruths = std::accumulate(
156 AllTruths.begin(), AllTruths.end(), 0U,
158 {
return total + (
info.truths?
info.truths->size(): 0); }
163 <<
" contains " << nTruths <<
" MC truth blocks in " 164 << AllTruths.size() <<
" collections";
166 else if (AllTruths.size() == 1) {
171 <<
" MC truth blocks from " << AllTruths.size()
172 <<
" collections in event " <<
event.id();
178 unsigned int nParticles = 0, nNeutrinos = 0;
179 for (ProductInfo_t
const& truths_info: AllTruths) {
181 auto const* truths = truths_info.truths;
186 <<
"Data product '" << productName
187 <<
"' has been dropped. No information available.";
190 if (AllTruths.size() > 1) {
192 <<
"Data product '" << productName
193 <<
"' contains " << truths->size() <<
" truth blocks:";
195 else if (truths->size() > 1) {
197 << truths->size() <<
" truth blocks:";
203 unsigned int iTruth = 0;
204 for (
auto const& truth: *truths) {
208 if (truths->size() > 1) log <<
"(#" << iTruth <<
") ";
215 nParticles += truth.NParticles();
216 if (truth.NeutrinoSet()) ++nNeutrinos;
226 <<
" neutrinos generated, " << nParticles
227 <<
" generated particles to be simulated downstream.";
233 template <
typename Handle>
235 auto const* prov = handle.provenance();
236 return prov->moduleLabel()
237 +
'_' + prov->productInstanceName()
238 +
'_' + prov->processName()
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
DumpMCTruth & operator=(DumpMCTruth const &)=delete
fhicl::OptionalSequence< art::InputTag > InputTruth
ChannelGroupService::Name Name
Collection of configuration parameters for the module.
EDAnalyzer(fhicl::ParameterSet const &pset)
unsigned int fPointsPerLine
trajectory points per output line
T const * product() const
void analyze(art::Event const &event) override
fhicl::Atom< unsigned int > PointsPerLine
T const * product() const
#define DEFINE_ART_MODULE(klass)
Provenance const * provenance() const
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
Dumps the content of the specified MC truth in the output stream.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool bAllTruth
Whether to process all MCTruth collections.
DumpMCTruth(Parameters const &config)
Configuration-checking constructor.
Code to link reconstructed objects back to the MC truth information.
std::vector< art::InputTag > fInputTruth
Name of MCTruth data products.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string fOutputCategory
Name of the stream for output.
fhicl::Atom< std::string > OutputCategory
static std::string productName(Handle const &handle)
Returns the name of the product in the form "module_instance_process".
Event finding and building.