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"
32 using namespace fhicl;
37 using Comment = fhicl::Comment;
39 fhicl::Atom<art::InputTag> InputTracks {
41 Comment(
"data product with the MC tracks to be dumped")
44 fhicl::Atom<std::string> OutputCategory {
45 Name(
"OutputCategory"),
46 Comment(
"name of the output stream (managed by the message facility)"),
54 std::string OriginDescription(simb::Origin_t
origin) {
56 case simb::kUnknown:
return "unknown";
57 case simb::kBeamNeutrino:
return "beam neutrino";
59 case simb::kSuperNovaNeutrino:
return "supernova neutrinos";
60 case simb::kSingleParticle:
return "single particles thrown at the detector";
64 throw art::Exception(art::errors::LogicError)
65 <<
"Unexpected origin type #" << ((int) origin) <<
"\n";
70 template <
typename Stream>
73 << step.
X() <<
", " << step.
Y() <<
", " << step.
Z() <<
") cm, t="
74 << step.
T() <<
" ns; momentum ("
75 << step.
Px() <<
", " << step.
Py() <<
", " << step.
Pz() <<
"; "
76 << step.
E() <<
") MeV/c";
99 virtual void analyze(art::Event
const& event)
override;
115 template <
typename Stream>
118 std::string indent =
"",
bool bIndentFirst =
true
136 , fInputTracks(config().InputTracks())
137 , fOutputCategory(config().OutputCategory())
141 template <
typename Stream>
144 std::string indent ,
bool bIndentFirst
146 if (bIndentFirst) out << indent;
148 <<
"from GEANT track ID=" << track.
TrackID()
149 <<
" PDG ID=" << track.
PdgCode()
150 <<
" from " << OriginDescription(track.
Origin())
151 <<
" via '" << track.
Process() <<
"'";
152 out <<
"\n" << indent
154 ::PrintMCStep(out, track.
Start());
155 out <<
"\n" << indent
157 ::PrintMCStep(out, track.
End());
159 std::vector<std::vector<double>>
const& dQdx = track.
dQdx();
160 std::vector<double>
const&
dEdx = track.
dEdx();
161 size_t const nQSteps = dQdx.size(), nESteps = dEdx.size();
162 size_t const nSteps = std::max(nQSteps, nESteps);
163 out <<
"\n" << indent;
166 <<
"energy information for " << nSteps
167 <<
" steps (dE/dX in MeV/cm, then dQ/dx per plane):";
168 for (
size_t iStep = 0; iStep < nSteps; ++iStep) {
169 out <<
"\n" << indent
170 <<
" [#" << iStep <<
"] dE/dx=";
171 if (iStep < nESteps) out << dEdx[iStep];
174 if (iStep < nQSteps) {
175 std::vector<double>
const& step_dQdx = dQdx[iStep];
176 for (
size_t iPlane = 0; iPlane < step_dQdx.size(); ++iPlane) {
177 out <<
" [#" << iPlane <<
"] " << step_dQdx[iPlane];
183 else out <<
"no energy or charge information available";
185 out <<
"\n" << indent
189 out <<
"\n" << indent
192 out <<
"\n" << indent
196 out <<
"\n" << indent
200 out <<
"\n" << indent
203 out <<
"\n" << indent
215 = *(
event.getValidHandle<std::vector<sim::MCTrack>>(fInputTracks));
217 mf::LogVerbatim(fOutputCategory)
218 <<
"Event " <<
event.id() <<
": data product '"
219 << fInputTracks.encode() <<
"' contains "
220 <<
Tracks.size() <<
" MCTrack objects";
222 unsigned int iTrack = 0;
223 mf::LogVerbatim log(fOutputCategory);
227 log <<
"\n[#" << (iTrack++) <<
"] ";
228 DumpMCTrack(log,
track,
" ",
false);
process_name opflashCryo1 flashfilter analyze
simb::Origin_t Origin() const
const std::string & AncestorProcess() const
art::InputTag fInputTracks
name of MCTrack's data product
const MCStep & MotherEnd() const
unsigned int AncestorTrackID() const
process_name use argoneut_mc_hitfinder track
int AncestorPdgCode() const
const MCStep & End() const
const std::vector< std::vector< double > > & dQdx() const
Class def header for mcstep data container.
unsigned int MotherTrackID() const
BEGIN_PROLOG vertical distance to the surface Name
Class def header for mctrack data container.
const MCStep & AncestorStart() const
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
void DumpMCTrack(Stream &&out, sim::MCTrack const &track, std::string indent="", bool bIndentFirst=true) const
Dumps the content of the specified particle in the output stream.
std::string fOutputCategory
name of the stream for output
const MCStep & MotherStart() const
int MotherPdgCode() const
const std::string & Process() const
const std::string & MotherProcess() const
const MCStep & Start() const
unsigned int TrackID() const
const std::vector< double > & dEdx() const
DumpMCTracks(Parameters const &config)
Configuration-checking constructor.
virtual void analyze(art::Event const &event) override
art::EDAnalyzer::Table< Config > Parameters
const MCStep & AncestorEnd() const
constexpr Point origin()
Returns a origin position with a point of the specified type.