LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
BeamGateInfo.h
Go to the documentation of this file.
1 // Simulation/BeamGateInfo.h
2 // William Seligman <seligman@nevis.columbia.edu>
3 
4 // A simple model of a single beam gate signal.
5 
6 #ifndef Simulation_BeamGateInfo_h
7 #define Simulation_BeamGateInfo_h
8 
10 
11 #include <functional> // std::less
12 
13 namespace sim {
14 
15  class BeamGateInfo {
16  public:
17  // Simple constructors/destructors.
18  // Units are nanoseconds (ns).
19  // The default values are those of the BNB beam gate.
20  BeamGateInfo(double start = 0, double width = 1600., BeamType_t type = kBNB)
21  : fm_start(start), fm_width(width), fm_beam_type(type)
22  {}
23 
24  // No "setters" for beam-gate start or width; you have to assign
25  // them when you create a BeamGateInfo object.
26  double Start() const { return fm_start; }
27  double Width() const { return fm_width; }
28  BeamType_t BeamType() const { return fm_beam_type; }
29 
30  private:
31  double
32  fm_start; // Start of the beam gate relative to the t0 of the initial simulated event window, in ns.
33  double fm_width; // Width of the beam gate.
35  };
36 
37  // In case we want to sort a collection of BeamGateInfos (e.g.,
38  // std::set<BeamGateInfo>), here's the definition of the less-than
39  // operator.
40  bool operator<(const BeamGateInfo& lhs, const BeamGateInfo& rhs)
41  {
42  // Sort by start; in the enormously-unlikely case that two beam
43  // gates (BNB and NuMI?) start at the same time, sort by width.
44  if (lhs.Start() < rhs.Start()) return true;
45  if (lhs.Start() == rhs.Start()) return (lhs.Width() < lhs.Width());
46  return false;
47  }
48 
49 } // namespace sim
50 
51 // For no extra charge, include how to sort BeamGateInfo*, just in
52 // case we want (for example) a std::set<BeamGateInfo*>.
53 namespace std {
54  template <>
55  class less<sim::BeamGateInfo*> {
56  public:
57  bool operator()(const sim::BeamGateInfo* lhs, const sim::BeamGateInfo* rhs)
58  {
59  return (*lhs) < (*rhs);
60  }
61  };
62 } // std
63 
64 #endif // Simulation_BeamGateInfo_h
BeamGateInfo(double start=0, double width=1600., BeamType_t type=kBNB)
Definition: BeamGateInfo.h:20
STL namespace.
double Start() const
Definition: BeamGateInfo.h:26
BeamType_t fm_beam_type
Type of beam.
Definition: BeamGateInfo.h:34
bool operator()(const sim::BeamGateInfo *lhs, const sim::BeamGateInfo *rhs)
Definition: BeamGateInfo.h:57
Monte Carlo Simulation.
BNB.
Definition: BeamTypes.h:11
double Width() const
Definition: BeamGateInfo.h:27
BeamType_t BeamType() const
Definition: BeamGateInfo.h:28
BeamType_t
Defines category of beams to be stored in sim::BeamGateInfo.
Definition: BeamTypes.h:9
bool operator<(const BeamGateInfo &lhs, const BeamGateInfo &rhs)
Definition: BeamGateInfo.h:40