17 #include "art/Framework/Core/EDAnalyzer.h"
18 #include "art/Framework/Core/ModuleMacros.h"
19 #include "art/Framework/Principal/Event.h"
20 #include "art/Framework/Principal/Handle.h"
21 #include "canvas/Utilities/InputTag.h"
24 #include "messagefacility/MessageLogger/MessageLogger.h"
25 #include "fhiclcpp/types/Atom.h"
26 #include "fhiclcpp/types/Name.h"
27 #include "fhiclcpp/types/Comment.h"
35 namespace sim {
class DumpSimEnergyDeposits; }
60 Name(
"EnergyDepositTag"),
62 (
"tag of data product containing the `sim::SimEnergyDeposit` to dump"),
63 art::InputTag{
"largeant",
"TPCActive" }
68 Comment(
"whether to show where the deposition took place"),
74 Comment(
"whether to show start and end position of the particle step"),
80 Comment(
"whether to show the number of photons and electrons generated"),
86 Comment(
"whether to list fast- and slow-emitted photons separately"),
92 Name(
"OutputCategory"),
93 Comment(
"the messagefacility category used for the output"),
94 "DumpSimEnergyDeposits"
118 template <
typename Stream>
128 : EDAnalyzer (config)
129 , fEnergyDepositTag(config().EnergyDepositTag())
130 , fOutputCategory (config().OutputCategory())
131 , bShowLocation(config().ShowLocation())
132 , bShowStep (config().ShowStep())
133 , bShowEmission(config().ShowEmission())
134 , bSplitPhotons(config().SplitPhotons())
141 using namespace util::quantities::energy_literals;
142 using namespace util::quantities::space_literals;
147 auto const& Deps = *(
148 event.getValidHandle<std::vector<sim::SimEnergyDeposit>>(fEnergyDepositTag)
151 mf::LogVerbatim(fOutputCategory)
152 <<
"Event " <<
event.id() <<
" contains " << Deps.size() <<
" '"
153 << fEnergyDepositTag.encode() <<
"' energy deposits";
157 unsigned int TotalElectrons = 0U, TotalPhotons = 0U,
158 TotalPhotonsFast = 0U, TotalPhotonsSlow = 0U;
163 mf::LogVerbatim log(fOutputCategory);
164 log <<
"[#" << iDep <<
"] ";
165 dumpEnergyDeposit(log, dep);
169 TotalLength +=
centimeter{ dep.StepLength() };
170 TotalElectrons += dep.NumElectrons();
171 TotalPhotons += dep.NumPhotons();
172 TotalPhotonsSlow += dep.NumSPhotons();
173 TotalPhotonsFast += dep.NumFPhotons();
177 mf::LogVerbatim(fOutputCategory)
178 <<
"Event " <<
event.id() <<
" energy deposits '"
179 << fEnergyDepositTag.encode() <<
"' include "
180 << TotalE <<
" worth of energy, " << TotalElectrons
181 <<
" electrons and " << TotalPhotons <<
" photons ("
182 << TotalPhotonsFast <<
" fast and " << TotalPhotonsSlow
183 <<
" slow); tracked particles crossed " << TotalLength <<
" of space."
190 template <
typename Stream>
202 out <<
"TrkID=" << dep.
TrackID()
204 << energy <<
" on " << time;
205 if (bShowLocation) out <<
" at " << dep.
MidPoint();
206 if (bShowStep) out <<
" from " << dep.
Start() <<
" to " << dep.
End();
207 out <<
" (step: " << length <<
")";
211 out <<
"; photons: " << dep.
NumFPhotons() <<
" (fast), "
214 else out <<
"; photons: " << dep.
NumPhotons();
DumpSimEnergyDeposits(Parameters const &config)
Constructor: reads the configuration.
fhicl::Atom< std::string > OutputCategory
geo::Length_t StepLength() const
Definition of util::enumerate().
fhicl::Atom< bool > ShowEmission
fhicl::Atom< art::InputTag > EnergyDepositTag
bool bSplitPhotons
Print photons by emission speed.
Prints the content of all the deposited energies on screen.
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
art::InputTag fEnergyDepositTag
Tag for input data product.
geo::Point_t Start() const
Definitions of geometry vector data types.
megaelectronvolt_as<> megaelectronvolt
Type of energy stored in megaelectronvolt, in double precision.
void analyze(art::Event const &evt)
Does the printing.
std::string ParticleName(int pigid)
Returns a string with the name of particle the specified with PDG ID.
geo::Point_t MidPoint() const
BEGIN_PROLOG vertical distance to the surface Name
bool bShowStep
Print the step ends.
gigaelectronvolt_as<> gigaelectronvolt
Type of energy stored in gigaelectronvolt, in double precision.
art::EDAnalyzer::Table< Config > Parameters
bool bShowEmission
Print the photons and electrons emitted.
void dumpEnergyDeposit(Stream &out, sim::SimEnergyDeposit const &dep) const
Dimensioned variables representing energy.
Utility functions to print MC truth information.
Dimensioned variables representing space or time quantities.
contains information for a single step in the detector simulation
Energy deposition in the active material.
nanosecond_as<> nanosecond
Type of time stored in nanoseconds, in double precision.
fhicl::Atom< bool > ShowLocation
centimeter_as<> centimeter
Type of space stored in centimeters, in double precision.
fhicl::Atom< bool > SplitPhotons
bool bShowLocation
Print the center of the deposition.
fhicl::Atom< bool > ShowStep
std::string fOutputCategory
Category for LogInfo output.