Tools/CIC/cic/Event.h
Go to the documentation of this file.
1 // \author Darko Veberic
2 // \date 2014
3 
4 #ifndef _cic_Event_h_
5 #define _cic_Event_h_
6 
7 #include <iostream>
8 #include <vector>
9 #include <cmath>
10 #include <limits>
11 
12 
13 namespace cic {
14 
15  struct Event {
16 
17  Event() { }
18 
19  Event(const double sin2Theta, const double sin2ThetaErr,
20  const double lnS1000, const double lnS1000Err) :
21  fSin2Theta(sin2Theta),
22  fThetaErr(sin2ThetaErr),
23  fLnS1000(lnS1000),
24  fLnS1000Err(lnS1000Err)
25  { }
26 
27  static bool LessSin2Theta(const Event& a, const Event& b)
28  { return a.fSin2Theta < b.fSin2Theta; }
29 
30  static bool LessLnS1000(const Event& a, const Event& b)
31  { return a.fLnS1000 < b.fLnS1000; }
32 
33  double GetTheta() const { return std::asin(GetSinTheta()); }
34  double GetSinTheta() const { return std::sqrt(fSin2Theta); }
35  double GetCosTheta() const { return std::sqrt(GetCos2Theta()); }
36  double GetCos2Theta() const { return 1 - fSin2Theta; }
37 
38  explicit
39  operator bool()
40  const
41  {
42  return
43  0 <= fSin2Theta && fSin2Theta <= 1 &&
44  fThetaErr > 0 &&
45  -std::numeric_limits<double>::infinity() < fLnS1000 &&
46  fLnS1000 < std::numeric_limits<double>::infinity() &&
47  fLnS1000Err > 0;
48  }
49 
50  double fSin2Theta = -1;
51  double fThetaErr = 0;
52  double fLnS1000 = -std::numeric_limits<double>::infinity();
53  double fLnS1000Err = 0;
54 
55  };
56 
57 
58  inline
59  std::ostream&
60  operator<<(std::ostream& os, const Event& e)
61  {
62  return os << e.fSin2Theta << ' ' << e.fThetaErr << ' '
63  << e.fLnS1000 << ' ' << e.fLnS1000Err;
64  }
65 
66 
67  inline
68  std::istream&
69  operator>>(std::istream& is, Event& e)
70  {
71  return is >> std::ws >> e.fSin2Theta >> std::ws >> e.fThetaErr
72  >> std::ws >> e.fLnS1000 >> std::ws >> e.fLnS1000Err;
73  }
74 
75 
76  std::vector<Event> Bootstrap(const std::vector<Event>& events);
77 
78  std::vector<Event> ResampleWithErrors(const std::vector<Event>& events);
79 
80 }
81 
82 
83 #endif
Event(const double sin2Theta, const double sin2ThetaErr, const double lnS1000, const double lnS1000Err)
static bool LessSin2Theta(const Event &a, const Event &b)
bool is(const double a, const double b)
Definition: testlib.cc:113
double GetTheta() const
vector< Event > Bootstrap(const vector< Event > &events)
double GetSinTheta() const
std::ostream & operator<<(std::ostream &os, const Event &e)
std::istream & operator>>(std::istream &is, Event &e)
static bool LessLnS1000(const Event &a, const Event &b)
double GetCosTheta() const
vector< Event > ResampleWithErrors(const vector< Event > &events)
double GetCos2Theta() const

, generated on Tue Sep 26 2023.