LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CheatTrack.h
Go to the documentation of this file.
1 
13 #ifndef LAREXAMPLES_ALGORITHMS_TOTALLYCHEATTRACKS_CHEATTRACKDATA_CHEATTRACK_H
14 #define LAREXAMPLES_ALGORITHMS_TOTALLYCHEATTRACKS_CHEATTRACKDATA_CHEATTRACK_H
15 
16 
17 // LArSoft libraries
19 
20 // ROOT libraries
21 #include "TDatabasePDG.h"
22 
23 // C/C++ standard libraries
24 #include <ostream>
25 #include <string>
26 #include <utility> // std::move(), std::forward()
27 
28 
29 namespace lar {
30 
31  namespace example {
32  // BEGIN TotallyCheatTracks group ------------------------------------------
35 
52  class CheatTrack {
53 
54  public:
55 
56  using PDGID_t = int;
57 
59  static constexpr PDGID_t InvalidParticleID = 0;
60 
62  CheatTrack() = default;
63 
73  : fTraj(std::move(traj))
74  , fPDGID(pid)
75  {}
76 
77 
79  recob::Trajectory const& trajectory() const { return fTraj; }
80 
81  // --- BEGIN access to data ----------------------------------------------
84 
86  double momentum() const { return trajectory().StartMomentum(); }
87 
89  PDGID_t particleId() const { return fPDGID; }
90 
92  bool hasParticleId() const { return particleId() != InvalidParticleID; }
93 
95  // --- END access to data ------------------------------------------------
96 
97  // --- BEGIN printing data -----------------------------------------------
100 
102  static constexpr unsigned int DefaultDumpVerbosity = 1U;
103 
105  static constexpr unsigned int MaxDumpVerbosity
107 
109 
124  template <typename Stream>
125  void dump(
126  Stream&& out, unsigned int verbosity,
127  std::string indent, std::string firstIndent
128  ) const;
129  template <typename Stream>
130  void dump(
131  Stream&& out, unsigned int verbosity = DefaultDumpVerbosity,
132  std::string indent = ""
133  ) const
134  { dump(std::forward<Stream>(out), verbosity, indent, indent); }
136 
138 
139  // --- END printing data -------------------------------------------------
140 
141  private:
142 
145 
146  }; // class CheatTrack
147 
148 
152  inline std::ostream& operator<<
153  (std::ostream& out, lar::example::CheatTrack const& track)
154  { track.dump(out); return out; }
155 
157  // END TotallyCheatTracks group ------------------------------------------
158 
159  } // namespace example
160 
161 } // namespace lar
162 
163 
164 //------------------------------------------------------------------------------
165 //--- template implementation
166 //------------------------------------------------------------------------------
167 template <typename Stream>
169  Stream&& out, unsigned int verbosity,
170  std::string indent, std::string firstIndent
171  ) const
172 {
173 
174  // we could use ROOT's TDatabasePDG to get the name of the ID, but we'd rather
175  // not depend on ROOT here...
176  out << firstIndent
177  << "particle: ";
178  auto const* pPDGinfo = TDatabasePDG::Instance()->GetParticle(particleId());
179  if (pPDGinfo) out << pPDGinfo->GetName() << " (ID=" << particleId() << ")";
180  else out << "ID " << particleId();
181  out << "; momentum: " << momentum() << " GeV/c; ";
182  trajectory().Dump(std::forward<Stream>(out), verbosity, indent, "");
183 
184 } // lar::example::CheatTrack::dump()
185 
186 //------------------------------------------------------------------------------
187 
188 
189 #endif // LAREXAMPLES_ALGORITHMS_TOTALLYCHEATTRACKS_CHEATTRACKDATA_CHEATTRACK_H
CheatTrack(recob::Trajectory &&traj, PDGID_t pid)
Constructor from trajectory (stolen) and particle ID.
Definition: CheatTrack.h:72
static constexpr unsigned int DefaultDumpVerbosity
Default verbosity level.
Definition: CheatTrack.h:102
PDGID_t particleId() const
Returns the particle ID, in PDG standard.
Definition: CheatTrack.h:89
Data product for reconstructed trajectory in space.
CheatTrack()=default
Default constructor, only for ROOT I/O (do not use it!).
recob::Trajectory fTraj
The trejectory of this track.
Definition: CheatTrack.h:143
PDGID_t fPDGID
Particle ID in PDG standard.
Definition: CheatTrack.h:144
bool hasParticleId() const
Returns whether the particle ID is valid.
Definition: CheatTrack.h:92
STL namespace.
double StartMomentum() const
Computes and returns the modulus of momentum at the first point [GeV/c].
Definition: Trajectory.h:403
Pseudo-track object for TotallyCheatTracks example.
Definition: CheatTrack.h:52
static constexpr PDGID_t InvalidParticleID
Value of a particle ID that denotes it as invalid.
Definition: CheatTrack.h:59
int PDGID_t
Type of the particle ID.
Definition: CheatTrack.h:56
void dump(Stream &&out, unsigned int verbosity=DefaultDumpVerbosity, std::string indent="") const
Default verbosity level.
Definition: CheatTrack.h:130
std::string indent(std::size_t const i)
double momentum() const
Returns the initial momentum of the particle [MeV].
Definition: CheatTrack.h:86
static constexpr unsigned int MaxDumpVerbosity
Maximum verbosity level.
Definition: CheatTrack.h:106
recob::Trajectory const & trajectory() const
Returns the trajectory of this track.
Definition: CheatTrack.h:79
static constexpr unsigned int MaxDumpVerbosity
Largest verbosity level supported by Dump().
Definition: Trajectory.h:668
void dump(Stream &&out, unsigned int verbosity, std::string indent, std::string firstIndent) const
Prints the content of this object into an output stream.
Definition: CheatTrack.h:168
A trajectory in space reconstructed from hits.
Definition: Trajectory.h:73
LArSoft-specific namespace.
void Dump(Stream &&out, unsigned int verbosity, std::string indent, std::string indentFirst) const
Prints trajectory content into a stream.
Float_t track
Definition: plot.C:34