Jpp  pmt_effective_area_update_2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JStart.hh
Go to the documentation of this file.
1 #ifndef __JRECONSTRUCTION__JSTART__
2 #define __JRECONSTRUCTION__JSTART__
3 
4 #include <istream>
5 #include <ostream>
6 
7 
8 /**
9  * \file
10  * Auxiliary method to locate start and end point of muon trajectory.
11  * \author mdejong
12  */
13 namespace JRECONSTRUCTION {}
14 namespace JPP { using namespace JRECONSTRUCTION; }
15 
16 namespace JRECONSTRUCTION {
17 
18  /**
19  * Auxiliary class for start or end point evaluation.
20  */
21  struct JStart {
22  /**
23  * Default constructor.
24  */
25  JStart() :
26  Pmin1(0.0),
27  Pmin2(0.0)
28  {}
29 
30 
31  /**
32  * Constructor.
33  *
34  * \param Pmin1 minimal probability single observation
35  * \param Pmin2 minimal probability each of two consecutive observations
36  */
37  JStart(const double Pmin1,
38  const double Pmin2)
39  {
40  this->Pmin1 = Pmin1;
41  this->Pmin2 = Pmin2;
42  }
43 
44 
45  /**
46  * Check validity of start or end point conditions.
47  *
48  * \return true if valid; else false
49  */
50  bool is_valid() const
51  {
52  return (Pmin1 > 0.0 && Pmin2 > 0.0);
53  }
54 
55 
56  /**
57  * Evaluate start or end point conditions.
58  *
59  * The template parameter should correspond to a data type which has the member method:
60  * <pre>
61  * double getP() const; // return probability
62  * </pre>
63  *
64  * \param observation observation
65  * \return true if start or end point; else false
66  */
67  template<class JHit_t>
68  bool operator()(const JHit_t& observation) const
69  {
70  return observation.getP() < Pmin1;
71  }
72 
73 
74  /**
75  * Evaluate start or end point conditions.
76  *
77  * The template parameter should correspond to a data type which has the member method:
78  * <pre>
79  * double getP() const; // return probability
80  * </pre>
81  *
82  * \param first first observation
83  * \param second second observation
84  * \return true if start or end point; else false
85  */
86  template<class JHit_t>
87  bool operator()(const JHit_t& first,
88  const JHit_t& second) const
89  {
90  return ((first.getP() < Pmin1) ||
91  (first.getP() < Pmin2 && second.getP() < Pmin2));
92  }
93 
94 
95  /**
96  * Get start or end point of muon trajectory.
97  *
98  * The template parameter should correspond to a data type which has the member method:
99  * <pre>
100  * double getP() const; // return probability
101  * </pre>
102  * The input data should have been sorted along the muon path.
103  *
104  * \param __begin begin of data
105  * \param __end end of data
106  */
107  template<class T>
108  inline T find(T __begin, T __end) const
109  {
110  if (__begin != __end) {
111  for (T q = __begin, p = q++; q != __end; ++p, ++q) {
112  if ((*this)(*p,*q)) {
113  return p;
114  }
115  }
116  }
117 
118  return __end;
119  }
120 
121 
122  /**
123  * Read parameters from input.
124  *
125  * \param in input stream
126  * \param parameters parameters
127  * \return input stream
128  */
129  friend inline std::istream& operator>>(std::istream& in, JStart& parameters)
130  {
131  in >> parameters.Pmin1 >> parameters.Pmin2;
132 
133  return in;
134  }
135 
136 
137  /**
138  * Write parameters to output.
139  *
140  * \param out output stream
141  * \param parameters parameters
142  * \return output stream
143  */
144  friend inline std::ostream& operator<<(std::ostream& out, const JStart& parameters)
145  {
146  out << parameters.Pmin1 << ' ' << parameters.Pmin2;
147 
148  return out;
149  }
150 
151 
152  double Pmin1; //!< minimal probability single observation
153  double Pmin2; //!< minimal probability each of two consecutive observations
154  };
155 }
156 
157 #endif
JStart()
Default constructor.
Definition: JStart.hh:25
bool operator()(const JHit_t &observation) const
Evaluate start or end point conditions.
Definition: JStart.hh:68
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
T find(T __begin, T __end) const
Get start or end point of muon trajectory.
Definition: JStart.hh:108
bool operator()(const JHit_t &first, const JHit_t &second) const
Evaluate start or end point conditions.
Definition: JStart.hh:87
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
Auxiliary class for start or end point evaluation.
Definition: JStart.hh:21
do set_variable OUTPUT_DIRECTORY $WORKDIR T
friend std::istream & operator>>(std::istream &in, JStart &parameters)
Read parameters from input.
Definition: JStart.hh:129
friend std::ostream & operator<<(std::ostream &out, const JStart &parameters)
Write parameters to output.
Definition: JStart.hh:144
double Pmin1
minimal probability single observation
Definition: JStart.hh:152
JStart(const double Pmin1, const double Pmin2)
Constructor.
Definition: JStart.hh:37
double Pmin2
minimal probability each of two consecutive observations
Definition: JStart.hh:153
bool is_valid() const
Check validity of start or end point conditions.
Definition: JStart.hh:50
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40