14 #include "art/Framework/Core/EDAnalyzer.h"
15 #include "art/Framework/Core/ModuleMacros.h"
16 #include "art/Framework/Principal/Event.h"
17 #include "art/Framework/Principal/Handle.h"
18 #include "canvas/Utilities/InputTag.h"
19 #include "fhiclcpp/types/Atom.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
33 using namespace fhicl;
38 using Comment = fhicl::Comment;
40 fhicl::Atom<art::InputTag> InputShowers {
42 Comment(
"data product with the MC showers to be dumped")
45 fhicl::Atom<std::string> OutputCategory {
46 Name(
"OutputCategory"),
47 Comment(
"name of the output stream (managed by the message facility)"),
51 fhicl::Atom<unsigned int> DaughtersPerLine {
52 Name(
"DaughtersPerLine"),
53 Comment(
"daughter IDs to print on each output line"),
61 std::string OriginDescription(simb::Origin_t
origin) {
63 case simb::kUnknown:
return "unknown";
64 case simb::kBeamNeutrino:
return "beam neutrino";
66 case simb::kSuperNovaNeutrino:
return "supernova neutrinos";
67 case simb::kSingleParticle:
return "single particles thrown at the detector";
71 throw art::Exception(art::errors::LogicError)
72 <<
"Unexpected origin type #" << ((int) origin) <<
"\n";
77 template <
typename Stream>
80 << step.
X() <<
", " << step.
Y() <<
", " << step.
Z() <<
") cm, t="
81 << step.
T() <<
" ns; momentum ("
82 << step.
Px() <<
", " << step.
Py() <<
", " << step.
Pz() <<
"; "
83 << step.
E() <<
") MeV/c";
106 virtual void analyze(art::Event
const& event)
override;
122 template <
typename Stream>
125 std::string indent =
"",
bool bIndentFirst =
true
144 , fInputShowers(config().InputShowers())
145 , fOutputCategory(config().OutputCategory())
146 , fDaughtersPerLine(config().DaughtersPerLine())
150 template <
typename Stream>
153 std::string indent ,
bool bIndentFirst
155 if (bIndentFirst) out << indent;
157 <<
"from GEANT track ID=" << shower.
TrackID()
158 <<
" PDG ID=" << shower.
PdgCode()
159 <<
" from " << OriginDescription(shower.
Origin())
160 <<
" via '" << shower.
Process() <<
"'";
161 out <<
"\n" << indent
163 ::PrintMCStep(out, shower.
Start());
164 out <<
"\n" << indent
166 ::PrintMCStep(out, shower.
End());
168 TVector3
const& startDir = shower.
StartDir();
169 out <<
"\n" << indent
170 <<
"pointing toward ("
171 << startDir.X() <<
", " << startDir.Y() <<
", " << startDir.Z() <<
") cm";
172 std::vector<double>
const& charges = shower.
Charge();
173 std::vector<double>
const& dQdx = shower.
dQdx();
174 size_t const nQPlanes = dQdx.size(), nChPlanes = charges.size();
175 size_t const nPlanes = std::max(nQPlanes, nChPlanes);
176 out <<
"\n" << indent;
179 <<
"dE/dx=" << shower.
dEdx() <<
" MeV/cm and dQ/dx (charge) on "
180 << nPlanes <<
" planes:";
181 for (
size_t iPlane = 0; iPlane < nPlanes; ++iPlane) {
182 out <<
" [#" << iPlane <<
"] ";
183 if (iPlane < dQdx.size()) out << dQdx[iPlane];
185 if (iPlane < charges.size()) out <<
" (" << charges[iPlane] <<
")";
189 else out <<
"no energy or charge information available";
192 out <<
"\n" << indent
193 <<
"combined energy deposition information: ";
195 out <<
"\n" << indent
196 << daughters.size() <<
" daughters, ID:";
197 for (
size_t i = 0; i < daughters.size(); ++i) {
198 if ((i % fDaughtersPerLine) == 0) out <<
"\n" << indent <<
" ";
199 out <<
" " << std::setw(8) << daughters[i];
202 out <<
"\n" << indent
206 out <<
"\n" << indent
209 out <<
"\n" << indent
213 out <<
"\n" << indent
217 out <<
"\n" << indent
220 out <<
"\n" << indent
232 = *(
event.getValidHandle<std::vector<sim::MCShower>>(fInputShowers));
234 mf::LogVerbatim(fOutputCategory)
235 <<
"Event " <<
event.id() <<
": data product '"
236 << fInputShowers.encode() <<
"' contains "
237 << Showers.size() <<
" MCShower objects";
239 unsigned int iShower = 0;
240 mf::LogVerbatim log(fOutputCategory);
244 log <<
"\n[#" << (iShower++) <<
"] ";
245 DumpMCShower(log,
shower,
" ",
false);
process_name opflashCryo1 flashfilter analyze
const MCStep & End() const
art::InputTag fInputShowers
name of MCShower's data product
unsigned int TrackID() const
std::string fOutputCategory
name of the stream for output
DumpMCShowers(Parameters const &config)
Configuration-checking constructor.
art::EDAnalyzer::Table< Config > Parameters
Class def header for mcstep data container.
const std::vector< unsigned int > & DaughterTrackID() const
const TVector3 & StartDir() const
simb::Origin_t Origin() const
int MotherPdgCode() const
const std::string & AncestorProcess() const
BEGIN_PROLOG vertical distance to the surface Name
unsigned int fDaughtersPerLine
number of daughter IDs printed per line
const MCStep & AncestorStart() const
const std::string & MotherProcess() const
unsigned int AncestorTrackID() const
const MCStep & AncestorEnd() const
const MCStep & DetProfile() const
const MCStep & Start() const
double Charge(size_t plane) const
virtual void analyze(art::Event const &event) override
const MCStep & MotherEnd() const
void DumpMCShower(Stream &&out, sim::MCShower const &shower, std::string indent="", bool bIndentFirst=true) const
Dumps the content of the specified particle in the output stream.
Class def header for MCShower data container.
unsigned int MotherTrackID() const
const std::string & Process() const
const MCStep & MotherStart() const
int AncestorPdgCode() const
double dQdx(size_t plane) const
constexpr Point origin()
Returns a origin position with a point of the specified type.