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 
16  {
17  public:
18 
19  // Simple constructors/destructors.
20  // Units are nanoseconds (ns).
21  // The default values are those of the BNB beam gate.
22  BeamGateInfo( double start = 0, double width = 1600., BeamType_t type = kBNB )
23  : fm_start(start)
24  , fm_width(width)
26  {}
27 
28  // No "setters" for beam-gate start or width; you have to assign
29  // them when you create a BeamGateInfo object.
30  double Start() const { return fm_start; }
31  double Width() const { return fm_width; }
32  BeamType_t BeamType() const { return fm_beam_type; }
33 
34 
35  private:
36  double fm_start; // Start of the beam gate relative to the t0 of the initial simulated event window, in ns.
37  double fm_width; // Width of the beam gate.
38  BeamType_t fm_beam_type; ///< Type of beam
39 
40  };
41 
42  // In case we want to sort a collection of BeamGateInfos (e.g.,
43  // std::set<BeamGateInfo>), here's the definition of the less-than
44  // operator.
45  bool operator<( const BeamGateInfo& lhs, const BeamGateInfo& rhs )
46  {
47  // Sort by start; in the enormously-unlikely case that two beam
48  // gates (BNB and NuMI?) start at the same time, sort by width.
49  if ( lhs.Start() < rhs.Start() )
50  return true;
51  if ( lhs.Start() == rhs.Start() )
52  return ( lhs.Width() < lhs.Width() );
53  return false;
54  }
55 
56 } // namespace sim
57 
58 // For no extra charge, include how to sort BeamGateInfo*, just in
59 // case we want (for example) a std::set<BeamGateInfo*>.
60 namespace std {
61  template <>
63  {
64  public:
65  bool operator()( const sim::BeamGateInfo* lhs, const sim::BeamGateInfo* rhs )
66  {
67  return (*lhs) < (*rhs);
68  }
69  };
70 } // std
71 
72 #endif // Simulation_BeamGateInfo_h
BeamGateInfo(double start=0, double width=1600., BeamType_t type=kBNB)
Definition: BeamGateInfo.h:22
STL namespace.
double Start() const
Definition: BeamGateInfo.h:30
BeamType_t fm_beam_type
Type of beam.
Definition: BeamGateInfo.h:38
bool operator()(const sim::BeamGateInfo *lhs, const sim::BeamGateInfo *rhs)
Definition: BeamGateInfo.h:65
Code to link reconstructed objects back to the MC truth information.
BNB.
Definition: BeamTypes.h:11
double Width() const
Definition: BeamGateInfo.h:31
BeamType_t BeamType() const
Definition: BeamGateInfo.h:32
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:45