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 namespace gar {
12  namespace sdp {
13 
15  {
16  public:
17 
18  // Simple constructors/destructors.
19  // Units are nanoseconds (ns).
20  // The default values are those of the BNB beam gate.
21  BeamGateInfo(double start = 0,
22  double width = 1600.,
23  BeamType_t type = kBNB )
24  : fm_start(start)
25  , fm_width(width)
27  {}
28 
30 
31  // The sections bracketed with GCCXML tests handle a problem ART
32  // with generating its data dictionaries.
33 #ifndef __GCCXML__
34 
35  // No "setters" for beam-gate start or width; you have to assign
36  // them when you create a BeamGateInfo object.
37  double Start() const { return fm_start; }
38  double Width() const { return fm_width; }
39  BeamType_t BeamType() const { return fm_beam_type; }
40 
41 #endif
42 
43  private:
44  double fm_start; ///< Start of the beam gate relative to the t0 of the initial simulated event window, in ns.
45  double fm_width; ///< Width of the beam gate.
46  BeamType_t fm_beam_type; ///< Type of beam
47 
48  };
49 
50 #ifndef __GCCXML__
51  // In case we want to sort a collection of BeamGateInfos (e.g.,
52  // std::set<BeamGateInfo>), here's the definition of the less-than
53  // operator.
54  bool operator<( const BeamGateInfo& lhs, const BeamGateInfo& rhs )
55  {
56  // Sort by start; in the enormously-unlikely case that two beam
57  // gates (BNB and NuMI?) start at the same time, sort by width.
58  if ( lhs.Start() < rhs.Start() )
59  return true;
60  if ( lhs.Start() == rhs.Start() )
61  return ( lhs.Width() < lhs.Width() );
62  return false;
63  }
64 #endif
65 
66  } // namespace sdp
67 }// gar
68 
69 #ifndef __GCCXML__
70 // For no extra charge, include how to sort BeamGateInfo*, just in
71 // case we want (for example) a std::set<BeamGateInfo*>.
72 namespace std {
73  template <>
74  class less<gar::sdp::BeamGateInfo*>
75  {
76  public:
78  {
79  return (*lhs) < (*rhs);
80  }
81  };
82 } // std
83 #endif
84 
85 #endif // Simulation_BeamGateInfo_h
double fm_start
Start of the beam gate relative to the t0 of the initial simulated event window, in ns...
Definition: BeamGateInfo.h:44
bool operator<(const BeamGateInfo &lhs, const BeamGateInfo &rhs)
Definition: BeamGateInfo.h:54
STL namespace.
BeamGateInfo(double start=0, double width=1600., BeamType_t type=kBNB)
Definition: BeamGateInfo.h:21
BeamType_t
Defines category of beams to be stored in sdp::BeamGateInfo.
Definition: BeamTypes.h:10
BeamType_t fm_beam_type
Type of beam.
Definition: BeamGateInfo.h:46
double fm_width
Width of the beam gate.
Definition: BeamGateInfo.h:45
General GArSoft Utilities.
double Width() const
Definition: BeamGateInfo.h:38
BeamType_t BeamType() const
Definition: BeamGateInfo.h:39
double Start() const
Definition: BeamGateInfo.h:37
bool operator()(const gar::sdp::BeamGateInfo *lhs, const gar::sdp::BeamGateInfo *rhs)
Definition: BeamGateInfo.h:77