LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
9 #include "BeamTypes.h"
10 
11 namespace sim {
12 
13  class BeamGateInfo
14  {
15  public:
16 
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)
22  , fm_width(width)
23  , fm_beam_type(type)
24  {}
25 
27 
28  // The sections bracketed with GCCXML tests handle a problem ART
29  // with generating its data dictionaries.
30 
31  // No "setters" for beam-gate start or width; you have to assign
32  // them when you create a BeamGateInfo object.
33  double Start() const { return fm_start; }
34  double Width() const { return fm_width; }
35  BeamType_t BeamType() const { return fm_beam_type; }
36 
37 
38  private:
39  double fm_start; // Start of the beam gate relative to the t0 of the initial simulated event window, in ns.
40  double fm_width; // Width of the beam gate.
42 
43  };
44 
45  // In case we want to sort a collection of BeamGateInfos (e.g.,
46  // std::set<BeamGateInfo>), here's the definition of the less-than
47  // operator.
48  bool operator<( const BeamGateInfo& lhs, const BeamGateInfo& rhs )
49  {
50  // Sort by start; in the enormously-unlikely case that two beam
51  // gates (BNB and NuMI?) start at the same time, sort by width.
52  if ( lhs.Start() < rhs.Start() )
53  return true;
54  if ( lhs.Start() == rhs.Start() )
55  return ( lhs.Width() < lhs.Width() );
56  return false;
57  }
58 
59 } // namespace sim
60 
61 // For no extra charge, include how to sort BeamGateInfo*, just in
62 // case we want (for example) a std::set<BeamGateInfo*>.
63 namespace std {
64  template <>
66  {
67  public:
68  bool operator()( const sim::BeamGateInfo* lhs, const sim::BeamGateInfo* rhs )
69  {
70  return (*lhs) < (*rhs);
71  }
72  };
73 } // std
74 
75 #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:33
BeamType_t fm_beam_type
Type of beam.
Definition: BeamGateInfo.h:41
bool operator()(const sim::BeamGateInfo *lhs, const sim::BeamGateInfo *rhs)
Definition: BeamGateInfo.h:68
Monte Carlo Simulation.
BNB.
Definition: BeamTypes.h:11
double Width() const
Definition: BeamGateInfo.h:34
BeamType_t BeamType() const
Definition: BeamGateInfo.h:35
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:48