34 using namespace fhicl;
43 Comment(
"data product with the MC tracks to be dumped")
47 Name(
"OutputCategory"),
48 Comment(
"name of the output stream (managed by the message facility)"),
67 <<
"Unexpected origin type #" << ((int) origin) <<
"\n";
72 template <
typename Stream>
73 void PrintMCStep(Stream&& out,
sim::MCStep const& step) {
75 << step.
X() <<
", " << step.
Y() <<
", " << step.
Z() <<
") cm, t=" 76 << step.
T() <<
" ns; momentum (" 77 << step.
Px() <<
", " << step.
Py() <<
", " << step.
Pz() <<
"; " 78 << step.
E() <<
") MeV/c";
117 template <
typename Stream>
120 std::string
indent =
"",
bool bIndentFirst =
true 143 template <
typename Stream>
146 std::string
indent ,
bool bIndentFirst
148 if (bIndentFirst) out <<
indent;
150 <<
"from GEANT track ID=" << track.
TrackID()
151 <<
" PDG ID=" << track.
PdgCode()
152 <<
" from " << OriginDescription(track.
Origin())
153 <<
" via '" << track.
Process() <<
"'";
154 out <<
"\n" << indent
156 ::PrintMCStep(out, track.
Start());
157 out <<
"\n" << indent
159 ::PrintMCStep(out, track.
End());
161 std::vector<std::vector<double>>
const& dQdx = track.
dQdx();
162 std::vector<double>
const& dEdx = track.
dEdx();
163 size_t const nQSteps = dQdx.size(), nESteps = dEdx.size();
164 size_t const nSteps =
std::max(nQSteps, nESteps);
168 <<
"energy information for " << nSteps
169 <<
" steps (dE/dX in MeV/cm, then dQ/dx per plane):";
170 for (
size_t iStep = 0; iStep < nSteps; ++iStep) {
171 out <<
"\n" << indent
172 <<
" [#" << iStep <<
"] dE/dx=";
173 if (iStep < nESteps) out << dEdx[iStep];
176 if (iStep < nQSteps) {
177 std::vector<double>
const& step_dQdx = dQdx[iStep];
178 for (
size_t iPlane = 0; iPlane < step_dQdx.size(); ++iPlane) {
179 out <<
" [#" << iPlane <<
"] " << step_dQdx[iPlane];
185 else out <<
"no energy or charge information available";
187 out <<
"\n" << indent
191 out <<
"\n" << indent
194 out <<
"\n" << indent
198 out <<
"\n" << indent
202 out <<
"\n" << indent
205 out <<
"\n" << indent
217 = *(
event.getValidHandle<std::vector<sim::MCTrack>>(
fInputTracks));
220 <<
"Event " <<
event.id() <<
": data product '" 222 << Tracks.size() <<
" MCTrack objects";
224 unsigned int iTrack = 0;
229 log <<
"\n[#" << (iTrack++) <<
"] ";
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
simb::Origin_t Origin() const
const std::string & AncestorProcess() const
enum simb::_ev_origin Origin_t
event origin types
art::InputTag fInputTracks
name of MCTrack's data product
const MCStep & MotherEnd() const
unsigned int AncestorTrackID() const
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
#define DEFINE_ART_MODULE(klass)
DumpMCTracks & operator=(DumpMCTracks const &)=delete
single particles thrown at the detector
std::string indent(std::size_t const i)
EDAnalyzer(Table< Config > const &config)
Class def header for mctrack data container.
const MCStep & AncestorStart() const
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
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
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
const MCStep & AncestorEnd() const
constexpr Point origin()
Returns a origin position with a point of the specified type.
Event finding and building.